Don't overwrite settings with defaults
Also changes the way the JSON fields are set to force ActiveRecord to recognise the changes. Is there a better way?
This commit is contained in:
parent
fba9a87c39
commit
daf534edb7
|
@ -11,8 +11,10 @@ module Travis::API::V3
|
|||
end
|
||||
|
||||
def update(settings = {})
|
||||
settings = defaults.merge(settings)
|
||||
repository.update_attributes(settings: JSON.generate(settings))
|
||||
settings = to_h.merge(settings)
|
||||
repository.settings.clear
|
||||
settings.each { |k, v| repository.settings[k] = v }
|
||||
repository.save!
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -107,6 +107,7 @@ describe Travis::API::V3::Services::Settings do
|
|||
let(:params) { JSON.dump('settings.build_pushes' => false) }
|
||||
|
||||
before do
|
||||
repo.update_attributes(settings: JSON.dump('maximum_number_of_builds' => 20))
|
||||
patch("/v3/repo/#{repo.id}/settings", params, json_headers.merge(auth_headers))
|
||||
end
|
||||
|
||||
|
@ -118,7 +119,7 @@ describe Travis::API::V3::Services::Settings do
|
|||
'builds_only_with_travis_yml' => false,
|
||||
'build_pushes' => false,
|
||||
'build_pull_requests' => true,
|
||||
'maximum_number_of_builds' => 0
|
||||
'maximum_number_of_builds' => 20
|
||||
}
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user