diff options
| -rw-r--r-- | app/controllers/referentials_controller.rb | 4 | ||||
| -rw-r--r-- | app/models/referential.rb | 4 | ||||
| -rw-r--r-- | spec/models/referential_spec.rb | 3 |
3 files changed, 5 insertions, 6 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 838c46168..afd376092 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -9,7 +9,7 @@ class ReferentialsController < BreadcrumbController def new if params[:from] source_referential = Referential.find(params[:from]) - @referential = Referential.new_from(source_referential, organisation: current_organisation) + @referential = Referential.new_from(source_referential) end new! do @@ -118,7 +118,7 @@ class ReferentialsController < BreadcrumbController end def create_resource(referential) - referential.organisation = current_organisation unless referential.created_from + referential.organisation = current_organisation referential.ready = true super end diff --git a/app/models/referential.rb b/app/models/referential.rb index e65d6a33b..cb2c7b23b 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -130,14 +130,13 @@ class Referential < ActiveRecord::Base self end - def self.new_from(from, organisation:) + def self.new_from(from) Referential.new( name: I18n.t("activerecord.copy", :name => from.name), slug: "#{from.slug}_clone", prefix: from.prefix, time_zone: from.time_zone, bounds: from.bounds, - organisation: organisation, line_referential: from.line_referential, stop_area_referential: from.stop_area_referential, workbench: from.workbench, @@ -206,7 +205,6 @@ class Referential < ActiveRecord::Base end def clone_associations - self.organisation = created_from.organisation self.line_referential = created_from.line_referential self.stop_area_referential = created_from.stop_area_referential self.workbench = created_from.workbench diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index 2390cc470..53eaa60a3 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -27,11 +27,12 @@ describe Referential, :type => :model do context "Cloning referential" do let(:clone) do - Referential.new_from(ref, organisation: ref.organisation) + Referential.new_from(ref) end let(:saved_clone) do clone.tap do |clone| + clone.organisation = ref.organisation clone.metadatas.each do |metadata| metadata.periodes = metadata.periodes.map { |period| Range.new(period.end+1, period.end+10) } end |
