spree_api 1.2.5 → 1.3.0.rc1
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.
- data/.rspec +1 -0
- data/app/controllers/spree/api/addresses_controller.rb +17 -0
- data/app/controllers/spree/api/base_controller.rb +111 -0
- data/app/controllers/spree/api/countries_controller.rb +14 -0
- data/app/controllers/spree/api/images_controller.rb +29 -0
- data/app/controllers/spree/api/line_items_controller.rb +38 -0
- data/app/controllers/spree/api/orders_controller.rb +81 -0
- data/app/controllers/spree/api/payments_controller.rb +75 -0
- data/app/controllers/spree/api/product_properties_controller.rb +61 -0
- data/app/controllers/spree/api/products_controller.rb +45 -0
- data/app/controllers/spree/api/return_authorizations_controller.rb +50 -0
- data/app/controllers/spree/api/shipments_controller.rb +41 -0
- data/app/controllers/spree/api/taxonomies_controller.rb +46 -0
- data/app/controllers/spree/api/taxons_controller.rb +49 -0
- data/app/controllers/spree/api/variants_controller.rb +71 -0
- data/app/controllers/spree/api/zones_controller.rb +43 -0
- data/app/helpers/spree/api/api_helpers.rb +0 -5
- data/app/overrides/api_admin_user_edit_form.rb +1 -1
- data/app/views/spree/admin/users/_api_fields.html.erb +26 -14
- data/app/views/spree/api/{v1/addresses/show.rabl → addresses/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/countries/index.rabl → countries/index.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/countries/show.rabl → countries/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/errors/gateway_error.rabl → errors/gateway_error.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/errors/invalid_api_key.rabl → errors/invalid_api_key.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/errors/invalid_resource.rabl → errors/invalid_resource.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/errors/must_specify_api_key.rabl → errors/must_specify_api_key.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/errors/not_found.rabl → errors/not_found.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/errors/unauthorized.rabl → errors/unauthorized.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/images/show.rabl → images/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/line_items/new.rabl → line_items/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/line_items/show.rabl → line_items/show.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/orders/address.rabl → orders/address.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/canceled.rabl → orders/canceled.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/cart.rabl → orders/cart.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/complete.rabl → orders/complete.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/could_not_transition.rabl → orders/could_not_transition.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/delivery.rabl → orders/delivery.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/index.rabl → orders/index.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/invalid_shipping_method.rabl → orders/invalid_shipping_method.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/payment.rabl → orders/payment.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/orders/show.rabl → orders/show.v1.rabl} +6 -6
- data/app/views/spree/api/{v1/payments/credit_over_limit.rabl → payments/credit_over_limit.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/payments/index.rabl → payments/index.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/payments/new.rabl → payments/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/payments/show.rabl → payments/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/product_properties/index.rabl → product_properties/index.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/product_properties/new.rabl → product_properties/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/product_properties/show.rabl → product_properties/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/products/index.rabl → products/index.v1.rabl} +1 -2
- data/app/views/spree/api/{v1/products/new.rabl → products/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/products/product.rabl → products/product.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/products/show.rabl → products/show.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/return_authorizations/index.rabl → return_authorizations/index.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/return_authorizations/new.rabl → return_authorizations/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/return_authorizations/show.rabl → return_authorizations/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/shipments/cannot_ready_shipment.rabl → shipments/cannot_ready_shipment.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/shipments/show.rabl → shipments/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/taxonomies/index.rabl → taxonomies/index.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/taxonomies/nested.rabl → taxonomies/nested.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/taxonomies/new.rabl → taxonomies/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/taxonomies/show.rabl → taxonomies/show.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/taxons/index.rabl → taxons/index.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/taxons/new.rabl → taxons/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/taxons/show.rabl → taxons/show.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/taxons/taxons.rabl → taxons/taxons.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/variants/index.rabl → variants/index.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/variants/new.rabl → variants/new.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/variants/show.rabl → variants/show.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/variants/variant.rabl → variants/variant.v1.rabl} +0 -0
- data/app/views/spree/api/{v1/zones/index.rabl → zones/index.v1.rabl} +1 -1
- data/app/views/spree/api/{v1/zones/show.rabl → zones/show.v1.rabl} +0 -0
- data/config/initializers/metal_load_paths.rb +1 -1
- data/config/routes.rb +34 -37
- data/db/migrate/20120411123334_resize_api_key_field.rb +1 -1
- data/lib/spree/api/engine.rb +8 -1
- data/lib/spree_api.rb +1 -0
- data/spec/controllers/spree/api/{v1/addresses_controller_spec.rb → addresses_controller_spec.rb} +3 -3
- data/spec/controllers/spree/api/{v1/base_controller_spec.rb → base_controller_spec.rb} +2 -9
- data/spec/controllers/spree/api/{v1/countries_controller_spec.rb → countries_controller_spec.rb} +5 -5
- data/spec/controllers/spree/api/{v1/images_controller_spec.rb → images_controller_spec.rb} +1 -1
- data/spec/controllers/spree/api/{v1/line_items_controller_spec.rb → line_items_controller_spec.rb} +2 -2
- data/spec/controllers/spree/api/{v1/orders_controller_spec.rb → orders_controller_spec.rb} +7 -12
- data/spec/controllers/spree/api/{v1/payments_controller_spec.rb → payments_controller_spec.rb} +2 -2
- data/spec/controllers/spree/api/{v1/product_properties_controller_spec.rb → product_properties_controller_spec.rb} +2 -3
- data/spec/controllers/spree/api/{v1/products_controller_spec.rb → products_controller_spec.rb} +14 -7
- data/spec/controllers/spree/api/{v1/return_authorizations_controller_spec.rb → return_authorizations_controller_spec.rb} +4 -4
- data/spec/controllers/spree/api/{v1/shipments_controller_spec.rb → shipments_controller_spec.rb} +4 -9
- data/spec/controllers/spree/api/{v1/taxonomies_controller_spec.rb → taxonomies_controller_spec.rb} +11 -11
- data/spec/controllers/spree/api/{v1/taxons_controller_spec.rb → taxons_controller_spec.rb} +7 -7
- data/spec/controllers/spree/api/{v1/unauthenticated_products_controller_spec.rb → unauthenticated_products_controller_spec.rb} +1 -1
- data/spec/controllers/spree/api/{v1/variants_controller_spec.rb → variants_controller_spec.rb} +4 -5
- data/spec/controllers/spree/api/{v1/zones_controller_spec.rb → zones_controller_spec.rb} +7 -7
- data/spec/support/controller_hacks.rb +1 -1
- data/spec/support/have_attributes_matcher.rb +2 -2
- data/spree_api.gemspec +1 -0
- metadata +139 -115
- checksums.yaml +0 -7
- data/app/controllers/spree/api/v1/addresses_controller.rb +0 -19
- data/app/controllers/spree/api/v1/base_controller.rb +0 -111
- data/app/controllers/spree/api/v1/countries_controller.rb +0 -18
- data/app/controllers/spree/api/v1/images_controller.rb +0 -32
- data/app/controllers/spree/api/v1/inventory_units_controller.rb +0 -50
- data/app/controllers/spree/api/v1/line_items_controller.rb +0 -40
- data/app/controllers/spree/api/v1/orders_controller.rb +0 -83
- data/app/controllers/spree/api/v1/payments_controller.rb +0 -77
- data/app/controllers/spree/api/v1/product_properties_controller.rb +0 -64
- data/app/controllers/spree/api/v1/products_controller.rb +0 -47
- data/app/controllers/spree/api/v1/return_authorizations_controller.rb +0 -53
- data/app/controllers/spree/api/v1/shipments_controller.rb +0 -43
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +0 -50
- data/app/controllers/spree/api/v1/taxons_controller.rb +0 -51
- data/app/controllers/spree/api/v1/variants_controller.rb +0 -74
- data/app/controllers/spree/api/v1/zones_controller.rb +0 -45
- data/app/views/spree/api/v1/inventory_units/show.rabl +0 -2
- data/spec/controllers/spree/api/v1/inventory_units_controller_spec.rb +0 -46
data/app/views/spree/api/{v1/payments/credit_over_limit.rabl → payments/credit_over_limit.v1.rabl}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/app/views/spree/api/{v1/product_properties/index.rabl → product_properties/index.v1.rabl}
RENAMED
|
File without changes
|
|
File without changes
|
data/app/views/spree/api/{v1/product_properties/show.rabl → product_properties/show.v1.rabl}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/app/views/spree/api/{v1/return_authorizations/index.rabl → return_authorizations/index.v1.rabl}
RENAMED
|
File without changes
|
data/app/views/spree/api/{v1/return_authorizations/new.rabl → return_authorizations/new.v1.rabl}
RENAMED
|
File without changes
|
data/app/views/spree/api/{v1/return_authorizations/show.rabl → return_authorizations/show.v1.rabl}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Spree::Api::
|
|
1
|
+
Spree::Api::BaseController.append_view_path(ApplicationController.view_paths)
|
data/config/routes.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Spree::Core::Engine.routes.
|
|
1
|
+
Spree::Core::Engine.routes.prepend do
|
|
2
2
|
namespace :admin do
|
|
3
3
|
resources :users do
|
|
4
4
|
member do
|
|
@@ -9,51 +9,48 @@ Spree::Core::Engine.routes.draw do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
namespace :api do
|
|
12
|
-
|
|
13
|
-
resources :
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
resources :products do
|
|
13
|
+
resources :variants
|
|
14
|
+
resources :product_properties
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
resources :images
|
|
18
|
+
resources :variants, :only => [:index] do
|
|
19
|
+
end
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
resources :
|
|
21
|
+
resources :orders do
|
|
22
|
+
resources :return_authorizations
|
|
23
|
+
member do
|
|
24
|
+
put :address
|
|
25
|
+
put :delivery
|
|
26
|
+
put :cancel
|
|
27
|
+
put :empty
|
|
20
28
|
end
|
|
21
29
|
|
|
22
|
-
resources :
|
|
23
|
-
|
|
30
|
+
resources :line_items
|
|
31
|
+
resources :payments do
|
|
24
32
|
member do
|
|
25
|
-
put :
|
|
26
|
-
put :
|
|
27
|
-
put :
|
|
28
|
-
put :
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
resources :line_items
|
|
32
|
-
resources :payments do
|
|
33
|
-
member do
|
|
34
|
-
put :authorize
|
|
35
|
-
put :capture
|
|
36
|
-
put :purchase
|
|
37
|
-
put :void
|
|
38
|
-
put :credit
|
|
39
|
-
end
|
|
33
|
+
put :authorize
|
|
34
|
+
put :capture
|
|
35
|
+
put :purchase
|
|
36
|
+
put :void
|
|
37
|
+
put :credit
|
|
40
38
|
end
|
|
39
|
+
end
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
end
|
|
41
|
+
resources :shipments do
|
|
42
|
+
member do
|
|
43
|
+
put :ready
|
|
44
|
+
put :ship
|
|
47
45
|
end
|
|
48
46
|
end
|
|
47
|
+
end
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
resources :inventory_units, :only => [:show, :update]
|
|
49
|
+
resources :zones
|
|
50
|
+
resources :countries, :only => [:index, :show]
|
|
51
|
+
resources :addresses, :only => [:show, :update]
|
|
52
|
+
resources :taxonomies do
|
|
53
|
+
resources :taxons
|
|
57
54
|
end
|
|
58
55
|
end
|
|
59
56
|
end
|
data/lib/spree/api/engine.rb
CHANGED
|
@@ -6,6 +6,14 @@ module Spree
|
|
|
6
6
|
isolate_namespace Spree
|
|
7
7
|
engine_name 'spree_api'
|
|
8
8
|
|
|
9
|
+
Rabl.configure do |config|
|
|
10
|
+
config.include_json_root = false
|
|
11
|
+
config.include_child_root = false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
config.view_versions = [1]
|
|
15
|
+
config.view_version_extraction_strategy = :http_header
|
|
16
|
+
|
|
9
17
|
initializer "spree.api.environment", :before => :load_config_initializers do |app|
|
|
10
18
|
Spree::Api::Config = Spree::ApiConfiguration.new
|
|
11
19
|
end
|
|
@@ -20,7 +28,6 @@ module Spree
|
|
|
20
28
|
def self.root
|
|
21
29
|
@root ||= Pathname.new(File.expand_path('../../../../', __FILE__))
|
|
22
30
|
end
|
|
23
|
-
|
|
24
31
|
end
|
|
25
32
|
end
|
|
26
33
|
end
|
data/lib/spree_api.rb
CHANGED
data/spec/controllers/spree/api/{v1/addresses_controller_spec.rb → addresses_controller_spec.rb}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
describe Api::
|
|
4
|
+
describe Api::AddressesController do
|
|
5
5
|
render_views
|
|
6
6
|
|
|
7
7
|
before do
|
|
@@ -16,13 +16,13 @@ module Spree
|
|
|
16
16
|
|
|
17
17
|
it "gets an address" do
|
|
18
18
|
api_get :show, :id => @address.id
|
|
19
|
-
json_response['
|
|
19
|
+
json_response['address1'].should eq @address.address1
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "updates an address" do
|
|
23
23
|
api_put :update, :id => @address.id,
|
|
24
24
|
:address => { :address1 => "123 Test Lane" }
|
|
25
|
-
json_response['
|
|
25
|
+
json_response['address1'].should eq '123 Test Lane'
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Spree::Api::
|
|
3
|
+
describe Spree::Api::BaseController do
|
|
4
4
|
render_views
|
|
5
|
-
controller(Spree::Api::
|
|
5
|
+
controller(Spree::Api::BaseController) do
|
|
6
6
|
def index
|
|
7
7
|
render :json => { "products" => [] }
|
|
8
8
|
end
|
|
@@ -28,13 +28,6 @@ describe Spree::Api::V1::BaseController do
|
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
it 'handles exceptions' do
|
|
32
|
-
subject.should_receive(:authenticate_user).and_return(true)
|
|
33
|
-
subject.should_receive(:index).and_raise(Exception.new("no joy"))
|
|
34
|
-
get :index, :token => "fake_key"
|
|
35
|
-
json_response.should == { "exception" => "no joy" }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
31
|
it "maps symantec keys to nested_attributes keys" do
|
|
39
32
|
klass = stub(:nested_attributes_options => { :line_items => {},
|
|
40
33
|
:bill_address => {} })
|
data/spec/controllers/spree/api/{v1/countries_controller_spec.rb → countries_controller_spec.rb}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
describe Api::
|
|
4
|
+
describe Api::CountriesController do
|
|
5
5
|
render_views
|
|
6
6
|
|
|
7
7
|
before do
|
|
@@ -12,7 +12,7 @@ module Spree
|
|
|
12
12
|
|
|
13
13
|
it "gets all countries" do
|
|
14
14
|
api_get :index
|
|
15
|
-
json_response[
|
|
15
|
+
json_response['countries'].first['iso3'].should eq @country.iso3
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
context "with two countries" do
|
|
@@ -28,7 +28,7 @@ module Spree
|
|
|
28
28
|
it 'can query the results through a paramter' do
|
|
29
29
|
api_get :index, :q => { :name_cont => 'zam' }
|
|
30
30
|
json_response['count'].should == 1
|
|
31
|
-
json_response['countries'].first['
|
|
31
|
+
json_response['countries'].first['name'].should eq @zambia.name
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it 'can control the page size through a parameter' do
|
|
@@ -41,8 +41,8 @@ module Spree
|
|
|
41
41
|
|
|
42
42
|
it "includes states" do
|
|
43
43
|
api_get :show, :id => @country.id
|
|
44
|
-
states = json_response['
|
|
45
|
-
states.first['
|
|
44
|
+
states = json_response['states']
|
|
45
|
+
states.first['name'].should eq @state.name
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
data/spec/controllers/spree/api/{v1/line_items_controller_spec.rb → line_items_controller_spec.rb}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
describe Api::
|
|
4
|
+
describe Api::LineItemsController do
|
|
5
5
|
render_views
|
|
6
6
|
|
|
7
7
|
let!(:order) do
|
|
@@ -34,7 +34,7 @@ module Spree
|
|
|
34
34
|
api_post :create, :line_item => { :variant_id => product.master.to_param, :quantity => 1 }
|
|
35
35
|
response.status.should == 201
|
|
36
36
|
json_response.should have_attributes(attributes)
|
|
37
|
-
json_response["
|
|
37
|
+
json_response["variant"]["name"].should_not be_blank
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "can update a line item on the order" do
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
describe Api::
|
|
4
|
+
describe Api::OrdersController do
|
|
5
5
|
render_views
|
|
6
6
|
|
|
7
7
|
let!(:order) { create(:order) }
|
|
@@ -66,14 +66,14 @@ module Spree
|
|
|
66
66
|
order.line_items.count.should == 1
|
|
67
67
|
order.line_items.first.variant.should == variant
|
|
68
68
|
order.line_items.first.quantity.should == 5
|
|
69
|
-
json_response["
|
|
69
|
+
json_response["state"].should == "address"
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "can create an order without any parameters" do
|
|
73
73
|
lambda { api_post :create }.should_not raise_error(NoMethodError)
|
|
74
74
|
response.status.should == 201
|
|
75
75
|
order = Order.last
|
|
76
|
-
json_response["
|
|
76
|
+
json_response["state"].should == "address"
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
context "working with an order" do
|
|
@@ -108,7 +108,7 @@ module Spree
|
|
|
108
108
|
order.shipping_address.firstname.should == shipping_address[:firstname]
|
|
109
109
|
order.billing_address.firstname.should == billing_address[:firstname]
|
|
110
110
|
order.state.should == "delivery"
|
|
111
|
-
json_response["
|
|
111
|
+
json_response["shipping_methods"].should_not be_empty
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it "can add just shipping address information to an order" do
|
|
@@ -147,7 +147,7 @@ module Spree
|
|
|
147
147
|
api_put :update, :id => order.to_param, :order => { :line_items => [{:variant_id => create(:variant).id, :quantity => 2}] }
|
|
148
148
|
|
|
149
149
|
response.status.should == 200
|
|
150
|
-
json_response['
|
|
150
|
+
json_response['item_total'].to_f.should_not == order.item_total.to_f
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
context "with a line item" do
|
|
@@ -230,7 +230,7 @@ module Spree
|
|
|
230
230
|
api_get :index, :q => { :email_cont => 'spree' }
|
|
231
231
|
json_response["orders"].count.should == 1
|
|
232
232
|
json_response["orders"].first.should have_attributes(attributes)
|
|
233
|
-
json_response["orders"].first["
|
|
233
|
+
json_response["orders"].first["email"].should == expected_result.email
|
|
234
234
|
json_response["count"].should == 1
|
|
235
235
|
json_response["current_page"].should == 1
|
|
236
236
|
json_response["pages"].should == 1
|
|
@@ -239,11 +239,6 @@ module Spree
|
|
|
239
239
|
|
|
240
240
|
context "can cancel an order" do
|
|
241
241
|
before do
|
|
242
|
-
Spree::MailMethod.create!(
|
|
243
|
-
:environment => Rails.env,
|
|
244
|
-
:preferred_mails_from => "spree@example.com"
|
|
245
|
-
)
|
|
246
|
-
|
|
247
242
|
order.completed_at = Time.now
|
|
248
243
|
order.state = 'complete'
|
|
249
244
|
order.shipment_state = 'ready'
|
|
@@ -252,7 +247,7 @@ module Spree
|
|
|
252
247
|
|
|
253
248
|
specify do
|
|
254
249
|
api_put :cancel, :id => order.to_param
|
|
255
|
-
json_response["
|
|
250
|
+
json_response["state"].should == "canceled"
|
|
256
251
|
end
|
|
257
252
|
end
|
|
258
253
|
end
|
data/spec/controllers/spree/api/{v1/payments_controller_spec.rb → payments_controller_spec.rb}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
describe Spree::Api::
|
|
4
|
+
describe Spree::Api::PaymentsController do
|
|
5
5
|
render_views
|
|
6
6
|
let!(:order) { create(:order) }
|
|
7
7
|
let!(:payment) { create(:payment, :order => order) }
|
|
@@ -88,7 +88,7 @@ module Spree
|
|
|
88
88
|
it 'can query the results through a paramter' do
|
|
89
89
|
api_get :index, :q => { :response_code_cont => '999' }
|
|
90
90
|
json_response['count'].should == 1
|
|
91
|
-
json_response['payments'].first['
|
|
91
|
+
json_response['payments'].first['response_code'].should eq @payment.response_code
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|