diff --git a/app/views/admin/api_users/edit.haml b/app/views/admin/api_users/edit.haml index 7e9e56282..867d084d5 100644 --- a/app/views/admin/api_users/edit.haml +++ b/app/views/admin/api_users/edit.haml @@ -1,5 +1,5 @@ - content_for :actions do = link_to(t(:back_to_api_user), [:admin, @api_user], class: 'btn btn-default') -= render 'shared/title', name: "#{t(:edit)}: #{@api_user.name}" += render 'shared/title', name: "#{t(:edit)}: #{@api_user.username}" = render 'form' diff --git a/app/views/admin/api_users/show.haml b/app/views/admin/api_users/show.haml index 78689854a..1b855eeba 100644 --- a/app/views/admin/api_users/show.haml +++ b/app/views/admin/api_users/show.haml @@ -2,7 +2,7 @@ = link_to(t(:edit), edit_admin_api_user_path(@api_user), class: 'btn btn-primary') = link_to(t(:delete), admin_api_user_path(@api_user), method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') -= render 'shared/title', @api_user.name += render 'shared/title', name: @api_user.username - if @api_user.errors.any? - @api_user.errors.each do |attr, err| diff --git a/spec/features/admin/api_user_spec.rb b/spec/features/admin/api_user_spec.rb new file mode 100644 index 000000000..a8a752154 --- /dev/null +++ b/spec/features/admin/api_user_spec.rb @@ -0,0 +1,42 @@ +require 'rails_helper' + +feature 'Api users', type: :feature do + background { create_settings } + + before :all do + @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') + @api_user = Fabricate(:api_user) + end + + context 'as unknown user' do + it 'should redirect to login path' do + visit admin_api_users_url + + current_path.should == '/admin/login' + end + + it 'should redirect to login path' do + visit admin_api_user_url(@api_user) + + current_path.should == '/admin/login' + end + + end + + context 'as logged in user' do + it 'should show index of contacts' do + sign_in @user + visit admin_api_users_url + + current_path.should == '/admin/api_users' + page.should have_content('API users') + end + + it 'should show api user' do + sign_in @user + visit admin_api_user_url(@api_user) + + current_path.should == "/admin/api_users/#{@api_user.id}" + end + end +end diff --git a/spec/features/admin/repp_log_spec.rb b/spec/features/admin/repp_log_spec.rb index 471c5527e..95a73c4e5 100644 --- a/spec/features/admin/repp_log_spec.rb +++ b/spec/features/admin/repp_log_spec.rb @@ -5,7 +5,6 @@ feature 'Repp log', type: :feature do before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') - @contact = Fabricate(:contact, name: 'Mr John') end context 'as unknown user' do diff --git a/spec/features/admin/zonefile_setting_spec.rb b/spec/features/admin/zonefile_setting_spec.rb index 19c4f4c25..d7653c75a 100644 --- a/spec/features/admin/zonefile_setting_spec.rb +++ b/spec/features/admin/zonefile_setting_spec.rb @@ -5,7 +5,6 @@ feature 'Zonefile settings', type: :feature do before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') - @contact = Fabricate(:contact, name: 'Mr John') end context 'as unknown user' do