spree_no_shipping 0.0.01 → 0.0.02

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjYzYjlhODVkMzNjYTFiY2JiZWE5YTEzZDY0Mjc2YTljZjc5YmViOQ==
4
+ Y2UxYzYwMjk0ODhjYTU0NmQyZmI3YmNiZmQ4NzVlN2FjOTg0OWZhNg==
5
5
  data.tar.gz: !binary |-
6
- ZTBlM2Q5NDAzYjBmMWQ4NGUzNDBmNTAwMDBjZjk2MzNmN2Q4ZDNiZQ==
6
+ ZDQ3MWUyM2YxMmNiNTY2ZjNjOTM0NDhiMWI1ODhiYjYzNTU1MTE4Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmUyOTk1N2NkMjdiYWMxMWYyOGNmZDg5NmFiODAyNTU1NjEzMTdiNTg1ZGEw
10
- Yzg1MmNhMGNmNGZkYmM1ZDdkNWY4YzJkYTgxZDlmNzkyYmY3MjJlMTE0NTY0
11
- MGI2M2IyOGFiNzE2ZGZlNzM5MTQyMDk3Mjc3NmJiYWY4ZjJmOGY=
9
+ ZmU3MTk1YTA3NmNmZjA0MjVkYzZhZTY2Y2QxZWUyZjljNDRlMGE1NmE2NWM0
10
+ NTExMDA5YzA3MzgyNjQ0YjMxYjFiNTY4MDk0MmE1YTc3ZDk0YmM0YzBiM2Nj
11
+ YzhiNjM2NWM2ZjM3Yjg1MDNkYjI3OTZkNWY3MzFjNzA5MjkwMDQ=
12
12
  data.tar.gz: !binary |-
13
- MDk3MDVhYjliZDY1NGViMzk2ZjYzNWYxMzM5YWEyZmVkM2E5ODIzYzk4NzNm
14
- MTY0ZWEzMDE1YmUxZTdiM2MyMTVmZWY1MDkxMjMwNDg4YjE3ZGMyY2U0MTBk
15
- NmNiZDNlZTQ5ZjA3MmRmY2RjNGY4MjIyYzY5YjNiN2UyMWEzOGU=
13
+ YmUyY2VjZjQ3Nzk4MDBiMmJmODM0OTE3Njg4NWJlZDA3MDNhNWI1ODQxMzRi
14
+ ODg4ZDc4MWFkMDI3MDIwYTJjZTRkMjVjOTU3ODI0MjI0MTQ3YWE5YjIxNjY0
15
+ OTJmYzkyMzIyMjM2YzNmZTM2MWUyZDQ2ZmRiZDhiYWU3ZGZjOWQ=
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ .sass-cache
8
+ coverage
9
+ Gemfile.lock
10
+ tmp
11
+ nbproject
12
+ pkg
13
+ *.swp
14
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Provides basic authentication functionality for testing parts of your engine
4
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-1-stable'
5
+
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2014 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ SpreeNoShipping
2
+ ===============
3
+
4
+ Introduction goes here.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add spree_no_shipping to your Gemfile:
10
+
11
+ ```ruby
12
+ gem 'spree_no_shipping'
13
+ ```
14
+
15
+ Bundle your dependencies and run the installation generator:
16
+
17
+ ```shell
18
+ bundle
19
+ bundle exec rails g spree_no_shipping:install
20
+ ```
21
+
22
+ Testing
23
+ -------
24
+
25
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
26
+
27
+ ```shell
28
+ bundle
29
+ bundle exec rake test_app
30
+ bundle exec rspec spec
31
+ ```
32
+
33
+ When testing your applications integration with this extension you may use it's factories.
34
+ Simply add this require statement to your spec_helper:
35
+
36
+ ```ruby
37
+ require 'spree_no_shipping/factories'
38
+ ```
39
+
40
+ Copyright (c) 2014 [name of extension creator], released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default => [:spec]
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree_no_shipping'
14
+ Rake::Task['extension:test_app'].invoke
15
+ end
@@ -0,0 +1 @@
1
+ //= require admin/spree_backend
@@ -0,0 +1 @@
1
+ //= require store/spree_frontend
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_backend
3
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_frontend
3
+ */
@@ -0,0 +1,9 @@
1
+ Spree::Order.class_eval do
2
+ #replace :delivery to any other state
3
+ checkout_flow do
4
+ go_to_state :address
5
+ go_to_state :payment
6
+ go_to_state :confirm
7
+ go_to_state :complete
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ Product.class_eval do
3
+ before_validation :set_to_default_shipping
4
+
5
+ def set_to_default_shipping
6
+ unless self.shipping_category_id.present?
7
+ shipping_category = Spree::ShippingCategory.where(name: 'default').first_or_create
8
+ self.shipping_category_id = shipping_category.id
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(
2
+ :virtual_path => "spree/checkout/_address",
3
+ :remove => "[data-hook='shipping_fieldset_wrapper']",
4
+ :name => "remove_shipping_from_checkout_address"
5
+ )
@@ -0,0 +1,11 @@
1
+ Deface::Override.new(
2
+ :virtual_path => "spree/admin/shared/_configuration_menu",
3
+ :remove => "erb[loud]:contains('configurations_sidebar_menu_item Spree.t(:shipping_methods), admin_shipping_methods_path')",
4
+ :name => "remove_shipping_methods_from_products_new"
5
+ )
6
+
7
+ Deface::Override.new(
8
+ :virtual_path => "spree/admin/shared/_configuration_menu",
9
+ :remove => "erb[loud]:contains('configurations_sidebar_menu_item Spree.t(:shipping_categories), admin_shipping_categories_path')",
10
+ :name => "remove_shipping_categories_from_products_new"
11
+ )
@@ -0,0 +1,13 @@
1
+ Deface::Override.new(
2
+ :virtual_path => "spree/admin/products/new",
3
+ :remove => "erb[loud]:contains(' f.field_container :shipping_category do')",
4
+ :closing_selector => "erb[silent]:contains('end')",
5
+ :name => "remove_shipping_from_products_new"
6
+ )
7
+
8
+ Deface::Override.new(
9
+ :virtual_path => "spree/admin/products/_form",
10
+ :remove => "erb[loud]:contains(' f.field_container :shipping_categories do')",
11
+ :closing_selector => "erb[silent]:contains('end')",
12
+ :name => "remove_shipping_from_products_new"
13
+ )
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_no_shipping/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,31 @@
1
+ module SpreeNoShipping
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ class_option :auto_run_migrations, :type => :boolean, :default => false
6
+
7
+ def add_javascripts
8
+ append_file 'app/assets/javascripts/store/all.js', "//= require store/spree_no_shipping\n"
9
+ append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_no_shipping\n"
10
+ end
11
+
12
+ def add_stylesheets
13
+ inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_no_shipping\n", :before => /\*\//, :verbose => true
14
+ inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_no_shipping\n", :before => /\*\//, :verbose => true
15
+ end
16
+
17
+ def add_migrations
18
+ run 'bundle exec rake railties:install:migrations FROM=spree_no_shipping'
19
+ end
20
+
21
+ def run_migrations
22
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
23
+ if run_migrations
24
+ run 'bundle exec rake db:migrate'
25
+ else
26
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,22 @@
1
+ module SpreeNoShipping
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_no_shipping'
6
+
7
+ config.autoload_paths += %W(#{config.root}/lib)
8
+
9
+ # use rspec for tests
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
13
+
14
+ def self.activate
15
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
16
+ Rails.configuration.cache_classes ? require(c) : load(c)
17
+ end
18
+ end
19
+
20
+ config.to_prepare &method(:activate).to_proc
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'spree_no_shipping/factories'
6
+ end
@@ -0,0 +1,3 @@
1
+ module SpreeNoShipping
2
+ VERSION = "0.0.02"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_no_shipping/engine'
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe "Checkout steps" do
4
+
5
+ stub_authorization!
6
+
7
+
8
+ it "removes " do
9
+ product = create(:product)
10
+
11
+ visit spree.edit_admin_general_settings_path
12
+ expect(page).to_not have_text('SHIPPING CATEGORIES')
13
+ expect(page).to_not have_text('SHIPPING METHODS')
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe "Checkout steps" do
4
+
5
+ stub_authorization!
6
+
7
+
8
+ it "removes delivery step from checkout" do
9
+ product = create(:product)
10
+
11
+ visit spree.product_path(product)
12
+ click_button 'add-to-cart-button'
13
+ save_and_open_page
14
+ click_button 'checkout-link'
15
+
16
+ expect(page).to_not have_test('Shipping Address')
17
+ expect(page).to_not have_test('Delivery')
18
+
19
+ fill_in_address
20
+ click_button 'Save and Continue'
21
+
22
+ fill_in_payment
23
+ click_button 'Save and Continue'
24
+
25
+ expect(page).to_not have_test('Shipping Address')
26
+ expect(page).to_not have_test('Delivery')
27
+
28
+ click_button 'Place Order'
29
+
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Product do
4
+ describe "#shipping_category_id" do
5
+
6
+ it 'assigns the default shipping category' do
7
+ shipping_category = create(:shipping_category, name: 'default')
8
+ product = create(:product, shipping_category_id: nil)
9
+
10
+ product.shipping_category_id.should eq(shipping_category.id)
11
+ end
12
+
13
+ it "creates a default shipping category if one doesnt exist" do
14
+ expect{
15
+ create(:product, shipping_category_id: nil)
16
+ }.to change{Spree::ShippingCategory.count}.by(1)
17
+
18
+ Spree::ShippingCategory.last.name.should eq('default')
19
+ end
20
+
21
+ it 'does nothing if shipping_category is already set' do
22
+ expect{
23
+ create(:product, shipping_category_id:99)
24
+ }.to change{Spree::ShippingCategory.count}.by(0)
25
+
26
+ Spree::Product.last.shipping_category_id.should eq(99)
27
+ end
28
+
29
+ end
30
+ end
31
+
32
+
@@ -0,0 +1,85 @@
1
+ # Run Coverage report
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec/dummy'
5
+ add_group 'Controllers', 'app/controllers'
6
+ add_group 'Helpers', 'app/helpers'
7
+ add_group 'Mailers', 'app/mailers'
8
+ add_group 'Models', 'app/models'
9
+ add_group 'Views', 'app/views'
10
+ add_group 'Libraries', 'lib'
11
+ end
12
+
13
+ # Configure Rails Environment
14
+ ENV['RAILS_ENV'] = 'test'
15
+
16
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
17
+
18
+ require 'rspec/rails'
19
+ require 'database_cleaner'
20
+ require 'ffaker'
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc,
23
+ # in spec/support/ and its subdirectories.
24
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
25
+
26
+ # Requires factories defined in spree_core
27
+ require 'spree/testing_support/factories'
28
+ require 'spree/testing_support/controller_requests'
29
+ require 'spree/testing_support/authorization_helpers'
30
+ require 'spree/testing_support/url_helpers'
31
+
32
+ # Requires factories defined in lib/spree_no_shipping/factories.rb
33
+ require 'spree_no_shipping/factories'
34
+
35
+ RSpec.configure do |config|
36
+ config.include FactoryGirl::Syntax::Methods
37
+ # config.extend ControllerMacros , :type => :feature
38
+
39
+ # == URL Helpers
40
+ #
41
+ # Allows access to Spree's routes in specs:
42
+ #
43
+ # visit spree.admin_path
44
+ # current_path.should eql(spree.products_path)
45
+ config.include Spree::TestingSupport::UrlHelpers
46
+
47
+
48
+
49
+ # == Mock Framework
50
+ #
51
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
52
+ #
53
+ # config.mock_with :mocha
54
+ # config.mock_with :flexmock
55
+ # config.mock_with :rr
56
+ config.mock_with :rspec
57
+ config.color = true
58
+
59
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
60
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
61
+
62
+ # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
63
+ # to cleanup after each test instead. Without transactional fixtures set to false the records created
64
+ # to setup a test will be unavailable to the browser, which runs under a seperate server instance.
65
+ config.use_transactional_fixtures = false
66
+
67
+ # Ensure Suite is set to use transactions for speed.
68
+ config.before :suite do
69
+ DatabaseCleaner.strategy = :transaction
70
+ DatabaseCleaner.clean_with :truncation
71
+ end
72
+
73
+ # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
74
+ config.before :each do
75
+ DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
76
+ DatabaseCleaner.start
77
+ end
78
+
79
+ # After each spec clean the database.
80
+ config.after :each do
81
+ DatabaseCleaner.clean
82
+ end
83
+
84
+ config.fail_fast = ENV['FAIL_FAST'] || false
85
+ end
@@ -0,0 +1,12 @@
1
+ module AuthenticationHelpers
2
+ def sign_in_as!(user)
3
+ visit '/login'
4
+ fill_in 'Email', :with => user.email
5
+ fill_in 'Password', :with => 'secret'
6
+ click_button 'Login'
7
+ end
8
+ end
9
+
10
+ RSpec.configure do |c|
11
+ c.include AuthenticationHelpers, :type => :feature
12
+ end
Binary file
@@ -0,0 +1,36 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "spree_no_shipping/version"
3
+
4
+ # encoding: UTF-8
5
+ Gem::Specification.new do |s|
6
+ s.platform = Gem::Platform::RUBY
7
+ s.name = 'spree_no_shipping'
8
+ s.version = SpreeNoShipping::VERSION
9
+ s.authors = ["joshblour"]
10
+ s.email = ["joshblour@hotmail.com"]
11
+ s.summary = 'Removes the delivery step from spree'
12
+ s.description = 'Removes shipping options from the product and admin menu and the deliver step from checkout'
13
+ s.required_ruby_version = '>= 1.9.3'
14
+
15
+ # s.author = 'You'
16
+ # s.email = 'you@example.com'
17
+ # s.homepage = 'http://www.spreecommerce.com'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.require_path = 'lib'
22
+ s.requirements << 'none'
23
+
24
+ s.add_dependency 'spree_core', '~> 2.1.3'
25
+
26
+ s.add_development_dependency 'capybara', '~> 2.1'
27
+ s.add_development_dependency 'coffee-rails'
28
+ s.add_development_dependency 'database_cleaner'
29
+ s.add_development_dependency 'factory_girl', '~> 4.2'
30
+ s.add_development_dependency 'ffaker'
31
+ s.add_development_dependency 'rspec-rails', '~> 2.13'
32
+ s.add_development_dependency 'sass-rails'
33
+ s.add_development_dependency 'selenium-webdriver'
34
+ s.add_development_dependency 'simplecov'
35
+ s.add_development_dependency 'sqlite3'
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_no_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.01
4
+ version: 0.0.02
5
5
  platform: ruby
6
6
  authors:
7
7
  - joshblour
@@ -171,7 +171,37 @@ email:
171
171
  executables: []
172
172
  extensions: []
173
173
  extra_rdoc_files: []
174
- files: []
174
+ files:
175
+ - .gitignore
176
+ - .rspec
177
+ - Gemfile
178
+ - LICENSE
179
+ - README.md
180
+ - Rakefile
181
+ - app/assets/javascripts/admin/spree_no_shipping.js
182
+ - app/assets/javascripts/store/spree_no_shipping.js
183
+ - app/assets/stylesheets/admin/spree_no_shipping.css
184
+ - app/assets/stylesheets/store/spree_no_shipping.css
185
+ - app/models/spree/order_decorator.rb
186
+ - app/models/spree/product_decorator.rb
187
+ - app/overrides/remove_shipping_from_checkout_address.rb
188
+ - app/overrides/remove_shipping_from_configuration_sidebar.rb
189
+ - app/overrides/remove_shipping_from_products_form.rb
190
+ - bin/rails
191
+ - config/locales/en.yml
192
+ - config/routes.rb
193
+ - lib/generators/spree_no_shipping/install/install_generator.rb
194
+ - lib/spree_no_shipping.rb
195
+ - lib/spree_no_shipping/engine.rb
196
+ - lib/spree_no_shipping/factories.rb
197
+ - lib/spree_no_shipping/version.rb
198
+ - spec/features/admin_menu_spec.rb
199
+ - spec/features/checkout_spec.rb
200
+ - spec/models/spree/product_decorator_spec.rb
201
+ - spec/spec_helper.rb
202
+ - spec/support/controller_macros.rb
203
+ - spree_no_shipping-0.0.01.gem
204
+ - spree_no_shipping.gemspec
175
205
  homepage:
176
206
  licenses: []
177
207
  metadata: {}
@@ -196,5 +226,10 @@ rubygems_version: 2.2.1
196
226
  signing_key:
197
227
  specification_version: 4
198
228
  summary: Removes the delivery step from spree
199
- test_files: []
229
+ test_files:
230
+ - spec/features/admin_menu_spec.rb
231
+ - spec/features/checkout_spec.rb
232
+ - spec/models/spree/product_decorator_spec.rb
233
+ - spec/spec_helper.rb
234
+ - spec/support/controller_macros.rb
200
235
  has_rdoc: