diff options
| -rw-r--r-- | app/controllers/companies_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/group_of_lines_controller.rb | 5 | ||||
| -rw-r--r-- | app/controllers/lines_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/networks_controller.rb | 4 | ||||
| -rw-r--r-- | app/views/lines/index.html.slim | 2 | ||||
| -rw-r--r-- | spec/controllers/lines_controller_spec.rb | 4 | ||||
| -rw-r--r-- | spec/factories/line_referentials.rb | 9 | ||||
| -rw-r--r-- | spec/features/companies_spec.rb | 2 | ||||
| -rw-r--r-- | spec/features/group_of_lines_permissions_spec.rb | 4 | ||||
| -rw-r--r-- | spec/features/group_of_lines_spec.rb | 2 | ||||
| -rw-r--r-- | spec/features/lines_spec.rb | 3 | ||||
| -rw-r--r-- | spec/features/networks_spec.rb | 2 | 
12 files changed, 35 insertions, 10 deletions
| diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index 931d846c5..f84252920 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -61,6 +61,10 @@ class CompaniesController < ChouetteController    alias_method :current_referential, :line_referential    helper_method :current_referential +  def begin_of_association_chain +    current_organisation +  end +    def company_params      params.require(:company).permit( :objectid, :object_version, :name, :short_name, :organizational_unit, :operating_department_name, :code, :phone, :fax, :email, :registration_number, :url, :time_zone )    end diff --git a/app/controllers/group_of_lines_controller.rb b/app/controllers/group_of_lines_controller.rb index 5762108dc..46d9d077f 100644 --- a/app/controllers/group_of_lines_controller.rb +++ b/app/controllers/group_of_lines_controller.rb @@ -42,7 +42,6 @@ class GroupOfLinesController < ChouetteController      end    end -    protected    def filtered_group_of_lines_maps @@ -70,6 +69,10 @@ class GroupOfLinesController < ChouetteController    alias_method :line_referential, :parent +  def begin_of_association_chain +    current_organisation +  end +    private    def group_of_line_params diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index f446e1d37..7041a3a26 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -114,6 +114,10 @@ class LinesController < ChouetteController    alias_method :current_referential, :line_referential    helper_method :current_referential +  def begin_of_association_chain +    current_organisation +  end +    def line_params      params.require(:line).permit(        :transport_mode, diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb index 494d1e69f..79a5eb97b 100644 --- a/app/controllers/networks_controller.rb +++ b/app/controllers/networks_controller.rb @@ -71,6 +71,10 @@ class NetworksController < ChouetteController    alias_method :current_referential, :line_referential    helper_method :current_referential +  def begin_of_association_chain +    current_organisation +  end +    def network_params      params.require(:network).permit(:objectid, :object_version, :version_date, :description, :name, :registration_number, :source_name, :source_type_name, :source_identifier, :comment )    end diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim index e94837ed5..b62263263 100644 --- a/app/views/lines/index.html.slim +++ b/app/views/lines/index.html.slim @@ -1,6 +1,6 @@  - breadcrumb :lines, @line_referential  - content_for :page_header_actions do -  - if (policy(Chouette::Line).create? && @line_referential.organisations.include?(current_organisation)) +  - if policy(Chouette::Line).create?      = link_to(t('lines.actions.new'), new_line_referential_line_path(@line_referential), class: 'btn btn-primary')  .page_content diff --git a/spec/controllers/lines_controller_spec.rb b/spec/controllers/lines_controller_spec.rb index ce5adbbdd..65fe88b96 100644 --- a/spec/controllers/lines_controller_spec.rb +++ b/spec/controllers/lines_controller_spec.rb @@ -1,14 +1,14 @@  RSpec.describe LinesController, :type => :controller do    login_user -  let(:line_referential) { create :line_referential } +  let(:line_referential) { create :line_referential, member: @user.organisation }    let(:line) { create :line, line_referential: line_referential }    describe 'PUT deactivate' do      let(:request){ put :deactivate, id: line.id, line_referential_id: line_referential.id }      it 'should redirect to 403' do -       expect(request).to redirect_to "/403" +      expect(request).to redirect_to "/403"      end      with_permission "lines.change_status" do diff --git a/spec/factories/line_referentials.rb b/spec/factories/line_referentials.rb index e9e6dce5a..8c2aad646 100644 --- a/spec/factories/line_referentials.rb +++ b/spec/factories/line_referentials.rb @@ -2,5 +2,14 @@ FactoryGirl.define do    factory :line_referential do      sequence(:name) { |n| "Line Referential #{n}" }      objectid_format 'stif_codifligne' + +    transient do +      member nil +    end + +    after(:create) do |line_referential, evaluator| +      line_referential.add_member evaluator.member if evaluator.member +      line_referential.save +    end    end  end diff --git a/spec/features/companies_spec.rb b/spec/features/companies_spec.rb index 1b9dae56f..4e778b3a0 100644 --- a/spec/features/companies_spec.rb +++ b/spec/features/companies_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper'  describe "Companies", :type => :feature do    login_user -  let(:line_referential) { create :line_referential } +  let(:line_referential) { create :line_referential, member: @user.organisation }    let!(:companies) { Array.new(2) { create :company, line_referential: line_referential } }    subject { companies.first } diff --git a/spec/features/group_of_lines_permissions_spec.rb b/spec/features/group_of_lines_permissions_spec.rb index 5c03481ec..33d78c0dd 100644 --- a/spec/features/group_of_lines_permissions_spec.rb +++ b/spec/features/group_of_lines_permissions_spec.rb @@ -22,7 +22,7 @@ describe "Group of lines", :type => :feature do        context 'on show view' do          let( :path ){ line_referential_group_of_line_path(line_referential, group_of_line, delete: true) } -        context 'if permissions present → ' do  +        context 'if permissions present → ' do            let( :permission ){ true }            it 'shows the appropriate buttons' do @@ -30,7 +30,7 @@ describe "Group of lines", :type => :feature do              expect( page ).to have_link('Supprimer', href: expected_url)            end          end -        context 'if permissions absent → ' do  +        context 'if permissions absent → ' do            let( :permission ){ false }            it 'shows the appropriate buttons' do diff --git a/spec/features/group_of_lines_spec.rb b/spec/features/group_of_lines_spec.rb index 59101ccd5..8b88e6e9e 100644 --- a/spec/features/group_of_lines_spec.rb +++ b/spec/features/group_of_lines_spec.rb @@ -10,7 +10,7 @@ describe "Group of lines", :type => :feature do    let!(:group_of_lines) { Array.new(2) { create(:group_of_line, line_referential: line_referential) } }    subject { group_of_lines.first } -  let(:line_referential) { create :line_referential } +  let(:line_referential) { create :line_referential, member: @user.organisation }    before :each do      subject.lines << line diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb index 2a442bd2f..f142b7da9 100644 --- a/spec/features/lines_spec.rb +++ b/spec/features/lines_spec.rb @@ -1,7 +1,8 @@ +# coding: utf-8  describe "Lines", type: :feature do    login_user -  let(:line_referential) { create :line_referential } +  let(:line_referential) { create :line_referential, member: @user.organisation }    let!(:network) { create(:network) }    let!(:company) { create(:company) }    let!(:lines) { Array.new(2) { create :line_with_stop_areas, network: network, company: company, line_referential: line_referential } } diff --git a/spec/features/networks_spec.rb b/spec/features/networks_spec.rb index 75070e7fa..1a822e7c9 100644 --- a/spec/features/networks_spec.rb +++ b/spec/features/networks_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper'  describe "Networks", :type => :feature do    login_user -  let(:line_referential) { create :line_referential } +  let(:line_referential) { create :line_referential, member: @user.organisation }    let!(:networks) { Array.new(2) { create(:network, line_referential: line_referential) } }    subject { networks.first } | 
