diff options
| author | Teddy Wing | 2017-08-01 19:45:59 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-08-01 19:45:59 +0200 |
| commit | f189c4331d4f6f1ed10b7545d90a92dc2b7ca9b1 (patch) | |
| tree | 198d60c9f9aaac94bd922689277f0cf04698c80c | |
| parent | 240c2270ca8e21c75170d6b7764562c049ef661a (diff) | |
| download | chouette-core-f189c4331d4f6f1ed10b7545d90a92dc2b7ca9b1.tar.bz2 | |
Import: Add #ready?
This boolean method answers whether or not the current import's
`current_step` and `total_steps` fields match. If so, all of its
subtasks are finished, in which case it can be thought of as "ready".
Refs #4174, #3511
| -rw-r--r-- | app/models/import.rb | 4 | ||||
| -rw-r--r-- | spec/models/import_spec.rb | 22 |
2 files changed, 26 insertions, 0 deletions
diff --git a/app/models/import.rb b/app/models/import.rb index 3cbdb964f..46de0d727 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -20,6 +20,10 @@ class Import < ActiveRecord::Base def child_change(child) end + def ready? + current_step == total_steps + end + private def initialize_fields diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 53513eb0c..1b8fe72c2 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -23,4 +23,26 @@ RSpec.describe Import, :type => :model do netex_import.notify_parent end end + + describe "#ready?" do + it "returns true if #current_step == #total_steps" do + import = build_stubbed( + :import, + total_steps: 4, + current_step: 4 + ) + + expect(import.ready?).to be true + end + + it "returns false if #current_step != #total_steps" do + import = build_stubbed( + :import, + total_steps: 6, + current_step: 3 + ) + + expect(import.ready?).to be false + end + end end |
