aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/referentials_spec.rb
diff options
context:
space:
mode:
authorVlatka Pavisic2017-04-13 16:14:59 +0200
committerVlatka Pavisic2017-04-13 16:15:05 +0200
commit7dbafc403f96c6aad2ed6862f1234ce76d7d123a (patch)
treec4d62f5ee46c86db1289c9a74735ce41e9a8db2a /spec/features/referentials_spec.rb
parentbc09c8f16726f520c116e158ef3390dc84736bd2 (diff)
downloadchouette-core-7dbafc403f96c6aad2ed6862f1234ce76d7d123a.tar.bz2
Refs #3128 : Modify ReferentialPolicy to check user permissions
Diffstat (limited to 'spec/features/referentials_spec.rb')
-rw-r--r--spec/features/referentials_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/features/referentials_spec.rb b/spec/features/referentials_spec.rb
index ebaf70bca..3c2258a3a 100644
--- a/spec/features/referentials_spec.rb
+++ b/spec/features/referentials_spec.rb
@@ -55,6 +55,59 @@ describe "Referentials", :type => :feature do
expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential))
end
end
+
+ context 'user has the permission to create referentials' do
+ it 'shows the clone link for referetnial' do
+ expect(page).to have_link(I18n.t('actions.clone'), href: new_referential_path(from: referential.id))
+ end
+ end
+
+ context 'user does not have the permission to create referentials' do
+ it 'does not show the clone link for referetnial' do
+ @user.update_attribute(:permissions, [])
+ visit referential_path(referential)
+ expect(page).not_to have_link(I18n.t('actions.clone'), href: new_referential_path(from: referential.id))
+ end
+ end
+
+ context 'user has the permission to edit referentials' do
+ it 'shows the link to edit the referential' do
+ expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential))
+ end
+
+ it 'shows the link to archive the referential' do
+ expect(page).to have_link(I18n.t('actions.archive'), href: archive_referential_path(referential))
+ end
+ end
+
+ context 'user does not have the permission to edit referentials' do
+ before(:each) do
+ @user.update_attribute(:permissions, [])
+ visit referential_path(referential)
+ end
+
+ it 'does not show the link to edit the referential' do
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_path(referential))
+ end
+
+ it 'does not show the link to archive the referential' do
+ expect(page).not_to have_link(I18n.t('actions.archive'), href: archive_referential_path(referential))
+ end
+ end
+
+ context 'user has the permission to destroy referentials' do
+ it 'shows the link to destroy the referential' do
+ expect(page).to have_link(I18n.t('actions.destroy'), href: referential_path(referential))
+ end
+ end
+
+ context 'user does not have the permission to destroy referentials' do
+ it 'does not show the destroy link for referetnial' do
+ @user.update_attribute(:permissions, [])
+ visit referential_path(referential)
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_path(referential))
+ end
+ end
end
describe "create" do