diff options
| author | Robert | 2017-07-03 15:34:11 +0200 | 
|---|---|---|
| committer | Robert | 2017-07-04 21:54:04 +0200 | 
| commit | c48ad4fde3056ef04645b73f7eab54ff867d370c (patch) | |
| tree | 57af273b48f1ece1b5e16244d6957f407a5d9563 /spec/features | |
| parent | 747d333ffbcc8ee0c9f1daf93ccca32799434e04 (diff) | |
| download | chouette-core-c48ad4fde3056ef04645b73f7eab54ff867d370c.tar.bz2 | |
Refs: #3478@1h
newapplication helper default authorization, (no if) ->
   * DefaultPolicy (all true)
   * Add some policies (LinePolicy)
   * Use `boiv:read` pour show, index
   * Adapted `table_builder`
Diffstat (limited to 'spec/features')
| -rw-r--r-- | spec/features/lines_spec.rb | 144 | ||||
| -rw-r--r-- | spec/features/routes_spec.rb | 193 | ||||
| -rw-r--r-- | spec/features/workbenches_spec.rb | 7 | 
3 files changed, 172 insertions, 172 deletions
| diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb index a55f30ebc..2a442bd2f 100644 --- a/spec/features/lines_spec.rb +++ b/spec/features/lines_spec.rb @@ -8,89 +8,91 @@ describe "Lines", type: :feature do    let!(:group_of_line) { create(:group_of_line) }    subject { lines.first } -  describe "index" do -    before(:each) { visit line_referential_lines_path(line_referential) } +  with_permissions "boiv:read" do +    describe "index" do +      before(:each) { visit line_referential_lines_path(line_referential) } -    it "displays lines" do -      expect(page).to have_content(lines.first.name) -      expect(page).to have_content(lines.last.name) -    end - -    it 'allows only R in CRUD' do -      expect(page).to have_link(I18n.t('actions.show')) -      expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_path(referential, lines.first)) -      expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_path(referential, lines.first)) -      expect(page).not_to have_link(I18n.t('actions.add'), href: new_referential_line_path(referential)) -    end - -    context 'filtering' do -      it 'supports filtering by name' do -        fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.name -        click_button 'search-btn' +      it "displays lines" do          expect(page).to have_content(lines.first.name) -        expect(page).not_to have_content(lines.last.name) +        expect(page).to have_content(lines.last.name)        end -      it 'supports filtering by number' do -        fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.number -        click_button 'search-btn' -        expect(page).to have_content(lines.first.name) -        expect(page).not_to have_content(lines.last.name) +      it 'allows only R in CRUD' do +        expect(page).to have_link(I18n.t('actions.show')) +        expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_path(referential, lines.first)) +        expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_path(referential, lines.first)) +        expect(page).not_to have_link(I18n.t('actions.add'), href: new_referential_line_path(referential))        end -      it 'supports filtering by objectid' do -        fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.objectid -        click_button 'search-btn' -        expect(page).to have_content(lines.first.name) -        expect(page).not_to have_content(lines.last.name) +      context 'filtering' do +        it 'supports filtering by name' do +          fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.name +          click_button 'search-btn' +          expect(page).to have_content(lines.first.name) +          expect(page).not_to have_content(lines.last.name) +        end + +        it 'supports filtering by number' do +          fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.number +          click_button 'search-btn' +          expect(page).to have_content(lines.first.name) +          expect(page).not_to have_content(lines.last.name) +        end + +        it 'supports filtering by objectid' do +          fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.objectid +          click_button 'search-btn' +          expect(page).to have_content(lines.first.name) +          expect(page).not_to have_content(lines.last.name) +        end        end      end -  end -  describe "show" do -    it "displays line" do -      visit line_referential_line_path(line_referential, lines.first) -      expect(page).to have_content(lines.first.name) +    describe "show" do +      it "displays line" do +        visit line_referential_line_path(line_referential, lines.first) +        expect(page).to have_content(lines.first.name) +      end      end -  end -  # Fixme #1780 -  # describe "new" do -  #   it "creates line and return to show" do -  #     visit line_referential_lines_path(line_referential) -  #     click_link "Ajouter une ligne" -  #     fill_in "line_name", :with => "Line 1" -  #     fill_in "Numéro d'enregistrement", :with => "1" -  #     fill_in "Identifiant Neptune", :with => "chouette:test:Line:999" -  #     click_button("Créer ligne") -  #     expect(page).to have_content("Line 1") -  #   end -  # end +    # Fixme #1780 +    # describe "new" do +    #   it "creates line and return to show" do +    #     visit line_referential_lines_path(line_referential) +    #     click_link "Ajouter une ligne" +    #     fill_in "line_name", :with => "Line 1" +    #     fill_in "Numéro d'enregistrement", :with => "1" +    #     fill_in "Identifiant Neptune", :with => "chouette:test:Line:999" +    #     click_button("Créer ligne") +    #     expect(page).to have_content("Line 1") +    #   end +    # end -  # Fixme #1780 -  # describe "new with group of line", :js => true do -  #   it "creates line and return to show" do -  #     visit new_line_referential_line_path(line_referential) -  #     fill_in "line_name", :with => "Line 1" -  #     fill_in "Numéro d'enregistrement", :with => "1" -  #     fill_in "Identifiant Neptune", :with => "test:Line:999" -  #     fill_in_token_input('line_group_of_line_tokens', :with => "#{group_of_line.name}") -  #     find_button("Créer ligne").trigger("click") -  #     expect(page).to have_text("Line 1") -  #     expect(page).to have_text("#{group_of_line.name}") -  #   end -  # end +    # Fixme #1780 +    # describe "new with group of line", :js => true do +    #   it "creates line and return to show" do +    #     visit new_line_referential_line_path(line_referential) +    #     fill_in "line_name", :with => "Line 1" +    #     fill_in "Numéro d'enregistrement", :with => "1" +    #     fill_in "Identifiant Neptune", :with => "test:Line:999" +    #     fill_in_token_input('line_group_of_line_tokens', :with => "#{group_of_line.name}") +    #     find_button("Créer ligne").trigger("click") +    #     expect(page).to have_text("Line 1") +    #     expect(page).to have_text("#{group_of_line.name}") +    #   end +    # end -  # Fixme #1780 -  # describe "edit and return to show" do -  #   it "edit line" do -  #     visit line_referential_line_path(line_referential, subject) -  #     click_link "Editer cette ligne" -  #     fill_in "line_name", :with => "Line Modified" -  #     fill_in "Numéro d'enregistrement", :with => "test-1" -  #     click_button("Editer ligne") -  #     expect(page).to have_content("Line Modified") -  #   end -  # end +    # Fixme #1780 +    # describe "edit and return to show" do +    #   it "edit line" do +    #     visit line_referential_line_path(line_referential, subject) +    #     click_link "Editer cette ligne" +    #     fill_in "line_name", :with => "Line Modified" +    #     fill_in "Numéro d'enregistrement", :with => "test-1" +    #     click_button("Editer ligne") +    #     expect(page).to have_content("Line Modified") +    #   end +    # end +  end  end diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb index 28015f011..561725ddd 100644 --- a/spec/features/routes_spec.rb +++ b/spec/features/routes_spec.rb @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -require 'spec_helper' -  describe "Routes", :type => :feature do    login_user @@ -13,130 +10,132 @@ describe "Routes", :type => :feature do    before { @user.update(organisation: referential.organisation) } -  describe "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) +  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      end -  end -  describe "from line's page to route's page" do -    it "display route properties" do -      visit referential_line_path(referential, line) -      click_link "#{route.name}" -      expect(page).to have_content(route.name) -      expect(page).to have_content(route.number) +    describe "from line's page to route's page" do +      it "display route properties" do +        visit referential_line_path(referential, line) +        click_link "#{route.name}" +        expect(page).to have_content(route.name) +        expect(page).to have_content(route.number) +      end      end -  end -  describe "from line's page, create a new route" do -    it "return to line's page that display new route" do -      visit referential_line_path(referential, line) -      click_link "Ajouter un itinéraire" -      fill_in "route_name", :with => "A to B" -      fill_in "route_published_name", :with => "Published A to B" -      # select 'Aller', :from => "route_direction" -      check('route[wayback]') -      click_button("Valider") -      expect(page).to have_content("A to B") -      expect(page).to have_content("Published A to B") -       +    describe "from line's page, create a new route" do +      it "return to line's page that display new route" do +        visit referential_line_path(referential, line) +        click_link "Ajouter un itinéraire" +        fill_in "route_name", :with => "A to B" +        fill_in "route_published_name", :with => "Published A to B" +        # select 'Aller', :from => "route_direction" +        check('route[wayback]') +        click_button("Valider") +        expect(page).to have_content("A to B") +        expect(page).to have_content("Published A to B") + +      end      end -  end -  describe "Modifies boarding/alighting properties on route stops" do -    xit "Puts (http) an update request" do -      #visit edit_boarding_alighting_referential_line_route_path(referential, line, route) -      visit referential_line_route_path(referential, line, route) - -      click_link I18n.t('routes.actions.edit_boarding_alighting') -      #select('', :from => '') -      # Changes the boarding of the first stop -      # Changes the alighting of the last stop -      # save -      #click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one'))) -      click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one'))) +    describe "Modifies boarding/alighting properties on route stops" do +      xit "Puts (http) an update request" do +        #visit edit_boarding_alighting_referential_line_route_path(referential, line, route) +        visit referential_line_route_path(referential, line, route) + +        click_link I18n.t('routes.actions.edit_boarding_alighting') +        #select('', :from => '') +        # Changes the boarding of the first stop +        # Changes the alighting of the last stop +        # save +        #click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one'))) +        click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one'))) +      end      end -  end -  describe 'show' do -    before(:each) { visit referential_line_route_path(referential, line, route) } +    describe 'show' do +      before(:each) { visit referential_line_route_path(referential, line, route) } -    context 'user has permission to edit journey patterns' do -      skip "not sure the spec is correct or the code" do -        it 'shows edit links for journey patterns' do -          expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern)) +      context 'user has permission to edit journey patterns' do +        skip "not sure the spec is correct or the code" do +          it 'shows edit links for journey patterns' do +            expect(page).to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern)) +          end          end        end -    end -    context 'user does not have permission to edit journey patterns' do -      it 'does not show edit links for journey patterns' do -        @user.update_attribute(:permissions, []) -        visit referential_line_route_path(referential, line, route) -        expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern)) +      context 'user does not have permission to edit journey patterns' do +        it 'does not show edit links for journey patterns' do +          @user.update_attribute(:permissions, []) +          visit referential_line_route_path(referential, line, route) +          expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_journey_pattern_path(referential, line, route, journey_pattern)) +        end        end -    end -    context 'user has permission to destroy journey patterns' do -      it 'shows destroy links for journey patterns' do -        expect(page).to have_content(I18n.t('actions.destroy')) +      context 'user has permission to destroy journey patterns' do +        it 'shows destroy links for journey patterns' do +          expect(page).to have_content(I18n.t('actions.destroy')) +        end        end -    end -    context 'user does not have permission to destroy journey patterns' do -      it 'does not show destroy links for journey patterns' do -        @user.update_attribute(:permissions, []) -        visit referential_line_route_path(referential, line, route) -        expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_journey_pattern_path(referential, line, route, journey_pattern)) +      context 'user does not have permission to destroy journey patterns' do +        it 'does not show destroy links for journey patterns' do +          @user.update_attribute(:permissions, []) +          visit referential_line_route_path(referential, line, route) +          expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_journey_pattern_path(referential, line, route, journey_pattern)) +        end        end      end -  end -  describe 'referential line show' do -    before(:each) { visit referential_line_path(referential, line) } +    describe 'referential line show' do +      before(:each) { visit referential_line_path(referential, line) } -    context 'user has permission to edit routes' do -      it 'shows edit buttons for routes' do -        expect(page).to have_content(I18n.t('actions.edit')) +      context 'user has permission to edit routes' do +        it 'shows edit buttons for routes' do +          expect(page).to have_content(I18n.t('actions.edit')) +        end        end -    end -    context 'user does not have permission to edit routes' do -      it 'does not show edit buttons for routes' do -        @user.update_attribute(:permissions, []) -        visit referential_line_path(referential, line) -        expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_path(referential, line, route)) +      context 'user does not have permission to edit routes' do +        it 'does not show edit buttons for routes' do +          @user.update_attribute(:permissions, []) +          visit referential_line_path(referential, line) +          expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_path(referential, line, route)) +        end        end -    end -    context 'user has permission to create routes' do -      it 'shows link to a create route page' do -        expect(page).to have_content(I18n.t('routes.actions.new')) +      context 'user has permission to create routes' do +        it 'shows link to a create route page' do +          expect(page).to have_content(I18n.t('routes.actions.new')) +        end        end -    end -    context 'user belongs to another organisation' do -      xit 'does not show link to a create route page' do -        expect(page).not_to have_content(I18n.t('routes.actions.new')) +      context 'user belongs to another organisation' do +        xit 'does not show link to a create route page' do +          expect(page).not_to have_content(I18n.t('routes.actions.new')) +        end        end -    end -    context 'user does not have permission to create routes' do -      it 'does not show link to a create route page' do -        @user.update_attribute(:permissions, []) -        visit referential_line_path(referential, line) -        expect(page).not_to have_content(I18n.t('routes.actions.new')) +      context 'user does not have permission to create routes' do +        it 'does not show link to a create route page' do +          @user.update_attribute(:permissions, []) +          visit referential_line_path(referential, line) +          expect(page).not_to have_content(I18n.t('routes.actions.new')) +        end        end -    end -    context 'user does not have permission to destroy routes' do -      it 'does not show destroy buttons for routes' do -        @user.update_attribute(:permissions, []) -        visit referential_line_path(referential, line) -        expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_path(referential, line, route)) +      context 'user does not have permission to destroy routes' do +        it 'does not show destroy buttons for routes' do +          @user.update_attribute(:permissions, []) +          visit referential_line_path(referential, line) +          expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_path(referential, line, route)) +        end        end      end    end diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb index 9a40a8376..cad70624f 100644 --- a/spec/features/workbenches_spec.rb +++ b/spec/features/workbenches_spec.rb @@ -156,7 +156,6 @@ describe 'Workbenches', type: :feature do            end          end        end -    end      context 'permissions' do        before(:each) do @@ -177,7 +176,6 @@ describe 'Workbenches', type: :feature do          end        end      end -  end    describe 'create new Referential' do      it "create a new Referential with a specifed line and period" do @@ -188,8 +186,9 @@ describe 'Workbenches', type: :feature do        fill_in "referential[name]", with: "Referential to test creation"        select workbench.lines.first.id, from: 'referential[metadatas_attributes][0][lines][]' -      click_button "Valider" -      expect(page).to have_css("h1", text: "Referential to test creation") +        click_button "Valider" +        expect(page).to have_css("h1", text: "Referential to test creation") +      end      end    end  end | 
