Skip to content

Commit

Permalink
Always set latest scenario of SavedScenario to keep_compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
noracato committed Sep 28, 2023
1 parent 79d23cf commit aca612b
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/services/create_saved_scenario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
return ServiceResult.failure(saved_scenario.errors.map(&:full_message), saved_scenario)
end

SetAPIScenarioCompatibility.keep_compatible(http_client, api_scenario.id)

saved_scenario.save
saved_scenario.scenario = api_scenario

Expand Down
6 changes: 6 additions & 0 deletions app/services/update_saved_scenario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def call
return failure
end

protect

ss.save
saved_scenario.scenario = api_scenario
end
Expand All @@ -40,6 +42,10 @@ def call

private

def protect
SetAPIScenarioCompatibility.keep_compatible(http_client, api_scenario.id)
end

def unprotect
SetAPIScenarioCompatibility.dont_keep_compatible(http_client, api_scenario.id)
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions spec/services/update_saved_scenario_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
.and_return(api_result)
allow(saved_scenario).to receive(:scenario)
.and_return(ete_scenario_mock)
allow(client).to receive(:put).with(
'/api/v3/scenarios/11', scenario: { keep_compatible: true }
)
end

context 'when the API response is successful' do
Expand Down

0 comments on commit aca612b

Please sign in to comment.