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
+
1
4
v1.4.19
2
5
- create SparkQLErrors attribute for SparkApi::Response and populate when present
3
6
- 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
4
4
5
5
module Destroyable
6
6
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
+
7
20
def destroy ( arguments = { } )
8
21
self . errors = [ ]
9
22
begin
Original file line number Diff line number Diff line change @@ -14,15 +14,32 @@ class MyExampleModel < Base
14
14
@model = MyExampleModel . first
15
15
end
16
16
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
19
22
end
20
23
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
+
26
43
end
27
44
28
45
end
You can’t perform that action at this time.
0 commit comments