cloudrider 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/cloudrider.gemspec +0 -3
- data/generica/app/assets/javascripts/adapters/admin/taxon.js.em +2 -0
- data/generica/app/assets/javascripts/components/hero-splash.js.em +1 -15
- data/generica/app/assets/javascripts/components/products-showcase.js.em +6 -0
- data/generica/app/assets/javascripts/components/select-locale.js.em +2 -2
- data/generica/app/assets/javascripts/components/tr-span.js.em +1 -0
- data/generica/app/assets/javascripts/components/tree/taxon-li.js.em +27 -2
- data/generica/app/assets/javascripts/components/tree/taxon-wrapper.js.em +5 -18
- data/generica/app/assets/javascripts/config/i18n-translations.js.ls +6 -2
- data/generica/app/assets/javascripts/config/router.js.ls +4 -1
- data/generica/app/assets/javascripts/controllers/admin/messages/index_controller.js.em +10 -0
- data/generica/app/assets/javascripts/controllers/admin/product/edit_controller.js.em +10 -1
- data/generica/app/assets/javascripts/controllers/admin/products/new_controller.js.em +6 -0
- data/generica/app/assets/javascripts/controllers/admin/taxon/edit_controller.js.em +17 -0
- data/generica/app/assets/javascripts/controllers/admin/taxons/new_controller.js.em +25 -0
- data/generica/app/assets/javascripts/controllers/messages/new_controller.js.em +16 -0
- data/generica/app/assets/javascripts/controllers/products/index_controller.js.em +5 -8
- data/generica/app/assets/javascripts/helpers/hash_ex.js.ls +6 -0
- data/generica/app/assets/javascripts/helpers/string_ex.js.ls +1 -1
- data/generica/app/assets/javascripts/models/admin/product.js.em +2 -0
- data/generica/app/assets/javascripts/models/admin/taxon.js.em +4 -1
- data/generica/app/assets/javascripts/models/message.js.em +7 -0
- data/generica/app/assets/javascripts/models/product.js.em +7 -2
- data/generica/app/assets/javascripts/models/taxon.js.em +3 -5
- data/generica/app/assets/javascripts/routes/admin/messages/index_route.js.em +1 -0
- data/generica/app/assets/javascripts/routes/admin/taxon_route.js.em +3 -0
- data/generica/app/assets/javascripts/routes/admin/taxons/index_route.js.em +1 -1
- data/generica/app/assets/javascripts/routes/admin/taxons/new_route.js.em +2 -0
- data/generica/app/assets/javascripts/routes/index_route.js.em +3 -2
- data/generica/app/assets/javascripts/routes/products/index_route.js.em +1 -1
- data/generica/app/assets/javascripts/templates/admin.emblem +17 -5
- data/generica/app/assets/javascripts/templates/admin/messages/index.emblem +19 -0
- data/generica/app/assets/javascripts/templates/admin/messages/slice.emblem +12 -0
- data/generica/app/assets/javascripts/templates/admin/product/edit.emblem +23 -6
- data/generica/app/assets/javascripts/templates/admin/products/new.emblem +17 -0
- data/generica/app/assets/javascripts/templates/admin/products/slice.emblem +6 -1
- data/generica/app/assets/javascripts/templates/admin/taxon/edit.emblem +36 -0
- data/generica/app/assets/javascripts/templates/admin/taxons/index.emblem +1 -1
- data/generica/app/assets/javascripts/templates/admin/taxons/new.emblem +40 -0
- data/generica/app/assets/javascripts/templates/admin/translations/index.emblem +1 -1
- data/generica/app/assets/javascripts/templates/components/product-display.emblem +4 -0
- data/generica/app/assets/javascripts/templates/components/product-listing.emblem +9 -0
- data/generica/app/assets/javascripts/templates/components/search-and-filter.emblem +1 -1
- data/generica/app/assets/javascripts/templates/components/site-nav/_top-nav.emblem +1 -1
- data/generica/app/assets/javascripts/templates/components/table-booths.emblem +3 -65
- data/generica/app/assets/javascripts/templates/components/tree-taxon-li.emblem +11 -3
- data/generica/app/assets/javascripts/templates/components/tree-taxon-ul.emblem +6 -7
- data/generica/app/assets/javascripts/templates/components/tree-taxon-wrapper.emblem +2 -2
- data/generica/app/assets/javascripts/templates/employees/index.emblem +32 -0
- data/generica/app/assets/javascripts/templates/index.emblem +2 -1
- data/generica/app/assets/javascripts/templates/messages/new.emblem +43 -0
- data/generica/app/assets/javascripts/templates/products/product/show.emblem +8 -0
- data/generica/app/assets/javascripts/transforms/form_data_transformer.js.ls +4 -0
- data/generica/app/assets/stylesheets/apiv1/_admin.css.scss +1 -0
- data/generica/app/assets/stylesheets/apiv1/admin/messages/_index.css.scss +34 -0
- data/generica/app/assets/stylesheets/apiv1/components/_product-display.css.scss +24 -0
- data/generica/app/assets/stylesheets/apiv1/components/_product-listing.css.scss +27 -2
- data/generica/app/assets/stylesheets/apiv1/components/_table-booths.css.scss +10 -0
- data/generica/app/assets/stylesheets/apiv1/components/_tree-taxon-wrapper.css.scss +37 -22
- data/generica/app/assets/stylesheets/apiv1/products/product/_show.css.scss +24 -0
- data/generica/app/assets/stylesheets/apiv1/shared/_constants.css.scss +2 -2
- data/generica/app/controllers/admin/taxons/create_controller.rb +26 -0
- data/generica/app/controllers/apiv1/i18n_translations/index_controller.rb +9 -5
- data/generica/app/controllers/apiv1/messages/create_controller.rb +17 -0
- data/generica/app/controllers/apiv1/messages/index_controller.rb +18 -0
- data/generica/app/controllers/apiv1/products/index_controller.rb +1 -1
- data/generica/app/controllers/apiv1/taxons/destroy_controller.rb +9 -0
- data/generica/app/controllers/apiv1/taxons/index_controller.rb +1 -0
- data/generica/app/controllers/apiv1/taxons/update_controller.rb +28 -0
- data/generica/app/controllers/apiv1/translations/create_controller.rb +5 -4
- data/generica/app/controllers/apiv1/translations/update_controller.rb +2 -2
- data/generica/app/models/admin/product_modifier.rb +16 -3
- data/generica/app/models/admin/taxon_factory.rb +23 -0
- data/generica/app/models/admin/taxon_relationships_factory.rb +32 -0
- data/generica/app/models/apiv1/employee.rb +1 -2
- data/generica/app/models/apiv1/message.rb +24 -0
- data/generica/app/models/apiv1/messages_machine.rb +31 -0
- data/generica/app/models/apiv1/product.rb +33 -13
- data/generica/app/models/apiv1/products_machine.rb +9 -1
- data/generica/app/models/apiv1/taxon.rb +8 -2
- data/generica/app/models/apiv1/translation.rb +73 -14
- data/generica/app/models/i18n/backend/active_record.rb +49 -0
- data/generica/app/varissets/javascripts/templates/components/introductory-lobby.emblem.erb +15 -1
- data/generica/app/varissets/javascripts/templates/components/table-booths.emblem.erb +39 -0
- data/generica/app/varissets/stylesheets/apiv1/components/_introductory-lobby.css.scss.erb +15 -1
- data/generica/app/varissets/stylesheets/apiv1/components/_table-booths.css.scss.erb +71 -0
- data/generica/config/initializers/i18n_backend.rb +7 -0
- data/generica/config/routes.rb +5 -2
- data/generica/db/migrate/20141010215459_create_apiv1_translations.rb +3 -1
- data/generica/db/migrate/20141105231548_add_showcase_priority_to_apiv1_products.rb +5 -0
- data/generica/db/migrate/20141107174821_create_apiv1_messages.rb +12 -0
- data/generica/db/schema.rb +11 -16
- data/generica/lib/tasks/production.rake +2 -1
- data/generica/spec/controllers/admin/taxons/create_controller_spec.rb +44 -0
- data/generica/spec/controllers/apiv1/messages/index_controller_spec.rb +5 -0
- data/generica/spec/controllers/apiv1/taxons/index_controller_spec.rb +59 -0
- data/generica/spec/controllers/apiv1/taxons/update_controller_spec.rb +54 -0
- data/generica/spec/controllers/apiv1/translations/create_controller_spec.rb +50 -0
- data/generica/spec/controllers/apiv1/translations/update_controller_spec.rb +54 -0
- data/generica/spec/factories/apiv1/product_factory.rb +12 -11
- data/generica/spec/models/admin/product_modifier_spec.rb +32 -0
- data/generica/spec/models/admin/taxon_relationships_factory_spec.rb +49 -0
- data/generica/spec/models/apiv1/message_spec.rb +16 -0
- data/generica/spec/models/apiv1/product_spec.rb +13 -12
- data/generica/spec/models/apiv1/translation_spec.rb +41 -0
- data/generica/spec/models/i18n/backend/active_record_spec.rb +27 -0
- data/lib/cloudrider/apiv1/base.rb +4 -4
- data/lib/cloudrider/apiv1/introductory_lobby_component.rb +1 -0
- data/lib/cloudrider/apiv1/introductory_lobby_sass.rb +9 -0
- data/lib/cloudrider/apiv1/table_booths_component.rb +6 -0
- data/lib/cloudrider/master_context.rb +105 -0
- data/lib/cloudrider/version.rb +1 -1
- metadata +43 -31
- data/generica/app/assets/javascripts/components/products-showcase.js.ls +0 -5
- data/generica/config/locales/ar.yml +0 -78
- data/generica/config/locales/ca.yml +0 -78
- data/generica/config/locales/cs.yml +0 -78
- data/generica/config/locales/da.yml +0 -78
- data/generica/config/locales/de.yml +0 -78
- data/generica/config/locales/el.yml +0 -78
- data/generica/config/locales/en.yml +0 -78
- data/generica/config/locales/es.yml +0 -78
- data/generica/config/locales/fi.yml +0 -78
- data/generica/config/locales/fr.yml +0 -78
- data/generica/config/locales/hu.yml +0 -78
- data/generica/config/locales/id.yml +0 -78
- data/generica/config/locales/is.yml +0 -78
- data/generica/config/locales/it.yml +0 -78
- data/generica/config/locales/ja.yml +0 -78
- data/generica/config/locales/ko.yml +0 -78
- data/generica/config/locales/ms.yml +0 -78
- data/generica/config/locales/nl.yml +0 -78
- data/generica/config/locales/no.yml +0 -78
- data/generica/config/locales/pl.yml +0 -78
- data/generica/config/locales/pt.yml +0 -78
- data/generica/config/locales/ru.yml +0 -78
- data/generica/config/locales/sv.yml +0 -78
- data/generica/config/locales/th.yml +0 -78
- data/generica/config/locales/tr.yml +0 -78
- data/generica/config/locales/zh-CN.yml +0 -78
- data/generica/config/locales/zh-TW.yml +0 -78
- data/lib/cloudrider/file_orders_maker.rb +0 -24
@@ -1,7 +1,8 @@
|
|
1
1
|
namespace :production do
|
2
2
|
desc "These tasks should be run once on a virgin fresh installation"
|
3
3
|
task virgin: :environment do
|
4
|
-
|
4
|
+
Rake::Task["db:create"].invoke
|
5
|
+
Rake::Task["db:migrate"].invoke
|
5
6
|
end
|
6
7
|
|
7
8
|
desc "These tasks should be run everytime you restart the server"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Admin::Taxons::CreateController do
|
4
|
+
let(:user) { Admin::UserFactory.mock }
|
5
|
+
let(:create) { post :create, admin_taxon: @taxon_params }
|
6
|
+
before do
|
7
|
+
@taxon_params = {
|
8
|
+
taxon_name: "husky",
|
9
|
+
explanation: "cold weather dog"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
before { controller.auto_login user }
|
13
|
+
context 'successful' do
|
14
|
+
subject { -> { create } }
|
15
|
+
specify { should change(Apiv1::Taxon, :count).by 1 }
|
16
|
+
end
|
17
|
+
context 'status' do
|
18
|
+
before { create }
|
19
|
+
subject { response.status }
|
20
|
+
specify { should eq 200 }
|
21
|
+
end
|
22
|
+
context 'body' do
|
23
|
+
before { create }
|
24
|
+
subject { response.body }
|
25
|
+
specify { should match /root_genus/ }
|
26
|
+
end
|
27
|
+
context 'errors' do
|
28
|
+
before do
|
29
|
+
@taxon_params = { dog: 1 }
|
30
|
+
create
|
31
|
+
end
|
32
|
+
subject { response.status }
|
33
|
+
specify { should eq 417 }
|
34
|
+
end
|
35
|
+
context 'errors' do
|
36
|
+
before do
|
37
|
+
@taxon_params = { dog: 1 }
|
38
|
+
create
|
39
|
+
end
|
40
|
+
subject { response.body }
|
41
|
+
specify { should match /can't be blank/ }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Apiv1::Taxons::IndexController do
|
4
|
+
before do
|
5
|
+
@place = Apiv1::Taxon.create! taxon_name: "place"
|
6
|
+
@material = Apiv1::Taxon.create! taxon_name: "material"
|
7
|
+
@place.children.create! taxon_name: "West Coast"
|
8
|
+
@place.children.create! taxon_name: "East Coast"
|
9
|
+
@place.children.create! taxon_name: "China"
|
10
|
+
@fish = @material.children.create! taxon_name: "fish"
|
11
|
+
@material.children.create! taxon_name: "plastic"
|
12
|
+
@fish.children.create! taxon_name: "shellfish"
|
13
|
+
@fish.children.create! taxon_name: "regular fish"
|
14
|
+
end
|
15
|
+
context 'everything' do
|
16
|
+
before { get :index }
|
17
|
+
context 'type' do
|
18
|
+
subject { JSON.parse(response.body)["taxons"] }
|
19
|
+
specify { should be_a Array }
|
20
|
+
end
|
21
|
+
context 'count' do
|
22
|
+
subject { JSON.parse(response.body)["taxons"].count }
|
23
|
+
specify { should eq Apiv1::Taxon.count }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
context 'roots' do
|
27
|
+
before { get :index, parent_id: nil }
|
28
|
+
context 'count' do
|
29
|
+
subject { JSON.parse(response.body)["taxons"].count }
|
30
|
+
specify { should eq 2 }
|
31
|
+
end
|
32
|
+
context 'ids' do
|
33
|
+
subject { JSON.parse(response.body)["taxons"].map { |h| h["id"] } }
|
34
|
+
specify { should eq [@place.id, @material.id] }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
context 'all of a root genus' do
|
38
|
+
before { get :index, root_genus: "place" }
|
39
|
+
context 'count' do
|
40
|
+
subject { JSON.parse(response.body)["taxons"].count }
|
41
|
+
specify { should eq 4 }
|
42
|
+
end
|
43
|
+
context 'ids' do
|
44
|
+
subject { JSON.parse(response.body)["taxons"].map { |h| h["id"] } }
|
45
|
+
specify { should eq [@place.id] + @place.children.map(&:id) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
context 'children of parent' do
|
49
|
+
before { get :index, parent_id: @material.id }
|
50
|
+
context 'count' do
|
51
|
+
subject { JSON.parse(response.body)["taxons"].count }
|
52
|
+
specify { should eq 2 }
|
53
|
+
end
|
54
|
+
context 'ids' do
|
55
|
+
subject { JSON.parse(response.body)["taxons"].map { |h| h["id"] } }
|
56
|
+
specify { should eq @material.children.map(&:id) }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Apiv1::Taxons::UpdateController do
|
4
|
+
let(:taxon) { Apiv1::Taxon.create! taxon_name: "dog" }
|
5
|
+
let(:update) { put :update, id: taxon.id, taxon: @taxon_params }
|
6
|
+
let(:user) { Admin::UserFactory.mock }
|
7
|
+
before { controller.auto_login user }
|
8
|
+
context "success" do
|
9
|
+
before do
|
10
|
+
@taxon_params = { taxon_name: "cat" }
|
11
|
+
update
|
12
|
+
end
|
13
|
+
context 'status' do
|
14
|
+
subject { response.status }
|
15
|
+
specify { should eq 200 }
|
16
|
+
end
|
17
|
+
context 'response' do
|
18
|
+
subject { response.body }
|
19
|
+
specify { should match /taxon/ }
|
20
|
+
specify { should match /cat/ }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
context 'failure' do
|
24
|
+
before do
|
25
|
+
@taxon_params = { taxon_name: "", explanation: "should not be valid" }
|
26
|
+
update
|
27
|
+
end
|
28
|
+
context 'status' do
|
29
|
+
subject { response.status }
|
30
|
+
specify { should eq 417 }
|
31
|
+
end
|
32
|
+
context 'response' do
|
33
|
+
subject { response.body }
|
34
|
+
specify { should match /can't be blank/ }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
describe Apiv1::Taxons::UpdateController do
|
42
|
+
let(:taxon) { Apiv1::Taxon.create! taxon_name: "dog" }
|
43
|
+
let(:update) { put :update, id: taxon.id, taxon: @taxon_params }
|
44
|
+
context "not authorized" do
|
45
|
+
before do
|
46
|
+
@taxon_params = { taxon_name: "cat" }
|
47
|
+
update
|
48
|
+
end
|
49
|
+
context 'status' do
|
50
|
+
subject { response.status }
|
51
|
+
specify { should eq 401 }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
describe Apiv1::Translations::CreateController do
|
4
|
+
let(:user) { Admin::UserFactory.mock }
|
5
|
+
before { controller.auto_login user }
|
6
|
+
let(:create) { post :create, translation: @translation_params }
|
7
|
+
context 'success' do
|
8
|
+
before do
|
9
|
+
@translation_params = {
|
10
|
+
key: "itsuka_kieteshimau_sozen",
|
11
|
+
translated_text: "konna fuu ni warau you ni",
|
12
|
+
locale: "en"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
context 'creation' do
|
16
|
+
subject { -> { create } }
|
17
|
+
specify { should change(Apiv1::Translation, :count).by 1 }
|
18
|
+
end
|
19
|
+
context 'responses' do
|
20
|
+
before { create }
|
21
|
+
context 'status' do
|
22
|
+
subject { response.status }
|
23
|
+
specify { should eq 200 }
|
24
|
+
end
|
25
|
+
context 'body' do
|
26
|
+
subject { response.body }
|
27
|
+
specify { should match /konna fuu/ }
|
28
|
+
specify { should match /itsuka_ki/ }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
context 'invalid' do
|
33
|
+
before { @translation_params = { locale: "ja" } }
|
34
|
+
context 'creation' do
|
35
|
+
subject { -> { create } }
|
36
|
+
specify { should_not change(Apiv1::Translation, :count) }
|
37
|
+
end
|
38
|
+
context 'responses' do
|
39
|
+
before { create }
|
40
|
+
context 'status' do
|
41
|
+
subject { response.status }
|
42
|
+
specify { should eq 417 }
|
43
|
+
end
|
44
|
+
context 'body' do
|
45
|
+
subject { response.body }
|
46
|
+
specify { should match /can't be blank/ }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Apiv1::Translations::UpdateController do
|
4
|
+
let(:translation) { Apiv1::Translation.create! locale: "en", key: "tsuyosa_ni_kawaru_kara", value: "tsuyosa ni kawaru kara" }
|
5
|
+
let(:update) { put :update, id: translation.id, translation: @translation_params }
|
6
|
+
let(:user) { Admin::UserFactory.mock }
|
7
|
+
before { controller.auto_login user }
|
8
|
+
context "success" do
|
9
|
+
before do
|
10
|
+
@translation_params = { value: "because it becomes my strength" }
|
11
|
+
update
|
12
|
+
end
|
13
|
+
context 'status' do
|
14
|
+
subject { response.status }
|
15
|
+
specify { should eq 200 }
|
16
|
+
end
|
17
|
+
context 'response' do
|
18
|
+
subject { response.body }
|
19
|
+
specify { should match /tsuyosa/ }
|
20
|
+
specify { should match /strength/ }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
context 'failure' do
|
24
|
+
before do
|
25
|
+
@translation_params = { value: "", key: "" }
|
26
|
+
update
|
27
|
+
end
|
28
|
+
context 'status' do
|
29
|
+
subject { response.status }
|
30
|
+
specify { should eq 417 }
|
31
|
+
end
|
32
|
+
context 'response' do
|
33
|
+
subject { response.body }
|
34
|
+
specify { should match /can't be blank/ }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
describe Apiv1::Translations::UpdateController do
|
42
|
+
let(:translation) { Apiv1::Translation.create! locale: "en", key: "tsuyosa_ni_kawaru_kara", value: "tsuyosa ni kawaru kara" }
|
43
|
+
let(:update) { put :update, id: translation.id, translation: @translation_params }
|
44
|
+
context "not authorized" do
|
45
|
+
before do
|
46
|
+
@translation_params = { value: "because it becomes my strength" }
|
47
|
+
update
|
48
|
+
end
|
49
|
+
context 'status' do
|
50
|
+
subject { response.status }
|
51
|
+
specify { should eq 401 }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -2,17 +2,18 @@
|
|
2
2
|
#
|
3
3
|
# Table name: apiv1_products
|
4
4
|
#
|
5
|
-
# id
|
6
|
-
# permalink
|
7
|
-
# sku
|
8
|
-
# material
|
9
|
-
# quality
|
10
|
-
# price
|
11
|
-
# amount
|
12
|
-
# place
|
13
|
-
# others
|
14
|
-
# created_at
|
15
|
-
# updated_at
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# permalink :string(255)
|
7
|
+
# sku :string(255)
|
8
|
+
# material :string(255)
|
9
|
+
# quality :string(255)
|
10
|
+
# price :string(255)
|
11
|
+
# amount :string(255)
|
12
|
+
# place :string(255)
|
13
|
+
# others :text
|
14
|
+
# created_at :datetime
|
15
|
+
# updated_at :datetime
|
16
|
+
# showcase_order :integer
|
16
17
|
#
|
17
18
|
|
18
19
|
class Apiv1::ProductFactory
|
@@ -4,6 +4,7 @@ describe Admin::ProductModifier do
|
|
4
4
|
let(:modifier) { described_class.new product, @params }
|
5
5
|
let(:product) { Apiv1::ProductFactory.new.create }
|
6
6
|
let(:picture) { Apiv1::PictureFactory.rack_file }
|
7
|
+
let(:taxon) { Apiv1::Taxon.create! taxon_name: "fish" }
|
7
8
|
describe "success" do
|
8
9
|
before do
|
9
10
|
@picture_params = { 0 => picture }
|
@@ -18,6 +19,37 @@ describe Admin::ProductModifier do
|
|
18
19
|
pictures: @picture_params
|
19
20
|
}
|
20
21
|
end
|
22
|
+
context 'with taxons' do
|
23
|
+
before do
|
24
|
+
@taxon_params = { 0 => taxon.id }
|
25
|
+
@params = @params.merge taxons: @taxon_params
|
26
|
+
end
|
27
|
+
context '#satisfy_specifications?' do
|
28
|
+
subject { modifier }
|
29
|
+
specify { should be_satisfy_specifications }
|
30
|
+
end
|
31
|
+
context '_good_relationships' do
|
32
|
+
subject { modifier.send('_good_relationships').count }
|
33
|
+
specify { should eq 1 }
|
34
|
+
end
|
35
|
+
context '_bad_relationships' do
|
36
|
+
subject { modifier.send('_bad_relationships').count }
|
37
|
+
specify { should eq 2 }
|
38
|
+
end
|
39
|
+
context 'update' do
|
40
|
+
before { modifier.satisfy_specifications? && modifier.update! }
|
41
|
+
context 'taxons' do
|
42
|
+
before { product.reload }
|
43
|
+
subject { product.taxons.count }
|
44
|
+
specify { should eq 1 }
|
45
|
+
end
|
46
|
+
context 'taxon' do
|
47
|
+
before { product.reload }
|
48
|
+
subject { product.taxons }
|
49
|
+
specify { should eq [taxon] }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
21
53
|
context '#satisfy_specifications?' do
|
22
54
|
subject { modifier }
|
23
55
|
specify { should be_satisfy_specifications }
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Admin::TaxonRelationshipsFactory do
|
4
|
+
let(:product) { Apiv1::ProductFactory.new.create }
|
5
|
+
let(:factory) { described_class.new product, @relationship_params }
|
6
|
+
let(:taxon) { Apiv1::Taxon.create! taxon_name: "detective" }
|
7
|
+
before { @relationship_params = { 0 => taxon.id } }
|
8
|
+
describe 'taxons' do
|
9
|
+
subject { product.taxons.count }
|
10
|
+
specify { should eq 2 }
|
11
|
+
end
|
12
|
+
describe 'bad_relationships' do
|
13
|
+
subject { factory.bad_relationships }
|
14
|
+
specify { should eq product.taxon_relationships }
|
15
|
+
end
|
16
|
+
describe '_existing_relationship' do
|
17
|
+
subject { factory.send '_existing_relationship', taxon.id }
|
18
|
+
specify { should be_blank }
|
19
|
+
end
|
20
|
+
describe '_bad_taxon_ids' do
|
21
|
+
subject { factory.send '_bad_taxon_ids' }
|
22
|
+
specify { should eq product.taxons.map(&:id) }
|
23
|
+
end
|
24
|
+
describe 'good_relationships' do
|
25
|
+
subject { factory.good_relationships.count }
|
26
|
+
specify { should eq 1 }
|
27
|
+
end
|
28
|
+
describe 'good_relationships.taxon' do
|
29
|
+
subject { factory.good_relationships.first.taxon }
|
30
|
+
specify { should eq taxon }
|
31
|
+
end
|
32
|
+
describe 'usage' do
|
33
|
+
before { factory.bad_relationships.each(&:destroy) }
|
34
|
+
subject { -> { factory.good_relationships; product.save! } }
|
35
|
+
specify { should change(Apiv1::Listings::TaxonRelationship, :count).by 1 }
|
36
|
+
specify { should_not change(Apiv1::Taxon, :count) }
|
37
|
+
specify { should_not change(Apiv1::Product, :count) }
|
38
|
+
end
|
39
|
+
describe 'relationship' do
|
40
|
+
before do
|
41
|
+
factory.bad_relationships.each(&:destroy)
|
42
|
+
factory.good_relationships
|
43
|
+
product.save!
|
44
|
+
product.reload
|
45
|
+
end
|
46
|
+
subject { product.taxons }
|
47
|
+
specify { should eq [taxon] }
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe Apiv1::Message, :type => :model do
|
4
|
+
let(:message) { Apiv1::Message.new @message_params }
|
5
|
+
before { @message_params = { from_company: ""} }
|
6
|
+
context 'validation' do
|
7
|
+
subject { message }
|
8
|
+
specify { should_not be_valid }
|
9
|
+
end
|
10
|
+
context 'errors' do
|
11
|
+
let(:expected) { { from_company: "can't be blank", sender_email: "can't be blank", subject_text: "can't be blank", message: "can't be blank" } }
|
12
|
+
before { message.valid? }
|
13
|
+
subject { message.errors.to_h }
|
14
|
+
specify { should eq expected }
|
15
|
+
end
|
16
|
+
end
|
@@ -2,17 +2,18 @@
|
|
2
2
|
#
|
3
3
|
# Table name: apiv1_products
|
4
4
|
#
|
5
|
-
# id
|
6
|
-
# permalink
|
7
|
-
# sku
|
8
|
-
# material
|
9
|
-
# quality
|
10
|
-
# price
|
11
|
-
# amount
|
12
|
-
# place
|
13
|
-
# others
|
14
|
-
# created_at
|
15
|
-
# updated_at
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# permalink :string(255)
|
7
|
+
# sku :string(255)
|
8
|
+
# material :string(255)
|
9
|
+
# quality :string(255)
|
10
|
+
# price :string(255)
|
11
|
+
# amount :string(255)
|
12
|
+
# place :string(255)
|
13
|
+
# others :text
|
14
|
+
# created_at :datetime
|
15
|
+
# updated_at :datetime
|
16
|
+
# showcase_order :integer
|
16
17
|
#
|
17
18
|
|
18
19
|
require 'rails_helper'
|
@@ -58,4 +59,4 @@ describe Apiv1::Product do
|
|
58
59
|
specify { should change(Apiv1::Product, :count).by -1 }
|
59
60
|
specify { should change(Apiv1::Picture, :count).by -2 }
|
60
61
|
end
|
61
|
-
end
|
62
|
+
end
|