blob: 0d156f0d6508eff0ee70940b0c81d60620575fc6 (
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
39
40
41
42
43
44
 | # -*- coding: utf-8 -*-
describe 'ReferentialLines', type: :feature do
  login_user
  let!(:referential_metadata) { create :referential_metadata, referential: referential }
  let( :line ){ referential.lines.first }
  context 'permissions' do 
    before do
      allow_any_instance_of(RoutePolicy).to receive(:create?).and_return permission
      visit path
    end
    
    context 'on show view' do 
      let( :path ){ referential_line_path(referential, line) }
      context 'if present → ' do 
        let( :permission ){ true }
        it 'shows the corresponding button' do
          expected_href = new_referential_line_route_path(referential, line)
          expect( page ).to have_link("Ajouter un itinéraire", href: expected_href)
        end
      end
      context 'if absent → ' do 
        let( :permission ){ false }
        it 'does not show the corresponding button' do
          expect( page ).not_to have_link("Ajouter un itinéraire")
        end
      end
    end
    
  end
  # describe 'show' do
  #   it 'displays referential line' do
  #     visit referential_line_path(referential, referential.lines.first)
  #     expect(page).to have_content(referential.lines.first.name)
  #   end
  #   it 'displays referential line' do
  #     visit referential_line_path(referential, referential.lines.first, sort: "stop_points")
  #     expect(page).to have_content(referential.lines.first.name)
  #   end
  # end
end
 |