piggybak_free_shipping_by_product 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +32 -0
  5. data/lib/piggybak_free_shipping_by_product.rb +6 -0
  6. data/lib/piggybak_free_shipping_by_product/engine.rb +13 -0
  7. data/lib/piggybak_free_shipping_by_product/free_shipping_by_product.rb +25 -0
  8. data/lib/piggybak_free_shipping_by_product/piggybak_orders_controller_decorator.rb +27 -0
  9. data/lib/piggybak_free_shipping_by_product/version.rb +3 -0
  10. data/test/dummy/README.rdoc +28 -0
  11. data/test/dummy/Rakefile +6 -0
  12. data/test/dummy/app/assets/javascripts/application.js +13 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  14. data/test/dummy/app/controllers/application_controller.rb +5 -0
  15. data/test/dummy/app/helpers/application_helper.rb +2 -0
  16. data/test/dummy/app/models/image.rb +3 -0
  17. data/test/dummy/app/models/user.rb +4 -0
  18. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  19. data/test/dummy/app/views/piggybak/orders/_user_details.html.erb +11 -0
  20. data/test/dummy/bin/bundle +3 -0
  21. data/test/dummy/bin/rails +4 -0
  22. data/test/dummy/bin/rake +4 -0
  23. data/test/dummy/config.ru +4 -0
  24. data/test/dummy/config/application.rb +23 -0
  25. data/test/dummy/config/boot.rb +5 -0
  26. data/test/dummy/config/database.yml +25 -0
  27. data/test/dummy/config/environment.rb +8 -0
  28. data/test/dummy/config/environments/development.rb +37 -0
  29. data/test/dummy/config/environments/production.rb +82 -0
  30. data/test/dummy/config/environments/test.rb +39 -0
  31. data/test/dummy/config/initializers/assets.rb +8 -0
  32. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  33. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  34. data/test/dummy/config/initializers/devise.rb +256 -0
  35. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  36. data/test/dummy/config/initializers/inflections.rb +16 -0
  37. data/test/dummy/config/initializers/mime_types.rb +4 -0
  38. data/test/dummy/config/initializers/session_store.rb +3 -0
  39. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  40. data/test/dummy/config/locales/devise.en.yml +59 -0
  41. data/test/dummy/config/locales/en.yml +23 -0
  42. data/test/dummy/config/routes.rb +7 -0
  43. data/test/dummy/config/secrets.yml +22 -0
  44. data/test/dummy/db/migrate/20111221175014_create_roles_users.rb +8 -0
  45. data/test/dummy/db/migrate/20111231040339_devise_create_users.rb +33 -0
  46. data/test/dummy/db/migrate/20111231040340_create_rails_admin_histories_table.rb +18 -0
  47. data/test/dummy/db/migrate/20111231040354_create_images.rb +9 -0
  48. data/test/dummy/db/migrate/20111231041048_create_roles.rb +7 -0
  49. data/test/dummy/db/migrate/20111231052811_create_pages.rb +11 -0
  50. data/test/dummy/db/migrate/20111231055412_acts_as_taggable_on_migration.rb +30 -0
  51. data/test/dummy/db/migrate/20120102162414_create_countries.rb +10 -0
  52. data/test/dummy/db/migrate/20120102162415_create_states.rb +9 -0
  53. data/test/dummy/db/migrate/20120103020918_create_orders.rb +21 -0
  54. data/test/dummy/db/migrate/20120103020919_create_addresses.rb +15 -0
  55. data/test/dummy/db/migrate/20120103020920_create_line_items.rb +10 -0
  56. data/test/dummy/db/migrate/20120103020921_create_variants.rb +14 -0
  57. data/test/dummy/db/migrate/20120103020922_create_shipping_methods.rb +9 -0
  58. data/test/dummy/db/migrate/20120103020923_create_payment_methods.rb +11 -0
  59. data/test/dummy/db/migrate/20120103020924_create_payments.rb +19 -0
  60. data/test/dummy/db/migrate/20120103020925_create_shipments.rb +12 -0
  61. data/test/dummy/db/migrate/20120103020926_create_shipping_method_values.rb +9 -0
  62. data/test/dummy/db/migrate/20120103020927_create_payment_method_values.rb +9 -0
  63. data/test/dummy/db/migrate/20120103020928_create_tax_methods.rb +9 -0
  64. data/test/dummy/db/migrate/20120103020930_create_tax_method_values.rb +9 -0
  65. data/test/dummy/db/migrate/20120104020930_populate_countries_and_states.rb +30 -0
  66. data/test/dummy/db/migrate/20120106010846_create_credits.rb +14 -0
  67. data/test/dummy/db/migrate/20120106034634_create_posts.rb +14 -0
  68. data/test/dummy/db/migrate/20120107140039_add_active_to_countries.rb +11 -0
  69. data/test/dummy/db/migrate/20120111195717_drop_cc_fields.rb +11 -0
  70. data/test/dummy/db/migrate/20120627151032_add_price_to_line_item.piggybak_engine.rb +14 -0
  71. data/test/dummy/db/migrate/20120627175044_add_description_to_line_item.piggybak_engine.rb +14 -0
  72. data/test/dummy/db/migrate/20120829140525_add_masked_credit_card_numbers.piggybak_engine.rb +10 -0
  73. data/test/dummy/db/migrate/20120829140526_order_debugging.piggybak_engine.rb +12 -0
  74. data/test/dummy/db/migrate/20120829140527_create_order_notes.piggybak_engine.rb +11 -0
  75. data/test/dummy/db/migrate/20120829140528_modify_credits.piggybak_engine.rb +7 -0
  76. data/test/dummy/db/migrate/20120829140529_add_to_be_cancelled_to_orders.piggybak_engine.rb +6 -0
  77. data/test/dummy/db/migrate/20121008195802_rename_variants_to_sellables.piggybak_engine.rb +12 -0
  78. data/test/dummy/db/migrate/20121017151401_line_item_rearchitecture.piggybak_engine.rb +105 -0
  79. data/test/dummy/db/migrate/20121022161614_fix_sellable_price_scale.rb +9 -0
  80. data/test/dummy/db/migrate/20121022164235_convert_all_decimal_fields.rb +15 -0
  81. data/test/dummy/db/migrate/20121022202530_create_new_variants.piggybak_variants.rb +14 -0
  82. data/test/dummy/db/migrate/20121108204215_drop_sort_from_line_items.piggybak_engine.rb +10 -0
  83. data/test/dummy/db/migrate/20130516201046_change_user_agent_type.piggybak_engine.rb +10 -0
  84. data/test/dummy/db/migrate/20130516201047_add_confirmation_sent_to_orders.piggybak_engine.rb +6 -0
  85. data/test/dummy/db/migrate/20140325133841_upgrade_piggybak_tables.rb +19 -0
  86. data/test/dummy/db/schema.rb +245 -0
  87. data/test/dummy/db/test.sqlite3 +0 -0
  88. data/test/dummy/public/404.html +67 -0
  89. data/test/dummy/public/422.html +67 -0
  90. data/test/dummy/public/500.html +66 -0
  91. data/test/dummy/public/favicon.ico +0 -0
  92. data/test/dummy/test.sqlite3 +0 -0
  93. data/test/dummy/test/fixtures/images.yml +9 -0
  94. data/test/dummy/test/fixtures/piggybak_orders.yml +0 -0
  95. data/test/dummy/test/fixtures/piggybak_payment_methods.yml +5 -0
  96. data/test/dummy/test/fixtures/piggybak_sellables.yml +15 -0
  97. data/test/dummy/test/fixtures/piggybak_shipping_method_values.yml +17 -0
  98. data/test/dummy/test/fixtures/piggybak_shipping_methods.yml +17 -0
  99. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  100. data/test/dummy/tmp/cache/assets/test/sprockets/204f3ed344cab052c25904aa340641c9 +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/3522e8667e0d6e452a01c6b40e7efa4d +0 -0
  103. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  104. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  105. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  106. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  107. data/test/piggybak_free_shipping_by_product_test.rb +84 -0
  108. data/test/test_helper.rb +15 -0
  109. metadata +322 -0
@@ -0,0 +1,7 @@
1
+ Rails.application.routes.draw do
2
+ mount Piggybak::Engine => '/', as: :piggybak
3
+
4
+ devise_for :users
5
+
6
+ root 'home#index'
7
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: bd571ce03dbeb700250deab5a3dffe8caea598bf2ad92eb54b9859564ed1e700648e2ac180147147e03f1186894c0c80394e41290e495e639f9d8ee0f1dd8e91
15
+
16
+ test:
17
+ secret_key_base: d29bc1ced4362f8076bf785b90e0df7c9743c87c03729cfa6f1643e2e5dd87614c3bedb6966b04617d82c8c21e89053f453e61f011f5d2175c0f119bcf7e9a61
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,8 @@
1
+ class CreateRolesUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :roles_users, :id => false do |t|
4
+ t.references :role
5
+ t.references :user
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ class DeviseCreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, :null => false, :default => ""
6
+ t.string :encrypted_password, :null => false, :default => ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, :default => 0
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+ t.string :display_name, :null => false
22
+
23
+ t.timestamps
24
+ end
25
+
26
+ add_index :users, :email, :unique => true
27
+ add_index :users, :reset_password_token, :unique => true
28
+ # add_index :users, :confirmation_token, :unique => true
29
+ # add_index :users, :unlock_token, :unique => true
30
+ # add_index :users, :authentication_token, :unique => true
31
+ end
32
+
33
+ end
@@ -0,0 +1,18 @@
1
+ class CreateRailsAdminHistoriesTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :rails_admin_histories do |t|
4
+ t.text :message # title, name, or object_id
5
+ t.string :username
6
+ t.integer :item
7
+ t.string :table
8
+ t.integer :month, :limit => 2
9
+ t.integer :year, :limit => 5
10
+ t.timestamps
11
+ end
12
+ add_index(:rails_admin_histories, [:item, :table, :month, :year], :name => 'index_rails_admin_histories' )
13
+ end
14
+
15
+ def self.down
16
+ drop_table :rails_admin_histories
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ class CreateImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :images do |t|
4
+ t.string :title, :null => false
5
+ t.boolean :free_shipping, :null => false, :default => false
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ class CreateRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :roles do |t|
4
+ t.string :name
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ class CreatePages < ActiveRecord::Migration
2
+ def change
3
+ create_table :pages do |t|
4
+ t.string :title
5
+ t.string :slug
6
+ t.text :content
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ class ActsAsTaggableOnMigration < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :tags do |t|
4
+ t.string :name
5
+ end
6
+
7
+ create_table :taggings do |t|
8
+ t.references :tag
9
+
10
+ # You should make sure that the column created is
11
+ # long enough to store the required class names.
12
+ t.references :taggable, :polymorphic => true
13
+ t.references :tagger, :polymorphic => true
14
+
15
+ # limit is created to prevent mysql error o index lenght for myisam table type.
16
+ # http://bit.ly/vgW2Ql
17
+ t.string :context, :limit => 128
18
+
19
+ t.datetime :created_at
20
+ end
21
+
22
+ add_index :taggings, :tag_id
23
+ add_index :taggings, [:taggable_id, :taggable_type, :context]
24
+ end
25
+
26
+ def self.down
27
+ drop_table :taggings
28
+ drop_table :tags
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ require "countries"
2
+
3
+ class CreateCountries < ActiveRecord::Migration
4
+ def change
5
+ create_table :countries do |t|
6
+ t.string :name
7
+ t.string :abbr
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class CreateStates < ActiveRecord::Migration
2
+ def change
3
+ create_table :states do |t|
4
+ t.string :name
5
+ t.string :abbr
6
+ t.references :country
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ class CreateOrders < ActiveRecord::Migration
2
+ def change
3
+ create_table :orders do |t|
4
+ t.references :billing_address, :null => false
5
+ t.references :shipping_address, :null => false
6
+
7
+ t.references :user
8
+ t.string :email, :null => false
9
+ t.string :phone, :null => false
10
+
11
+ t.decimal :total, :null => false
12
+ t.decimal :total_due, :null => false
13
+ t.decimal :tax_charge, :null => false
14
+ t.string :status, :null => false
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
20
+
21
+ # Note: To force precision, alter column type in database console
@@ -0,0 +1,15 @@
1
+ class CreateAddresses < ActiveRecord::Migration
2
+ def change
3
+ create_table :addresses do |t|
4
+ t.string :firstname, :null => false
5
+ t.string :lastname, :null => false
6
+ t.string :address1, :null => false
7
+ t.string :address2
8
+ t.string :city, :null => false
9
+ t.references :state, :null => false
10
+ t.references :country, :null => false
11
+ t.string :zip, :null => false
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ class CreateLineItems < ActiveRecord::Migration
2
+ def change
3
+ create_table :line_items do |t|
4
+ t.references :order, :null => false
5
+ t.integer :quantity, :null => false
6
+ t.references :variant, :null => false
7
+ t.decimal :total
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ class CreateVariants < ActiveRecord::Migration
2
+ def change
3
+ create_table :variants do |t|
4
+ t.string :sku, :null => false
5
+ t.string :description, :null => false
6
+ t.decimal :price, :null => false
7
+ t.integer :quantity, :null => false, :default => 0
8
+ t.integer :item_id, :null => false
9
+ t.string :item_type, :null => false
10
+ t.boolean :active, :null => false, :default => false
11
+ t.boolean :unlimited_inventory, :null => false, :default => false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class CreateShippingMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :shipping_methods do |t|
4
+ t.string :description, :null => false
5
+ t.string :klass, :null => false
6
+ t.boolean :active, :null => false, :default => false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class CreatePaymentMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :payment_methods do |t|
4
+ t.string :description, :null => false
5
+ t.string :klass, :null => false
6
+ t.boolean :active, :null => false, :default => false
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ class CreatePayments < ActiveRecord::Migration
2
+ def change
3
+ create_table :payments do |t|
4
+ t.references :order
5
+ t.references :payment_method
6
+ t.string :status, :null => false, :default => 'paid'
7
+ t.decimal :total, :null => false, :default => 0.0
8
+
9
+ t.string :number
10
+ t.integer :month
11
+ t.integer :year
12
+ t.string :verification_value
13
+
14
+ t.string :transaction_id
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ class CreateShipments < ActiveRecord::Migration
2
+ def change
3
+ create_table :shipments do |t|
4
+ t.references :order, :null => false
5
+ t.references :shipping_method, :null => false
6
+ t.string :status, :null => false, :default => "new"
7
+ t.decimal :total, :null => false, :default => 0.0
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ class CreateShippingMethodValues < ActiveRecord::Migration
2
+ def change
3
+ create_table :shipping_method_values do |t|
4
+ t.references :shipping_method
5
+ t.string :key
6
+ t.string :value
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreatePaymentMethodValues < ActiveRecord::Migration
2
+ def change
3
+ create_table :payment_method_values do |t|
4
+ t.references :payment_method
5
+ t.string :key
6
+ t.string :value
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTaxMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :tax_methods do |t|
4
+ t.string :description, :null => false
5
+ t.string :klass, :null => false
6
+ t.boolean :active, :null => false, :default => false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTaxMethodValues < ActiveRecord::Migration
2
+ def change
3
+ create_table :tax_method_values do |t|
4
+ t.references :tax_method
5
+ t.string :key
6
+ t.string :value
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ require "countries"
2
+
3
+ class PopulateCountriesAndStates < ActiveRecord::Migration
4
+ def up
5
+ Piggybak::Country.class_eval do
6
+ self.table_name = 'countries'
7
+ end
8
+ Piggybak::State.class_eval do
9
+ self.table_name = 'states'
10
+ end
11
+
12
+ ISO3166::Country.all.each do |country_array|
13
+ name = country_array[0]
14
+ abbr = country_array[1]
15
+
16
+ country = Piggybak::Country.create :name => name, :abbr => abbr
17
+
18
+ iso3166_country = ISO3166::Country.new(abbr)
19
+ iso3166_country.states.each do |key, value|
20
+ name = key
21
+ abbr = value["name"]
22
+ Piggybak::State.create! :name => name, :abbr => abbr, :country => country
23
+ end
24
+ end
25
+ end
26
+
27
+ def down
28
+ # nothing here
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ class CreateCredits < ActiveRecord::Migration
2
+ def change
3
+ create_table :credits do |t|
4
+ t.references :order
5
+
6
+ t.string :source_type
7
+ t.integer :source_id
8
+
9
+ t.decimal :total
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :posts do |t|
4
+ t.string :title, :null => false
5
+ t.string :slug, :null => false
6
+
7
+ t.references :user
8
+
9
+ t.text :content
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ class AddActiveToCountries < ActiveRecord::Migration
2
+ def up
3
+ add_column :countries, :active_shipping, :boolean, :default => false
4
+ add_column :countries, :active_billing, :boolean, :default => false
5
+ end
6
+
7
+ def down
8
+ remove_column :countries, :active_shipping
9
+ remove_column :countries, :active_billing
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class DropCcFields < ActiveRecord::Migration
2
+ def up
3
+ remove_column :payments, :number
4
+ remove_column :payments, :verification_value
5
+ end
6
+
7
+ def down
8
+ add_column :payments, :number, :string
9
+ add_column :payments, :verification_value, :string
10
+ end
11
+ end