Added api user feature spec

This commit is contained in:
Priit Tark 2015-04-16 16:41:21 +03:00
parent 8d4124585c
commit 752e39e4a9
5 changed files with 44 additions and 4 deletions

View file

@ -1,5 +1,5 @@
- content_for :actions do - content_for :actions do
= link_to(t(:back_to_api_user), [:admin, @api_user], class: 'btn btn-default') = 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' = render 'form'

View file

@ -2,7 +2,7 @@
= link_to(t(:edit), edit_admin_api_user_path(@api_user), class: 'btn btn-primary') = 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), = link_to(t(:delete), admin_api_user_path(@api_user),
method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') 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? - if @api_user.errors.any?
- @api_user.errors.each do |attr, err| - @api_user.errors.each do |attr, err|

View file

@ -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

View file

@ -5,7 +5,6 @@ feature 'Repp log', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087')
@contact = Fabricate(:contact, name: 'Mr John')
end end
context 'as unknown user' do context 'as unknown user' do

View file

@ -5,7 +5,6 @@ feature 'Zonefile settings', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087')
@contact = Fabricate(:contact, name: 'Mr John')
end end
context 'as unknown user' do context 'as unknown user' do