aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/features/referentials_spec.rb53
-rw-r--r--spec/features/workbenches_spec.rb17
-rw-r--r--spec/support/devise.rb6
3 files changed, 73 insertions, 3 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
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb
index 608746e56..0a71a0b6b 100644
--- a/spec/features/workbenches_spec.rb
+++ b/spec/features/workbenches_spec.rb
@@ -18,11 +18,26 @@ describe 'Workbenches', type: :feature do
let!(:ready_referential) { create :referential, workbench: workbench, metadatas: referential_metadatas, ready: true, organisation: @user.organisation }
let!(:unready_referential) { create :referential, workbench: workbench }
+ before(:each) { visit workbench_path(workbench) }
+
it 'shows ready referentials belonging to that workbench by default' do
- visit workbench_path(workbench)
expect(page).to have_content(ready_referential.name)
expect(page).not_to have_content(unready_referential.name)
end
+
+ context 'user has the permission to create referentials' do
+ it 'shows the link for a new referetnial' do
+ expect(page).to have_link(I18n.t('referentials.actions.new'), href: new_referential_path(workbench_id: workbenches.first))
+ 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('referentials.actions.new'), href: new_referential_path(workbench_id: workbenches.first))
+ end
+ end
end
describe 'create new Referential' do
diff --git a/spec/support/devise.rb b/spec/support/devise.rb
index 0e3ceefac..14e316bea 100644
--- a/spec/support/devise.rb
+++ b/spec/support/devise.rb
@@ -8,7 +8,8 @@ module DeviseRequestHelper
'vehicle_journeys.create', 'vehicle_journeys.edit', 'vehicle_journeys.destroy', 'time_tables.create', 'time_tables.edit', 'time_tables.destroy',
'footnotes.edit', 'footnotes.create', 'footnotes.destroy', 'routing_constraint_zones.create', 'routing_constraint_zones.edit', 'routing_constraint_zones.destroy',
'access_points.create', 'access_points.edit', 'access_points.destroy', 'access_links.create', 'access_links.edit', 'access_links.destroy',
- 'connection_links.create', 'connection_links.edit', 'connection_links.destroy', 'route_sections.create', 'route_sections.edit', 'route_sections.destroy'])
+ 'connection_links.create', 'connection_links.edit', 'connection_links.destroy', 'route_sections.create', 'route_sections.edit', 'route_sections.destroy',
+ 'referentials.create', 'referentials.edit', 'referentials.destroy'])
login_as @user, :scope => :user
# post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password
end
@@ -44,7 +45,8 @@ module DeviseControllerHelper
'vehicle_journeys.create', 'vehicle_journeys.edit', 'vehicle_journeys.destroy', 'time_tables.create', 'time_tables.edit', 'time_tables.destroy',
'footnotes.edit', 'footnotes.create', 'footnotes.destroy', 'routing_constraint_zones.create', 'routing_constraint_zones.edit', 'routing_constraint_zones.destroy',
'access_points.create', 'access_points.edit', 'access_points.destroy', 'access_links.create', 'access_links.edit', 'access_links.destroy',
- 'connection_links.create', 'connection_links.edit', 'connection_links.destroy', 'route_sections.create', 'route_sections.edit', 'route_sections.destroy'])
+ 'connection_links.create', 'connection_links.edit', 'connection_links.destroy', 'route_sections.create', 'route_sections.edit', 'route_sections.destroy',
+ 'referentials.create', 'referentials.edit', 'referentials.destroy'])
sign_in @user
end
end