File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
spec/unit/spark_api/models Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,17 @@ def save!(arguments = {})
22
22
23
23
def create! ( arguments = { } )
24
24
results = connection . post self . path , post_data . merge ( params_for_save ) , arguments
25
- update_attributes ( results . first )
25
+ update_attributes_after_create ( results . first )
26
26
reset_dirty
27
27
params_for_save . clear
28
28
true
29
29
end
30
30
31
+ def update_attributes ( attrs = { } )
32
+ attrs . each { |k , v | public_send ( :"#{ k } =" , v ) }
33
+ save!
34
+ end
35
+
31
36
def update! ( arguments = { } )
32
37
return true unless changed? && persisted?
33
38
connection . put resource_uri , dirty_attributes , arguments
@@ -48,7 +53,7 @@ def post_data
48
53
49
54
private
50
55
51
- def update_attributes ( result )
56
+ def update_attributes_after_create ( result )
52
57
attributes [ 'Id' ] = result [ 'Id' ] ? result [ 'Id' ] : parse_id ( result [ 'ResourceUri' ] )
53
58
result . delete ( 'Id' )
54
59
attributes . merge! result
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ def self.tagged(tag, arguments={})
35
35
collect ( connection . get ( "/#{ self . element_name } /tags/#{ tag } " , arguments ) )
36
36
end
37
37
38
+ def favorite?
39
+ @attributes [ "Tags" ] && @attributes [ "Tags" ] . include? ( "Favorites" )
40
+ end
41
+
38
42
# list contacts (private role)
39
43
def contacts
40
44
return [ ] unless persisted?
Original file line number Diff line number Diff line change 165
165
end
166
166
end
167
167
168
+ describe "favorite?" do
169
+ it "should return true if the search has been tagged as a favorite" do
170
+ search = SavedSearch . new ( Tags : [ "Favorites" ] )
171
+ search . should be_favorite
172
+ end
173
+
174
+ it "should return false if the search has not been tagged as a favorite" do
175
+ search = SavedSearch . new
176
+ search . should_not be_favorite
177
+ end
178
+ end
179
+
168
180
describe "can_have_newsfeed?" do
169
181
170
182
it "should return false without at least three filter parameters" do
You can’t perform that action at this time.
0 commit comments