Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the key from workspace to objects #15977

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/automate_workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class AutomateWorkspace < ApplicationRecord
validates :user, :presence => true

def merge_output!(hash)
if hash['workspace'].nil? || hash['state_vars'].nil?
raise ArgumentError, "No workspace or state_vars specified for edit"
if hash['objects'].nil? || hash['state_vars'].nil?
raise ArgumentError, "No objects or state_vars specified for edit"
end

self[:output] = (output || {}).deep_merge(hash)
Expand Down
6 changes: 3 additions & 3 deletions spec/models/automate_workspace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
end

it "properly merges the hash with the new output" do
hash = {'workspace' => {'a' => 1}, 'state_vars' => {'b' => 2}}
partial_hash = {'workspace' => {'c' => 1}, 'state_vars' => {} }
merged_hash = {'workspace' => {'a' => 1, 'c' => 1}, 'state_vars' => {'b' => 2}}
hash = {'objects' => {'root' => {'a' => 1}}, 'state_vars' => {'b' => 2}}
partial_hash = {'objects' => {'root' => {'c' => 1}}, 'state_vars' => {} }
merged_hash = {'objects' => {'root' => {'a' => 1, 'c' => 1}}, 'state_vars' => {'b' => 2}}

aw.merge_output!(hash)
aw.reload
Expand Down