diff options
| author | Luc Donnet | 2018-03-02 11:15:23 +0100 |
|---|---|---|
| committer | GitHub | 2018-03-02 11:15:23 +0100 |
| commit | a6de378529be7ca51ba2d1d7a8f03df263f3d2a8 (patch) | |
| tree | 2be36e14e00afed1d934de285f7c0e412fb6b78a /spec/models | |
| parent | f6f29efdac828a8d44130868215307daa1ab07c3 (diff) | |
| parent | 63ab2c81b292fe18c28f9f22232ad3cb712a9717 (diff) | |
| download | chouette-core-a6de378529be7ca51ba2d1d7a8f03df263f3d2a8.tar.bz2 | |
Merge pull request #295 from af83/5865-validate-referential-cloning
5865 Ensure user is allowed to duplicate a referential
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/referential_spec.rb | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index 025ad80f9..1d9b3d78a 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -58,16 +58,21 @@ describe Referential, :type => :model do Referential.new_from(ref, []) end - # let(:saved_clone) do - # clone.tap do |clone| - # clone.organisation = ref.organisation - # clone.metadatas.each do |metadata| - # metadata.line_ids = ref.lines.where(id: clone.line_ids, objectid: JSON.parse(ref.organisation.sso_attributes["functional_scope"]).collect(&:id) - # metadata.periodes = metadata.periodes.map { |period| Range.new(period.end+1, period.end+10) } - # end - # clone.save! - # end - # end + let!(:workbench){ create :workbench } + + let(:saved_clone) do + clone.tap do |clone| + clone.organisation = workbench.organisation + clone.workbench = workbench + clone.metadatas = [create(:referential_metadata, referential: clone)] + clone.save! + end + end + + it 'should create a Referential' do + ref + expect { saved_clone }.to change{Referential.count}.by(1) + end xit 'should create a ReferentialCloning' do expect { saved_clone }.to change{ReferentialCloning.count}.by(1) |
