diff options
| -rw-r--r-- | spec/features/line_referentials_permissions_spec.rb | 30 | ||||
| -rw-r--r-- | spec/features/stop_area_referentials_permissions_spec.rb | 30 | ||||
| -rw-r--r-- | spec/policies/stop_area_referential_policy_spec.rb (renamed from spec/policies/sto_area_referential_policy_spec.rb) | 0 | 
3 files changed, 60 insertions, 0 deletions
| diff --git a/spec/features/line_referentials_permissions_spec.rb b/spec/features/line_referentials_permissions_spec.rb new file mode 100644 index 000000000..845ffe9c1 --- /dev/null +++ b/spec/features/line_referentials_permissions_spec.rb @@ -0,0 +1,30 @@ +RSpec.describe 'LineReferentials', type: :feature do +  login_user + +  let(:line_referential) { first_workgroup.line_referential } + +  describe 'permissions' do +    before do +      allow_any_instance_of(LineReferentialPolicy).to receive(:synchronize?).and_return permission +      visit path +    end + +    context 'on show view' do +      let( :path ){ line_referential_path(line_referential.id) } + +      context 'if present → ' do +        let( :permission ){ true } +        it 'shows an edit button' do +          expect(page).to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) +        end +      end + +      context 'if absent → ' do +        let( :permission ){ false } +        it 'does not show any edit button' do +          expect(page).not_to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) +        end +      end +    end +  end +end diff --git a/spec/features/stop_area_referentials_permissions_spec.rb b/spec/features/stop_area_referentials_permissions_spec.rb new file mode 100644 index 000000000..ca7038d51 --- /dev/null +++ b/spec/features/stop_area_referentials_permissions_spec.rb @@ -0,0 +1,30 @@ +RSpec.describe 'StopAreaReferentials', type: :feature do +  login_user + +  let(:stop_area_referential) { first_workgroup.stop_area_referential } + +  describe 'permissions' do +    before do +      allow_any_instance_of(StopAreaReferentialPolicy).to receive(:synchronize?).and_return permission +      visit path +    end + +    context 'on show view' do +      let( :path ){ stop_area_referential_path(stop_area_referential.id) } + +      context 'if present → ' do +        let( :permission ){ true } +        it 'shows an edit button' do +          expect(page).to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) +        end +      end + +      context 'if absent → ' do +        let( :permission ){ false } +        it 'does not show any edit button' do +          expect(page).not_to have_css('a.btn.btn-default', text: I18n.t('actions.sync')) +        end +      end +    end +  end +end diff --git a/spec/policies/sto_area_referential_policy_spec.rb b/spec/policies/stop_area_referential_policy_spec.rb index 5bd6da427..5bd6da427 100644 --- a/spec/policies/sto_area_referential_policy_spec.rb +++ b/spec/policies/stop_area_referential_policy_spec.rb | 
