diff options
| author | cedricnjanga | 2018-01-30 06:37:52 -0800 | 
|---|---|---|
| committer | cedricnjanga | 2018-01-30 06:37:52 -0800 | 
| commit | 7ec19d8dc153e1491cb1a693b11b3b0a351f316c (patch) | |
| tree | 6da6a8bbcf1ae789a460fece5cf7e961562c5222 /spec/views | |
| parent | f32d869cc3f34a939764cc3fa4d612a5d6544d08 (diff) | |
| parent | 617a54cf63d7f11111b168534d49cdc04a5865d4 (diff) | |
| download | chouette-core-7ec19d8dc153e1491cb1a693b11b3b0a351f316c.tar.bz2 | |
Merge branch 'master' into 5683-add_workgroup_id_to_calendars
Diffstat (limited to 'spec/views')
| -rw-r--r-- | spec/views/lines/index.html.slim_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/referentials/show.html.erb_spec.rb | 45 | ||||
| -rw-r--r-- | spec/views/stop_areas/index.html.slim_spec.rb | 1 | 
3 files changed, 48 insertions, 0 deletions
| diff --git a/spec/views/lines/index.html.slim_spec.rb b/spec/views/lines/index.html.slim_spec.rb index 498784912..fb436c545 100644 --- a/spec/views/lines/index.html.slim_spec.rb +++ b/spec/views/lines/index.html.slim_spec.rb @@ -19,7 +19,9 @@ describe "/lines/index", :type => :view do      deactivated_line      allow(view).to receive(:collection).and_return(lines)      allow(view).to receive(:current_referential).and_return(line_referential) +    allow(view).to receive(:params).and_return({action: :index})      controller.request.path_parameters[:line_referential_id] = line_referential.id +    controller.request.path_parameters[:action] = "index"      render    end diff --git a/spec/views/referentials/show.html.erb_spec.rb b/spec/views/referentials/show.html.erb_spec.rb index f1fa7188a..4a2afe2ca 100644 --- a/spec/views/referentials/show.html.erb_spec.rb +++ b/spec/views/referentials/show.html.erb_spec.rb @@ -1,4 +1,49 @@  require 'spec_helper'  describe "referentials/show", type: :view do + +  let!(:referential) do +    referential = create(:referential) +    assign :referential, referential.decorate(context: { +      current_organisation: referential.organisation +    }) +  end +  let(:permissions){ [] } +  let(:current_organisation) { organisation } +  let(:current_offer_workbench) { create :workbench, organisation: current_organisation} +  let(:readonly){ false } + +  before :each do +    assign :reflines, [] +    allow(view).to receive(:current_offer_workbench).and_return(current_offer_workbench) +    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 +    controller.request.path_parameters[:id] = referential.id +    allow(view).to receive(:params).and_return({action: :show}) + +    allow(referential).to receive(:referential_read_only?){ readonly } +    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 diff --git a/spec/views/stop_areas/index.html.slim_spec.rb b/spec/views/stop_areas/index.html.slim_spec.rb index 520cecc1a..6e66c5ab9 100644 --- a/spec/views/stop_areas/index.html.slim_spec.rb +++ b/spec/views/stop_areas/index.html.slim_spec.rb @@ -13,6 +13,7 @@ describe "/stop_areas/index", :type => :view do      allow(view).to receive(:link_with_search).and_return("#")      allow(view).to receive(:collection).and_return(stop_areas)      allow(view).to receive(:current_referential).and_return(stop_area_referential) +    allow(view).to receive(:params).and_return({action: :index})      controller.request.path_parameters[:stop_area_referential_id] = stop_area_referential.id      render    end | 
