diff options
| author | soykje | 2017-07-12 13:45:23 +0200 | 
|---|---|---|
| committer | GitHub | 2017-07-12 13:45:23 +0200 | 
| commit | 5a55f529aad6b5edc805d774e5cca1e1ff3f66da (patch) | |
| tree | c76eb6abdc2482560599bee1b52d8a9d4625733e /spec | |
| parent | c120db456568dfcc6bb4f0653fc9d9ffa3f1a80a (diff) | |
| parent | 7ea4ab54b53e9d14bf4562df24ed341fbe297f9e (diff) | |
| download | chouette-core-5a55f529aad6b5edc805d774e5cca1e1ff3f66da.tar.bz2 | |
Merge pull request #30 from af83/3479-migrate-all-remaining-table-builder-helper-calls-to-new-version
3479 migrate all remaining table builder helper calls to new version
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/features/referential_lines_spec.rb | 39 | ||||
| -rw-r--r-- | spec/features/routes_spec.rb | 11 | ||||
| -rw-r--r-- | spec/helpers/table_builder_helper/custom_links_spec.rb | 18 | ||||
| -rw-r--r-- | spec/helpers/table_builder_helper_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/networks/show.html.erb_spec.rb | 7 | ||||
| -rw-r--r-- | spec/views/routes/show.html.erb_spec.rb | 11 | ||||
| -rw-r--r-- | spec/views/stop_areas/show.html.erb_spec.rb | 2 | 
7 files changed, 39 insertions, 51 deletions
diff --git a/spec/features/referential_lines_spec.rb b/spec/features/referential_lines_spec.rb index fd003effb..95fc596fd 100644 --- a/spec/features/referential_lines_spec.rb +++ b/spec/features/referential_lines_spec.rb @@ -5,45 +5,6 @@ describe 'ReferentialLines', type: :feature do    login_user    let!(:referential_metadata) { create :referential_metadata, referential: referential } -  describe 'index' do -    before(:each) { visit referential_lines_path(referential) } - -    it 'displays referential lines' do -      expect(page).to have_content(referential.lines.first.name) -      expect(page).to have_content(referential.lines.last.name) -    end - -    it 'allows only R in CRUD' do -      expect(page).to have_content(I18n.t('actions.show')) -      expect(page).not_to have_content(I18n.t('actions.edit')) -      expect(page).not_to have_content(I18n.t('actions.destroy')) -      expect(page).not_to have_content(I18n.t('actions.add')) -    end - -    context 'filtering' do -      it 'supports filtering by name' do -        fill_in 'q[name_or_number_or_objectid_cont]', with: referential.lines.first.name -        click_button 'search-btn' -        expect(page).to have_content(referential.lines.first.name) -        expect(page).not_to have_content(referential.lines.last.name) -      end - -      it 'supports filtering by number' do -        fill_in 'q[name_or_number_or_objectid_cont]', with: referential.lines.first.number -        click_button 'search-btn' -        expect(page).to have_content(referential.lines.first.name) -        expect(page).not_to have_content(referential.lines.last.name) -      end - -      it 'supports filtering by objectid' do -        fill_in 'q[name_or_number_or_objectid_cont]', with: referential.lines.first.objectid -        click_button 'search-btn' -        expect(page).to have_content(referential.lines.first.name) -        expect(page).not_to have_content(referential.lines.last.name) -      end -    end -  end -    describe 'show' do      it 'displays referential line' do        visit referential_line_path(referential, referential.lines.first) diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb index 561725ddd..3bd2071d2 100644 --- a/spec/features/routes_spec.rb +++ b/spec/features/routes_spec.rb @@ -11,13 +11,10 @@ describe "Routes", :type => :feature do    before { @user.update(organisation: referential.organisation) }    with_permissions "boiv:read" do -    context "from lines page to a line page" do -      it "display line's routes" do -        visit referential_lines_path(referential) -        first(:link, 'Consulter').click -        expect(page).to have_content(route.name) -        expect(page).to have_content(route2.name) -      end +    it "line page displays line's routes" do +      visit referential_line_path(referential, line) +      expect(page).to have_content(route.name) +      expect(page).to have_content(route2.name)      end      describe "from line's page to route's page" do diff --git a/spec/helpers/table_builder_helper/custom_links_spec.rb b/spec/helpers/table_builder_helper/custom_links_spec.rb index 4b07922a7..ac60c7da3 100644 --- a/spec/helpers/table_builder_helper/custom_links_spec.rb +++ b/spec/helpers/table_builder_helper/custom_links_spec.rb @@ -1,5 +1,21 @@  describe TableBuilderHelper::CustomLinks do -  describe "#actions_after_policy_check" do +  describe "#polymorphic_url" do +    it "returns the correct URL path for Companies#show" do +      company = build_stubbed(:company) +      user_context = UserContext.new(build_stubbed(:user)) + +      expect( +        TableBuilderHelper::CustomLinks.new( +          company, +          user_context, +          [:show], +          company.line_referential +        ).polymorphic_url(:show) +      ).to eq([company.line_referential, company]) +    end +  end + +  describe "#authorized_actions" do      it "includes :show" do        referential = build_stubbed(:referential)        user_context = UserContext.new( diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index 4f7c1bd69..c536a4c62 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -302,7 +302,7 @@ describe TableBuilderHelper, type: :helper do        companies = ModelDecorator.decorate(          companies,          with: CompanyDecorator, -        context: {line_referential: line_referential} +        context: { referential: line_referential }        )        stub_policy_scope(company) diff --git a/spec/views/networks/show.html.erb_spec.rb b/spec/views/networks/show.html.erb_spec.rb index e613ea948..72605fb46 100644 --- a/spec/views/networks/show.html.erb_spec.rb +++ b/spec/views/networks/show.html.erb_spec.rb @@ -2,7 +2,12 @@ require 'spec_helper'  describe "/networks/show", :type => :view do -  let!(:network) { assign(:network, create(:network)) } +  let!(:network) do +    network = create(:network) +    assign(:network, network.decorate(context: { +      line_referential: network.line_referential +    })) +  end    let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) }    let!(:line_referential) { assign :line_referential, network.line_referential } diff --git a/spec/views/routes/show.html.erb_spec.rb b/spec/views/routes/show.html.erb_spec.rb index 538563578..dae8c9ed3 100644 --- a/spec/views/routes/show.html.erb_spec.rb +++ b/spec/views/routes/show.html.erb_spec.rb @@ -3,7 +3,12 @@ RSpec.describe "/routes/show", type: :view do    assign_referential    let!(:line) { assign :line, create(:line) }    let!(:route) { assign :route, create(:route, :line => line).decorate(context: {referential: referential, line: line }) } -  let!(:route_sp) { assign :route_sp, route.stop_points } +  let!(:route_sp) do +    assign :route_sp, ModelDecorator.decorate( +      route.stop_points, +      with: StopPointDecorator +    ) +  end    before do      self.params.merge!({ @@ -12,6 +17,10 @@ RSpec.describe "/routes/show", type: :view do        referential_id: referential.id      })      allow(view).to receive(:current_referential).and_return(referential) +    allow(view).to receive(:pundit_user).and_return(UserContext.new( +      build_stubbed(:user), +      referential +    ))    end    it "should render h1 with the route name" do diff --git a/spec/views/stop_areas/show.html.erb_spec.rb b/spec/views/stop_areas/show.html.erb_spec.rb index a22379402..6fd416128 100644 --- a/spec/views/stop_areas/show.html.erb_spec.rb +++ b/spec/views/stop_areas/show.html.erb_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper'  describe "/stop_areas/show", :type => :view do    let!(:stop_area_referential) { assign :stop_area_referential, stop_area.stop_area_referential } -  let!(:stop_area) { assign :stop_area, create(:stop_area) } +  let!(:stop_area) { assign :stop_area, create(:stop_area).decorate }    let!(:access_points) { assign :access_points, [] }    let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) }  | 
