Skip to content

Commit

Permalink
Clean out finished_at in create (#94)
Browse files Browse the repository at this point in the history
* Clean out finished_at in create

* make it raisey
  • Loading branch information
jmileham authored Mar 7, 2019
1 parent ba507f5 commit e250cc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/split_creation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class SplitCreation
validate :split_must_be_valid

def save
split.finished_at = nil
split.reassign_weight(merged_registry) unless split.registry == merged_registry
return false unless valid?
split.save
Expand Down
9 changes: 9 additions & 0 deletions spec/models/split_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
expect(weather.registry.symbolize_keys).to eq rain: 0, snow: 0, clear_skies: 100, hurricane: 0
end

it 'reenables a finished split' do
bad_weather_create.save
Split.find_by!(name: "weather").update!(finished_at: Time.zone.now)
good_weather_create.save

weather = Split.find_by(name: "weather")
expect(weather.finished_at).to be_nil
end

it 'delegates validation errors to split' do
split_creation = SplitCreation.new(app: default_app, name: "bad_test", weighting_registry: { badBadBad: 100 })
expect(split_creation.save).to eq false
Expand Down

0 comments on commit e250cc1

Please sign in to comment.