spree_api 1.2.0.rc2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ module Spree
|
|
6
6
|
|
7
7
|
attr_accessor :current_api_user
|
8
8
|
|
9
|
+
before_filter :set_content_type
|
9
10
|
before_filter :check_for_api_key
|
10
11
|
before_filter :authenticate_user
|
11
12
|
|
@@ -25,6 +26,16 @@ module Spree
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
29
|
+
def set_content_type
|
30
|
+
content_type = case params[:format]
|
31
|
+
when "json"
|
32
|
+
"application/json"
|
33
|
+
when "xml"
|
34
|
+
"text/xml"
|
35
|
+
end
|
36
|
+
headers["Content-Type"] = content_type
|
37
|
+
end
|
38
|
+
|
28
39
|
def check_for_api_key
|
29
40
|
render "spree/api/v1/errors/must_specify_api_key", :status => 401 and return if api_key.blank?
|
30
41
|
end
|
@@ -13,21 +13,10 @@ module Spree
|
|
13
13
|
stub_authentication!
|
14
14
|
end
|
15
15
|
|
16
|
-
it "can upload a new image for a product" do
|
17
|
-
lambda do
|
18
|
-
api_post :create,
|
19
|
-
:image => { :attachment => upload_image("thinking-cat.jpg"),
|
20
|
-
:viewable_type => 'Spree::Product',
|
21
|
-
:viewable_id => product.id }
|
22
|
-
response.status.should == 201
|
23
|
-
json_response.should have_attributes(attributes)
|
24
|
-
end.should change(Image, :count).by(1)
|
25
|
-
end
|
26
|
-
|
27
16
|
it "can upload a new image for a variant" do
|
28
17
|
lambda do
|
29
18
|
api_post :create,
|
30
|
-
:image => { :attachment => upload_image(
|
19
|
+
:image => { :attachment => upload_image('thinking-cat.jpg'),
|
31
20
|
:viewable_type => 'Spree::Variant',
|
32
21
|
:viewable_id => product.master.to_param }
|
33
22
|
response.status.should == 201
|
@@ -36,7 +25,7 @@ module Spree
|
|
36
25
|
end
|
37
26
|
|
38
27
|
context "working with an existing image" do
|
39
|
-
let!(:product_image) { product.master.images.create!(:attachment => image(
|
28
|
+
let!(:product_image) { product.master.images.create!(:attachment => image('thinking-cat.jpg')) }
|
40
29
|
|
41
30
|
it "can update image data" do
|
42
31
|
product_image.position.should == 1
|
metadata
CHANGED
@@ -1,67 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Bigg
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-30 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70196103586700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.2.0
|
21
|
+
version: 1.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - '='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.2.0.rc2
|
24
|
+
version_requirements: *70196103586700
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: rabl
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70196103585920 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
|
-
- -
|
30
|
+
- - =
|
36
31
|
- !ruby/object:Gem::Version
|
37
32
|
version: 0.6.5
|
38
33
|
type: :runtime
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - '='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.6.5
|
35
|
+
version_requirements: *70196103585920
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: rspec-rails
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70196103585220 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
|
-
- -
|
41
|
+
- - =
|
52
42
|
- !ruby/object:Gem::Version
|
53
43
|
version: 2.9.0
|
54
44
|
type: :development
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.9.0
|
46
|
+
version_requirements: *70196103585220
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
48
|
name: database_cleaner
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &70196103584480 !ruby/object:Gem::Requirement
|
65
50
|
none: false
|
66
51
|
requirements:
|
67
52
|
- - ! '>='
|
@@ -69,12 +54,7 @@ dependencies:
|
|
69
54
|
version: '0'
|
70
55
|
type: :development
|
71
56
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
57
|
+
version_requirements: *70196103584480
|
78
58
|
description: Spree's API
|
79
59
|
email:
|
80
60
|
- ryan@spreecommerce.com
|
@@ -200,16 +180,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
180
|
version: '0'
|
201
181
|
segments:
|
202
182
|
- 0
|
203
|
-
hash:
|
183
|
+
hash: 1643031983782340233
|
204
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
185
|
none: false
|
206
186
|
requirements:
|
207
|
-
- - ! '
|
187
|
+
- - ! '>='
|
208
188
|
- !ruby/object:Gem::Version
|
209
|
-
version:
|
189
|
+
version: '0'
|
190
|
+
segments:
|
191
|
+
- 0
|
192
|
+
hash: 1643031983782340233
|
210
193
|
requirements: []
|
211
194
|
rubyforge_project:
|
212
|
-
rubygems_version: 1.8.
|
195
|
+
rubygems_version: 1.8.10
|
213
196
|
signing_key:
|
214
197
|
specification_version: 3
|
215
198
|
summary: Spree's API
|