File tree Expand file tree Collapse file tree 4 files changed +41
-8
lines changed
lib/spark_api/models/concerns
spec/unit/spark_api/models/concerns Expand file tree Collapse file tree 4 files changed +41
-8
lines changed Original file line number Diff line number Diff line change 1+ v1.4.20
2+ - added destroy class method to Destroyable
3+
14v1.4.19
25 - create SparkQLErrors attribute for SparkApi::Response and populate when present
36 - create Errors attribute for SparkApi::Response and populate when present
Original file line number Diff line number Diff line change 1- 1.4.19
1+ 1.4.20
Original file line number Diff line number Diff line change @@ -4,6 +4,19 @@ module Concerns
44
55 module Destroyable
66
7+ def self . included ( base )
8+ base . extend ( ClassMethods )
9+ end
10+
11+ module ClassMethods
12+
13+ def destroy ( id , arguments = { } )
14+ connection . delete ( "#{ path } /#{ id } " , arguments )
15+ end
16+
17+ end
18+
19+
720 def destroy ( arguments = { } )
821 self . errors = [ ]
922 begin
Original file line number Diff line number Diff line change @@ -14,15 +14,32 @@ class MyExampleModel < Base
1414 @model = MyExampleModel . first
1515 end
1616
17- it "should not be destroyed" do
18- @model . destroyed? . should eq ( false )
17+ describe 'destroyed?' do
18+
19+ it "should not be destroyed" do
20+ @model . destroyed? . should eq ( false )
21+ end
1922 end
2023
21- it "should be destroyable" do
22- stub_api_delete ( "/some/place/20101230223226074201000000" )
23- @model = MyExampleModel . first
24- @model . destroy
25- @model . destroyed? . should eq ( true )
24+ describe 'destroy' do
25+
26+ it "should be destroyable" do
27+ stub_api_delete ( "/some/place/20101230223226074201000000" )
28+ @model = MyExampleModel . first
29+ @model . destroy
30+ @model . destroyed? . should eq ( true )
31+ end
32+
33+ end
34+
35+ describe 'destroy class method' do
36+
37+ it "allows you to destroy with only the id" do
38+ stub_api_delete ( "/test/example/20101230223226074201000000" )
39+ MyExampleModel . destroy ( '20101230223226074201000000' )
40+ expect_api_request ( :delete , "/test/example/20101230223226074201000000" ) . to have_been_made . once
41+ end
42+
2643 end
2744
2845end
You can’t perform that action at this time.
0 commit comments