Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] Change Model#attribute's :squash options to accept a String a…
…s well as a Symbol * Spec to test "squashed" value patch
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
|
||
class FogAttributeTestModel < Fog::Model | ||
attribute :key_id, :aliases => "key", :squash => "id" | ||
end | ||
|
||
describe 'Fog::Attributes' do | ||
|
||
describe ".attribute" do | ||
describe "squashing a value" do | ||
it "should accept squashed key as symbol" do | ||
data = {"key" => {:id => "value"}} | ||
model = FogAttributeTestModel.new | ||
model.merge_attributes(data) | ||
model.key_id.should == "value" | ||
end | ||
|
||
it "should accept squashed key as string" do | ||
data = {"key" => {"id" => "value"}} | ||
model = FogAttributeTestModel.new | ||
model.merge_attributes(data) | ||
model.key_id.should == "value" | ||
end | ||
end | ||
|
||
end | ||
|
||
end |