aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/line_footnotes_permissions_spec.rb
blob: 62adbfcd55c518597082800f2e8e6d908cdbcff8 (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
31
32
33
34
35
36
37
38
describe 'Line Footnotes', type: :feature do
  login_user

  let!(:line) { create :line_with_stop_areas, network: network, company: company, line_referential: line_referential }
  let(:referential) { Referential.first }
  let( :line_referential ){ referential.line_referential }
  let(:network) { create(:network) }
  let(:company) { create(:company) }


  describe 'permissions' do
    before do
      allow_any_instance_of(LinePolicy).to receive(:update_footnote?).and_return permission
      visit path
    end

    describe 'on show view' do
      let( :path ){ referential_line_footnotes_path(line_referential, line) }

      context 'if present → ' do 
        let( :permission ){ true }

        it 'displays the corresponding button' do
          expect( page ).to have_link('Editer', href: edit_referential_line_footnotes_path(line_referential, line))
        end
      end

      context 'if absent → ' do 
        let( :permission ){ false }

        it 'does not display the corresponding button' do
          expect( page ).not_to have_link('Editer', href: edit_referential_line_footnotes_path(line_referential, line))
        end
      end
    end

  end
end