workarea-api-admin 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/README.md +82 -0
- data/Rakefile +10 -0
- data/app/assets/images/workarea/api/admin/icons/api.svg +1 -0
- data/app/controllers/workarea/api/admin/application_controller.rb +73 -0
- data/app/controllers/workarea/api/admin/categories_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/category_product_rules_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/content_assets_controller.rb +299 -0
- data/app/controllers/workarea/api/admin/content_controller.rb +268 -0
- data/app/controllers/workarea/api/admin/discounts_controller.rb +271 -0
- data/app/controllers/workarea/api/admin/email_signups_controller.rb +108 -0
- data/app/controllers/workarea/api/admin/fulfillments_controller.rb +268 -0
- data/app/controllers/workarea/api/admin/inventory_skus_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/navigation_menus_controller.rb +267 -0
- data/app/controllers/workarea/api/admin/navigation_taxons_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/orders_controller.rb +160 -0
- data/app/controllers/workarea/api/admin/pages_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/payment_profiles_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/payment_transactions_controller.rb +108 -0
- data/app/controllers/workarea/api/admin/payments_controller.rb +115 -0
- data/app/controllers/workarea/api/admin/prices_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/pricing_skus_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/product_images_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/products_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/promo_code_lists_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/recommendation_settings_controller.rb +122 -0
- data/app/controllers/workarea/api/admin/redirects_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/releases_controller.rb +304 -0
- data/app/controllers/workarea/api/admin/saved_addresses_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/saved_credit_cards_controller.rb +256 -0
- data/app/controllers/workarea/api/admin/shipping_rates_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/shipping_services_controller.rb +299 -0
- data/app/controllers/workarea/api/admin/shippings_controller.rb +105 -0
- data/app/controllers/workarea/api/admin/swagger_controller.rb +41 -0
- data/app/controllers/workarea/api/admin/tax_categories_controller.rb +242 -0
- data/app/controllers/workarea/api/admin/tax_rates_controller.rb +292 -0
- data/app/controllers/workarea/api/admin/users_controller.rb +296 -0
- data/app/controllers/workarea/api/admin/variants_controller.rb +232 -0
- data/app/models/workarea/api/admin/bulk_upsert.rb +74 -0
- data/app/models/workarea/user.decorator +7 -0
- data/app/views/workarea/admin/users/_api_permissions.html.haml +6 -0
- data/app/workers/workarea/perform_api_bulk_upsert.rb +15 -0
- data/bin/rails +18 -0
- data/config/initializers/append_points.rb +4 -0
- data/config/initializers/config.rb +15 -0
- data/config/locales/en.yml +9 -0
- data/config/routes.rb +81 -0
- data/lib/workarea/api/admin.rb +21 -0
- data/lib/workarea/api/admin/engine.rb +14 -0
- data/lib/workarea/api/admin/swagger.rb +106 -0
- data/test/documentation/workarea/api/admin/categories_documentation_test.rb +106 -0
- data/test/documentation/workarea/api/admin/category_product_rules_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/content_assets_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/content_documentation_test.rb +87 -0
- data/test/documentation/workarea/api/admin/discounts_documentation_test.rb +85 -0
- data/test/documentation/workarea/api/admin/email_signups_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/fulfillment_documentation_test.rb +84 -0
- data/test/documentation/workarea/api/admin/inventory_skus_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/navigation_menus_documentation_test.rb +81 -0
- data/test/documentation/workarea/api/admin/navigation_taxons_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/orders_documentation_test.rb +65 -0
- data/test/documentation/workarea/api/admin/pages_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/payment_profiles_documentation_test.rb +98 -0
- data/test/documentation/workarea/api/admin/payment_transactions_documentation_test.rb +43 -0
- data/test/documentation/workarea/api/admin/payments_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/prices_documentation_test.rb +82 -0
- data/test/documentation/workarea/api/admin/pricing_skus_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/product_images_documentation_test.rb +101 -0
- data/test/documentation/workarea/api/admin/products_documentation_test.rb +96 -0
- data/test/documentation/workarea/api/admin/promo_code_lists_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/recommendation_settings_documentation_test.rb +37 -0
- data/test/documentation/workarea/api/admin/redirects_documentation_test.rb +96 -0
- data/test/documentation/workarea/api/admin/release_changes_documentation_test.rb +32 -0
- data/test/documentation/workarea/api/admin/releases_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/saved_addresses_documentation_test.rb +92 -0
- data/test/documentation/workarea/api/admin/saved_credit_cards_documentation_test.rb +86 -0
- data/test/documentation/workarea/api/admin/shipping_rates_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/shipping_services_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/shippings_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/tax_categories_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/tax_rates_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/users_documentation_test.rb +99 -0
- data/test/documentation/workarea/api/admin/variants_documentation_test.rb +80 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +55 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/workarea.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +1 -0
- data/test/integration/workarea/api/admin/audit_log_integration_test.rb +20 -0
- data/test/integration/workarea/api/admin/authentication_integration_test.rb +61 -0
- data/test/integration/workarea/api/admin/categories_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/category_product_rules_integration_test.rb +58 -0
- data/test/integration/workarea/api/admin/content_assets_integration_test.rb +65 -0
- data/test/integration/workarea/api/admin/content_integration_test.rb +59 -0
- data/test/integration/workarea/api/admin/discounts_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/email_signups_integration_test.rb +32 -0
- data/test/integration/workarea/api/admin/error_handling_integration_test.rb +16 -0
- data/test/integration/workarea/api/admin/fulfillments_integration_test.rb +62 -0
- data/test/integration/workarea/api/admin/inventory_skus_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/navigation_menus_integration_test.rb +54 -0
- data/test/integration/workarea/api/admin/navigation_taxons_integration_test.rb +63 -0
- data/test/integration/workarea/api/admin/orders_integration_test.rb +53 -0
- data/test/integration/workarea/api/admin/pages_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/payment_profiles_integration_test.rb +75 -0
- data/test/integration/workarea/api/admin/payment_transactions_integration_test.rb +45 -0
- data/test/integration/workarea/api/admin/payments_integration_test.rb +29 -0
- data/test/integration/workarea/api/admin/prices_integration_test.rb +55 -0
- data/test/integration/workarea/api/admin/pricing_skus_integration_test.rb +72 -0
- data/test/integration/workarea/api/admin/product_images_integration_test.rb +56 -0
- data/test/integration/workarea/api/admin/products_integration_test.rb +66 -0
- data/test/integration/workarea/api/admin/promo_code_lists_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/recommendation_settings_integration_test.rb +41 -0
- data/test/integration/workarea/api/admin/redirects_integration_test.rb +69 -0
- data/test/integration/workarea/api/admin/release_changes_integration_test.rb +32 -0
- data/test/integration/workarea/api/admin/releases_integration_test.rb +60 -0
- data/test/integration/workarea/api/admin/saved_addresses_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/saved_credit_cards_integration_test.rb +76 -0
- data/test/integration/workarea/api/admin/shipping_rates_integration_test.rb +54 -0
- data/test/integration/workarea/api/admin/shipping_services_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/shippings_integration_test.rb +34 -0
- data/test/integration/workarea/api/admin/tax_categories_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/tax_rates_integration_test.rb +66 -0
- data/test/integration/workarea/api/admin/users_integration_test.rb +67 -0
- data/test/integration/workarea/api/admin/variants_integration_test.rb +59 -0
- data/test/models/workarea/api/admin/bulk_upsert_test.rb +79 -0
- data/test/test_helper.rb +10 -0
- data/test/vcr_cassettes/product_image_from_url.yml +43 -0
- data/workarea-api-admin.gemspec +18 -0
- metadata +252 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class ProductImagesIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_sample_attributes
|
10
|
+
|
11
|
+
def set_sample_attributes
|
12
|
+
@product = create_product
|
13
|
+
@sample_attributes = { image: product_image_file }
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_image
|
17
|
+
@product.images.create!(@sample_attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_lists_images
|
21
|
+
images = [create_image, create_image]
|
22
|
+
get admin_api.product_images_path(@product.id)
|
23
|
+
result = JSON.parse(response.body)['images']
|
24
|
+
|
25
|
+
assert_equal(2, result.length)
|
26
|
+
assert_equal(images.first, Catalog::ProductImage.new(result.first))
|
27
|
+
assert_equal(images.second, Catalog::ProductImage.new(result.second))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_creates_images
|
31
|
+
data = @sample_attributes
|
32
|
+
|
33
|
+
assert_difference '@product.reload.images.count', 1 do
|
34
|
+
post admin_api.product_images_path(@product.id), params: { image: data }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_updates_images
|
39
|
+
image = create_image
|
40
|
+
patch admin_api.product_image_path(@product.id, image.id),
|
41
|
+
params: { image: { name: 'foo' } }
|
42
|
+
|
43
|
+
assert_equal('foo', image.reload.name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_destroys_images
|
47
|
+
image = create_image
|
48
|
+
|
49
|
+
assert_difference '@product.reload.images.count', -1 do
|
50
|
+
delete admin_api.product_image_path(@product.id, image.id)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class ProductsIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_sample_attributes
|
10
|
+
|
11
|
+
def set_sample_attributes
|
12
|
+
@sample_attributes = create_product
|
13
|
+
.as_json
|
14
|
+
.except('_id', 'slug', 'last_indexed_at')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_lists_products
|
18
|
+
products = [create_product, create_product]
|
19
|
+
get admin_api.products_path
|
20
|
+
result = JSON.parse(response.body)['products']
|
21
|
+
|
22
|
+
assert_equal(3, result.length)
|
23
|
+
assert_equal(products.second, Catalog::Product.new(result.first))
|
24
|
+
assert_equal(products.first, Catalog::Product.new(result.second))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_creates_products
|
28
|
+
assert_difference 'Catalog::Product.count', 1 do
|
29
|
+
post admin_api.products_path, params: { product: @sample_attributes }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_shows_products
|
34
|
+
product = create_product
|
35
|
+
get admin_api.product_path(product.id)
|
36
|
+
result = JSON.parse(response.body)['product']
|
37
|
+
assert_equal(product, Catalog::Product.new(result))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_updates_products
|
41
|
+
product = create_product
|
42
|
+
patch admin_api.product_path(product.id), params: { product: { name: 'foo' } }
|
43
|
+
|
44
|
+
product.reload
|
45
|
+
assert_equal('foo', product.name)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_bulk_upserts_products
|
49
|
+
data = [@sample_attributes] * 10
|
50
|
+
|
51
|
+
assert_difference 'Catalog::Product.count', 10 do
|
52
|
+
patch admin_api.bulk_products_path, params: { products: data }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_destroys_products
|
57
|
+
product = create_product
|
58
|
+
|
59
|
+
assert_difference 'Catalog::Product.count', -1 do
|
60
|
+
delete admin_api.product_path(product.id)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class PromoCodeListsIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_sample_attributes
|
10
|
+
|
11
|
+
def set_sample_attributes
|
12
|
+
@sample_attributes = create_code_list.as_json.except('_id')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_lists_promo_code_lists
|
16
|
+
promo_code_lists = [create_code_list, create_code_list]
|
17
|
+
get admin_api.promo_code_lists_path
|
18
|
+
result = JSON.parse(response.body)['promo_code_lists']
|
19
|
+
|
20
|
+
assert_equal(3, result.length)
|
21
|
+
assert_equal(
|
22
|
+
promo_code_lists.second,
|
23
|
+
Pricing::Discount::CodeList.new(result.first)
|
24
|
+
)
|
25
|
+
assert_equal(
|
26
|
+
promo_code_lists.first,
|
27
|
+
Pricing::Discount::CodeList.new(result.second)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_creates_promo_code_lists
|
32
|
+
assert_difference 'Pricing::Discount::CodeList.count', 1 do
|
33
|
+
post admin_api.promo_code_lists_path,
|
34
|
+
params: { promo_code_list: @sample_attributes }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_shows_promo_code_lists
|
39
|
+
promo_code_list = create_code_list
|
40
|
+
get admin_api.promo_code_list_path(promo_code_list.id)
|
41
|
+
result = JSON.parse(response.body)['promo_code_list']
|
42
|
+
assert_equal(promo_code_list, Pricing::Discount::CodeList.new(result))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_updates_promo_code_lists
|
46
|
+
promo_code_list = create_code_list
|
47
|
+
patch admin_api.promo_code_list_path(promo_code_list.id),
|
48
|
+
params: { promo_code_list: { name: 'foo' } }
|
49
|
+
|
50
|
+
assert_equal('foo', promo_code_list.reload.name)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_bulk_upserts_promo_code_lists
|
54
|
+
assert_difference 'Pricing::Discount::CodeList.count', 10 do
|
55
|
+
patch admin_api.bulk_promo_code_lists_path,
|
56
|
+
params: { promo_code_lists: [@sample_attributes] * 10 }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_destroys_promo_code_lists
|
61
|
+
promo_code_list = create_code_list
|
62
|
+
|
63
|
+
assert_difference 'Pricing::Discount::CodeList.count', -1 do
|
64
|
+
delete admin_api.promo_code_list_path(promo_code_list.id)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class RecommendationSettingsIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_product
|
10
|
+
|
11
|
+
def set_product
|
12
|
+
@product = create_product
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_recommendation_settings
|
16
|
+
Recommendation::Settings.create!(id: @product.id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_shows_recommendation_settings
|
20
|
+
recommendation_settings = create_recommendation_settings
|
21
|
+
get admin_api.product_recommendation_settings_path(@product.id)
|
22
|
+
|
23
|
+
result = JSON.parse(response.body)['recommendation_settings']
|
24
|
+
assert_equal(
|
25
|
+
recommendation_settings,
|
26
|
+
Recommendation::Settings.new(result)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_updates_recommendation_settings
|
31
|
+
recommendation_settings = create_recommendation_settings
|
32
|
+
|
33
|
+
patch admin_api.product_recommendation_settings_path(@product.id),
|
34
|
+
params: { recommendation_settings: { product_ids: ['foo'] } }
|
35
|
+
|
36
|
+
assert_equal(['foo'], recommendation_settings.reload.product_ids)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class RedirectsIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_sample_attributes
|
10
|
+
|
11
|
+
def set_sample_attributes
|
12
|
+
@sample_attributes = create_redirect.as_json.except('_id')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_lists_redirects
|
16
|
+
redirects = [create_redirect(path: '/1'), create_redirect(path: '/2')]
|
17
|
+
get admin_api.redirects_path
|
18
|
+
result = JSON.parse(response.body)['redirects']
|
19
|
+
|
20
|
+
assert_equal(3, result.length)
|
21
|
+
assert_equal(redirects.second, Navigation::Redirect.new(result.first))
|
22
|
+
assert_equal(redirects.first, Navigation::Redirect.new(result.second))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_creates_redirects
|
26
|
+
assert_difference 'Navigation::Redirect.count', 1 do
|
27
|
+
post admin_api.redirects_path,
|
28
|
+
params: { redirect: @sample_attributes.merge('path' => '/2') }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_shows_redirects
|
33
|
+
redirect = create_redirect(path: '/foo')
|
34
|
+
get admin_api.redirect_path(redirect.id)
|
35
|
+
result = JSON.parse(response.body)['redirect']
|
36
|
+
assert_equal(redirect, Navigation::Redirect.new(result))
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_updates_redirects
|
40
|
+
redirect = create_redirect(path: '/foo')
|
41
|
+
patch admin_api.redirect_path(redirect.id),
|
42
|
+
params: { redirect: { path: '/foo' } }
|
43
|
+
|
44
|
+
assert_equal('/foo', redirect.reload.path)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_bulk_upserts_redirects
|
48
|
+
count = 0
|
49
|
+
data = Array.new(10) do
|
50
|
+
count += 1
|
51
|
+
@sample_attributes.merge('path' => "/#{count}")
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_difference 'Navigation::Redirect.count', 10 do
|
55
|
+
patch admin_api.bulk_redirects_path, params: { redirects: data }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_destroys_redirects
|
60
|
+
redirect = create_redirect(path: '/foo')
|
61
|
+
|
62
|
+
assert_difference 'Navigation::Redirect.count', -1 do
|
63
|
+
delete admin_api.redirect_path(redirect.id)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class ReleaseChangesIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_sample_attributes
|
10
|
+
|
11
|
+
def set_sample_attributes
|
12
|
+
@release = create_release(name: 'API Release')
|
13
|
+
@sample_attributes = create_product
|
14
|
+
.as_json
|
15
|
+
.except('_id', 'slug', 'last_indexed_at')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_creates_a_changeset_for_the_specific_release
|
19
|
+
product = create_product(name: 'foo')
|
20
|
+
patch admin_api.product_path(product.id),
|
21
|
+
params: { product: { name: 'bar' }, release_id: @release.id.to_s }
|
22
|
+
|
23
|
+
product.reload
|
24
|
+
assert_equal('foo', product.name)
|
25
|
+
|
26
|
+
changes = product.changesets.first
|
27
|
+
assert_equal({ I18n.locale.to_s => 'bar' }, changes.changeset[:name])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class ReleasesIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_sample_attributes
|
10
|
+
|
11
|
+
def set_sample_attributes
|
12
|
+
@sample_attributes = create_release.as_json.except('_id')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_lists_releases
|
16
|
+
releases = [create_release, create_release]
|
17
|
+
get admin_api.releases_path
|
18
|
+
result = JSON.parse(response.body)['releases']
|
19
|
+
|
20
|
+
assert_equal(3, result.length)
|
21
|
+
assert_equal(releases.second, Release.new(result.first))
|
22
|
+
assert_equal(releases.first, Release.new(result.second))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_creates_releases
|
26
|
+
assert_difference 'Release.count', 1 do
|
27
|
+
post admin_api.releases_path, params: { release: @sample_attributes }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_shows_releases
|
32
|
+
release = create_release
|
33
|
+
get admin_api.release_path(release.id)
|
34
|
+
result = JSON.parse(response.body)['release']
|
35
|
+
assert_equal(release, Release.new(result))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_updates_releases
|
39
|
+
release = create_release
|
40
|
+
patch admin_api.release_path(release.id), params: { release: { name: 'foo' } }
|
41
|
+
assert_equal('foo', release.reload.name)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_bulk_upserts_releases
|
45
|
+
assert_difference 'Release.count', 10 do
|
46
|
+
patch admin_api.bulk_releases_path,
|
47
|
+
params: { releases: [@sample_attributes] * 10 }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_destroys_releases
|
52
|
+
release = create_release
|
53
|
+
assert_difference 'Release.count', -1 do
|
54
|
+
delete admin_api.release_path(release.id)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Api
|
5
|
+
module Admin
|
6
|
+
class SavedAddressesIntegrationTest < IntegrationTest
|
7
|
+
include Workarea::Admin::IntegrationTest
|
8
|
+
|
9
|
+
setup :set_sample_attributes
|
10
|
+
|
11
|
+
def set_sample_attributes
|
12
|
+
@user = create_user
|
13
|
+
|
14
|
+
@sample_attributes = {
|
15
|
+
first_name: 'Ben',
|
16
|
+
last_name: 'Crouse',
|
17
|
+
street: '22 S. 3rd St.',
|
18
|
+
city: 'Philadelphia',
|
19
|
+
region: 'PA',
|
20
|
+
postal_code: '19106',
|
21
|
+
country: 'US',
|
22
|
+
phone_number: '2159251800'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_address
|
27
|
+
@count ||= 0
|
28
|
+
@count += 1
|
29
|
+
|
30
|
+
@user.addresses.create!(
|
31
|
+
@sample_attributes.merge(street: "#{@count} S 3rd St")
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_lists_addresses
|
36
|
+
addresses = [create_address, create_address]
|
37
|
+
get admin_api.user_saved_addresses_path(@user.id)
|
38
|
+
result = JSON.parse(response.body)['saved_addresses']
|
39
|
+
|
40
|
+
assert_equal(2, result.length)
|
41
|
+
assert_equal(addresses.first, User::SavedAddress.new(result.first))
|
42
|
+
assert_equal(addresses.second, User::SavedAddress.new(result.second))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_creates_addresses
|
46
|
+
assert_difference '@user.reload.addresses.count', 1 do
|
47
|
+
post admin_api.user_saved_addresses_path(@user.id),
|
48
|
+
params: { saved_address: @sample_attributes }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_updates_addresses
|
53
|
+
address = create_address
|
54
|
+
patch admin_api.user_saved_address_path(@user.id, address.id),
|
55
|
+
params: { saved_address: { first_name: 'foo' } }
|
56
|
+
|
57
|
+
assert_equal('foo', address.reload.first_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_destroys_addresses
|
61
|
+
address = create_address
|
62
|
+
|
63
|
+
assert_difference '@user.reload.addresses.count', -1 do
|
64
|
+
delete admin_api.user_saved_address_path(@user.id, address.id)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|