-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from appirits/implement-comable-sample
Implement comable_sample
- Loading branch information
Showing
43 changed files
with
470 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
require 'comable_core' | ||
require 'comable_frontend' | ||
require 'comable_backend' | ||
require 'comable_sample' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--require ../spec/rails_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Comable 0.4.2 (unreleased) ## | ||
|
||
* Initialize this gem. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
eval File.read(File.expand_path('../../Gemfile.common', __FILE__)) | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../MIT-LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../Rakefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version = File.read(File.expand_path('../../COMABLE_VERSION', __FILE__)).strip | ||
|
||
# Describe your gem and declare its dependencies: | ||
Gem::Specification.new do |s| | ||
s.name = 'comable_sample' | ||
s.version = version | ||
s.authors = ['YOSHIDA Hiroki'] | ||
s.email = ['hyoshida@appirits.com'] | ||
s.homepage = 'https://github.com/appirits/comable#comable' | ||
s.summary = 'Provide sample data for Comable.' | ||
s.description = 'Provide sample data for Comable.' | ||
s.license = 'MIT' | ||
|
||
s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile'] | ||
|
||
s.add_dependency 'comable_core', version | ||
|
||
s.add_dependency 'ffaker', '~> 2.0.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Billing address | ||
Comable::Address.create!( | ||
family_name: Comable::Sample::Name.family_name, | ||
first_name: Comable::Sample::Name.first_name, | ||
zip_code: Comable::Sample::Address.zip_code, | ||
state_name: Comable::Sample::Address.state_name, | ||
city: Comable::Sample::Address.city, | ||
detail: Comable::Sample::Address.detail, | ||
phone_number: Comable::Sample::PhoneNumber.phone_number | ||
) | ||
|
||
# Shipping address | ||
Comable::Address.create!( | ||
family_name: Comable::Sample::Name.family_name, | ||
first_name: Comable::Sample::Name.first_name, | ||
zip_code: Comable::Sample::Address.zip_code, | ||
state_name: Comable::Sample::Address.state_name, | ||
city: Comable::Sample::Address.city, | ||
detail: Comable::Sample::Address.detail, | ||
phone_number: Comable::Sample::PhoneNumber.phone_number | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Comable::Category.create!(name: Comable::Sample.t(:clothing)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Comable::Sample.import('products') | ||
|
||
suede_dress = Comable::Product.where(name: Comable::Sample.t(:suede_dress)).first! | ||
girly_coat = Comable::Product.where(name: Comable::Sample.t(:girly_coat)).first! | ||
fur_gloves = Comable::Product.where(name: Comable::Sample.t(:fur_gloves)).first! | ||
leather_boots = Comable::Product.where(name: Comable::Sample.t(:leather_boots)).first! | ||
|
||
def image(name, suffix: '.jpg') | ||
image_path = File.join(File.dirname(__FILE__), 'images', name + suffix) | ||
File.open(image_path) | ||
end | ||
|
||
images_attributes = [ | ||
{ | ||
product: suede_dress, | ||
file: image('suede_dress') | ||
}, | ||
{ | ||
product: suede_dress, | ||
file: image('suede_dress_full') | ||
}, | ||
{ | ||
product: girly_coat, | ||
file: image('girly_coat') | ||
}, | ||
{ | ||
product: fur_gloves, | ||
file: image('fur_gloves') | ||
}, | ||
{ | ||
product: leather_boots, | ||
file: image('leather_boots') | ||
}, | ||
{ | ||
product: leather_boots, | ||
file: image('leather_boots_front') | ||
}, | ||
{ | ||
product: leather_boots, | ||
file: image('leather_boots_back') | ||
} | ||
] | ||
|
||
images_attributes.each do |attributes| | ||
Comable::Image.create!(attributes) | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Comable::Sample.import('products') | ||
Comable::Sample.import('stocks') | ||
Comable::Sample.import('addresses') | ||
|
||
bill_address = Comable::Address.first | ||
ship_address = Comable::Address.last | ||
suede_dress = Comable::Product.where(name: Comable::Sample.t(:suede_dress)).first! | ||
girly_coat = Comable::Product.where(name: Comable::Sample.t(:girly_coat)).first! | ||
|
||
orders_attributes = [ | ||
{ | ||
email: 'comable@example.com', | ||
bill_address: bill_address, | ||
ship_address: ship_address, | ||
shipment_fee: 300, | ||
payment_fee: 200, | ||
total_price: 500 + suede_dress.price, | ||
order_items_attributes: [ | ||
{ | ||
stock: suede_dress.stocks.first, | ||
quantity: 1 | ||
} | ||
] | ||
}, | ||
{ | ||
email: 'comable@example.com', | ||
bill_address: bill_address, | ||
ship_address: ship_address, | ||
shipment_fee: 300, | ||
payment_fee: 200, | ||
total_price: 500 + (suede_dress.price * 2) + (girly_coat.price * 3), | ||
order_items_attributes: [ | ||
{ | ||
stock: suede_dress.stocks.first, | ||
quantity: 2 | ||
}, | ||
{ | ||
stock: girly_coat.stocks.first, | ||
quantity: 3 | ||
} | ||
] | ||
} | ||
] | ||
|
||
orders_attributes.each do |attributes| | ||
order = Comable::Order.create!(attributes) | ||
order.send(:generate_code) | ||
order.state = 'completed' | ||
order.completed_at = Time.now | ||
order.save! | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Comable::PaymentMethod.create!( | ||
name: Comable::Sample.t(:credit_card), | ||
fee: 200, | ||
payment_provider_type: Comable::PaymentProvider::General.name, | ||
payment_provider_kind: 1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Comable::Sample.import('orders') | ||
Comable::Sample.import('payment_methods') | ||
|
||
payment_method = Comable::PaymentMethod.first | ||
|
||
Comable::Order.complete.each do |order| | ||
payment = order.create_payment!(payment_method: payment_method, fee: payment_method.fee) | ||
payment.state = 'completed' | ||
payment.completed_at = Time.now | ||
payment.save! | ||
end |
Oops, something went wrong.