blob: 7910ace288385fc42f52df7ecfdf810658e076f0 (
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
45
46
47
48
49
50
|
require 'spec_helper'
describe "referentials/show", type: :view do
let(:referential) do
referential = create(:workbench_referential)
assign :referential, referential.decorate(context: {
current_organisation: referential.organisation
})
end
let(:organisation){ referential.try(:organisation) }
let(:permissions){ [] }
let(:current_organisation) { organisation }
let(:organisation) { referential.organisation }
let(:readonly){ false }
before :each do
allow(referential.object).to receive(:referential_read_only?){ readonly }
assign :reflines, []
allow(view).to receive(:current_organisation).and_return(current_organisation)
allow(view).to receive(:current_user).and_return(current_user)
allow(view).to receive(:resource).and_return(referential)
allow(view).to receive(:has_feature?).and_return(true)
allow(view).to receive(:user_signed_in?).and_return true
allow(view).to receive(:mutual_workbench).and_return referential.workbench
controller.request.path_parameters[:id] = referential.id
allow(view).to receive(:params).and_return({action: :show})
render template: "referentials/show", layout: "layouts/application"
end
it "should not present edit button" do
expect(rendered).to_not have_selector("a[href=\"#{view.edit_referential_path(referential)}\"]")
end
with_permission "referentials.update" do
it "should present edit button" do
expect(rendered).to have_selector("a[href=\"#{view.edit_referential_path(referential)}\"]")
end
context "with a readonly referential" do
let(:readonly){ true }
it "should not present edit button" do
expect(rendered).to_not have_selector("a[href=\"#{view.edit_referential_path(referential)}\"]")
end
end
end
end
|