Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support Double#destroy for ruby client

  • Loading branch information...
commit 4d34b9fcaf820c3f3ad0bfc1ea3a0297308bbc81 1 parent 8b21f51
@artemave artemave authored
View
22 Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- rest-assured (1.1.3)
+ rest-assured (1.1.5)
activerecord (~> 3.2.0)
activeresource (~> 3.2.0)
childprocess (~> 0.3.0)
@@ -12,18 +12,18 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.2.2)
- activesupport (= 3.2.2)
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
builder (~> 3.0.0)
- activerecord (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
+ activerecord (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
- activesupport (3.2.2)
+ activeresource (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.7)
@@ -146,7 +146,7 @@ GEM
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
- tzinfo (0.3.32)
+ tzinfo (0.3.33)
xpath (0.1.4)
nokogiri (~> 1.3)
View
4 lib/rest-assured/routes/double.rb
@@ -98,10 +98,10 @@ def verbs
end
end
- router.delete %r{/doubles/(\d+)} do |id|
+ router.delete %r{/doubles/(\d+)(\.json)?$} do |id, is_json|
if Models::Double.destroy(id)
flash[:notice] = 'Double deleted'
- redirect '/doubles'
+ redirect '/doubles' unless is_json
end
end
View
2  lib/rest-assured/version.rb
@@ -1,3 +1,3 @@
module RestAssured
- VERSION = '1.1.4'
+ VERSION = '1.1.5'
end
View
22 spec/functional/double_routes_spec.rb
@@ -140,6 +140,16 @@ module RestAssured
last_response.body.should =~ /\{"fullpath":\["can't be blank"\]\}/
end
+ it "deletes double" do
+ f = Models::Double.create test_double
+
+ delete "/doubles/#{f.id}.json"
+
+ last_response.should be_ok
+
+ Models::Double.exists?(test_double.except(:response_headers)).should be_false
+ end
+
it "deletes all doubles" do
Models::Double.create test_double
@@ -151,6 +161,18 @@ module RestAssured
end
context 'REST (ActiveResource compatible) json api', :ui => false do
+ it "gets list of doubles" do
+ f = Models::Double.create test_double
+ f1 = Models::Double.create test_double.merge(:verb => 'GET')
+
+ get '/doubles.json'
+
+ json = JSON.parse(last_response.body)
+
+ json.first['double']['verb'].should == 'POST'
+ json.last['double']['verb'].should == 'GET'
+ end
+
it "creates double as AR resource" do
post '/doubles.json', { :double => test_double }.to_json, 'CONTENT_TYPE' => 'Application/json'
Please sign in to comment.
Something went wrong with that request. Please try again.