diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/factories/calendars.rb | 1 | ||||
| -rw-r--r-- | spec/features/calendars_permissions_spec.rb | 7 | ||||
| -rw-r--r-- | spec/mailers/calendar_mailer_spec.rb | 2 | ||||
| -rw-r--r-- | spec/support/pundit/pundit_view_policy.rb | 5 | ||||
| -rw-r--r-- | spec/support/referential.rb | 4 | ||||
| -rw-r--r-- | spec/views/referentials/show.html.erb_spec.rb | 6 |
6 files changed, 14 insertions, 11 deletions
diff --git a/spec/factories/calendars.rb b/spec/factories/calendars.rb index 5f3188bee..d9fd242d1 100644 --- a/spec/factories/calendars.rb +++ b/spec/factories/calendars.rb @@ -6,6 +6,7 @@ FactoryGirl.define do sequence(:dates) { |n| [ Date.yesterday - n, Date.yesterday - 2*n ] } shared false organisation + workgroup end sequence :date_range do |n| diff --git a/spec/features/calendars_permissions_spec.rb b/spec/features/calendars_permissions_spec.rb index 9b47ab2bb..4857592d5 100644 --- a/spec/features/calendars_permissions_spec.rb +++ b/spec/features/calendars_permissions_spec.rb @@ -2,6 +2,7 @@ RSpec.describe 'Calendars', type: :feature do login_user let(:calendar) { create :calendar, organisation_id: 1 } + let(:workgroup) { calendar.workgroup } describe 'permissions' do before do @@ -13,7 +14,7 @@ RSpec.describe 'Calendars', type: :feature do end context 'on show view' do - let( :path ){ calendar_path(calendar) } + let( :path ){ workgroup_calendar_path(workgroup, calendar) } context 'if present → ' do let( :permission ){ true } @@ -33,7 +34,7 @@ RSpec.describe 'Calendars', type: :feature do end context 'on edit view' do - let( :path ){ edit_calendar_path(calendar) } + let( :path ){ edit_workgroup_calendar_path(workgroup, calendar) } context 'if present → ' do let( :permission ){ true } @@ -51,7 +52,7 @@ RSpec.describe 'Calendars', type: :feature do end context 'on index view' do - let( :path ){ calendars_path } + let( :path ){ workgroup_calendars_path(workgroup) } context 'if present → ' do let( :permission ){ true } diff --git a/spec/mailers/calendar_mailer_spec.rb b/spec/mailers/calendar_mailer_spec.rb index 9a2076f64..00d73a58b 100644 --- a/spec/mailers/calendar_mailer_spec.rb +++ b/spec/mailers/calendar_mailer_spec.rb @@ -20,7 +20,7 @@ RSpec.describe CalendarMailer, type: :mailer do end it 'should have correct body' do - key = I18n.t("mailers.calendar_mailer.#{type}.body", cal_name: calendar.name, cal_index_url: calendars_url) + key = I18n.t("mailers.calendar_mailer.#{type}.body", cal_name: calendar.name, cal_index_url: workgroup_calendars_url(calendar.workgroup)) expect(email).to have_body_text /#{key}/ end end diff --git a/spec/support/pundit/pundit_view_policy.rb b/spec/support/pundit/pundit_view_policy.rb index 91be0624c..330209049 100644 --- a/spec/support/pundit/pundit_view_policy.rb +++ b/spec/support/pundit/pundit_view_policy.rb @@ -2,9 +2,8 @@ module Pundit module PunditViewPolicy def self.included into into.let(:permissions){ nil } - into.let(:organisation){ referential.try(:organisation) } - into.let(:current_referential){ referential || build_stubbed(:referential) } - into.let(:current_user){ build_stubbed :user, permissions: permissions, organisation: organisation } + into.let(:current_referential){ referential || build_stubbed(:referential, organisation: organisation) } + into.let(:current_user){ create :user, permissions: permissions, organisation: organisation } into.let(:pundit_user){ UserContext.new(current_user, referential: current_referential) } into.before do allow(view).to receive(:pundit_user) { pundit_user } diff --git a/spec/support/referential.rb b/spec/support/referential.rb index 497ff47a8..9acdce73a 100644 --- a/spec/support/referential.rb +++ b/spec/support/referential.rb @@ -11,8 +11,8 @@ module ReferentialHelper def self.included(base) base.class_eval do extend ClassMethods - alias_method :referential, :first_referential - alias_method :organisation, :first_organisation + base.let(:referential){ first_referential } + base.let(:organisation){ first_organisation } end end diff --git a/spec/views/referentials/show.html.erb_spec.rb b/spec/views/referentials/show.html.erb_spec.rb index 4a2afe2ca..6fd51949a 100644 --- a/spec/views/referentials/show.html.erb_spec.rb +++ b/spec/views/referentials/show.html.erb_spec.rb @@ -3,20 +3,22 @@ require 'spec_helper' describe "referentials/show", type: :view do let!(:referential) do - referential = create(:referential) + referential = create(:referential, organisation: organisation) assign :referential, referential.decorate(context: { current_organisation: referential.organisation }) end let(:permissions){ [] } let(:current_organisation) { organisation } - let(:current_offer_workbench) { create :workbench, organisation: current_organisation} + let(:current_offer_workbench) { create :workbench, organisation: organisation} + let(:current_workgroup) { current_offer_workbench.workgroup } let(:readonly){ false } before :each do assign :reflines, [] allow(view).to receive(:current_offer_workbench).and_return(current_offer_workbench) allow(view).to receive(:current_organisation).and_return(current_organisation) + allow(view).to receive(:current_workgroup).and_return(current_workgroup) allow(view).to receive(:current_user).and_return(current_user) allow(view).to receive(:resource).and_return(referential) |
