solidus_json_api 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +224 -0
- data/Gemfile +6 -0
- data/LICENSE +26 -0
- data/README.md +94 -0
- data/Rakefile +38 -0
- data/app/controllers/concerns/spree/api/v2/renderable.rb +63 -0
- data/app/controllers/spree/api/v2/base_controller.rb +9 -0
- data/app/controllers/spree/api/v2/children_controller.rb +29 -0
- data/app/controllers/spree/api/v2/countries_controller.rb +21 -0
- data/app/controllers/spree/api/v2/images_controller.rb +29 -0
- data/app/controllers/spree/api/v2/line_items_controller.rb +36 -0
- data/app/controllers/spree/api/v2/option_types_controller.rb +31 -0
- data/app/controllers/spree/api/v2/option_values_controller.rb +29 -0
- data/app/controllers/spree/api/v2/orders_controller.rb +21 -0
- data/app/controllers/spree/api/v2/prices_controller.rb +27 -0
- data/app/controllers/spree/api/v2/products_controller.rb +37 -0
- data/app/controllers/spree/api/v2/states_controller.rb +29 -0
- data/app/controllers/spree/api/v2/taxonomies_controller.rb +21 -0
- data/app/controllers/spree/api/v2/taxons_controller.rb +40 -0
- data/app/controllers/spree/api/v2/variants_controller.rb +35 -0
- data/app/models/spree/base_decorator.rb +5 -0
- data/app/models/spree/image_decorator.rb +3 -0
- data/app/models/spree/line_item_decorator.rb +3 -0
- data/app/models/spree/order_decorator.rb +3 -0
- data/app/models/spree/price_decorator.rb +3 -0
- data/app/models/spree/state_decorator.rb +3 -0
- data/app/serializers/spree/address_serializer.rb +9 -0
- data/app/serializers/spree/base_serializer.rb +13 -0
- data/app/serializers/spree/country_serializer.rb +7 -0
- data/app/serializers/spree/error_serializer.rb +55 -0
- data/app/serializers/spree/image_serializer.rb +13 -0
- data/app/serializers/spree/line_item_serializer.rb +13 -0
- data/app/serializers/spree/option_type_serializer.rb +8 -0
- data/app/serializers/spree/option_value_serializer.rb +8 -0
- data/app/serializers/spree/order_serializer.rb +20 -0
- data/app/serializers/spree/price_serializer.rb +7 -0
- data/app/serializers/spree/product_serializer.rb +12 -0
- data/app/serializers/spree/role_serializer.rb +5 -0
- data/app/serializers/spree/state_serializer.rb +7 -0
- data/app/serializers/spree/store_serializer.rb +6 -0
- data/app/serializers/spree/taxon_serializer.rb +16 -0
- data/app/serializers/spree/taxonomy_serializer.rb +7 -0
- data/app/serializers/spree/user_serializer.rb +5 -0
- data/app/serializers/spree/variant_serializer.rb +12 -0
- data/circle.yml +12 -0
- data/config/locales/en.yml +25 -0
- data/config/routes.rb +53 -0
- data/docs/.nojekyll +0 -0
- data/docs/Dockerfile +12 -0
- data/docs/Gemfile +14 -0
- data/docs/README.md +12 -0
- data/docs/Rakefile +9 -0
- data/docs/config.rb +39 -0
- data/docs/font-selection.json +148 -0
- data/docs/source/CNAME +1 -0
- data/docs/source/fonts/slate.eot +0 -0
- data/docs/source/fonts/slate.svg +14 -0
- data/docs/source/fonts/slate.ttf +0 -0
- data/docs/source/fonts/slate.woff +0 -0
- data/docs/source/fonts/slate.woff2 +0 -0
- data/docs/source/images/favicon.ico +0 -0
- data/docs/source/images/navbar.png +0 -0
- data/docs/source/includes/_countries.md +133 -0
- data/docs/source/includes/_errors.md +17 -0
- data/docs/source/includes/_filtering.md +11 -0
- data/docs/source/includes/_images.md +201 -0
- data/docs/source/includes/_line_items.md +143 -0
- data/docs/source/includes/_option_types.md +267 -0
- data/docs/source/includes/_option_values.md +227 -0
- data/docs/source/includes/_orders.md +150 -0
- data/docs/source/includes/_pagination.md +10 -0
- data/docs/source/includes/_prices.md +188 -0
- data/docs/source/includes/_products.md +407 -0
- data/docs/source/includes/_states.md +96 -0
- data/docs/source/includes/_taxonomies.md +325 -0
- data/docs/source/includes/_taxons.md +414 -0
- data/docs/source/includes/_variants.md +430 -0
- data/docs/source/index.md +51 -0
- data/docs/source/javascripts/all.js +4 -0
- data/docs/source/javascripts/all_nosearch.js +3 -0
- data/docs/source/javascripts/app/_lang.js +162 -0
- data/docs/source/javascripts/app/_search.js +74 -0
- data/docs/source/javascripts/app/_toc.js +55 -0
- data/docs/source/javascripts/lib/_energize.js +169 -0
- data/docs/source/javascripts/lib/_imagesloaded.min.js +7 -0
- data/docs/source/javascripts/lib/_jquery.highlight.js +108 -0
- data/docs/source/javascripts/lib/_jquery.tocify.js +1042 -0
- data/docs/source/javascripts/lib/_jquery_ui.js +566 -0
- data/docs/source/javascripts/lib/_lunr.js +1910 -0
- data/docs/source/layouts/layout.erb +110 -0
- data/docs/source/stylesheets/_icon-font.scss +38 -0
- data/docs/source/stylesheets/_normalize.css +427 -0
- data/docs/source/stylesheets/_syntax.scss.erb +27 -0
- data/docs/source/stylesheets/_variables.scss +109 -0
- data/docs/source/stylesheets/print.css.scss +142 -0
- data/docs/source/stylesheets/screen.css.scss +622 -0
- data/lib/solidus_json_api/config.rb +8 -0
- data/lib/solidus_json_api/engine.rb +21 -0
- data/lib/solidus_json_api.rb +5 -0
- data/solidus_json_api.gemspec +36 -0
- data/spec/controllers/spree/api/v2/base_controller_spec.rb +46 -0
- data/spec/controllers/spree/api/v2/children_controller_spec.rb +28 -0
- data/spec/controllers/spree/api/v2/countries_controller_spec.rb +25 -0
- data/spec/controllers/spree/api/v2/images_controller_spec.rb +91 -0
- data/spec/controllers/spree/api/v2/line_items_controller_spec.rb +101 -0
- data/spec/controllers/spree/api/v2/option_types_controller_spec.rb +71 -0
- data/spec/controllers/spree/api/v2/option_values_controller_spec.rb +88 -0
- data/spec/controllers/spree/api/v2/orders_controller_spec.rb +61 -0
- data/spec/controllers/spree/api/v2/prices_controller_spec.rb +55 -0
- data/spec/controllers/spree/api/v2/products_controller_spec.rb +99 -0
- data/spec/controllers/spree/api/v2/states_controller_spec.rb +42 -0
- data/spec/controllers/spree/api/v2/taxonomies_controller_spec.rb +31 -0
- data/spec/controllers/spree/api/v2/taxons_controller_spec.rb +54 -0
- data/spec/controllers/spree/api/v2/variants_controller_spec.rb +106 -0
- data/spec/lib/solidus_json_api/config_spec.rb +10 -0
- data/spec/models/spree/base_decorator_spec.rb +9 -0
- data/spec/models/spree/price_decorator_spec.rb +3 -0
- data/spec/serializers/spree/address_serializer_spec.rb +35 -0
- data/spec/serializers/spree/country_serializer_spec.rb +27 -0
- data/spec/serializers/spree/error_serializer_spec.rb +141 -0
- data/spec/serializers/spree/image_serializer_spec.rb +30 -0
- data/spec/serializers/spree/line_item_serializer_spec.rb +40 -0
- data/spec/serializers/spree/option_type_serializer_spec.rb +27 -0
- data/spec/serializers/spree/option_value_serializer_spec.rb +29 -0
- data/spec/serializers/spree/order_serializer_spec.rb +68 -0
- data/spec/serializers/spree/price_serializer_spec.rb +28 -0
- data/spec/serializers/spree/product_serializer_spec.rb +47 -0
- data/spec/serializers/spree/role_serializer_spec.rb +17 -0
- data/spec/serializers/spree/state_serializer_spec.rb +25 -0
- data/spec/serializers/spree/store_serializer_spec.rb +25 -0
- data/spec/serializers/spree/taxon_serializer_spec.rb +44 -0
- data/spec/serializers/spree/taxonomy_serializer_spec.rb +27 -0
- data/spec/serializers/spree/user_serializer_spec.rb +17 -0
- data/spec/serializers/spree/variant_serializer_spec.rb +55 -0
- data/spec/spec_helper.rb +57 -0
- data/spec/support/shoulda_matchers.rb +6 -0
- metadata +442 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
describe Spree::PriceSerializer do
|
2
|
+
let(:price) { create :price }
|
3
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new price) }
|
4
|
+
|
5
|
+
its(:to_json) do
|
6
|
+
is_expected.to be_json_eql <<-JSON
|
7
|
+
{
|
8
|
+
"data" : {
|
9
|
+
"attributes" : {
|
10
|
+
"amount" : "19.99",
|
11
|
+
"currency" : "USD",
|
12
|
+
"display_amount" : "$19.99",
|
13
|
+
"display_price" : "$19.99",
|
14
|
+
"price" : "19.99"
|
15
|
+
},
|
16
|
+
"relationships" : {
|
17
|
+
"variant" : {
|
18
|
+
"data" : {
|
19
|
+
"type" : "spree_variants"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"type" : "spree_prices"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
JSON
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe Spree::ProductSerializer do
|
2
|
+
let(:image) { create :image }
|
3
|
+
let(:product) { create :product }
|
4
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new product) }
|
5
|
+
|
6
|
+
before { product.images << image }
|
7
|
+
|
8
|
+
its(:to_json) do
|
9
|
+
is_expected.to be_json_eql <<-JSON
|
10
|
+
{
|
11
|
+
"data" : {
|
12
|
+
"attributes" : {
|
13
|
+
"description" : #{product.description.to_json},
|
14
|
+
"meta_description" : null,
|
15
|
+
"meta_keywords" : null,
|
16
|
+
"name" : "#{product.name}",
|
17
|
+
"slug" : "#{product.slug}"
|
18
|
+
},
|
19
|
+
"relationships" : {
|
20
|
+
"images" : {
|
21
|
+
"data" : [
|
22
|
+
{
|
23
|
+
"type" : "spree_images"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
},
|
27
|
+
"master" : {
|
28
|
+
"data" : {
|
29
|
+
"type" : "spree_variants"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"option_types" : {
|
33
|
+
"data" : []
|
34
|
+
},
|
35
|
+
"taxons" : {
|
36
|
+
"data" : []
|
37
|
+
},
|
38
|
+
"variants" : {
|
39
|
+
"data" : []
|
40
|
+
}
|
41
|
+
},
|
42
|
+
"type" : "spree_products"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
JSON
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe Spree::RoleSerializer do
|
2
|
+
let(:role) { create :role }
|
3
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new role) }
|
4
|
+
|
5
|
+
its(:to_json) do
|
6
|
+
is_expected.to be_json_eql <<-JSON
|
7
|
+
{
|
8
|
+
"data" : {
|
9
|
+
"attributes" : {
|
10
|
+
"name" : "#{role.name}"
|
11
|
+
},
|
12
|
+
"type" : "spree_roles"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
JSON
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe Spree::StateSerializer do
|
2
|
+
let(:state) { create :state }
|
3
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new state) }
|
4
|
+
|
5
|
+
its(:to_json) do
|
6
|
+
is_expected.to be_json_eql <<-JSON
|
7
|
+
{
|
8
|
+
"data" : {
|
9
|
+
"attributes" : {
|
10
|
+
"abbr" : "#{state.abbr}",
|
11
|
+
"name" : "#{state.name}"
|
12
|
+
},
|
13
|
+
"relationships" : {
|
14
|
+
"country" : {
|
15
|
+
"data" : {
|
16
|
+
"type" : "spree_countries"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"type" : "spree_states"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
JSON
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe Spree::StoreSerializer do
|
2
|
+
let(:store) { create :store }
|
3
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new store) }
|
4
|
+
|
5
|
+
its(:to_json) do
|
6
|
+
is_expected.to be_json_eql <<-JSON
|
7
|
+
{
|
8
|
+
"data" : {
|
9
|
+
"attributes" : {
|
10
|
+
"code" : "#{store.code}",
|
11
|
+
"default" : #{store.default},
|
12
|
+
"default_currency" : #{store.default_currency || 'null'},
|
13
|
+
"mail_from_address" : "#{store.mail_from_address}",
|
14
|
+
"meta_description" : null,
|
15
|
+
"meta_keywords" : null,
|
16
|
+
"name" : "#{store.name}",
|
17
|
+
"seo_title" : null,
|
18
|
+
"url" : "#{store.url}"
|
19
|
+
},
|
20
|
+
"type" : "spree_stores"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
JSON
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
describe Spree::TaxonSerializer do
|
2
|
+
let(:taxon) { create :taxon }
|
3
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new taxon) }
|
4
|
+
|
5
|
+
its(:to_json) do
|
6
|
+
is_expected.to be_json_eql <<-JSON
|
7
|
+
{
|
8
|
+
"data" : {
|
9
|
+
"attributes" : {
|
10
|
+
"depth" : 0,
|
11
|
+
"description" : null,
|
12
|
+
"links": {
|
13
|
+
"large" : "/assets/default_taxon.png",
|
14
|
+
"mini" : "/assets/default_taxon.png",
|
15
|
+
"original" : "/assets/default_taxon.png",
|
16
|
+
"product" : "/assets/default_taxon.png",
|
17
|
+
"small" : "/assets/default_taxon.png"
|
18
|
+
},
|
19
|
+
"meta_description" : null,
|
20
|
+
"meta_keywords" : null,
|
21
|
+
"meta_title" : null,
|
22
|
+
"name" : "#{taxon.name}",
|
23
|
+
"permalink" : "#{taxon.permalink}",
|
24
|
+
"position" : 0
|
25
|
+
},
|
26
|
+
"relationships" : {
|
27
|
+
"children" : {
|
28
|
+
"data" : []
|
29
|
+
},
|
30
|
+
"parent" : {
|
31
|
+
"data" : null
|
32
|
+
},
|
33
|
+
"taxonomy" : {
|
34
|
+
"data" : {
|
35
|
+
"type" : "spree_taxonomies"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
},
|
39
|
+
"type" : "spree_taxons"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
JSON
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
describe Spree::TaxonomySerializer do
|
2
|
+
let(:taxonomy) { create :taxonomy }
|
3
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new taxonomy) }
|
4
|
+
|
5
|
+
its(:to_json) do
|
6
|
+
is_expected.to be_json_eql <<-JSON
|
7
|
+
{
|
8
|
+
"data" : {
|
9
|
+
"attributes" : {
|
10
|
+
"name" : "#{taxonomy.name}",
|
11
|
+
"position" : #{taxonomy.position}
|
12
|
+
},
|
13
|
+
"relationships" : {
|
14
|
+
"taxons" : {
|
15
|
+
"data" : [
|
16
|
+
{
|
17
|
+
"type" : "spree_taxons"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"type" : "spree_taxonomies"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
JSON
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe Spree::UserSerializer do
|
2
|
+
let(:user) { create :user }
|
3
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new user) }
|
4
|
+
|
5
|
+
its(:to_json) do
|
6
|
+
is_expected.to be_json_eql <<-JSON
|
7
|
+
{
|
8
|
+
"data" : {
|
9
|
+
"attributes" : {
|
10
|
+
"email" : "#{user.email}"
|
11
|
+
},
|
12
|
+
"type" : "spree_users"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
JSON
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe Spree::VariantSerializer do
|
2
|
+
let(:image) { create :image }
|
3
|
+
let(:variant) { create :variant, images: [image] }
|
4
|
+
subject { ActiveModel::Serializer::Adapter::JsonApi.new(described_class.new variant) }
|
5
|
+
|
6
|
+
its(:to_json) do
|
7
|
+
is_expected.to be_json_eql <<-JSON
|
8
|
+
{
|
9
|
+
"data" : {
|
10
|
+
"attributes" : {
|
11
|
+
"depth" : #{variant.depth.to_json},
|
12
|
+
"display_price" : "#{variant.display_price}",
|
13
|
+
"height" : #{variant.height.to_json},
|
14
|
+
"is_master" : #{variant.is_master},
|
15
|
+
"name" : "#{variant.name}",
|
16
|
+
"position" : #{variant.position},
|
17
|
+
"price" : "#{variant.price}",
|
18
|
+
"sku" : "#{variant.sku}",
|
19
|
+
"weight" : "#{variant.weight}",
|
20
|
+
"width" : #{variant.width.to_json}
|
21
|
+
},
|
22
|
+
"relationships" : {
|
23
|
+
"images" : {
|
24
|
+
"data" : [
|
25
|
+
{
|
26
|
+
"type" : "spree_images"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
},
|
30
|
+
"option_values" : {
|
31
|
+
"data" : [
|
32
|
+
{
|
33
|
+
"type" : "spree_option_values"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
},
|
37
|
+
"prices" : {
|
38
|
+
"data" : [
|
39
|
+
{
|
40
|
+
"type" : "spree_prices"
|
41
|
+
}
|
42
|
+
]
|
43
|
+
},
|
44
|
+
"product" : {
|
45
|
+
"data" : {
|
46
|
+
"type" : "spree_products"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"type" : "spree_variants"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
JSON
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
if ENV['CI']
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!('rails')
|
6
|
+
end
|
7
|
+
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter 'spec/dummy'
|
10
|
+
add_group 'Controllers', 'app/controllers'
|
11
|
+
add_group 'Models', 'app/models'
|
12
|
+
add_group 'Serializers', 'app/serializers'
|
13
|
+
add_group 'Libraries', 'lib'
|
14
|
+
end
|
15
|
+
|
16
|
+
ENV['RAILS_ENV'] = 'test'
|
17
|
+
|
18
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
19
|
+
|
20
|
+
require 'rspec/rails'
|
21
|
+
require 'rspec/its'
|
22
|
+
require 'database_cleaner'
|
23
|
+
require 'ffaker'
|
24
|
+
require 'json_spec'
|
25
|
+
require 'shoulda/matchers'
|
26
|
+
|
27
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
28
|
+
|
29
|
+
require 'spree/testing_support/factories'
|
30
|
+
|
31
|
+
RSpec.configure do |config|
|
32
|
+
config.include FactoryGirl::Syntax::Methods
|
33
|
+
config.include JsonSpec::Helpers
|
34
|
+
|
35
|
+
config.infer_spec_type_from_file_location!
|
36
|
+
config.mock_with :rspec
|
37
|
+
config.color = true
|
38
|
+
config.use_transactional_fixtures = false
|
39
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
40
|
+
config.order = "random"
|
41
|
+
|
42
|
+
config.before :suite do
|
43
|
+
ActiveModel::Serializer.config.adapter = :json_api
|
44
|
+
|
45
|
+
DatabaseCleaner.strategy = :transaction
|
46
|
+
DatabaseCleaner.clean_with :truncation
|
47
|
+
end
|
48
|
+
|
49
|
+
config.before :each do
|
50
|
+
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
51
|
+
DatabaseCleaner.start
|
52
|
+
end
|
53
|
+
|
54
|
+
config.after :each do
|
55
|
+
DatabaseCleaner.clean
|
56
|
+
end
|
57
|
+
end
|