diff options
| author | Zog | 2018-02-08 10:33:46 +0100 |
|---|---|---|
| committer | Zog | 2018-02-08 10:33:46 +0100 |
| commit | 9442303a794a32ee431baada5cea15467323f629 (patch) | |
| tree | d05aca8b761e5753110ba47879b076d5bbac440a /spec/controllers/referentials_controller_spec.rb | |
| parent | 4f58c4eaca46dc975aa907840cdbe067f6225d5e (diff) | |
| download | chouette-core-9442303a794a32ee431baada5cea15467323f629.tar.bz2 | |
Refs #5863 @6h; Remove workbench id from the querystring
Infer it when possible, and use a nested otherwise
Diffstat (limited to 'spec/controllers/referentials_controller_spec.rb')
| -rw-r--r-- | spec/controllers/referentials_controller_spec.rb | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb index f97480600..6964a3e8c 100644 --- a/spec/controllers/referentials_controller_spec.rb +++ b/spec/controllers/referentials_controller_spec.rb @@ -26,7 +26,7 @@ describe ReferentialsController, :type => :controller do it 'gets compliance control set for current organisation' do compliance_control_set = create(:compliance_control_set, organisation: @user.organisation) create(:compliance_control_set) - get :select_compliance_control_set, referential_id: referential.id + get :select_compliance_control_set, id: referential.id expect(assigns[:compliance_control_sets]).to eq([compliance_control_set]) end end @@ -43,16 +43,51 @@ describe ReferentialsController, :type => :controller do end end + describe "GET #new" do + context "when duplicating" do + let(:workbench){ create :workbench} + let(:request){ + get :new, + workbench_id: workbench.id, + from: referential.id + } + + it "duplicates the given referential" do + request + new_referential = assigns(:referential) + expect(new_referential.line_referential).to eq referential.line_referential + expect(new_referential.stop_area_referential).to eq referential.stop_area_referential + expect(new_referential.objectid_format).to eq referential.objectid_format + expect(new_referential.prefix).to eq referential.prefix + expect(new_referential.slug).to eq "#{referential.slug}_clone" + expect(new_referential.workbench).to eq workbench + end + end + end + describe "POST #create" do + let(:workbench){ create :workbench} context "when duplicating" do - it "displays a flash message", pending: 'requires more params to create a valid Referential' do + let(:request){ post :create, - from: referential.id, - current_workbench_id: referential.workbench_id, - referential: { - name: 'Duplicated' - } + workbench_id: workbench.id, + referential: { + name: 'Duplicated', + created_from_id: referential.id, + stop_area_referential: referential.stop_area_referential, + line_referential: referential.line_referential, + objectid_format: referential.objectid_format, + workbench_id: referential.workbench_id + } + } + + it "creates the new referential" do + expect{request}.to change{Referential.count}.by 1 + expect(Referential.last.name).to eq "Duplicated" + end + it "displays a flash message" do + request expect(controller).to set_flash[:notice].to( I18n.t('notice.referentials.duplicate') ) |
