rack-backend-api 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/backend_api.rb +6 -2
- data/rack-backend-api.gemspec +1 -1
- data/test/spec_backend_api.rb +4 -4
- metadata +4 -4
data/README.md
CHANGED
@@ -300,6 +300,7 @@ CHANGE LOG
|
|
300
300
|
0.2.3 Send a 404 if the entry does not exist
|
301
301
|
0.3.0 Implement cloning functionality
|
302
302
|
0.3.2 IDs are turned into integers only on the adapter side, not in the middleware
|
303
|
+
0.3.4 Removed 400 code when not valid - not as expected anymore
|
303
304
|
|
304
305
|
COPYRIGHT
|
305
306
|
=========
|
data/lib/backend_api.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class BackendAPI
|
2
|
-
VERSION = [0,3,
|
2
|
+
VERSION = [0,3,4]
|
3
3
|
WRAP = <<-EOT
|
4
4
|
<!doctype html>
|
5
5
|
<html>
|
@@ -118,7 +118,11 @@ class BackendAPI
|
|
118
118
|
else
|
119
119
|
form = @model_instance.backend_form(@req.path, @req['fields']||@req['model'].keys, :destination => @req['_destination'], :submit_text => @req['_submit_text'], :no_wrap => @req['_no_wrap'])
|
120
120
|
@res.write(wrap_response(form))
|
121
|
-
|
121
|
+
# Bad Request
|
122
|
+
# I used 400 code before but it does not work through Ajax anymore
|
123
|
+
# At least on Safari
|
124
|
+
# Content is not passed with this code
|
125
|
+
@res.status=200
|
122
126
|
end
|
123
127
|
end
|
124
128
|
|
data/rack-backend-api.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rack-backend-api'
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.4"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.summary = "A Rack middleware that provides a simple API for your Admin section"
|
6
6
|
s.description = "The purpose of this Rack Middleware is to provide an API that interfaces with database actions in order to build a CMS."
|
data/test/spec_backend_api.rb
CHANGED
@@ -116,14 +116,14 @@ describe 'API Post' do
|
|
116
116
|
should "Send back the appropriate form when the creation is not valid" do
|
117
117
|
|
118
118
|
res = req_lint(BackendAPI.new).post('/haiku', :params => {'model' => {'title' => '13'}})
|
119
|
-
res.status.should==
|
119
|
+
res.status.should==200
|
120
120
|
compared = Haiku.new.set('title' => '13')
|
121
121
|
compared.valid?
|
122
122
|
res.body.should==wrap('Haiku', compared.backend_form('/haiku', ['title']))
|
123
123
|
|
124
124
|
# Not wrapped when XHR
|
125
125
|
res = req_lint(BackendAPI.new).post('/haiku', "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", :params => {'model' => {'title' => '13'}})
|
126
|
-
res.status.should==
|
126
|
+
res.status.should==200
|
127
127
|
res.body.should==compared.backend_form('/haiku', ['title'])
|
128
128
|
end
|
129
129
|
|
@@ -245,14 +245,14 @@ describe 'API Put' do
|
|
245
245
|
should "Send back the appropriate form when the creation is not valid" do
|
246
246
|
|
247
247
|
res = req_lint(BackendAPI.new).put('/haiku/3', :params => {'model' => {'title' => '13'}})
|
248
|
-
res.status.should==
|
248
|
+
res.status.should==200
|
249
249
|
compared = Haiku[3].set('title' => '13')
|
250
250
|
compared.valid?
|
251
251
|
res.body.should==wrap('Haiku', compared.backend_form('/haiku/3', ['title']))
|
252
252
|
|
253
253
|
# Not wrapped when XHR
|
254
254
|
res = req_lint(BackendAPI.new).put('/haiku/3', "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest", :params => {'model' => {'title' => '13'}})
|
255
|
-
res.status.should==
|
255
|
+
res.status.should==200
|
256
256
|
res.body.should==compared.backend_form('/haiku/3', ['title'])
|
257
257
|
end
|
258
258
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-backend-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mickael Riga
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-21 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: The purpose of this Rack Middleware is to provide an API that interfaces with database actions in order to build a CMS.
|