aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/line_referentials_permissions_spec.rb
blob: 845ffe9c17c8d270c095228822a268e396d5972e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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