diff options
| author | Vlatka Pavisic | 2017-01-16 15:21:11 +0100 |
|---|---|---|
| committer | Vlatka Pavisic | 2017-01-16 15:21:11 +0100 |
| commit | 307f808e2c812bccccd1c6246ca6b8583be4ef40 (patch) | |
| tree | 694dc741ecef8f502097f5c79e5217f933bd727b /spec | |
| parent | 9e69db1f517d15ab52cd169e3a5774d9071c3630 (diff) | |
| download | chouette-core-307f808e2c812bccccd1c6246ca6b8583be4ef40.tar.bz2 | |
Refs #2399 : User routes permissions
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/features/routes_spec.rb | 88 | ||||
| -rw-r--r-- | spec/support/devise.rb | 4 |
2 files changed, 90 insertions, 2 deletions
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb index 5aea98c90..70d32c777 100644 --- a/spec/features/routes_spec.rb +++ b/spec/features/routes_spec.rb @@ -54,4 +54,92 @@ describe "Routes", :type => :feature do end end + describe 'referential line show' do + context 'user has permission to edit routes' do + it 'shows edit buttons for routes' do + visit referential_line_path(referential, line) + expect(page).to have_css('span.fa.fa-pencil') + end + end + + context 'user does not have permission to edit routes' do + it 'does not show edit buttons for routes' do + @user.update_attribute(:permissions, ['routes.create', 'routes.destroy']) + visit referential_line_path(referential, line) + expect(page).not_to have_css('span.fa.fa-pencil') + end + end + + context 'user has permission to create routes' do + it 'shows link to a create route page' do + visit referential_line_path(referential, line) + expect(page).to have_content(I18n.t('routes.actions.new')) + end + end + + context 'user does not have permission to create routes' do + it 'does not show link to a create route page' do + @user.update_attribute(:permissions, ['routes.edit', 'routes.destroy']) + visit referential_line_path(referential, line) + expect(page).not_to have_content(I18n.t('routes.actions.new')) + end + end + + context 'user has permission to destroy routes' do + it 'shows destroy buttons for routes' do + visit referential_line_path(referential, line) + expect(page).to have_css('span.fa.fa-trash-o') + end + end + + context 'user does not have permission to destroy routes' do + it 'does not show destroy buttons for routes' do + @user.update_attribute(:permissions, ['routes.edit', 'routes.create']) + visit referential_line_path(referential, line) + expect(page).not_to have_css('span.fa.fa-trash-o') + end + end + end end + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/support/devise.rb b/spec/support/devise.rb index 2258fefbb..ae166d284 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -3,7 +3,7 @@ module DeviseRequestHelper def login_user organisation = Organisation.where(:code => "first").first_or_create(attributes_for(:organisation)) - @user ||= create(:user, :organisation => organisation) + @user ||= create(:user, :organisation => organisation, :permissions => ['routes.create', 'routes.edit', 'routes.destroy']) login_as @user, :scope => :user # post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password end @@ -34,7 +34,7 @@ module DeviseControllerHelper before(:each) do @request.env["devise.mapping"] = Devise.mappings[:user] organisation = Organisation.where(:code => "first").first_or_create(attributes_for(:organisation)) - user = create(:user, :organisation => organisation) + user = create(:user, :organisation => organisation, :permissions => ['routes.create', 'routes.edit', 'routes.destroy']) sign_in user end end |
