aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/referentials_controller_spec.rb
diff options
context:
space:
mode:
authorZog2018-02-08 10:33:46 +0100
committerLuc Donnet2018-02-20 10:20:18 +0100
commit3dcea81c627c1c740630ce7306bac55256ce8037 (patch)
tree1ff79bdb5f04aba4503b47c781aaa0146d1ac32a /spec/controllers/referentials_controller_spec.rb
parent3809301116aec5466445b29637026804da3d6745 (diff)
downloadchouette-core-3dcea81c627c1c740630ce7306bac55256ce8037.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.rb52
1 files changed, 43 insertions, 9 deletions
diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb
index f97480600..5e0b1e505 100644
--- a/spec/controllers/referentials_controller_spec.rb
+++ b/spec/controllers/referentials_controller_spec.rb
@@ -15,8 +15,7 @@ describe ReferentialsController, :type => :controller do
end
context "user's organisation doesn't match referential's organisation" do
- pending "hotfix opens all unknow actions need to close the uneeded later" do
- #it 'raises a ActiveRecord::RecordNotFound' do
+ it 'raises a ActiveRecord::RecordNotFound' do
expect { put :archive, id: other_referential.id }.to raise_error(ActiveRecord::RecordNotFound)
end
end
@@ -26,7 +25,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 +42,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')
)