workarea-api-admin 4.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/README.md +82 -0
  4. data/Rakefile +10 -0
  5. data/app/assets/images/workarea/api/admin/icons/api.svg +1 -0
  6. data/app/controllers/workarea/api/admin/application_controller.rb +73 -0
  7. data/app/controllers/workarea/api/admin/categories_controller.rb +305 -0
  8. data/app/controllers/workarea/api/admin/category_product_rules_controller.rb +232 -0
  9. data/app/controllers/workarea/api/admin/content_assets_controller.rb +299 -0
  10. data/app/controllers/workarea/api/admin/content_controller.rb +268 -0
  11. data/app/controllers/workarea/api/admin/discounts_controller.rb +271 -0
  12. data/app/controllers/workarea/api/admin/email_signups_controller.rb +108 -0
  13. data/app/controllers/workarea/api/admin/fulfillments_controller.rb +268 -0
  14. data/app/controllers/workarea/api/admin/inventory_skus_controller.rb +305 -0
  15. data/app/controllers/workarea/api/admin/navigation_menus_controller.rb +267 -0
  16. data/app/controllers/workarea/api/admin/navigation_taxons_controller.rb +305 -0
  17. data/app/controllers/workarea/api/admin/orders_controller.rb +160 -0
  18. data/app/controllers/workarea/api/admin/pages_controller.rb +305 -0
  19. data/app/controllers/workarea/api/admin/payment_profiles_controller.rb +305 -0
  20. data/app/controllers/workarea/api/admin/payment_transactions_controller.rb +108 -0
  21. data/app/controllers/workarea/api/admin/payments_controller.rb +115 -0
  22. data/app/controllers/workarea/api/admin/prices_controller.rb +232 -0
  23. data/app/controllers/workarea/api/admin/pricing_skus_controller.rb +305 -0
  24. data/app/controllers/workarea/api/admin/product_images_controller.rb +232 -0
  25. data/app/controllers/workarea/api/admin/products_controller.rb +305 -0
  26. data/app/controllers/workarea/api/admin/promo_code_lists_controller.rb +305 -0
  27. data/app/controllers/workarea/api/admin/recommendation_settings_controller.rb +122 -0
  28. data/app/controllers/workarea/api/admin/redirects_controller.rb +305 -0
  29. data/app/controllers/workarea/api/admin/releases_controller.rb +304 -0
  30. data/app/controllers/workarea/api/admin/saved_addresses_controller.rb +232 -0
  31. data/app/controllers/workarea/api/admin/saved_credit_cards_controller.rb +256 -0
  32. data/app/controllers/workarea/api/admin/shipping_rates_controller.rb +232 -0
  33. data/app/controllers/workarea/api/admin/shipping_services_controller.rb +299 -0
  34. data/app/controllers/workarea/api/admin/shippings_controller.rb +105 -0
  35. data/app/controllers/workarea/api/admin/swagger_controller.rb +41 -0
  36. data/app/controllers/workarea/api/admin/tax_categories_controller.rb +242 -0
  37. data/app/controllers/workarea/api/admin/tax_rates_controller.rb +292 -0
  38. data/app/controllers/workarea/api/admin/users_controller.rb +296 -0
  39. data/app/controllers/workarea/api/admin/variants_controller.rb +232 -0
  40. data/app/models/workarea/api/admin/bulk_upsert.rb +74 -0
  41. data/app/models/workarea/user.decorator +7 -0
  42. data/app/views/workarea/admin/users/_api_permissions.html.haml +6 -0
  43. data/app/workers/workarea/perform_api_bulk_upsert.rb +15 -0
  44. data/bin/rails +18 -0
  45. data/config/initializers/append_points.rb +4 -0
  46. data/config/initializers/config.rb +15 -0
  47. data/config/locales/en.yml +9 -0
  48. data/config/routes.rb +81 -0
  49. data/lib/workarea/api/admin.rb +21 -0
  50. data/lib/workarea/api/admin/engine.rb +14 -0
  51. data/lib/workarea/api/admin/swagger.rb +106 -0
  52. data/test/documentation/workarea/api/admin/categories_documentation_test.rb +106 -0
  53. data/test/documentation/workarea/api/admin/category_product_rules_documentation_test.rb +78 -0
  54. data/test/documentation/workarea/api/admin/content_assets_documentation_test.rb +94 -0
  55. data/test/documentation/workarea/api/admin/content_documentation_test.rb +87 -0
  56. data/test/documentation/workarea/api/admin/discounts_documentation_test.rb +85 -0
  57. data/test/documentation/workarea/api/admin/email_signups_documentation_test.rb +41 -0
  58. data/test/documentation/workarea/api/admin/fulfillment_documentation_test.rb +84 -0
  59. data/test/documentation/workarea/api/admin/inventory_skus_documentation_test.rb +95 -0
  60. data/test/documentation/workarea/api/admin/navigation_menus_documentation_test.rb +81 -0
  61. data/test/documentation/workarea/api/admin/navigation_taxons_documentation_test.rb +94 -0
  62. data/test/documentation/workarea/api/admin/orders_documentation_test.rb +65 -0
  63. data/test/documentation/workarea/api/admin/pages_documentation_test.rb +93 -0
  64. data/test/documentation/workarea/api/admin/payment_profiles_documentation_test.rb +98 -0
  65. data/test/documentation/workarea/api/admin/payment_transactions_documentation_test.rb +43 -0
  66. data/test/documentation/workarea/api/admin/payments_documentation_test.rb +41 -0
  67. data/test/documentation/workarea/api/admin/prices_documentation_test.rb +82 -0
  68. data/test/documentation/workarea/api/admin/pricing_skus_documentation_test.rb +95 -0
  69. data/test/documentation/workarea/api/admin/product_images_documentation_test.rb +101 -0
  70. data/test/documentation/workarea/api/admin/products_documentation_test.rb +96 -0
  71. data/test/documentation/workarea/api/admin/promo_code_lists_documentation_test.rb +94 -0
  72. data/test/documentation/workarea/api/admin/recommendation_settings_documentation_test.rb +37 -0
  73. data/test/documentation/workarea/api/admin/redirects_documentation_test.rb +96 -0
  74. data/test/documentation/workarea/api/admin/release_changes_documentation_test.rb +32 -0
  75. data/test/documentation/workarea/api/admin/releases_documentation_test.rb +93 -0
  76. data/test/documentation/workarea/api/admin/saved_addresses_documentation_test.rb +92 -0
  77. data/test/documentation/workarea/api/admin/saved_credit_cards_documentation_test.rb +86 -0
  78. data/test/documentation/workarea/api/admin/shipping_rates_documentation_test.rb +78 -0
  79. data/test/documentation/workarea/api/admin/shipping_services_documentation_test.rb +93 -0
  80. data/test/documentation/workarea/api/admin/shippings_documentation_test.rb +41 -0
  81. data/test/documentation/workarea/api/admin/tax_categories_documentation_test.rb +95 -0
  82. data/test/documentation/workarea/api/admin/tax_rates_documentation_test.rb +78 -0
  83. data/test/documentation/workarea/api/admin/users_documentation_test.rb +99 -0
  84. data/test/documentation/workarea/api/admin/variants_documentation_test.rb +80 -0
  85. data/test/dummy/Rakefile +7 -0
  86. data/test/dummy/app/assets/config/manifest.js +4 -0
  87. data/test/dummy/app/assets/images/.keep +0 -0
  88. data/test/dummy/app/assets/javascripts/application.js +13 -0
  89. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  90. data/test/dummy/app/controllers/application_controller.rb +3 -0
  91. data/test/dummy/app/controllers/concerns/.keep +0 -0
  92. data/test/dummy/app/helpers/application_helper.rb +2 -0
  93. data/test/dummy/app/jobs/application_job.rb +2 -0
  94. data/test/dummy/app/mailers/.keep +0 -0
  95. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  96. data/test/dummy/app/models/.keep +0 -0
  97. data/test/dummy/app/models/concerns/.keep +0 -0
  98. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  99. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  100. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  101. data/test/dummy/bin/bundle +3 -0
  102. data/test/dummy/bin/rails +4 -0
  103. data/test/dummy/bin/rake +4 -0
  104. data/test/dummy/bin/setup +34 -0
  105. data/test/dummy/bin/update +29 -0
  106. data/test/dummy/config.ru +4 -0
  107. data/test/dummy/config/application.rb +25 -0
  108. data/test/dummy/config/boot.rb +5 -0
  109. data/test/dummy/config/cable.yml +9 -0
  110. data/test/dummy/config/environment.rb +5 -0
  111. data/test/dummy/config/environments/development.rb +55 -0
  112. data/test/dummy/config/environments/production.rb +86 -0
  113. data/test/dummy/config/environments/test.rb +43 -0
  114. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  115. data/test/dummy/config/initializers/assets.rb +11 -0
  116. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  117. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  118. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  119. data/test/dummy/config/initializers/inflections.rb +16 -0
  120. data/test/dummy/config/initializers/mime_types.rb +4 -0
  121. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  122. data/test/dummy/config/initializers/session_store.rb +3 -0
  123. data/test/dummy/config/initializers/workarea.rb +8 -0
  124. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  125. data/test/dummy/config/locales/en.yml +23 -0
  126. data/test/dummy/config/puma.rb +47 -0
  127. data/test/dummy/config/routes.rb +6 -0
  128. data/test/dummy/config/secrets.yml +22 -0
  129. data/test/dummy/config/spring.rb +6 -0
  130. data/test/dummy/db/seeds.rb +2 -0
  131. data/test/dummy/log/.keep +0 -0
  132. data/test/dummy/public/404.html +67 -0
  133. data/test/dummy/public/422.html +67 -0
  134. data/test/dummy/public/500.html +66 -0
  135. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  136. data/test/dummy/public/apple-touch-icon.png +0 -0
  137. data/test/dummy/public/favicon.ico +1 -0
  138. data/test/integration/workarea/api/admin/audit_log_integration_test.rb +20 -0
  139. data/test/integration/workarea/api/admin/authentication_integration_test.rb +61 -0
  140. data/test/integration/workarea/api/admin/categories_integration_test.rb +64 -0
  141. data/test/integration/workarea/api/admin/category_product_rules_integration_test.rb +58 -0
  142. data/test/integration/workarea/api/admin/content_assets_integration_test.rb +65 -0
  143. data/test/integration/workarea/api/admin/content_integration_test.rb +59 -0
  144. data/test/integration/workarea/api/admin/discounts_integration_test.rb +64 -0
  145. data/test/integration/workarea/api/admin/email_signups_integration_test.rb +32 -0
  146. data/test/integration/workarea/api/admin/error_handling_integration_test.rb +16 -0
  147. data/test/integration/workarea/api/admin/fulfillments_integration_test.rb +62 -0
  148. data/test/integration/workarea/api/admin/inventory_skus_integration_test.rb +70 -0
  149. data/test/integration/workarea/api/admin/navigation_menus_integration_test.rb +54 -0
  150. data/test/integration/workarea/api/admin/navigation_taxons_integration_test.rb +63 -0
  151. data/test/integration/workarea/api/admin/orders_integration_test.rb +53 -0
  152. data/test/integration/workarea/api/admin/pages_integration_test.rb +64 -0
  153. data/test/integration/workarea/api/admin/payment_profiles_integration_test.rb +75 -0
  154. data/test/integration/workarea/api/admin/payment_transactions_integration_test.rb +45 -0
  155. data/test/integration/workarea/api/admin/payments_integration_test.rb +29 -0
  156. data/test/integration/workarea/api/admin/prices_integration_test.rb +55 -0
  157. data/test/integration/workarea/api/admin/pricing_skus_integration_test.rb +72 -0
  158. data/test/integration/workarea/api/admin/product_images_integration_test.rb +56 -0
  159. data/test/integration/workarea/api/admin/products_integration_test.rb +66 -0
  160. data/test/integration/workarea/api/admin/promo_code_lists_integration_test.rb +70 -0
  161. data/test/integration/workarea/api/admin/recommendation_settings_integration_test.rb +41 -0
  162. data/test/integration/workarea/api/admin/redirects_integration_test.rb +69 -0
  163. data/test/integration/workarea/api/admin/release_changes_integration_test.rb +32 -0
  164. data/test/integration/workarea/api/admin/releases_integration_test.rb +60 -0
  165. data/test/integration/workarea/api/admin/saved_addresses_integration_test.rb +70 -0
  166. data/test/integration/workarea/api/admin/saved_credit_cards_integration_test.rb +76 -0
  167. data/test/integration/workarea/api/admin/shipping_rates_integration_test.rb +54 -0
  168. data/test/integration/workarea/api/admin/shipping_services_integration_test.rb +64 -0
  169. data/test/integration/workarea/api/admin/shippings_integration_test.rb +34 -0
  170. data/test/integration/workarea/api/admin/tax_categories_integration_test.rb +64 -0
  171. data/test/integration/workarea/api/admin/tax_rates_integration_test.rb +66 -0
  172. data/test/integration/workarea/api/admin/users_integration_test.rb +67 -0
  173. data/test/integration/workarea/api/admin/variants_integration_test.rb +59 -0
  174. data/test/models/workarea/api/admin/bulk_upsert_test.rb +79 -0
  175. data/test/test_helper.rb +10 -0
  176. data/test/vcr_cassettes/product_image_from_url.yml +43 -0
  177. data/workarea-api-admin.gemspec +18 -0
  178. metadata +252 -0
@@ -0,0 +1,58 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class CategoryProductRulesIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ setup :set_sample_attributes
10
+
11
+ def set_sample_attributes
12
+ @category = create_category
13
+ @sample_attributes = { name: 'search', operator: 'equals', value: '*' }
14
+ end
15
+
16
+ def create_rule
17
+ @category.product_rules.create!(@sample_attributes)
18
+ end
19
+
20
+ def test_lists_rules
21
+ rules = [create_rule, create_rule]
22
+ get admin_api.category_product_rules_path(@category.id)
23
+ result = JSON.parse(response.body)['product_rules']
24
+
25
+ assert_equal(2, result.length)
26
+ assert_equal(rules.first, ProductRule.new(result.first))
27
+ assert_equal(rules.second, ProductRule.new(result.second))
28
+ end
29
+
30
+ def test_creates_rules
31
+ data = @sample_attributes
32
+
33
+ assert_difference '@category.reload; @category.product_rules.count;', 1 do
34
+ post admin_api.category_product_rules_path(@category.id),
35
+ params: { product_rule: data }
36
+ end
37
+ end
38
+
39
+ def test_updates_rules
40
+ rule = create_rule
41
+ patch admin_api.category_product_rule_path(@category.id, rule.id),
42
+ params: { product_rule: { value: 'foo' } }
43
+
44
+ rule.reload
45
+ assert_equal('foo', rule.value)
46
+ end
47
+
48
+ def test_destroys_rules
49
+ rule = create_rule
50
+
51
+ assert_difference '@category.reload; @category.product_rules.count;', -1 do
52
+ delete admin_api.category_product_rule_path(@category.id, rule.id)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,65 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class ContentAssetsIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ setup :set_sample_attributes
10
+
11
+ def set_sample_attributes
12
+ @sample_attributes = create_asset.as_json.except('_id')
13
+ end
14
+
15
+ def test_lists_assets
16
+ assets = [create_asset, create_asset]
17
+ get admin_api.content_assets_path
18
+ result = JSON.parse(response.body)['assets']
19
+
20
+ assert_equal(3, result.length)
21
+ assert_equal(assets.second, Content::Asset.new(result.first))
22
+ assert_equal(assets.first, Content::Asset.new(result.second))
23
+ end
24
+
25
+ def test_creates_assets
26
+ data = @sample_attributes
27
+ assert_difference 'Content::Asset.count', 1 do
28
+ post admin_api.content_assets_path, params: { asset: data }
29
+ end
30
+ end
31
+
32
+ def test_shows_assets
33
+ asset = create_asset
34
+ get admin_api.content_asset_path(asset.id)
35
+ result = JSON.parse(response.body)['asset']
36
+ assert_equal(asset, Content::Asset.new(result))
37
+ end
38
+
39
+ def test_updates_assets
40
+ asset = create_asset
41
+ patch admin_api.content_asset_path(asset.id),
42
+ params: { asset: { name: 'foo' } }
43
+
44
+ asset.reload
45
+ assert_equal('foo', asset.name)
46
+ end
47
+
48
+ def test_bulk_upserts_assets
49
+ data = [@sample_attributes] * 10
50
+ assert_difference 'Content::Asset.count', 10 do
51
+ patch admin_api.bulk_content_assets_path, params: { assets: data }
52
+ end
53
+ end
54
+
55
+ def test_destroys_assets
56
+ asset = create_asset
57
+
58
+ assert_difference 'Content::Asset.count', -1 do
59
+ delete admin_api.content_asset_path(asset.id)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,59 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class ContentIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ setup :set_sample_attributes
10
+
11
+ def set_sample_attributes
12
+ @sample_attributes = create_content.as_json.except('_id')
13
+ end
14
+
15
+ def test_lists_content
16
+ content = [create_content, create_content]
17
+ get admin_api.content_index_path
18
+ result = JSON.parse(response.body)['content']
19
+
20
+ assert_equal(3, result.length)
21
+ assert_equal(content.second, Content.new(result.first))
22
+ assert_equal(content.first, Content.new(result.second))
23
+ end
24
+
25
+ def test_creates_content
26
+ data = @sample_attributes
27
+
28
+ assert_difference 'Content.count', 1 do
29
+ post admin_api.content_index_path, params: { content: data }
30
+ end
31
+ end
32
+
33
+ def test_shows_content
34
+ content = create_content
35
+ get admin_api.content_path(content.id)
36
+ result = JSON.parse(response.body)['content']
37
+ assert_equal(content, Content.new(result))
38
+ end
39
+
40
+ def test_updates_content
41
+ content = create_content
42
+ patch admin_api.content_path(content.id),
43
+ params: { content: { browser_title: 'foo' } }
44
+
45
+ content.reload
46
+ assert_equal('foo', content.browser_title)
47
+ end
48
+
49
+ def test_bulk_upserts_content
50
+ data = [@sample_attributes] * 10
51
+
52
+ assert_difference 'Content.count', 10 do
53
+ patch admin_api.bulk_content_index_path, params: { content: data }
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class DiscountsIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ setup :set_sample_attributes
10
+ alias create_discount create_product_discount
11
+
12
+ def set_sample_attributes
13
+ @sample_attributes = create_discount
14
+ .as_json
15
+ .except('_id')
16
+ .merge('type' => 'product')
17
+ end
18
+
19
+ def test_lists_discounts
20
+ discounts = [create_discount, create_discount]
21
+ get admin_api.discounts_path
22
+ result = JSON.parse(response.body)['discounts']
23
+
24
+ assert_equal(3, result.length)
25
+ assert_equal(discounts.second, Pricing::Discount::Product.new(result.first))
26
+ assert_equal(discounts.first, Pricing::Discount::Product.new(result.second))
27
+ end
28
+
29
+ def test_creates_discounts
30
+ data = @sample_attributes
31
+
32
+ assert_difference 'Pricing::Discount.count', 1 do
33
+ post admin_api.discounts_path, params: { discount: data }
34
+ end
35
+ end
36
+
37
+ def test_shows_discounts
38
+ discount = create_discount
39
+ get admin_api.discount_path(discount.id)
40
+ result = JSON.parse(response.body)['discount']
41
+ assert_equal(discount, Pricing::Discount::Product.new(result))
42
+ end
43
+
44
+ def test_updates_discounts
45
+ discount = create_discount
46
+
47
+ patch admin_api.discount_path(discount.id),
48
+ params: { discount: { name: 'foo' } }
49
+
50
+ discount.reload
51
+ assert_equal('foo', discount.name)
52
+ end
53
+
54
+ def test_destroys_discounts
55
+ discount = create_discount
56
+
57
+ assert_difference 'Pricing::Discount.count', -1 do
58
+ delete admin_api.discount_path(discount.id)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class EmailSignupsIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ def test_lists_email_signups
10
+ email_signups = [
11
+ create_email_signup(email: '1@workarea.com'),
12
+ create_email_signup(email: '2@workarea.com')
13
+ ]
14
+
15
+ get admin_api.email_signups_path
16
+ result = JSON.parse(response.body)['email_signups']
17
+
18
+ assert_equal(2, result.length)
19
+ assert_equal(email_signups.second, Email::Signup.new(result.first))
20
+ assert_equal(email_signups.first, Email::Signup.new(result.second))
21
+ end
22
+
23
+ def test_shows_email_signups
24
+ email_signup = create_email_signup
25
+ get admin_api.email_signup_path(email_signup.id)
26
+ result = JSON.parse(response.body)['email_signup']
27
+ assert_equal(email_signup, Email::Signup.new(result))
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class ErrorHandlingIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ def test_handles_mongoid_not_found
10
+ patch admin_api.product_path('FOO'), params: { product: { name: 'foo' } }
11
+ assert_equal(404, response.status)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,62 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class FulfillmentsIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ def create_fulfillment(*args)
10
+ order = create_placed_order(*args)
11
+ Fulfillment.find(order.id)
12
+ end
13
+
14
+ def test_lists_fulfillments
15
+ fulfillments = [create_fulfillment(id: '1'), create_fulfillment(id: '2')]
16
+ get admin_api.fulfillments_path
17
+ result = JSON.parse(response.body)['fulfillments']
18
+
19
+ assert_equal(2, result.length)
20
+ assert_equal(fulfillments.second, Fulfillment.new(result.first))
21
+ assert_equal(fulfillments.first, Fulfillment.new(result.second))
22
+ end
23
+
24
+ def test_shows_fulfillments
25
+ fulfillment = create_fulfillment
26
+ get admin_api.fulfillment_path(fulfillment.id)
27
+ result = JSON.parse(response.body)['fulfillment']
28
+ assert_equal(fulfillment, Fulfillment.new(result))
29
+ end
30
+
31
+ def test_ships_items
32
+ fulfillment = create_fulfillment
33
+ former_status = fulfillment.status
34
+
35
+ post admin_api.ship_items_fulfillment_path(fulfillment.id),
36
+ params: {
37
+ tracking_number: '1Z',
38
+ items: [
39
+ { id: fulfillment.items.first.order_item_id, quantity: 1 }
40
+ ]
41
+ }
42
+
43
+ refute_equal(former_status, fulfillment.reload.status)
44
+ end
45
+
46
+ def test_cancels_items
47
+ fulfillment = create_fulfillment
48
+ former_status = fulfillment.status
49
+
50
+ post admin_api.cancel_items_fulfillment_path(fulfillment.id),
51
+ params: {
52
+ items: [
53
+ { id: fulfillment.items.first.order_item_id, quantity: 1 }
54
+ ]
55
+ }
56
+
57
+ refute_equal(former_status, fulfillment.reload.status)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,70 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class InventorySkusIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ setup :set_sample_attributes
10
+
11
+ def set_sample_attributes
12
+ @sample_attributes = create_inventory.as_json.except('_id')
13
+ end
14
+
15
+ def test_lists_inventory_skus
16
+ inventory_skus = [create_inventory(id: '1'), create_inventory(id: '2')]
17
+ get admin_api.inventory_skus_path
18
+ result = JSON.parse(response.body)['inventory_skus']
19
+
20
+ assert_equal(3, result.length)
21
+ assert_equal(inventory_skus.second, Inventory::Sku.new(result.first))
22
+ assert_equal(inventory_skus.first, Inventory::Sku.new(result.second))
23
+ end
24
+
25
+ def test_creates_inventory_skus
26
+ data = @sample_attributes.merge(id: '1')
27
+
28
+ assert_difference 'Inventory::Sku.count', 1 do
29
+ post admin_api.inventory_skus_path, params: { inventory_sku: data }
30
+ end
31
+ end
32
+
33
+ def test_shows_inventory_skus
34
+ inventory_sku = create_inventory(id: 'foo')
35
+ get admin_api.inventory_sku_path('foo')
36
+ result = JSON.parse(response.body)['inventory_sku']
37
+ assert_equal(inventory_sku, Inventory::Sku.new(result))
38
+ end
39
+
40
+ def test_updates_inventory_skus
41
+ inventory_sku = create_inventory(id: 'foo')
42
+ patch admin_api.inventory_sku_path('foo'),
43
+ params: { inventory_sku: { policy: 'ignore' } }
44
+
45
+ assert_equal('ignore', inventory_sku.reload.policy)
46
+ end
47
+
48
+ def test_bulk_upserts_inventory_skus
49
+ count = 0
50
+ data = Array.new(10) do
51
+ count += 1
52
+ @sample_attributes.merge(id: count)
53
+ end
54
+
55
+ assert_difference 'Inventory::Sku.count', 10 do
56
+ patch admin_api.bulk_inventory_skus_path, params: { inventory_skus: data }
57
+ end
58
+ end
59
+
60
+ def test_destroys_inventory_skus
61
+ create_inventory(id: 'foo')
62
+
63
+ assert_difference 'Inventory::Sku.count', -1 do
64
+ delete admin_api.inventory_sku_path('foo')
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,54 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Api
5
+ module Admin
6
+ class NavigationMenusIntegrationTest < IntegrationTest
7
+ include Workarea::Admin::IntegrationTest
8
+
9
+ setup :set_sample_attributes
10
+
11
+ def set_sample_attributes
12
+ @sample_attributes = create_menu.as_json.except('_id')
13
+ end
14
+
15
+ def test_lists_menus
16
+ 2.times { create_menu }
17
+ get admin_api.navigation_menus_path
18
+ result = JSON.parse(response.body)['navigation_menus']
19
+ assert_equal(3, result.length)
20
+ end
21
+
22
+ def test_creates_menus
23
+ assert_difference 'Navigation::Menu.count', 1 do
24
+ post admin_api.navigation_menus_path,
25
+ params: { navigation_menu: @sample_attributes }
26
+ end
27
+ end
28
+
29
+ def test_shows_menus
30
+ menu = create_menu
31
+ get admin_api.navigation_menu_path(menu.id)
32
+ result = JSON.parse(response.body)['navigation_menu']
33
+ assert_equal(menu, Navigation::Menu.new(result))
34
+ end
35
+
36
+ def test_updates_menus
37
+ menu = create_menu
38
+ patch admin_api.navigation_menu_path(menu.id),
39
+ params: { navigation_menu: { name: 'foo' } }
40
+
41
+ assert_equal('foo', menu.reload.name)
42
+ end
43
+
44
+ def test_destroys_menus
45
+ menu = create_menu
46
+
47
+ assert_difference 'Navigation::Menu.count', -1 do
48
+ delete admin_api.navigation_menu_path(menu.id)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end