diff options
| author | Zog | 2018-04-13 11:06:27 +0200 | 
|---|---|---|
| committer | Zog | 2018-04-13 11:06:27 +0200 | 
| commit | 13087614ceb0e9e3a604cd08a023f11cd0567bea (patch) | |
| tree | 530f9cca1642fedc0c8a3ece201357ba6c4762b7 /spec/controllers | |
| parent | 94090e82bfb5f875f70aa1e8bffb8a51724eb760 (diff) | |
| download | chouette-core-13087614ceb0e9e3a604cd08a023f11cd0567bea.tar.bz2 | |
Refs #6536; Cleanup value passed for secondary_company_ids by the lines form6536-fix-lines-form
Diffstat (limited to 'spec/controllers')
| -rw-r--r-- | spec/controllers/lines_controller_spec.rb | 29 | 
1 files changed, 28 insertions, 1 deletions
| diff --git a/spec/controllers/lines_controller_spec.rb b/spec/controllers/lines_controller_spec.rb index 96f49bb36..78020484b 100644 --- a/spec/controllers/lines_controller_spec.rb +++ b/spec/controllers/lines_controller_spec.rb @@ -1,9 +1,36 @@  RSpec.describe LinesController, :type => :controller do    login_user -  let(:line_referential) { create :line_referential, member: @user.organisation } +  let(:line_referential) { create :line_referential, member: @user.organisation, objectid_format: :netex }    let(:line) { create :line, line_referential: line_referential } +  describe 'POST create' do +    let(:line_attrs){{ +      name: "test", +      transport_mode: "bus" +    }} +    let(:request){ post :create, line_referential_id: line_referential.id, line: line_attrs } + +    with_permission "lines.create" do +      it "should create a new line" do +        expect{request}.to change{ line_referential.lines.count }.by 1 +      end + +      context "with an empty value in secondary_company_ids" do +        let(:line_attrs){{ +          name: "test", +          transport_mode: "bus", +          secondary_company_ids: [""] +        }} + +        it "should cleanup secondary_company_ids" do +          expect{request}.to change{ line_referential.lines.count }.by 1 +          expect(line_referential.lines.last.secondary_company_ids).to eq [] +        end +      end +    end +  end +    describe 'PUT deactivate' do      let(:request){ put :deactivate, id: line.id, line_referential_id: line_referential.id } | 
