refinerycms-stores 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/Gemfile +26 -0
  2. data/Gemfile.lock +306 -0
  3. data/Guardfile +27 -0
  4. data/LICENSE.txt +20 -0
  5. data/Rakefile +65 -0
  6. data/VERSION +1 -0
  7. data/app/assets/stylesheets/refinery/refinerycms-stores.sass +76 -0
  8. data/app/controllers/refinery/addresses/admin/addresses_controller.rb +12 -0
  9. data/app/controllers/refinery/orders/admin/orders_controller.rb +12 -0
  10. data/app/controllers/refinery/orders/orders_controller.rb +96 -0
  11. data/app/controllers/refinery/products/admin/products_controller.rb +12 -0
  12. data/app/controllers/refinery/products/products_controller.rb +17 -0
  13. data/app/controllers/refinery/stores/admin/stores_controller.rb +12 -0
  14. data/app/controllers/refinery/stores/stores_controller.rb +80 -0
  15. data/app/helpers/refinery/orders/orders_helper.rb +11 -0
  16. data/app/models/refinery/addresses/address.rb +12 -0
  17. data/app/models/refinery/orders/line_item.rb +24 -0
  18. data/app/models/refinery/orders/order.rb +364 -0
  19. data/app/models/refinery/products/product.rb +17 -0
  20. data/app/models/refinery/stores/store.rb +33 -0
  21. data/app/views/refinery/addresses/admin/addresses/_actions.html.erb +25 -0
  22. data/app/views/refinery/addresses/admin/addresses/_address.html.erb +16 -0
  23. data/app/views/refinery/addresses/admin/addresses/_addresses.html.erb +2 -0
  24. data/app/views/refinery/addresses/admin/addresses/_form.html.erb +89 -0
  25. data/app/views/refinery/addresses/admin/addresses/_records.html.erb +18 -0
  26. data/app/views/refinery/addresses/admin/addresses/_sortable_list.html.erb +5 -0
  27. data/app/views/refinery/addresses/admin/addresses/edit.html.erb +1 -0
  28. data/app/views/refinery/addresses/admin/addresses/index.html.erb +7 -0
  29. data/app/views/refinery/addresses/admin/addresses/new.html.erb +1 -0
  30. data/app/views/refinery/orders/admin/orders/_actions.html.erb +25 -0
  31. data/app/views/refinery/orders/admin/orders/_form.html.erb +122 -0
  32. data/app/views/refinery/orders/admin/orders/_order.html.erb +20 -0
  33. data/app/views/refinery/orders/admin/orders/_orders.html.erb +2 -0
  34. data/app/views/refinery/orders/admin/orders/_records.html.erb +18 -0
  35. data/app/views/refinery/orders/admin/orders/_sortable_list.html.erb +5 -0
  36. data/app/views/refinery/orders/admin/orders/edit.html.erb +1 -0
  37. data/app/views/refinery/orders/admin/orders/index.html.erb +7 -0
  38. data/app/views/refinery/orders/admin/orders/new.html.erb +1 -0
  39. data/app/views/refinery/orders/orders/_address_form.html.haml +35 -0
  40. data/app/views/refinery/orders/orders/_card_form.html.haml +63 -0
  41. data/app/views/refinery/orders/orders/_order_snapshot.html.haml +44 -0
  42. data/app/views/refinery/orders/orders/confirmation.html.haml +26 -0
  43. data/app/views/refinery/orders/orders/edit.html.haml +36 -0
  44. data/app/views/refinery/orders/orders/index.html.haml +6 -0
  45. data/app/views/refinery/orders/orders/purchase.html.haml +25 -0
  46. data/app/views/refinery/orders/orders/show.html.haml +36 -0
  47. data/app/views/refinery/products/admin/products/_actions.html.erb +25 -0
  48. data/app/views/refinery/products/admin/products/_form.html.erb +127 -0
  49. data/app/views/refinery/products/admin/products/_product.html.erb +20 -0
  50. data/app/views/refinery/products/admin/products/_products.html.erb +2 -0
  51. data/app/views/refinery/products/admin/products/_records.html.erb +18 -0
  52. data/app/views/refinery/products/admin/products/_sortable_list.html.erb +5 -0
  53. data/app/views/refinery/products/admin/products/edit.html.erb +4 -0
  54. data/app/views/refinery/products/admin/products/index.html.erb +10 -0
  55. data/app/views/refinery/products/admin/products/new.html.erb +4 -0
  56. data/app/views/refinery/products/products/show.html.erb +105 -0
  57. data/app/views/refinery/stores/admin/stores/_actions.html.erb +57 -0
  58. data/app/views/refinery/stores/admin/stores/_form.html.erb +56 -0
  59. data/app/views/refinery/stores/admin/stores/_records.html.erb +18 -0
  60. data/app/views/refinery/stores/admin/stores/_sortable_list.html.erb +5 -0
  61. data/app/views/refinery/stores/admin/stores/_store.html.erb +20 -0
  62. data/app/views/refinery/stores/admin/stores/_stores.html.erb +2 -0
  63. data/app/views/refinery/stores/admin/stores/edit.html.erb +4 -0
  64. data/app/views/refinery/stores/admin/stores/index.html.erb +13 -0
  65. data/app/views/refinery/stores/admin/stores/new.html.erb +4 -0
  66. data/app/views/refinery/stores/stores/_cart.html.erb +22 -0
  67. data/app/views/refinery/stores/stores/_cart_item.html.erb +9 -0
  68. data/app/views/refinery/stores/stores/_list_product.html.erb +16 -0
  69. data/app/views/refinery/stores/stores/index.html.erb +11 -0
  70. data/app/views/refinery/stores/stores/show.html.erb +28 -0
  71. data/config/locales/en.yml +143 -0
  72. data/config/locales/es.yml +143 -0
  73. data/config/locales/fr.yml +139 -0
  74. data/config/locales/nb.yml +143 -0
  75. data/config/locales/nl.yml +143 -0
  76. data/config/routes.rb +81 -0
  77. data/db/migrate/1_create_stores_stores.rb +29 -0
  78. data/db/migrate/2_create_products_products.rb +44 -0
  79. data/db/migrate/3_create_orders_orders.rb +44 -0
  80. data/db/migrate/4_create_orders_line_items.rb +20 -0
  81. data/db/migrate/5_create_addresses_addresses.rb +39 -0
  82. data/db/seeds.rb +23 -0
  83. data/lib/generators/refinery/stores_generator.rb +17 -0
  84. data/lib/refinery/addresses/engine.rb +31 -0
  85. data/lib/refinery/addresses.rb +21 -0
  86. data/lib/refinery/cart.rb +36 -0
  87. data/lib/refinery/cart_item.rb +28 -0
  88. data/lib/refinery/orders/engine.rb +31 -0
  89. data/lib/refinery/orders.rb +21 -0
  90. data/lib/refinery/products/engine.rb +31 -0
  91. data/lib/refinery/products.rb +21 -0
  92. data/lib/refinery/store_gateway.rb +106 -0
  93. data/lib/refinery/stores/engine.rb +31 -0
  94. data/lib/refinery/stores.rb +21 -0
  95. data/lib/refinerycms-stores.rb +7 -0
  96. data/lib/tasks/refinery/stores.rake +13 -0
  97. data/readme.md +10 -0
  98. data/refinerycms-stores.gemspec +261 -0
  99. data/spec/models/refinery/addresses/address_spec.rb +18 -0
  100. data/spec/models/refinery/orders/order_spec.rb +18 -0
  101. data/spec/models/refinery/products/product_spec.rb +18 -0
  102. data/spec/models/refinery/stores/store_spec.rb +18 -0
  103. data/spec/requests/refinery/addresses/admin/addresses_spec.rb +101 -0
  104. data/spec/requests/refinery/orders/admin/orders_spec.rb +101 -0
  105. data/spec/requests/refinery/products/admin/products_spec.rb +101 -0
  106. data/spec/requests/refinery/stores/admin/stores_spec.rb +101 -0
  107. data/spec/spec_helper.rb +53 -0
  108. data/spec/support/factories/refinery/addresses.rb +7 -0
  109. data/spec/support/factories/refinery/orders.rb +7 -0
  110. data/spec/support/factories/refinery/products.rb +7 -0
  111. data/spec/support/factories/refinery/stores.rb +7 -0
  112. data/tasks/rspec.rake +6 -0
  113. data/tasks/testing.rake +8 -0
  114. data/test/helper.rb +17 -0
  115. data/test/test_refinerycms-cart.rb +7 -0
  116. 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
@@ -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
@@ -0,0 +1,7 @@
1
+
2
+ FactoryGirl.define do
3
+ factory :address, :class => Refinery::Addresses::Address do
4
+ sequence(:first_name) { |n| "refinery#{n}" }
5
+ end
6
+ end
7
+
@@ -0,0 +1,7 @@
1
+
2
+ FactoryGirl.define do
3
+ factory :order, :class => Refinery::Orders::Order do
4
+ sequence(:order_status) { |n| "refinery#{n}" }
5
+ end
6
+ end
7
+
@@ -0,0 +1,7 @@
1
+
2
+ FactoryGirl.define do
3
+ factory :product, :class => Refinery::Products::Product do
4
+ sequence(:name) { |n| "refinery#{n}" }
5
+ end
6
+ end
7
+
@@ -0,0 +1,7 @@
1
+
2
+ FactoryGirl.define do
3
+ factory :store, :class => Refinery::Stores::Store do
4
+ sequence(:name) { |n| "refinery#{n}" }
5
+ end
6
+ end
7
+
data/tasks/rspec.rake ADDED
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc "Run specs"
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.pattern = "./spec"
6
+ end
@@ -0,0 +1,8 @@
1
+ namespace :refinery do
2
+ namespace :testing do
3
+ # Put any code in here that you want run when you test this engine against a dummy app.
4
+ # For example, the call to require your gem and start your generator.
5
+ task :setup_extension do
6
+ end
7
+ end
8
+ end
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
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestRefinerycmsCart < Test::Unit::TestCase
4
+ def test_something_for_real
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end