aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/referentials_spec.rb
diff options
context:
space:
mode:
authorcedricnjanga2017-09-11 16:06:42 +0200
committercedricnjanga2017-09-11 16:21:41 +0200
commit8fe9a39516f6fb71545d6329c448680d6f8c75d1 (patch)
tree0b0e231aea62d32fe91544cd79c8224a755ceaf6 /spec/features/referentials_spec.rb
parentecef9d98cbe08e42434753477da4886dcfcb02bb (diff)
downloadchouette-core-8fe9a39516f6fb71545d6329c448680d6f8c75d1.tar.bz2
Update of ReferentialsController#new :
- Add some context to referential and workbench decorator to access current_referential and assign it to the cloned referential - Add a build_referential method to avoir duplicates of code (in the controller and in the model), need to clean a bit more - Need to add some Spec features to take into account the functional scope of the current_user
Diffstat (limited to 'spec/features/referentials_spec.rb')
-rw-r--r--spec/features/referentials_spec.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/features/referentials_spec.rb b/spec/features/referentials_spec.rb
index 337271fea..a38577aba 100644
--- a/spec/features/referentials_spec.rb
+++ b/spec/features/referentials_spec.rb
@@ -120,6 +120,73 @@ describe "Referentials", :type => :feature do
end
+ describe "new_from" do
+ # let(:cloning)
+ let(:worker) { ReferentialCloningWorker.new }
+
+ let(:line) { create(:line_with_stop_areas) }
+ let(:jp) { create(:journey_pattern, route: line.routes.first) }
+ let(:tt) { create(:time_table) }
+ let(:vj) { create(:vehicle_journey, journey_pattern: jp, time_table: tt) }
+ let(:ref_metadata) { create(:referential_metadata, lines: [line], referential: referential) }
+
+ context "when user is from the same organisation" do
+
+ xit "should" do
+ visit new_referential_path(from: referential.id, current_workbench_id: @user.organisation.workbenches.first.id)
+
+ select "2018", :from => "referential_metadatas_attributes_0_periods_attributes_0_begin_1i"
+
+ select "2018", :from => "referential_metadatas_attributes_0_periods_attributes_0_end_1i"
+
+ click_button "Valider"
+
+ clone = Referential.where(name: "Copie de first")
+
+ expect(clone.lines).to include(line)
+ expect(clone.lines.first.routes).to match_array(referential.lines.first.routes)
+
+ clone_jp = clone.lines.first.routes.first.journey_patterns
+ expect(clone_jp).to include(jp)
+
+ clone_vj = clone.lines.first.routes.first.journey_patterns.first.vehicle_journeys
+ expect(clone_vj).to include(vj)
+
+ clone_tt = clone.lines.first.routes.first.journey_patterns.first.vehicle_journeys.first.time_tables
+ expect(clone_tt).to include(tt)
+ end
+
+ # it "should have the lines from source" do
+ # expect(clone.lines).to include(line)
+ # end
+ #
+ # it "should have the routes from source" do
+ # expect(clone.lines.first.routes).to match_array(referential.lines.first.routes)
+ # end
+ #
+ # it "should have the journey patterns from source" do
+ # clone_jp = clone.lines.first.routes.first.journey_patterns
+ # expect(clone_jp).to include(jp)
+ # end
+ #
+ # it "should have the vehicle journeys from source" do
+ # clone_vj = clone.lines.first.routes.first.journey_patterns.first.vehicle_journeys
+ # expect(clone_vj).to include(vj)
+ # end
+ #
+ # it "should have the timetables from source" do
+ # clone_tt = clone.lines.first.routes.first.journey_patterns.first.vehicle_journeys.first.time_tables
+ # expect(clone_tt).to include(tt)
+ # end
+ end
+
+ # context "when user is from another organisation" do
+ # before :each do
+ #
+ # end
+ # end
+ end
+
describe "destroy" do
let(:referential) { create(:referential, :organisation => @user.organisation) }