aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorZog2018-04-18 13:19:18 +0200
committerJohan Van Ryseghem2018-04-27 11:17:19 +0200
commitf7fe4c24e29ceb517abdda66899952a5d6aa73bf (patch)
tree7fdd8323e8e5a0189771976878310167b6cdac49 /spec
parent0046e5a01cb08c10118b01c50f3c52d159854ef0 (diff)
downloadchouette-core-f7fe4c24e29ceb517abdda66899952a5d6aa73bf.tar.bz2
Refs #6572; New Referential#Show for noredy referentials
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/imports/gtfs_imports.rb7
-rw-r--r--spec/models/referential_spec.rb77
2 files changed, 78 insertions, 6 deletions
diff --git a/spec/factories/imports/gtfs_imports.rb b/spec/factories/imports/gtfs_imports.rb
new file mode 100644
index 000000000..b91e1ee5f
--- /dev/null
+++ b/spec/factories/imports/gtfs_imports.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ factory :gtfs_import, class: Import::Gtfs, parent: :import do
+ file { File.open(Rails.root.join('spec', 'fixtures', 'OFFRE_TRANSDEV_2017030112251.zip')) }
+ association :parent, factory: :workbench_import
+
+ end
+end
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index 220201d37..8b8cf4359 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -29,6 +29,71 @@ describe Referential, :type => :model do
end
end
+ context ".last_operation" do
+ subject(:operation){ referential.last_operation }
+ it "should return nothing" do
+ expect(operation).to be_nil
+ end
+
+ context "with a netex import" do
+ let!(:import) do
+ import = create :netex_import
+ import.referential = referential
+ import.save
+ import
+ end
+
+ it "should return the import" do
+ expect(operation).to eq import
+ end
+ end
+
+ context "with 2 netex imports" do
+ let!(:other_import) do
+ import = create :netex_import
+ import.referential = referential
+ import.save
+ import
+ end
+ let!(:import) do
+ import = create :netex_import
+ import.referential = referential
+ import.save
+ import
+ end
+
+ it "should return the last import" do
+ expect(operation).to eq import
+ end
+ end
+
+ context "with a gtfs import" do
+ let!(:import) do
+ import = create :gtfs_import
+ import.referential = referential
+ import.save
+ import
+ end
+
+ it "should return the import" do
+ expect(operation).to eq import
+ end
+ end
+
+ context "with a cleanup" do
+ let!(:cleanup) do
+ cleanup = create :clean_up
+ cleanup.referential = referential
+ cleanup.save
+ cleanup
+ end
+
+ it "should return the cleanup" do
+ expect(operation).to eq cleanup
+ end
+ end
+ end
+
context ".state" do
it "should return the expected values" do
referential = build :referential
@@ -38,7 +103,7 @@ describe Referential, :type => :model do
expect(referential.state).to eq :failed
referential.ready = true
referential.failed_at = nil
- expect(referential.state).to eq :ready
+ expect(referential.state).to eq :active
referential.archived_at = Time.now
expect(referential.state).to eq :archived
end
@@ -48,28 +113,28 @@ describe Referential, :type => :model do
referential = create :referential, ready: false
expect(Referential.pending).to include referential
expect(Referential.failed).to_not include referential
- expect(Referential.ready).to_not include referential
+ expect(Referential.active).to_not include referential
expect(Referential.archived).to_not include referential
referential = create :referential
referential.failed!
expect(Referential.pending).to_not include referential
expect(Referential.failed).to include referential
- expect(Referential.ready).to_not include referential
+ expect(Referential.active).to_not include referential
expect(Referential.archived).to_not include referential
referential = create :referential
- referential.ready!
+ referential.active!
expect(Referential.pending).to_not include referential
expect(Referential.failed).to_not include referential
- expect(Referential.ready).to include referential
+ expect(Referential.active).to include referential
expect(Referential.archived).to_not include referential
referential = create :referential
referential.archived!
expect(Referential.pending).to_not include referential
expect(Referential.failed).to_not include referential
- expect(Referential.ready).to_not include referential
+ expect(Referential.active).to_not include referential
expect(Referential.archived).to include referential
end
end