blob: 6d3db9d55f74564abec53d6044a638e77a27eac2 (
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
|
describe "Routes", :type => :feature do
login_user
let(:line) { create :line }
let(:route) { create(:route, :line => line) }
describe 'permissions' do
before do
@user.update(organisation: referential.organisation)
allow_any_instance_of(RoutePolicy).to receive(:edit?).and_return permission
allow_any_instance_of(RoutePolicy).to receive(:destroy?).and_return permission
visit path
end
describe 'on show view' do
let( :path ){ referential_line_route_path(referential, line, route) }
context 'if present → ' do
let( :permission ){ true }
it 'view shows the corresponding buttons' do
expected_edit_url = edit_referential_line_route_path(referential, line, route)
expected_delete_url = referential_line_route_path(referential, line, route)
expect( page ).to have_link('Editer', href: expected_edit_url)
expect( page ).to have_link('Supprimer', href: expected_delete_url)
end
end
context 'if absent → ' do
let( :permission ){ false }
it 'view does not show the corresponding buttons' do
expect( page ).not_to have_link('Editer')
expect( page ).not_to have_link('Supprimer')
end
end
end
end
end
|