diff options
| author | Robert | 2017-12-05 09:18:19 +0100 |
|---|---|---|
| committer | Robert | 2017-12-05 12:19:42 +0100 |
| commit | 089c6935ca0e036de484834381e5beda7545d499 (patch) | |
| tree | af6b9696de8069631234f032cf62e685e8039162 /spec | |
| parent | 8848d279b4d3a27c1ddebe7636a49abe545ba73a (diff) | |
| download | chouette-core-089c6935ca0e036de484834381e5beda7545d499.tar.bz2 | |
Refs: #5179@1h; Referential Creation Enforces objectid_format from associated Workbench [skip-ci]
- speced the `define_default_attributes` part
- speced the Reference.new_from part
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/referential/referential_oid_format_from_wkbch_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/models/referential/referential_oid_format_from_wkbch_spec.rb b/spec/models/referential/referential_oid_format_from_wkbch_spec.rb new file mode 100644 index 000000000..fe359ac6b --- /dev/null +++ b/spec/models/referential/referential_oid_format_from_wkbch_spec.rb @@ -0,0 +1,59 @@ +RSpec.describe Referential do + + describe 'default attributes' do + let( :referential ){ described_class.new } + let( :workbench ){ Workbench.new } + + it "of a referential with a workbench contain the workbench's objectid_format" do + ObjectidFormatterSupport.legal_formats.each do |legal_format| + workbench.objectid_format = legal_format + referential.workbench = workbench + referential.define_default_attributes + expect( referential.objectid_format ).to eq(legal_format) + end + end + + it 'of a referential w/o a workbench contain the default objectid_format' do + referential.define_default_attributes + expect( referential.objectid_format ).to eq(ObjectidFormatterSupport.default_format) + end + end + + + describe 'self.new_from' do + + # Referential.new( + # name: + # slug: "#{from.slug}_clone", + # prefix: from.prefix, + # time_zone: from.time_zone, + # bounds: from.bounds, + # line_referential: from.line_referential, + # stop_area_referential: from.stop_area_referential, + # created_from: from, + # metadatas: from.metadatas.map { |m| ReferentialMetadata.new_from(m, functional_scope) } + # ) + # + + let( :source ){ build :referential } + let( :functional_scope ){ double('functional scope') } + + it 'copies objectid_format from source' do + expect( described_class ) + .to receive(:new) + .with(name: I18n.t("activerecord.copy", name: source.name), + slug: "#{source.slug}_clone", + prefix: source.prefix, + time_zone: source.time_zone, + bounds: source.bounds, + line_referential: source.line_referential, + stop_area_referential: source.stop_area_referential, + created_from: source, + objectid_format: source.objectid_format, + metadatas: source.metadatas.map { |m| ReferentialMetadata.new_from(m, functional_scope) }) + + described_class.new_from( source, functional_scope ) + end + + end +end |
