refinerycms-stores 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +26 -0
- data/Gemfile.lock +306 -0
- data/Guardfile +27 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/app/assets/stylesheets/refinery/refinerycms-stores.sass +76 -0
- data/app/controllers/refinery/addresses/admin/addresses_controller.rb +12 -0
- data/app/controllers/refinery/orders/admin/orders_controller.rb +12 -0
- data/app/controllers/refinery/orders/orders_controller.rb +96 -0
- data/app/controllers/refinery/products/admin/products_controller.rb +12 -0
- data/app/controllers/refinery/products/products_controller.rb +17 -0
- data/app/controllers/refinery/stores/admin/stores_controller.rb +12 -0
- data/app/controllers/refinery/stores/stores_controller.rb +80 -0
- data/app/helpers/refinery/orders/orders_helper.rb +11 -0
- data/app/models/refinery/addresses/address.rb +12 -0
- data/app/models/refinery/orders/line_item.rb +24 -0
- data/app/models/refinery/orders/order.rb +364 -0
- data/app/models/refinery/products/product.rb +17 -0
- data/app/models/refinery/stores/store.rb +33 -0
- data/app/views/refinery/addresses/admin/addresses/_actions.html.erb +25 -0
- data/app/views/refinery/addresses/admin/addresses/_address.html.erb +16 -0
- data/app/views/refinery/addresses/admin/addresses/_addresses.html.erb +2 -0
- data/app/views/refinery/addresses/admin/addresses/_form.html.erb +89 -0
- data/app/views/refinery/addresses/admin/addresses/_records.html.erb +18 -0
- data/app/views/refinery/addresses/admin/addresses/_sortable_list.html.erb +5 -0
- data/app/views/refinery/addresses/admin/addresses/edit.html.erb +1 -0
- data/app/views/refinery/addresses/admin/addresses/index.html.erb +7 -0
- data/app/views/refinery/addresses/admin/addresses/new.html.erb +1 -0
- data/app/views/refinery/orders/admin/orders/_actions.html.erb +25 -0
- data/app/views/refinery/orders/admin/orders/_form.html.erb +122 -0
- data/app/views/refinery/orders/admin/orders/_order.html.erb +20 -0
- data/app/views/refinery/orders/admin/orders/_orders.html.erb +2 -0
- data/app/views/refinery/orders/admin/orders/_records.html.erb +18 -0
- data/app/views/refinery/orders/admin/orders/_sortable_list.html.erb +5 -0
- data/app/views/refinery/orders/admin/orders/edit.html.erb +1 -0
- data/app/views/refinery/orders/admin/orders/index.html.erb +7 -0
- data/app/views/refinery/orders/admin/orders/new.html.erb +1 -0
- data/app/views/refinery/orders/orders/_address_form.html.haml +35 -0
- data/app/views/refinery/orders/orders/_card_form.html.haml +63 -0
- data/app/views/refinery/orders/orders/_order_snapshot.html.haml +44 -0
- data/app/views/refinery/orders/orders/confirmation.html.haml +26 -0
- data/app/views/refinery/orders/orders/edit.html.haml +36 -0
- data/app/views/refinery/orders/orders/index.html.haml +6 -0
- data/app/views/refinery/orders/orders/purchase.html.haml +25 -0
- data/app/views/refinery/orders/orders/show.html.haml +36 -0
- data/app/views/refinery/products/admin/products/_actions.html.erb +25 -0
- data/app/views/refinery/products/admin/products/_form.html.erb +127 -0
- data/app/views/refinery/products/admin/products/_product.html.erb +20 -0
- data/app/views/refinery/products/admin/products/_products.html.erb +2 -0
- data/app/views/refinery/products/admin/products/_records.html.erb +18 -0
- data/app/views/refinery/products/admin/products/_sortable_list.html.erb +5 -0
- data/app/views/refinery/products/admin/products/edit.html.erb +4 -0
- data/app/views/refinery/products/admin/products/index.html.erb +10 -0
- data/app/views/refinery/products/admin/products/new.html.erb +4 -0
- data/app/views/refinery/products/products/show.html.erb +105 -0
- data/app/views/refinery/stores/admin/stores/_actions.html.erb +57 -0
- data/app/views/refinery/stores/admin/stores/_form.html.erb +56 -0
- data/app/views/refinery/stores/admin/stores/_records.html.erb +18 -0
- data/app/views/refinery/stores/admin/stores/_sortable_list.html.erb +5 -0
- data/app/views/refinery/stores/admin/stores/_store.html.erb +20 -0
- data/app/views/refinery/stores/admin/stores/_stores.html.erb +2 -0
- data/app/views/refinery/stores/admin/stores/edit.html.erb +4 -0
- data/app/views/refinery/stores/admin/stores/index.html.erb +13 -0
- data/app/views/refinery/stores/admin/stores/new.html.erb +4 -0
- data/app/views/refinery/stores/stores/_cart.html.erb +22 -0
- data/app/views/refinery/stores/stores/_cart_item.html.erb +9 -0
- data/app/views/refinery/stores/stores/_list_product.html.erb +16 -0
- data/app/views/refinery/stores/stores/index.html.erb +11 -0
- data/app/views/refinery/stores/stores/show.html.erb +28 -0
- data/config/locales/en.yml +143 -0
- data/config/locales/es.yml +143 -0
- data/config/locales/fr.yml +139 -0
- data/config/locales/nb.yml +143 -0
- data/config/locales/nl.yml +143 -0
- data/config/routes.rb +81 -0
- data/db/migrate/1_create_stores_stores.rb +29 -0
- data/db/migrate/2_create_products_products.rb +44 -0
- data/db/migrate/3_create_orders_orders.rb +44 -0
- data/db/migrate/4_create_orders_line_items.rb +20 -0
- data/db/migrate/5_create_addresses_addresses.rb +39 -0
- data/db/seeds.rb +23 -0
- data/lib/generators/refinery/stores_generator.rb +17 -0
- data/lib/refinery/addresses/engine.rb +31 -0
- data/lib/refinery/addresses.rb +21 -0
- data/lib/refinery/cart.rb +36 -0
- data/lib/refinery/cart_item.rb +28 -0
- data/lib/refinery/orders/engine.rb +31 -0
- data/lib/refinery/orders.rb +21 -0
- data/lib/refinery/products/engine.rb +31 -0
- data/lib/refinery/products.rb +21 -0
- data/lib/refinery/store_gateway.rb +106 -0
- data/lib/refinery/stores/engine.rb +31 -0
- data/lib/refinery/stores.rb +21 -0
- data/lib/refinerycms-stores.rb +7 -0
- data/lib/tasks/refinery/stores.rake +13 -0
- data/readme.md +10 -0
- data/refinerycms-stores.gemspec +261 -0
- data/spec/models/refinery/addresses/address_spec.rb +18 -0
- data/spec/models/refinery/orders/order_spec.rb +18 -0
- data/spec/models/refinery/products/product_spec.rb +18 -0
- data/spec/models/refinery/stores/store_spec.rb +18 -0
- data/spec/requests/refinery/addresses/admin/addresses_spec.rb +101 -0
- data/spec/requests/refinery/orders/admin/orders_spec.rb +101 -0
- data/spec/requests/refinery/products/admin/products_spec.rb +101 -0
- data/spec/requests/refinery/stores/admin/stores_spec.rb +101 -0
- data/spec/spec_helper.rb +53 -0
- data/spec/support/factories/refinery/addresses.rb +7 -0
- data/spec/support/factories/refinery/orders.rb +7 -0
- data/spec/support/factories/refinery/products.rb +7 -0
- data/spec/support/factories/refinery/stores.rb +7 -0
- data/tasks/rspec.rake +6 -0
- data/tasks/testing.rake +8 -0
- data/test/helper.rb +17 -0
- data/test/test_refinerycms-cart.rb +7 -0
- metadata +571 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Refinery do
|
5
|
+
describe "Orders" do
|
6
|
+
describe "Admin" do
|
7
|
+
describe "orders" do
|
8
|
+
login_refinery_user
|
9
|
+
|
10
|
+
describe "orders list" do
|
11
|
+
before(:each) do
|
12
|
+
FactoryGirl.create(:order, :order_status => "UniqueTitleOne")
|
13
|
+
FactoryGirl.create(:order, :order_status => "UniqueTitleTwo")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "shows two items" do
|
17
|
+
visit refinery.orders_admin_orders_path
|
18
|
+
page.should have_content("UniqueTitleOne")
|
19
|
+
page.should have_content("UniqueTitleTwo")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "create" do
|
24
|
+
before(:each) do
|
25
|
+
visit refinery.orders_admin_orders_path
|
26
|
+
|
27
|
+
click_link "Add New Order"
|
28
|
+
end
|
29
|
+
|
30
|
+
context "valid data" do
|
31
|
+
it "should succeed" do
|
32
|
+
fill_in "Order Status", :with => "This is a test of the first string field"
|
33
|
+
click_button "Save"
|
34
|
+
|
35
|
+
page.should have_content("'This is a test of the first string field' was successfully added.")
|
36
|
+
Refinery::Orders::Order.count.should == 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "invalid data" do
|
41
|
+
it "should fail" do
|
42
|
+
click_button "Save"
|
43
|
+
|
44
|
+
page.should have_content("Order Status can't be blank")
|
45
|
+
Refinery::Orders::Order.count.should == 0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "duplicate" do
|
50
|
+
before(:each) { FactoryGirl.create(:order, :order_status => "UniqueTitle") }
|
51
|
+
|
52
|
+
it "should fail" do
|
53
|
+
visit refinery.orders_admin_orders_path
|
54
|
+
|
55
|
+
click_link "Add New Order"
|
56
|
+
|
57
|
+
fill_in "Order Status", :with => "UniqueTitle"
|
58
|
+
click_button "Save"
|
59
|
+
|
60
|
+
page.should have_content("There were problems")
|
61
|
+
Refinery::Orders::Order.count.should == 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "edit" do
|
68
|
+
before(:each) { FactoryGirl.create(:order, :order_status => "A order_status") }
|
69
|
+
|
70
|
+
it "should succeed" do
|
71
|
+
visit refinery.orders_admin_orders_path
|
72
|
+
|
73
|
+
within ".actions" do
|
74
|
+
click_link "Edit this order"
|
75
|
+
end
|
76
|
+
|
77
|
+
fill_in "Order Status", :with => "A different order_status"
|
78
|
+
click_button "Save"
|
79
|
+
|
80
|
+
page.should have_content("'A different order_status' was successfully updated.")
|
81
|
+
page.should have_no_content("A order_status")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "destroy" do
|
86
|
+
before(:each) { FactoryGirl.create(:order, :order_status => "UniqueTitleOne") }
|
87
|
+
|
88
|
+
it "should succeed" do
|
89
|
+
visit refinery.orders_admin_orders_path
|
90
|
+
|
91
|
+
click_link "Remove this order forever"
|
92
|
+
|
93
|
+
page.should have_content("'UniqueTitleOne' was successfully removed.")
|
94
|
+
Refinery::Orders::Order.count.should == 0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Refinery do
|
5
|
+
describe "Products" do
|
6
|
+
describe "Admin" do
|
7
|
+
describe "products" do
|
8
|
+
login_refinery_user
|
9
|
+
|
10
|
+
describe "products list" do
|
11
|
+
before(:each) do
|
12
|
+
FactoryGirl.create(:product, :name => "UniqueTitleOne")
|
13
|
+
FactoryGirl.create(:product, :name => "UniqueTitleTwo")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "shows two items" do
|
17
|
+
visit refinery.products_admin_products_path
|
18
|
+
page.should have_content("UniqueTitleOne")
|
19
|
+
page.should have_content("UniqueTitleTwo")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "create" do
|
24
|
+
before(:each) do
|
25
|
+
visit refinery.products_admin_products_path
|
26
|
+
|
27
|
+
click_link "Add New Product"
|
28
|
+
end
|
29
|
+
|
30
|
+
context "valid data" do
|
31
|
+
it "should succeed" do
|
32
|
+
fill_in "Name", :with => "This is a test of the first string field"
|
33
|
+
click_button "Save"
|
34
|
+
|
35
|
+
page.should have_content("'This is a test of the first string field' was successfully added.")
|
36
|
+
Refinery::Products::Product.count.should == 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "invalid data" do
|
41
|
+
it "should fail" do
|
42
|
+
click_button "Save"
|
43
|
+
|
44
|
+
page.should have_content("Name can't be blank")
|
45
|
+
Refinery::Products::Product.count.should == 0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "duplicate" do
|
50
|
+
before(:each) { FactoryGirl.create(:product, :name => "UniqueTitle") }
|
51
|
+
|
52
|
+
it "should fail" do
|
53
|
+
visit refinery.products_admin_products_path
|
54
|
+
|
55
|
+
click_link "Add New Product"
|
56
|
+
|
57
|
+
fill_in "Name", :with => "UniqueTitle"
|
58
|
+
click_button "Save"
|
59
|
+
|
60
|
+
page.should have_content("There were problems")
|
61
|
+
Refinery::Products::Product.count.should == 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "edit" do
|
68
|
+
before(:each) { FactoryGirl.create(:product, :name => "A name") }
|
69
|
+
|
70
|
+
it "should succeed" do
|
71
|
+
visit refinery.products_admin_products_path
|
72
|
+
|
73
|
+
within ".actions" do
|
74
|
+
click_link "Edit this product"
|
75
|
+
end
|
76
|
+
|
77
|
+
fill_in "Name", :with => "A different name"
|
78
|
+
click_button "Save"
|
79
|
+
|
80
|
+
page.should have_content("'A different name' was successfully updated.")
|
81
|
+
page.should have_no_content("A name")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "destroy" do
|
86
|
+
before(:each) { FactoryGirl.create(:product, :name => "UniqueTitleOne") }
|
87
|
+
|
88
|
+
it "should succeed" do
|
89
|
+
visit refinery.products_admin_products_path
|
90
|
+
|
91
|
+
click_link "Remove this product forever"
|
92
|
+
|
93
|
+
page.should have_content("'UniqueTitleOne' was successfully removed.")
|
94
|
+
Refinery::Products::Product.count.should == 0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Refinery do
|
5
|
+
describe "Stores" do
|
6
|
+
describe "Admin" do
|
7
|
+
describe "stores" do
|
8
|
+
login_refinery_user
|
9
|
+
|
10
|
+
describe "stores list" do
|
11
|
+
before(:each) do
|
12
|
+
FactoryGirl.create(:store, :name => "UniqueTitleOne")
|
13
|
+
FactoryGirl.create(:store, :name => "UniqueTitleTwo")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "shows two items" do
|
17
|
+
visit refinery.stores_admin_stores_path
|
18
|
+
page.should have_content("UniqueTitleOne")
|
19
|
+
page.should have_content("UniqueTitleTwo")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "create" do
|
24
|
+
before(:each) do
|
25
|
+
visit refinery.stores_admin_stores_path
|
26
|
+
|
27
|
+
click_link "Add New Store"
|
28
|
+
end
|
29
|
+
|
30
|
+
context "valid data" do
|
31
|
+
it "should succeed" do
|
32
|
+
fill_in "Name", :with => "This is a test of the first string field"
|
33
|
+
click_button "Save"
|
34
|
+
|
35
|
+
page.should have_content("'This is a test of the first string field' was successfully added.")
|
36
|
+
Refinery::Stores::Store.count.should == 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "invalid data" do
|
41
|
+
it "should fail" do
|
42
|
+
click_button "Save"
|
43
|
+
|
44
|
+
page.should have_content("Name can't be blank")
|
45
|
+
Refinery::Stores::Store.count.should == 0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "duplicate" do
|
50
|
+
before(:each) { FactoryGirl.create(:store, :name => "UniqueTitle") }
|
51
|
+
|
52
|
+
it "should fail" do
|
53
|
+
visit refinery.stores_admin_stores_path
|
54
|
+
|
55
|
+
click_link "Add New Store"
|
56
|
+
|
57
|
+
fill_in "Name", :with => "UniqueTitle"
|
58
|
+
click_button "Save"
|
59
|
+
|
60
|
+
page.should have_content("There were problems")
|
61
|
+
Refinery::Stores::Store.count.should == 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "edit" do
|
68
|
+
before(:each) { FactoryGirl.create(:store, :name => "A name") }
|
69
|
+
|
70
|
+
it "should succeed" do
|
71
|
+
visit refinery.stores_admin_stores_path
|
72
|
+
|
73
|
+
within ".actions" do
|
74
|
+
click_link "Edit this store"
|
75
|
+
end
|
76
|
+
|
77
|
+
fill_in "Name", :with => "A different name"
|
78
|
+
click_button "Save"
|
79
|
+
|
80
|
+
page.should have_content("'A different name' was successfully updated.")
|
81
|
+
page.should have_no_content("A name")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "destroy" do
|
86
|
+
before(:each) { FactoryGirl.create(:store, :name => "UniqueTitleOne") }
|
87
|
+
|
88
|
+
it "should succeed" do
|
89
|
+
visit refinery.stores_admin_stores_path
|
90
|
+
|
91
|
+
click_link "Remove this store forever"
|
92
|
+
|
93
|
+
page.should have_content("'UniqueTitleOne' was successfully removed.")
|
94
|
+
Refinery::Stores::Store.count.should == 0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
def setup_environment
|
2
|
+
# Configure Rails Environment
|
3
|
+
ENV["RAILS_ENV"] ||= 'test'
|
4
|
+
|
5
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
6
|
+
|
7
|
+
require 'rspec/rails'
|
8
|
+
require 'capybara/rspec'
|
9
|
+
|
10
|
+
Rails.backtrace_cleaner.remove_silencers!
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.mock_with :rspec
|
14
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
15
|
+
config.filter_run :focus => true
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
end
|
18
|
+
|
19
|
+
# set javascript driver for capybara
|
20
|
+
Capybara.javascript_driver = :selenium
|
21
|
+
end
|
22
|
+
|
23
|
+
def each_run
|
24
|
+
Rails.cache.clear
|
25
|
+
ActiveSupport::Dependencies.clear
|
26
|
+
FactoryGirl.reload
|
27
|
+
|
28
|
+
# Requires supporting files with custom matchers and macros, etc,
|
29
|
+
# in ./support/ and its subdirectories including factories.
|
30
|
+
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
|
31
|
+
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
|
32
|
+
}.flatten.sort.each do |support_file|
|
33
|
+
require support_file
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# If spork is available in the Gemfile it'll be used but we don't force it.
|
38
|
+
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
|
39
|
+
Spork.prefork do
|
40
|
+
# Loading more in this block will cause your tests to run faster. However,
|
41
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
42
|
+
# need to restart spork for it take effect.
|
43
|
+
setup_environment
|
44
|
+
end
|
45
|
+
|
46
|
+
Spork.each_run do
|
47
|
+
# This code will be run each time you run your specs.
|
48
|
+
each_run
|
49
|
+
end
|
50
|
+
else
|
51
|
+
setup_environment
|
52
|
+
each_run
|
53
|
+
end
|
data/tasks/rspec.rake
ADDED
data/tasks/testing.rake
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
require 'refinerycms-cart'
|
15
|
+
|
16
|
+
class Test::Unit::TestCase
|
17
|
+
end
|