mirror of
https://github.com/internetee/registry.git
synced 2025-05-31 09:53:56 +02:00
Added admin feature test
This commit is contained in:
parent
752e39e4a9
commit
94950bfbdf
3 changed files with 53 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:back_to_user), [:admin, @admin_user], class: 'btn btn-default')
|
||||
= render 'shared/title', name: "#{t(:edit)}: #{@admin_user.name}"
|
||||
= render 'shared/title', name: "#{t(:edit)}: #{@admin_user.username}"
|
||||
|
||||
= render 'form'
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
= link_to(t(:edit), edit_admin_admin_user_path(@admin_user), class: 'btn btn-primary')
|
||||
= link_to(t(:delete), admin_admin_user_path(@admin_user),
|
||||
method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger')
|
||||
= render 'shared/title', name: @admin_user.name
|
||||
= render 'shared/title', name: @admin_user.username
|
||||
|
||||
- if @admin_user.errors.any?
|
||||
- @admin_user.errors.each do |attr, err|
|
||||
= err
|
||||
%br
|
||||
- if @admin_user.errors.any?
|
||||
.row
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
|
|
51
spec/features/admin/admin_user_spec.rb
Normal file
51
spec/features/admin/admin_user_spec.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Admin users', type: :feature do
|
||||
background { create_settings }
|
||||
|
||||
before :all do
|
||||
@admin_user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087')
|
||||
end
|
||||
|
||||
context 'as unknown user' do
|
||||
it 'should redirect to login path' do
|
||||
visit admin_admin_users_url
|
||||
current_path.should == '/admin/login'
|
||||
end
|
||||
|
||||
it 'should redirect to login path' do
|
||||
visit admin_admin_user_url(@admin_user)
|
||||
current_path.should == '/admin/login'
|
||||
end
|
||||
|
||||
it 'should redirect to login path' do
|
||||
visit edit_admin_admin_user_url(@admin_user)
|
||||
current_path.should == '/admin/login'
|
||||
end
|
||||
end
|
||||
|
||||
context 'as logged in user' do
|
||||
it 'should show index of contacts' do
|
||||
sign_in @admin_user
|
||||
visit admin_admin_users_url
|
||||
|
||||
current_path.should == '/admin/admin_users'
|
||||
page.should have_content('API users')
|
||||
end
|
||||
|
||||
it 'should show api user' do
|
||||
sign_in @admin_user
|
||||
visit admin_admin_user_url(@admin_user)
|
||||
|
||||
current_path.should == "/admin/admin_users/#{@admin_user.id}"
|
||||
end
|
||||
|
||||
it 'should show api user' do
|
||||
sign_in @admin_user
|
||||
visit edit_admin_admin_user_url(@admin_user)
|
||||
|
||||
current_path.should == "/admin/admin_users/#{@admin_user.id}/edit"
|
||||
page.should have_content("Edit: #{@admin_user.username}")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue