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.
Files changed (115) hide show
  1. data/.rspec +1 -0
  2. data/app/controllers/spree/api/addresses_controller.rb +17 -0
  3. data/app/controllers/spree/api/base_controller.rb +111 -0
  4. data/app/controllers/spree/api/countries_controller.rb +14 -0
  5. data/app/controllers/spree/api/images_controller.rb +29 -0
  6. data/app/controllers/spree/api/line_items_controller.rb +38 -0
  7. data/app/controllers/spree/api/orders_controller.rb +81 -0
  8. data/app/controllers/spree/api/payments_controller.rb +75 -0
  9. data/app/controllers/spree/api/product_properties_controller.rb +61 -0
  10. data/app/controllers/spree/api/products_controller.rb +45 -0
  11. data/app/controllers/spree/api/return_authorizations_controller.rb +50 -0
  12. data/app/controllers/spree/api/shipments_controller.rb +41 -0
  13. data/app/controllers/spree/api/taxonomies_controller.rb +46 -0
  14. data/app/controllers/spree/api/taxons_controller.rb +49 -0
  15. data/app/controllers/spree/api/variants_controller.rb +71 -0
  16. data/app/controllers/spree/api/zones_controller.rb +43 -0
  17. data/app/helpers/spree/api/api_helpers.rb +0 -5
  18. data/app/overrides/api_admin_user_edit_form.rb +1 -1
  19. data/app/views/spree/admin/users/_api_fields.html.erb +26 -14
  20. data/app/views/spree/api/{v1/addresses/show.rabl → addresses/show.v1.rabl} +0 -0
  21. data/app/views/spree/api/{v1/countries/index.rabl → countries/index.v1.rabl} +0 -0
  22. data/app/views/spree/api/{v1/countries/show.rabl → countries/show.v1.rabl} +0 -0
  23. data/app/views/spree/api/{v1/errors/gateway_error.rabl → errors/gateway_error.v1.rabl} +0 -0
  24. data/app/views/spree/api/{v1/errors/invalid_api_key.rabl → errors/invalid_api_key.v1.rabl} +0 -0
  25. data/app/views/spree/api/{v1/errors/invalid_resource.rabl → errors/invalid_resource.v1.rabl} +0 -0
  26. data/app/views/spree/api/{v1/errors/must_specify_api_key.rabl → errors/must_specify_api_key.v1.rabl} +0 -0
  27. data/app/views/spree/api/{v1/errors/not_found.rabl → errors/not_found.v1.rabl} +0 -0
  28. data/app/views/spree/api/{v1/errors/unauthorized.rabl → errors/unauthorized.v1.rabl} +0 -0
  29. data/app/views/spree/api/{v1/images/show.rabl → images/show.v1.rabl} +0 -0
  30. data/app/views/spree/api/{v1/line_items/new.rabl → line_items/new.v1.rabl} +0 -0
  31. data/app/views/spree/api/{v1/line_items/show.rabl → line_items/show.v1.rabl} +1 -1
  32. data/app/views/spree/api/{v1/orders/address.rabl → orders/address.v1.rabl} +0 -0
  33. data/app/views/spree/api/{v1/orders/canceled.rabl → orders/canceled.v1.rabl} +0 -0
  34. data/app/views/spree/api/{v1/orders/cart.rabl → orders/cart.v1.rabl} +0 -0
  35. data/app/views/spree/api/{v1/orders/complete.rabl → orders/complete.v1.rabl} +0 -0
  36. data/app/views/spree/api/{v1/orders/could_not_transition.rabl → orders/could_not_transition.v1.rabl} +0 -0
  37. data/app/views/spree/api/{v1/orders/delivery.rabl → orders/delivery.v1.rabl} +0 -0
  38. data/app/views/spree/api/{v1/orders/index.rabl → orders/index.v1.rabl} +0 -0
  39. data/app/views/spree/api/{v1/orders/invalid_shipping_method.rabl → orders/invalid_shipping_method.v1.rabl} +0 -0
  40. data/app/views/spree/api/{v1/orders/payment.rabl → orders/payment.v1.rabl} +0 -0
  41. data/app/views/spree/api/{v1/orders/show.rabl → orders/show.v1.rabl} +6 -6
  42. data/app/views/spree/api/{v1/payments/credit_over_limit.rabl → payments/credit_over_limit.v1.rabl} +0 -0
  43. data/app/views/spree/api/{v1/payments/index.rabl → payments/index.v1.rabl} +0 -0
  44. data/app/views/spree/api/{v1/payments/new.rabl → payments/new.v1.rabl} +0 -0
  45. data/app/views/spree/api/{v1/payments/show.rabl → payments/show.v1.rabl} +0 -0
  46. data/app/views/spree/api/{v1/product_properties/index.rabl → product_properties/index.v1.rabl} +0 -0
  47. data/app/views/spree/api/{v1/product_properties/new.rabl → product_properties/new.v1.rabl} +0 -0
  48. data/app/views/spree/api/{v1/product_properties/show.rabl → product_properties/show.v1.rabl} +0 -0
  49. data/app/views/spree/api/{v1/products/index.rabl → products/index.v1.rabl} +1 -2
  50. data/app/views/spree/api/{v1/products/new.rabl → products/new.v1.rabl} +0 -0
  51. data/app/views/spree/api/{v1/products/product.rabl → products/product.v1.rabl} +0 -0
  52. data/app/views/spree/api/{v1/products/show.rabl → products/show.v1.rabl} +1 -1
  53. data/app/views/spree/api/{v1/return_authorizations/index.rabl → return_authorizations/index.v1.rabl} +0 -0
  54. data/app/views/spree/api/{v1/return_authorizations/new.rabl → return_authorizations/new.v1.rabl} +0 -0
  55. data/app/views/spree/api/{v1/return_authorizations/show.rabl → return_authorizations/show.v1.rabl} +0 -0
  56. data/app/views/spree/api/{v1/shipments/cannot_ready_shipment.rabl → shipments/cannot_ready_shipment.v1.rabl} +0 -0
  57. data/app/views/spree/api/{v1/shipments/show.rabl → shipments/show.v1.rabl} +0 -0
  58. data/app/views/spree/api/{v1/taxonomies/index.rabl → taxonomies/index.v1.rabl} +1 -1
  59. data/app/views/spree/api/{v1/taxonomies/nested.rabl → taxonomies/nested.v1.rabl} +1 -1
  60. data/app/views/spree/api/{v1/taxonomies/new.rabl → taxonomies/new.v1.rabl} +0 -0
  61. data/app/views/spree/api/{v1/taxonomies/show.rabl → taxonomies/show.v1.rabl} +1 -1
  62. data/app/views/spree/api/{v1/taxons/index.rabl → taxons/index.v1.rabl} +1 -1
  63. data/app/views/spree/api/{v1/taxons/new.rabl → taxons/new.v1.rabl} +0 -0
  64. data/app/views/spree/api/{v1/taxons/show.rabl → taxons/show.v1.rabl} +0 -0
  65. data/app/views/spree/api/{v1/taxons/taxons.rabl → taxons/taxons.v1.rabl} +1 -1
  66. data/app/views/spree/api/{v1/variants/index.rabl → variants/index.v1.rabl} +0 -0
  67. data/app/views/spree/api/{v1/variants/new.rabl → variants/new.v1.rabl} +0 -0
  68. data/app/views/spree/api/{v1/variants/show.rabl → variants/show.v1.rabl} +1 -1
  69. data/app/views/spree/api/{v1/variants/variant.rabl → variants/variant.v1.rabl} +0 -0
  70. data/app/views/spree/api/{v1/zones/index.rabl → zones/index.v1.rabl} +1 -1
  71. data/app/views/spree/api/{v1/zones/show.rabl → zones/show.v1.rabl} +0 -0
  72. data/config/initializers/metal_load_paths.rb +1 -1
  73. data/config/routes.rb +34 -37
  74. data/db/migrate/20120411123334_resize_api_key_field.rb +1 -1
  75. data/lib/spree/api/engine.rb +8 -1
  76. data/lib/spree_api.rb +1 -0
  77. data/spec/controllers/spree/api/{v1/addresses_controller_spec.rb → addresses_controller_spec.rb} +3 -3
  78. data/spec/controllers/spree/api/{v1/base_controller_spec.rb → base_controller_spec.rb} +2 -9
  79. data/spec/controllers/spree/api/{v1/countries_controller_spec.rb → countries_controller_spec.rb} +5 -5
  80. data/spec/controllers/spree/api/{v1/images_controller_spec.rb → images_controller_spec.rb} +1 -1
  81. data/spec/controllers/spree/api/{v1/line_items_controller_spec.rb → line_items_controller_spec.rb} +2 -2
  82. data/spec/controllers/spree/api/{v1/orders_controller_spec.rb → orders_controller_spec.rb} +7 -12
  83. data/spec/controllers/spree/api/{v1/payments_controller_spec.rb → payments_controller_spec.rb} +2 -2
  84. data/spec/controllers/spree/api/{v1/product_properties_controller_spec.rb → product_properties_controller_spec.rb} +2 -3
  85. data/spec/controllers/spree/api/{v1/products_controller_spec.rb → products_controller_spec.rb} +14 -7
  86. data/spec/controllers/spree/api/{v1/return_authorizations_controller_spec.rb → return_authorizations_controller_spec.rb} +4 -4
  87. data/spec/controllers/spree/api/{v1/shipments_controller_spec.rb → shipments_controller_spec.rb} +4 -9
  88. data/spec/controllers/spree/api/{v1/taxonomies_controller_spec.rb → taxonomies_controller_spec.rb} +11 -11
  89. data/spec/controllers/spree/api/{v1/taxons_controller_spec.rb → taxons_controller_spec.rb} +7 -7
  90. data/spec/controllers/spree/api/{v1/unauthenticated_products_controller_spec.rb → unauthenticated_products_controller_spec.rb} +1 -1
  91. data/spec/controllers/spree/api/{v1/variants_controller_spec.rb → variants_controller_spec.rb} +4 -5
  92. data/spec/controllers/spree/api/{v1/zones_controller_spec.rb → zones_controller_spec.rb} +7 -7
  93. data/spec/support/controller_hacks.rb +1 -1
  94. data/spec/support/have_attributes_matcher.rb +2 -2
  95. data/spree_api.gemspec +1 -0
  96. metadata +139 -115
  97. checksums.yaml +0 -7
  98. data/app/controllers/spree/api/v1/addresses_controller.rb +0 -19
  99. data/app/controllers/spree/api/v1/base_controller.rb +0 -111
  100. data/app/controllers/spree/api/v1/countries_controller.rb +0 -18
  101. data/app/controllers/spree/api/v1/images_controller.rb +0 -32
  102. data/app/controllers/spree/api/v1/inventory_units_controller.rb +0 -50
  103. data/app/controllers/spree/api/v1/line_items_controller.rb +0 -40
  104. data/app/controllers/spree/api/v1/orders_controller.rb +0 -83
  105. data/app/controllers/spree/api/v1/payments_controller.rb +0 -77
  106. data/app/controllers/spree/api/v1/product_properties_controller.rb +0 -64
  107. data/app/controllers/spree/api/v1/products_controller.rb +0 -47
  108. data/app/controllers/spree/api/v1/return_authorizations_controller.rb +0 -53
  109. data/app/controllers/spree/api/v1/shipments_controller.rb +0 -43
  110. data/app/controllers/spree/api/v1/taxonomies_controller.rb +0 -50
  111. data/app/controllers/spree/api/v1/taxons_controller.rb +0 -51
  112. data/app/controllers/spree/api/v1/variants_controller.rb +0 -74
  113. data/app/controllers/spree/api/v1/zones_controller.rb +0 -45
  114. data/app/views/spree/api/v1/inventory_units/show.rabl +0 -2
  115. data/spec/controllers/spree/api/v1/inventory_units_controller_spec.rb +0 -46
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'shared_examples/protect_product_actions'
3
3
 
4
4
  module Spree
5
- describe Spree::Api::V1::ProductPropertiesController do
5
+ describe Spree::Api::ProductPropertiesController do
6
6
  render_views
7
7
 
8
8
  let!(:product) { create(:product) }
@@ -45,7 +45,7 @@ module Spree
45
45
  property = Spree::ProductProperty.last
46
46
  api_get :index, :q => { :value_cont => 'loose' }
47
47
  json_response['count'].should == 1
48
- json_response['product_properties'].first['product_property']['value'].should eq property.value
48
+ json_response['product_properties'].first['value'].should eq property.value
49
49
  end
50
50
 
51
51
  it "can see a single product_property" do
@@ -108,7 +108,6 @@ module Spree
108
108
 
109
109
  it "can see a single product_property by id" do
110
110
  api_get :show, :id => property_1.id
111
- json_response.count.should eq 1
112
111
  json_response.should have_attributes(attributes)
113
112
  end
114
113
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'shared_examples/protect_product_actions'
3
3
 
4
4
  module Spree
5
- describe Spree::Api::V1::ProductsController do
5
+ describe Spree::Api::ProductsController do
6
6
  render_views
7
7
 
8
8
  let!(:product) { create(:product) }
@@ -49,6 +49,14 @@ module Spree
49
49
  end
50
50
  end
51
51
 
52
+ context "jsonp" do
53
+ it "retrieves a list of products of jsonp" do
54
+ api_get :index, {:callback => 'callback'}
55
+ response.body.should =~ /^callback\(.*\)$/
56
+ response.header['Content-Type'].should include('application/javascript')
57
+ end
58
+ end
59
+
52
60
  it "can search for products" do
53
61
  create(:product, :name => "The best product in the world")
54
62
  api_get :index, :q => { :name_cont => "best" }
@@ -61,18 +69,17 @@ module Spree
61
69
  product.set_property("spree", "rocks")
62
70
  api_get :show, :id => product.to_param
63
71
  json_response.should have_attributes(attributes)
64
- product_json = json_response["product"]
65
- product_json["variants"].first.should have_attributes([:name,
72
+ json_response['variants'].first.should have_attributes([:name,
66
73
  :is_master,
67
74
  :count_on_hand,
68
75
  :price])
69
76
 
70
- product_json["images"].first.should have_attributes([:attachment_file_name,
77
+ json_response["images"].first.should have_attributes([:attachment_file_name,
71
78
  :attachment_width,
72
79
  :attachment_height,
73
80
  :attachment_content_type])
74
81
 
75
- product_json["product_properties"].first.should have_attributes([:value,
82
+ json_response["product_properties"].first.should have_attributes([:value,
76
83
  :product_id,
77
84
  :property_name])
78
85
  end
@@ -87,11 +94,11 @@ module Spree
87
94
 
88
95
  specify do
89
96
  api_get :show, :id => product.to_param
90
- json_response["product"]["permalink"].should =~ /and-1-ways/
97
+ json_response["permalink"].should =~ /and-1-ways/
91
98
  product.destroy
92
99
 
93
100
  api_get :show, :id => other_product.id
94
- json_response["product"]["permalink"].should =~ /droids/
101
+ json_response["permalink"].should =~ /droids/
95
102
  end
96
103
  end
97
104
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::V1::ReturnAuthorizationsController do
4
+ describe Api::ReturnAuthorizationsController do
5
5
  render_views
6
6
 
7
7
  let!(:order) do
@@ -67,7 +67,7 @@ module Spree
67
67
  api_get :show, :order_id => order.number, :id => return_authorization.id
68
68
  response.status.should == 200
69
69
  json_response.should have_attributes(attributes)
70
- json_response["return_authorization"]["state"].should_not be_blank
70
+ json_response["state"].should_not be_blank
71
71
  end
72
72
 
73
73
  it "can get a list of return authorizations" do
@@ -95,7 +95,7 @@ module Spree
95
95
  order.return_authorizations << expected_result
96
96
  api_get :index, :q => { :reason_cont => 'damage' }
97
97
  json_response['count'].should == 1
98
- json_response['return_authorizations'].first['return_authorization']['reason'].should eq expected_result.reason
98
+ json_response['return_authorizations'].first['reason'].should eq expected_result.reason
99
99
  end
100
100
 
101
101
  it "can learn how to create a new return authorization" do
@@ -125,7 +125,7 @@ module Spree
125
125
  api_post :create, :return_autorization => { :order_id => order.number, :amount => 14.22, :reason => "Defective" }
126
126
  response.status.should == 201
127
127
  json_response.should have_attributes(attributes)
128
- json_response["return_authorization"]["state"].should_not be_blank
128
+ json_response["state"].should_not be_blank
129
129
  end
130
130
  end
131
131
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::Api::V1::ShipmentsController do
3
+ describe Spree::Api::ShipmentsController do
4
4
  render_views
5
5
  let!(:shipment) { create(:shipment) }
6
6
  let!(:attributes) { [:id, :tracking, :number, :cost, :shipped_at] }
@@ -30,7 +30,7 @@ describe Spree::Api::V1::ShipmentsController do
30
30
  Spree::Order.any_instance.stub(:paid? => true, :complete? => true)
31
31
  api_put :ready
32
32
  json_response.should have_attributes(attributes)
33
- json_response["shipment"]["state"].should == "ready"
33
+ json_response["state"].should == "ready"
34
34
  shipment.reload.state.should == "ready"
35
35
  end
36
36
 
@@ -38,17 +38,12 @@ describe Spree::Api::V1::ShipmentsController do
38
38
  Spree::Order.any_instance.stub(:paid? => false)
39
39
  api_put :ready
40
40
  json_response["error"].should == "Cannot ready shipment."
41
+ response.status.should == 422
41
42
  end
42
43
 
43
44
  context "can transition a shipment from ready to ship" do
44
45
  before do
45
46
  Spree::Order.any_instance.stub(:paid? => true, :complete? => true)
46
- # For the shipment notification email
47
- Spree::MailMethod.create!(
48
- :environment => Rails.env,
49
- :preferred_mails_from => "spree@example.com"
50
- )
51
-
52
47
  shipment.update!(shipment.order)
53
48
  shipment.state.should == "ready"
54
49
  end
@@ -57,7 +52,7 @@ describe Spree::Api::V1::ShipmentsController do
57
52
  shipment.reload
58
53
  api_put :ship, :order_id => shipment.order.to_param, :id => shipment.to_param, :shipment => { :tracking => "123123" }
59
54
  json_response.should have_attributes(attributes)
60
- json_response["shipment"]["state"].should == "shipped"
55
+ json_response["state"].should == "shipped"
61
56
  end
62
57
  end
63
58
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::V1::TaxonomiesController do
4
+ describe Api::TaxonomiesController do
5
5
  render_views
6
6
 
7
7
  let(:taxonomy) { create(:taxonomy) }
@@ -20,8 +20,8 @@ module Spree
20
20
  it "gets all taxonomies" do
21
21
  api_get :index
22
22
 
23
- json_response["taxonomies"].first['taxonomy']['name'].should eq taxonomy.name
24
- json_response["taxonomies"].first['taxonomy']['root']['taxons'].count.should eq 1
23
+ json_response["taxonomies"].first['name'].should eq taxonomy.name
24
+ json_response["taxonomies"].first['root']['taxons'].count.should eq 1
25
25
  end
26
26
 
27
27
  it 'can control the page size through a parameter' do
@@ -36,27 +36,27 @@ module Spree
36
36
  expected_result = create(:taxonomy, :name => 'Style')
37
37
  api_get :index, :q => { :name_cont => 'style' }
38
38
  json_response['count'].should == 1
39
- json_response['taxonomies'].first['taxonomy']['name'].should eq expected_result.name
39
+ json_response['taxonomies'].first['name'].should eq expected_result.name
40
40
  end
41
41
 
42
42
  it "gets a single taxonomy" do
43
43
  api_get :show, :id => taxonomy.id
44
44
 
45
- json_response['taxonomy']['name'].should eq taxonomy.name
45
+ json_response['name'].should eq taxonomy.name
46
46
 
47
- children = json_response['taxonomy']['root']['taxons']
47
+ children = json_response['root']['taxons']
48
48
  children.count.should eq 1
49
- children.first['taxon']['name'].should eq taxon.name
50
- children.first['taxon'].key?('taxons').should be_false
49
+ children.first['name'].should eq taxon.name
50
+ children.first.key?('taxons').should be_false
51
51
  end
52
52
 
53
53
  it "gets a single taxonomy with set=nested" do
54
54
  api_get :show, :id => taxonomy.id, :set => 'nested'
55
55
 
56
- json_response['taxonomy']['name'].should eq taxonomy.name
56
+ json_response['name'].should eq taxonomy.name
57
57
 
58
- children = json_response['taxonomy']['root']['taxons']
59
- children.first['taxon'].key?('taxons').should be_true
58
+ children = json_response['root']['taxons']
59
+ children.first.key?('taxons').should be_true
60
60
  end
61
61
 
62
62
  it "can learn how to create a new taxonomy" do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::V1::TaxonsController do
4
+ describe Api::TaxonsController do
5
5
  render_views
6
6
 
7
7
  let(:taxonomy) { create(:taxonomy) }
@@ -20,18 +20,18 @@ module Spree
20
20
  it "gets all taxons" do
21
21
  api_get :index, :taxonomy_id => taxonomy.id
22
22
 
23
- json_response.first['taxon']['name'].should eq taxon.name
24
- children = json_response.first['taxon']['taxons']
23
+ json_response.first['name'].should eq taxon.name
24
+ children = json_response.first['taxons']
25
25
  children.count.should eq 1
26
- children.first['taxon']['name'].should eq taxon2.name
27
- children.first['taxon']['taxons'].count.should eq 1
26
+ children.first['name'].should eq taxon2.name
27
+ children.first['taxons'].count.should eq 1
28
28
  end
29
29
 
30
30
  it "gets a single taxon" do
31
31
  api_get :show, :id => taxon.id, :taxonomy_id => taxonomy.id
32
32
 
33
- json_response['taxon']['name'].should eq taxon.name
34
- json_response['taxon']['taxons'].count.should eq 1
33
+ json_response['name'].should eq taxon.name
34
+ json_response['taxons'].count.should eq 1
35
35
  end
36
36
 
37
37
  it "can learn how to create a new taxon" do
@@ -2,7 +2,7 @@ require 'shared_examples/protect_product_actions'
2
2
  require 'spec_helper'
3
3
 
4
4
  module Spree
5
- describe Spree::Api::V1::ProductsController do
5
+ describe Spree::Api::ProductsController do
6
6
  render_views
7
7
 
8
8
  let!(:product) { create(:product) }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::V1::VariantsController do
4
+ describe Api::VariantsController do
5
5
  render_views
6
6
 
7
7
 
@@ -40,12 +40,12 @@ module Spree
40
40
  expected_result = create(:variant, :sku => 'FOOBAR')
41
41
  api_get :index, :q => { :sku_cont => 'FOO' }
42
42
  json_response['count'].should == 1
43
- json_response['variants'].first['variant']['sku'].should eq expected_result.sku
43
+ json_response['variants'].first['sku'].should eq expected_result.sku
44
44
  end
45
45
 
46
46
  it "variants returned contain option values data" do
47
47
  api_get :index
48
- option_values = json_response["variants"].last["variant"]["option_values"]
48
+ option_values = json_response["variants"].last["option_values"]
49
49
  option_values.first.should have_attributes([:name,
50
50
  :presentation,
51
51
  :option_type_name,
@@ -85,7 +85,7 @@ module Spree
85
85
  it "can see a single variant" do
86
86
  api_get :show, :id => variant.to_param
87
87
  json_response.should have_attributes(attributes)
88
- option_values = json_response["variant"]["option_values"]
88
+ option_values = json_response["option_values"]
89
89
  option_values.first.should have_attributes([:name,
90
90
  :presentation,
91
91
  :option_type_name,
@@ -134,7 +134,6 @@ module Spree
134
134
  api_post :create, :variant => { :sku => "12345" }
135
135
  json_response.should have_attributes(attributes)
136
136
  response.status.should == 201
137
- json_response["variant"]["sku"].should == "12345"
138
137
 
139
138
  variant.product.variants.count.should == 1
140
139
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::V1::ZonesController do
4
+ describe Api::ZonesController do
5
5
  render_views
6
6
 
7
7
  let!(:attributes) { [:id, :name, :zone_members] }
@@ -28,14 +28,14 @@ module Spree
28
28
  expected_result = create(:zone, :name => 'South America')
29
29
  api_get :index, :q => { :name_cont => 'south' }
30
30
  json_response['count'].should == 1
31
- json_response['zones'].first['zone']['name'].should eq expected_result.name
31
+ json_response['zones'].first['name'].should eq expected_result.name
32
32
  end
33
33
 
34
34
  it "gets a zone" do
35
35
  api_get :show, :id => @zone.id
36
36
  json_response.should have_attributes(attributes)
37
- json_response['zone']['name'].should eq @zone.name
38
- json_response['zone']['zone_members'].size.should eq @zone.zone_members.count
37
+ json_response['name'].should eq @zone.name
38
+ json_response['zone_members'].size.should eq @zone.zone_members.count
39
39
  end
40
40
 
41
41
  context "as an admin" do
@@ -57,7 +57,7 @@ module Spree
57
57
  api_post :create, params
58
58
  response.status.should == 201
59
59
  json_response.should have_attributes(attributes)
60
- json_response["zone"]["zone_members"].should_not be_empty
60
+ json_response["zone_members"].should_not be_empty
61
61
  end
62
62
 
63
63
  it "updates a zone" do
@@ -75,8 +75,8 @@ module Spree
75
75
 
76
76
  api_put :update, params
77
77
  response.status.should == 200
78
- json_response['zone']['name'].should eq 'North Pole'
79
- json_response['zone']['zone_members'].should_not be_blank
78
+ json_response['name'].should eq 'North Pole'
79
+ json_response['zone_members'].should_not be_blank
80
80
  end
81
81
 
82
82
  it "can delete a zone" do
@@ -18,7 +18,7 @@ module ControllerHacks
18
18
 
19
19
  def api_process(action, params={}, session=nil, flash=nil, method="get")
20
20
  scoping = respond_to?(:resource_scoping) ? resource_scoping : {}
21
- process(action, params.merge(scoping).reverse_merge!(:use_route => :spree, :format => :json), session, { :foo => "bar" }, method)
21
+ process(action, params.merge(scoping).reverse_merge!(:use_route => :spree, :format => :json), session, flash, method)
22
22
  end
23
23
  end
24
24
 
@@ -5,8 +5,8 @@
5
5
  RSpec::Matchers.define :have_attributes do |expected_attributes|
6
6
  match do |actual|
7
7
  # actual is a Hash object representing an object, like this:
8
- # { "product" => { "name" => "Product #1" } }
9
- actual_attributes = actual.values.first.keys.map(&:to_sym)
8
+ # { "name" => "Product #1" }
9
+ actual_attributes = actual.keys.map(&:to_sym)
10
10
  expected_attributes.map(&:to_sym).all? { |attr| actual_attributes.include?(attr) }
11
11
  end
12
12
  end
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = version
17
17
 
18
18
  gem.add_dependency 'spree_core', version
19
+ gem.add_dependency 'versioncake', '0.4.0'
19
20
 
20
21
  gem.add_development_dependency 'rspec-rails', '2.9.0'
21
22
  gem.add_development_dependency 'database_cleaner'
metadata CHANGED
@@ -1,32 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0.rc1
5
+ prerelease: 6
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ryan Bigg
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-06-12 00:00:00.000000000 Z
12
+ date: 2012-12-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: spree_core
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - '='
18
20
  - !ruby/object:Gem::Version
19
- version: 1.2.5
21
+ version: 1.3.0.rc1
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - '='
25
28
  - !ruby/object:Gem::Version
26
- version: 1.2.5
29
+ version: 1.3.0.rc1
30
+ - !ruby/object:Gem::Dependency
31
+ name: versioncake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.4.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.4.0
27
46
  - !ruby/object:Gem::Dependency
28
47
  name: rspec-rails
29
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
30
50
  requirements:
31
51
  - - '='
32
52
  - !ruby/object:Gem::Version
@@ -34,6 +54,7 @@ dependencies:
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
37
58
  requirements:
38
59
  - - '='
39
60
  - !ruby/object:Gem::Version
@@ -41,15 +62,17 @@ dependencies:
41
62
  - !ruby/object:Gem::Dependency
42
63
  name: database_cleaner
43
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
44
66
  requirements:
45
- - - '>='
67
+ - - ! '>='
46
68
  - !ruby/object:Gem::Version
47
69
  version: '0'
48
70
  type: :development
49
71
  prerelease: false
50
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
51
74
  requirements:
52
- - - '>='
75
+ - - ! '>='
53
76
  - !ruby/object:Gem::Version
54
77
  version: '0'
55
78
  description: Spree's API
@@ -60,25 +83,25 @@ extensions: []
60
83
  extra_rdoc_files: []
61
84
  files:
62
85
  - .gitignore
86
+ - .rspec
63
87
  - Gemfile
64
88
  - LICENSE
65
89
  - Rakefile
66
- - app/controllers/spree/api/v1/addresses_controller.rb
67
- - app/controllers/spree/api/v1/base_controller.rb
68
- - app/controllers/spree/api/v1/countries_controller.rb
69
- - app/controllers/spree/api/v1/images_controller.rb
70
- - app/controllers/spree/api/v1/inventory_units_controller.rb
71
- - app/controllers/spree/api/v1/line_items_controller.rb
72
- - app/controllers/spree/api/v1/orders_controller.rb
73
- - app/controllers/spree/api/v1/payments_controller.rb
74
- - app/controllers/spree/api/v1/product_properties_controller.rb
75
- - app/controllers/spree/api/v1/products_controller.rb
76
- - app/controllers/spree/api/v1/return_authorizations_controller.rb
77
- - app/controllers/spree/api/v1/shipments_controller.rb
78
- - app/controllers/spree/api/v1/taxonomies_controller.rb
79
- - app/controllers/spree/api/v1/taxons_controller.rb
80
- - app/controllers/spree/api/v1/variants_controller.rb
81
- - app/controllers/spree/api/v1/zones_controller.rb
90
+ - app/controllers/spree/api/addresses_controller.rb
91
+ - app/controllers/spree/api/base_controller.rb
92
+ - app/controllers/spree/api/countries_controller.rb
93
+ - app/controllers/spree/api/images_controller.rb
94
+ - app/controllers/spree/api/line_items_controller.rb
95
+ - app/controllers/spree/api/orders_controller.rb
96
+ - app/controllers/spree/api/payments_controller.rb
97
+ - app/controllers/spree/api/product_properties_controller.rb
98
+ - app/controllers/spree/api/products_controller.rb
99
+ - app/controllers/spree/api/return_authorizations_controller.rb
100
+ - app/controllers/spree/api/shipments_controller.rb
101
+ - app/controllers/spree/api/taxonomies_controller.rb
102
+ - app/controllers/spree/api/taxons_controller.rb
103
+ - app/controllers/spree/api/variants_controller.rb
104
+ - app/controllers/spree/api/zones_controller.rb
82
105
  - app/helpers/spree/api/api_helpers.rb
83
106
  - app/models/spree/api_configuration.rb
84
107
  - app/models/spree/line_item_decorator.rb
@@ -87,59 +110,58 @@ files:
87
110
  - app/models/spree/user_decorator.rb
88
111
  - app/overrides/api_admin_user_edit_form.rb
89
112
  - app/views/spree/admin/users/_api_fields.html.erb
90
- - app/views/spree/api/v1/addresses/show.rabl
91
- - app/views/spree/api/v1/countries/index.rabl
92
- - app/views/spree/api/v1/countries/show.rabl
93
- - app/views/spree/api/v1/errors/gateway_error.rabl
94
- - app/views/spree/api/v1/errors/invalid_api_key.rabl
95
- - app/views/spree/api/v1/errors/invalid_resource.rabl
96
- - app/views/spree/api/v1/errors/must_specify_api_key.rabl
97
- - app/views/spree/api/v1/errors/not_found.rabl
98
- - app/views/spree/api/v1/errors/unauthorized.rabl
99
- - app/views/spree/api/v1/images/show.rabl
100
- - app/views/spree/api/v1/inventory_units/show.rabl
101
- - app/views/spree/api/v1/line_items/new.rabl
102
- - app/views/spree/api/v1/line_items/show.rabl
103
- - app/views/spree/api/v1/orders/address.rabl
104
- - app/views/spree/api/v1/orders/canceled.rabl
105
- - app/views/spree/api/v1/orders/cart.rabl
106
- - app/views/spree/api/v1/orders/complete.rabl
107
- - app/views/spree/api/v1/orders/could_not_transition.rabl
108
- - app/views/spree/api/v1/orders/delivery.rabl
109
- - app/views/spree/api/v1/orders/index.rabl
110
- - app/views/spree/api/v1/orders/invalid_shipping_method.rabl
111
- - app/views/spree/api/v1/orders/payment.rabl
112
- - app/views/spree/api/v1/orders/show.rabl
113
- - app/views/spree/api/v1/payments/credit_over_limit.rabl
114
- - app/views/spree/api/v1/payments/index.rabl
115
- - app/views/spree/api/v1/payments/new.rabl
116
- - app/views/spree/api/v1/payments/show.rabl
117
- - app/views/spree/api/v1/product_properties/index.rabl
118
- - app/views/spree/api/v1/product_properties/new.rabl
119
- - app/views/spree/api/v1/product_properties/show.rabl
120
- - app/views/spree/api/v1/products/index.rabl
121
- - app/views/spree/api/v1/products/new.rabl
122
- - app/views/spree/api/v1/products/product.rabl
123
- - app/views/spree/api/v1/products/show.rabl
124
- - app/views/spree/api/v1/return_authorizations/index.rabl
125
- - app/views/spree/api/v1/return_authorizations/new.rabl
126
- - app/views/spree/api/v1/return_authorizations/show.rabl
127
- - app/views/spree/api/v1/shipments/cannot_ready_shipment.rabl
128
- - app/views/spree/api/v1/shipments/show.rabl
129
- - app/views/spree/api/v1/taxonomies/index.rabl
130
- - app/views/spree/api/v1/taxonomies/nested.rabl
131
- - app/views/spree/api/v1/taxonomies/new.rabl
132
- - app/views/spree/api/v1/taxonomies/show.rabl
133
- - app/views/spree/api/v1/taxons/index.rabl
134
- - app/views/spree/api/v1/taxons/new.rabl
135
- - app/views/spree/api/v1/taxons/show.rabl
136
- - app/views/spree/api/v1/taxons/taxons.rabl
137
- - app/views/spree/api/v1/variants/index.rabl
138
- - app/views/spree/api/v1/variants/new.rabl
139
- - app/views/spree/api/v1/variants/show.rabl
140
- - app/views/spree/api/v1/variants/variant.rabl
141
- - app/views/spree/api/v1/zones/index.rabl
142
- - app/views/spree/api/v1/zones/show.rabl
113
+ - app/views/spree/api/addresses/show.v1.rabl
114
+ - app/views/spree/api/countries/index.v1.rabl
115
+ - app/views/spree/api/countries/show.v1.rabl
116
+ - app/views/spree/api/errors/gateway_error.v1.rabl
117
+ - app/views/spree/api/errors/invalid_api_key.v1.rabl
118
+ - app/views/spree/api/errors/invalid_resource.v1.rabl
119
+ - app/views/spree/api/errors/must_specify_api_key.v1.rabl
120
+ - app/views/spree/api/errors/not_found.v1.rabl
121
+ - app/views/spree/api/errors/unauthorized.v1.rabl
122
+ - app/views/spree/api/images/show.v1.rabl
123
+ - app/views/spree/api/line_items/new.v1.rabl
124
+ - app/views/spree/api/line_items/show.v1.rabl
125
+ - app/views/spree/api/orders/address.v1.rabl
126
+ - app/views/spree/api/orders/canceled.v1.rabl
127
+ - app/views/spree/api/orders/cart.v1.rabl
128
+ - app/views/spree/api/orders/complete.v1.rabl
129
+ - app/views/spree/api/orders/could_not_transition.v1.rabl
130
+ - app/views/spree/api/orders/delivery.v1.rabl
131
+ - app/views/spree/api/orders/index.v1.rabl
132
+ - app/views/spree/api/orders/invalid_shipping_method.v1.rabl
133
+ - app/views/spree/api/orders/payment.v1.rabl
134
+ - app/views/spree/api/orders/show.v1.rabl
135
+ - app/views/spree/api/payments/credit_over_limit.v1.rabl
136
+ - app/views/spree/api/payments/index.v1.rabl
137
+ - app/views/spree/api/payments/new.v1.rabl
138
+ - app/views/spree/api/payments/show.v1.rabl
139
+ - app/views/spree/api/product_properties/index.v1.rabl
140
+ - app/views/spree/api/product_properties/new.v1.rabl
141
+ - app/views/spree/api/product_properties/show.v1.rabl
142
+ - app/views/spree/api/products/index.v1.rabl
143
+ - app/views/spree/api/products/new.v1.rabl
144
+ - app/views/spree/api/products/product.v1.rabl
145
+ - app/views/spree/api/products/show.v1.rabl
146
+ - app/views/spree/api/return_authorizations/index.v1.rabl
147
+ - app/views/spree/api/return_authorizations/new.v1.rabl
148
+ - app/views/spree/api/return_authorizations/show.v1.rabl
149
+ - app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl
150
+ - app/views/spree/api/shipments/show.v1.rabl
151
+ - app/views/spree/api/taxonomies/index.v1.rabl
152
+ - app/views/spree/api/taxonomies/nested.v1.rabl
153
+ - app/views/spree/api/taxonomies/new.v1.rabl
154
+ - app/views/spree/api/taxonomies/show.v1.rabl
155
+ - app/views/spree/api/taxons/index.v1.rabl
156
+ - app/views/spree/api/taxons/new.v1.rabl
157
+ - app/views/spree/api/taxons/show.v1.rabl
158
+ - app/views/spree/api/taxons/taxons.v1.rabl
159
+ - app/views/spree/api/variants/index.v1.rabl
160
+ - app/views/spree/api/variants/new.v1.rabl
161
+ - app/views/spree/api/variants/show.v1.rabl
162
+ - app/views/spree/api/variants/variant.v1.rabl
163
+ - app/views/spree/api/zones/index.v1.rabl
164
+ - app/views/spree/api/zones/show.v1.rabl
143
165
  - config/initializers/metal_load_paths.rb
144
166
  - config/locales/en.yml
145
167
  - config/routes.rb
@@ -154,23 +176,22 @@ files:
154
176
  - lib/spree/api/version.rb
155
177
  - lib/spree_api.rb
156
178
  - script/rails
157
- - spec/controllers/spree/api/v1/addresses_controller_spec.rb
158
- - spec/controllers/spree/api/v1/base_controller_spec.rb
159
- - spec/controllers/spree/api/v1/countries_controller_spec.rb
160
- - spec/controllers/spree/api/v1/images_controller_spec.rb
161
- - spec/controllers/spree/api/v1/inventory_units_controller_spec.rb
162
- - spec/controllers/spree/api/v1/line_items_controller_spec.rb
163
- - spec/controllers/spree/api/v1/orders_controller_spec.rb
164
- - spec/controllers/spree/api/v1/payments_controller_spec.rb
165
- - spec/controllers/spree/api/v1/product_properties_controller_spec.rb
166
- - spec/controllers/spree/api/v1/products_controller_spec.rb
167
- - spec/controllers/spree/api/v1/return_authorizations_controller_spec.rb
168
- - spec/controllers/spree/api/v1/shipments_controller_spec.rb
169
- - spec/controllers/spree/api/v1/taxonomies_controller_spec.rb
170
- - spec/controllers/spree/api/v1/taxons_controller_spec.rb
171
- - spec/controllers/spree/api/v1/unauthenticated_products_controller_spec.rb
172
- - spec/controllers/spree/api/v1/variants_controller_spec.rb
173
- - spec/controllers/spree/api/v1/zones_controller_spec.rb
179
+ - spec/controllers/spree/api/addresses_controller_spec.rb
180
+ - spec/controllers/spree/api/base_controller_spec.rb
181
+ - spec/controllers/spree/api/countries_controller_spec.rb
182
+ - spec/controllers/spree/api/images_controller_spec.rb
183
+ - spec/controllers/spree/api/line_items_controller_spec.rb
184
+ - spec/controllers/spree/api/orders_controller_spec.rb
185
+ - spec/controllers/spree/api/payments_controller_spec.rb
186
+ - spec/controllers/spree/api/product_properties_controller_spec.rb
187
+ - spec/controllers/spree/api/products_controller_spec.rb
188
+ - spec/controllers/spree/api/return_authorizations_controller_spec.rb
189
+ - spec/controllers/spree/api/shipments_controller_spec.rb
190
+ - spec/controllers/spree/api/taxonomies_controller_spec.rb
191
+ - spec/controllers/spree/api/taxons_controller_spec.rb
192
+ - spec/controllers/spree/api/unauthenticated_products_controller_spec.rb
193
+ - spec/controllers/spree/api/variants_controller_spec.rb
194
+ - spec/controllers/spree/api/zones_controller_spec.rb
174
195
  - spec/fixtures/thinking-cat.jpg
175
196
  - spec/models/spree/legacy_user_spec.rb
176
197
  - spec/models/spree/order_spec.rb
@@ -182,45 +203,48 @@ files:
182
203
  - spree_api.gemspec
183
204
  homepage: ''
184
205
  licenses: []
185
- metadata: {}
186
206
  post_install_message:
187
207
  rdoc_options: []
188
208
  require_paths:
189
209
  - lib
190
210
  required_ruby_version: !ruby/object:Gem::Requirement
211
+ none: false
191
212
  requirements:
192
- - - '>='
213
+ - - ! '>='
193
214
  - !ruby/object:Gem::Version
194
215
  version: '0'
216
+ segments:
217
+ - 0
218
+ hash: 1028675823196415570
195
219
  required_rubygems_version: !ruby/object:Gem::Requirement
220
+ none: false
196
221
  requirements:
197
- - - '>='
222
+ - - ! '>'
198
223
  - !ruby/object:Gem::Version
199
- version: '0'
224
+ version: 1.3.1
200
225
  requirements: []
201
226
  rubyforge_project:
202
- rubygems_version: 2.0.0
227
+ rubygems_version: 1.8.23
203
228
  signing_key:
204
- specification_version: 4
229
+ specification_version: 3
205
230
  summary: Spree's API
206
231
  test_files:
207
- - spec/controllers/spree/api/v1/addresses_controller_spec.rb
208
- - spec/controllers/spree/api/v1/base_controller_spec.rb
209
- - spec/controllers/spree/api/v1/countries_controller_spec.rb
210
- - spec/controllers/spree/api/v1/images_controller_spec.rb
211
- - spec/controllers/spree/api/v1/inventory_units_controller_spec.rb
212
- - spec/controllers/spree/api/v1/line_items_controller_spec.rb
213
- - spec/controllers/spree/api/v1/orders_controller_spec.rb
214
- - spec/controllers/spree/api/v1/payments_controller_spec.rb
215
- - spec/controllers/spree/api/v1/product_properties_controller_spec.rb
216
- - spec/controllers/spree/api/v1/products_controller_spec.rb
217
- - spec/controllers/spree/api/v1/return_authorizations_controller_spec.rb
218
- - spec/controllers/spree/api/v1/shipments_controller_spec.rb
219
- - spec/controllers/spree/api/v1/taxonomies_controller_spec.rb
220
- - spec/controllers/spree/api/v1/taxons_controller_spec.rb
221
- - spec/controllers/spree/api/v1/unauthenticated_products_controller_spec.rb
222
- - spec/controllers/spree/api/v1/variants_controller_spec.rb
223
- - spec/controllers/spree/api/v1/zones_controller_spec.rb
232
+ - spec/controllers/spree/api/addresses_controller_spec.rb
233
+ - spec/controllers/spree/api/base_controller_spec.rb
234
+ - spec/controllers/spree/api/countries_controller_spec.rb
235
+ - spec/controllers/spree/api/images_controller_spec.rb
236
+ - spec/controllers/spree/api/line_items_controller_spec.rb
237
+ - spec/controllers/spree/api/orders_controller_spec.rb
238
+ - spec/controllers/spree/api/payments_controller_spec.rb
239
+ - spec/controllers/spree/api/product_properties_controller_spec.rb
240
+ - spec/controllers/spree/api/products_controller_spec.rb
241
+ - spec/controllers/spree/api/return_authorizations_controller_spec.rb
242
+ - spec/controllers/spree/api/shipments_controller_spec.rb
243
+ - spec/controllers/spree/api/taxonomies_controller_spec.rb
244
+ - spec/controllers/spree/api/taxons_controller_spec.rb
245
+ - spec/controllers/spree/api/unauthenticated_products_controller_spec.rb
246
+ - spec/controllers/spree/api/variants_controller_spec.rb
247
+ - spec/controllers/spree/api/zones_controller_spec.rb
224
248
  - spec/fixtures/thinking-cat.jpg
225
249
  - spec/models/spree/legacy_user_spec.rb
226
250
  - spec/models/spree/order_spec.rb