Skip to content

Commit

Permalink
Fix defaults for immutability of MiddlewareServers
Browse files Browse the repository at this point in the history
This commit backports the change extracted to
manageiq-providers-hawkular, for use with the 5.8 release of CloudForms.
It is meant to be replaced later with a type column in the affected
models, allowing the proper use of STI.
  • Loading branch information
Cainã Costa committed Apr 25, 2017
1 parent 688310e commit be1592d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/models/middleware_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def in_domain?

# Returns whether a server is immutable or not.
#
# By default, we define all servers as being immutable, so that power
# operations are not allowed, and it is the provider responsability to
# By default, we define all servers as being mutable, so that power
# operations are allowed, and it is the provider responsability to
# reimplement this method if necessary.
def immutable?
true
properties['Immutable'] == 'true'
end

# Returns whether a server is immutable or not.
Expand Down
14 changes: 12 additions & 2 deletions spec/models/middleware_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,18 @@
end

describe '#immutable?' do
it 'is always true' do
expect(server).to be_immutable
it 'is true if "Immutable" is set as true' do
subject.properties = { 'Immutable' => 'true' }
expect(subject).to be_immutable
end

it 'is false if "Immutable" is set as false' do
subject.properties = { 'Immutable' => 'false' }
expect(subject).not_to be_immutable
end

it 'is false if no keys are defined' do
expect(subject).not_to be_immutable
end
end

Expand Down

0 comments on commit be1592d

Please sign in to comment.