aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAlban Peignier2017-12-20 09:18:18 +0100
committerGitHub2017-12-20 09:18:18 +0100
commit0a5c1fd25403c327593a5cbe10c7c58be6128c89 (patch)
tree91a8aaf68a3b6291066c03b70ee3d315ce746897 /spec
parente7bece2f871d51ad71ee2ee258afd985bf8d8485 (diff)
parent49a515b474cf64b02f6dfc7a449f3a45aa21e7ca (diff)
downloadchouette-core-0a5c1fd25403c327593a5cbe10c7c58be6128c89.tar.bz2
Merge pull request #155 from af83/5325-use-policies-for-calendars-sharing
Use policies for calendar sharing. Refs #5325
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/stif/permission_translator_spec.rb14
-rw-r--r--spec/policies/calendar_policy_spec.rb13
2 files changed, 22 insertions, 5 deletions
diff --git a/spec/lib/stif/permission_translator_spec.rb b/spec/lib/stif/permission_translator_spec.rb
index ae1a2d1d5..355b0e336 100644
--- a/spec/lib/stif/permission_translator_spec.rb
+++ b/spec/lib/stif/permission_translator_spec.rb
@@ -42,4 +42,18 @@ RSpec.describe Stif::PermissionTranslator do
).to match_array(Support::Permissions.all_permissions)
end
end
+
+ context "For the STIF organisation" do
+ let(:organisation){ build_stubbed :organisation, name: "STIF" }
+ it "adds the calendars.share permission" do
+ expect( described_class.translate([], organisation) ).to eq(%w{calendars.share})
+ end
+
+ context "with the case changed" do
+ let(:organisation){ build_stubbed :organisation, name: "StiF" }
+ it "adds the calendars.share permission" do
+ expect( described_class.translate([], organisation) ).to eq(%w{calendars.share})
+ end
+ end
+ end
end
diff --git a/spec/policies/calendar_policy_spec.rb b/spec/policies/calendar_policy_spec.rb
index 294be8198..5fd1eca47 100644
--- a/spec/policies/calendar_policy_spec.rb
+++ b/spec/policies/calendar_policy_spec.rb
@@ -5,18 +5,21 @@ RSpec.describe CalendarPolicy, type: :policy do
permissions :create? do
- it_behaves_like 'permitted policy', 'calendars.create', archived: true
+ it_behaves_like 'permitted policy', 'calendars.create'
+ end
+ permissions :share? do
+ it_behaves_like 'permitted policy and same organisation', 'calendars.share'
end
permissions :destroy? do
- it_behaves_like 'permitted policy and same organisation', 'calendars.destroy', archived: true
+ it_behaves_like 'permitted policy and same organisation', 'calendars.destroy'
end
permissions :edit? do
- it_behaves_like 'permitted policy and same organisation', 'calendars.update', archived: true
+ it_behaves_like 'permitted policy and same organisation', 'calendars.update'
end
permissions :new? do
- it_behaves_like 'permitted policy', 'calendars.create', archived: true
+ it_behaves_like 'permitted policy', 'calendars.create'
end
permissions :update? do
- it_behaves_like 'permitted policy and same organisation', 'calendars.update', archived: true
+ it_behaves_like 'permitted policy and same organisation', 'calendars.update'
end
end