diff options
| author | Luc Donnet | 2017-07-13 17:13:12 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-07-13 17:13:12 +0200 |
| commit | ea3ad8d1f9db76e3d2dfc5f96c930af8db074690 (patch) | |
| tree | bde3f033418d512a80ef28703abb4c021c5a0f06 /spec | |
| parent | 3ef09ffa403dd253c19537bd3d477357d85bfa3d (diff) | |
| parent | 0a2f9ff965389133fb9656dfb5b222ccfc2b0531 (diff) | |
| download | chouette-core-ea3ad8d1f9db76e3d2dfc5f96c930af8db074690.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/referentials_controller_spec.rb | 3 | ||||
| -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/models/clean_up_spec.rb | 12 | ||||
| -rw-r--r-- | spec/views/networks/show.html.erb_spec.rb | 7 | ||||
| -rw-r--r-- | spec/views/routes/show.html.erb_spec.rb | 69 | ||||
| -rw-r--r-- | spec/views/stop_areas/show.html.erb_spec.rb | 2 |
9 files changed, 77 insertions, 86 deletions
diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb index 500c6d2d6..a3be0dbd1 100644 --- a/spec/controllers/referentials_controller_spec.rb +++ b/spec/controllers/referentials_controller_spec.rb @@ -15,7 +15,8 @@ describe ReferentialsController, :type => :controller do end context "user's organisation doesn't match referential's organisation" do - it 'raises a ActiveRecord::RecordNotFound' do + pending "hotfix opens all unknow actions need to close the uneeded later" do + #it 'raises a ActiveRecord::RecordNotFound' do expect { put :archive, id: other_referential.id }.to raise_error(ActiveRecord::RecordNotFound) end end 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/models/clean_up_spec.rb b/spec/models/clean_up_spec.rb index e03921582..2753c8718 100644 --- a/spec/models/clean_up_spec.rb +++ b/spec/models/clean_up_spec.rb @@ -6,6 +6,18 @@ RSpec.describe CleanUp, :type => :model do it { should validate_presence_of(:begin_date).with_message(:presence) } it { should belong_to(:referential) } + context 'Clean Up With Date Type : Between' do + subject(:cleaner) { create(:clean_up, date_type: :between) } + it { should validate_presence_of(:end_date).with_message(:presence) } + + it 'should have a end date strictly greater than the begin date' do + expect(cleaner).to be_valid + + cleaner.end_date = cleaner.begin_date + expect(cleaner).not_to be_valid + end + end + context '#exclude_dates_in_overlapping_period with :before date_type' do let(:time_table) { create(:time_table) } let(:period) { time_table.periods[0] } 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 7557ede27..dae8c9ed3 100644 --- a/spec/views/routes/show.html.erb_spec.rb +++ b/spec/views/routes/show.html.erb_spec.rb @@ -1,42 +1,41 @@ -require 'spec_helper' +RSpec.describe "/routes/show", type: :view do -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) do + assign :route_sp, ModelDecorator.decorate( + route.stop_points, + with: StopPointDecorator + ) + end - # Fix tests to permit params to be used... + before do + self.params.merge!({ + id: route.id, + line_id: line.id, + 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 - # assign_referential - # let!(:line) { assign :line, create(:line) } - # let!(:route) { assign :route, create(:route, :line => line) } - # let!(:route_sp) { assign :route_sp, route.stop_points } - # let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) } - # - # - # before do - # self.params.merge!({ - # id: route.id, - # line_id: line.id, - # referential_id: referential.id - # }) - # end + it "should render h1 with the route name" do + render + expect(rendered).to have_selector("h1", :text => Regexp.new(route.name)) + end - # it "should render h1 with the route name" do - # render - # expect(rendered).to have_selector("h1", :text => Regexp.new(line.name)) - # end + it "should render a link to edit the route" do + render + expect(rendered).to have_selector("a[href='#{view.edit_referential_line_route_path(referential, line, route)}']") + end - # it "should display a map with class 'line'" do - # render - # expect(rendered).to have_selector("#map", :class => 'line') - # end - - # it "should render a link to edit the route" do - # render - # expect(rendered).to have_selector("a[href='#{view.edit_referential_line_route_path(referential, line, route)}']") - # end - # - # it "should render a link to remove the route" do - # render - # expect(rendered).to have_selector("a[href='#{view.referential_line_route_path(referential, line, route)}']") - # end + it "should render a link to remove the route" do + render + expect(rendered).to have_selector("a[href='#{view.referential_line_route_path(referential, line, route)}']") + end end 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)) } |
