forked from vinsol-spree-contrib/spree_taxjar
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 50668c2
Showing
19 changed files
with
337 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
\#* | ||
*~ | ||
.#* | ||
.DS_Store | ||
.idea | ||
.project | ||
.sass-cache | ||
coverage | ||
Gemfile.lock | ||
tmp | ||
nbproject | ||
pkg | ||
*.swp | ||
spec/dummy | ||
.bundle | ||
.rvmrc | ||
.ruby-version | ||
.ruby-gemset |
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 @@ | ||
--color |
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,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'spree', github: 'spree/spree', branch: 'master' | ||
# Provides basic authentication functionality for testing parts of your engine | ||
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master' | ||
|
||
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,26 @@ | ||
Copyright (c) 2016 [name of plugin creator] | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
* Neither the name Spree nor the names of its contributors may be used to | ||
endorse or promote products derived from this software without specific | ||
prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,53 @@ | ||
SpreeTaxjar | ||
=========== | ||
|
||
Introduction goes here. | ||
|
||
## Installation | ||
|
||
1. Add this extension to your Gemfile with this line: | ||
```ruby | ||
gem 'spree_taxjar', github: '[your-github-handle]/spree_taxjar', branch: 'X-X-stable' | ||
``` | ||
|
||
The `branch` option is important: it must match the version of Spree you're using. | ||
For example, use `3-1-stable` if you're using Spree `3-1-stable` or any `3.1.x` version. | ||
|
||
2. Install the gem using Bundler: | ||
```ruby | ||
bundle install | ||
``` | ||
|
||
3. Copy & run migrations | ||
```ruby | ||
bundle exec rails g spree_taxjar:install | ||
``` | ||
|
||
4. Restart your server | ||
|
||
If your server was running, restart it so that it can find the assets properly. | ||
|
||
## Testing | ||
|
||
First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`. | ||
|
||
```shell | ||
bundle | ||
bundle exec rake | ||
``` | ||
|
||
When testing your applications integration with this extension you may use it's factories. | ||
Simply add this require statement to your spec_helper: | ||
|
||
```ruby | ||
require 'spree_taxjar/factories' | ||
``` | ||
|
||
|
||
## Contributing | ||
|
||
If you'd like to contribute, please take a look at the | ||
[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good | ||
pull request. | ||
|
||
Copyright (c) 2016 [name of extension creator], released under the New BSD 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,21 @@ | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks | ||
|
||
require 'rspec/core/rake_task' | ||
require 'spree/testing_support/extension_rake' | ||
|
||
RSpec::Core::RakeTask.new | ||
|
||
task :default do | ||
if Dir["spec/dummy"].empty? | ||
Rake::Task[:test_app].invoke | ||
Dir.chdir("../../") | ||
end | ||
Rake::Task[:spec].invoke | ||
end | ||
|
||
desc 'Generates a dummy app for testing' | ||
task :test_app do | ||
ENV['LIB_NAME'] = 'spree_taxjar' | ||
Rake::Task['extension:test_app'].invoke | ||
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,2 @@ | ||
// Placeholder manifest file. | ||
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js' |
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 @@ | ||
// Placeholder manifest file. | ||
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js' |
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,4 @@ | ||
/* | ||
Placeholder manifest file. | ||
the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css' | ||
*/ |
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,4 @@ | ||
/* | ||
Placeholder manifest file. | ||
the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css' | ||
*/ |
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,7 @@ | ||
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. | ||
|
||
ENGINE_ROOT = File.expand_path('../..', __FILE__) | ||
ENGINE_PATH = File.expand_path('../../lib/spree_taxjar/engine', __FILE__) | ||
|
||
require 'rails/all' | ||
require 'rails/engine/commands' |
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,5 @@ | ||
# Sample localization file for English. Add more files in this directory for other locales. | ||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. | ||
|
||
en: | ||
hello: "Hello world" |
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 @@ | ||
Spree::Core::Engine.routes.draw do | ||
# Add your extension routes here | ||
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,31 @@ | ||
module SpreeTaxjar | ||
module Generators | ||
class InstallGenerator < Rails::Generators::Base | ||
|
||
class_option :auto_run_migrations, :type => :boolean, :default => false | ||
|
||
def add_javascripts | ||
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_taxjar\n" | ||
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_taxjar\n" | ||
end | ||
|
||
def add_stylesheets | ||
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_taxjar\n", :before => /\*\//, :verbose => true | ||
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_taxjar\n", :before => /\*\//, :verbose => true | ||
end | ||
|
||
def add_migrations | ||
run 'bundle exec rake railties:install:migrations FROM=spree_taxjar' | ||
end | ||
|
||
def run_migrations | ||
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]') | ||
if run_migrations | ||
run 'bundle exec rake db:migrate' | ||
else | ||
puts 'Skipping rake db:migrate, don\'t forget to run it!' | ||
end | ||
end | ||
end | ||
end | ||
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,2 @@ | ||
require 'spree_core' | ||
require 'spree_taxjar/engine' |
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,20 @@ | ||
module SpreeTaxjar | ||
class Engine < Rails::Engine | ||
require 'spree/core' | ||
isolate_namespace Spree | ||
engine_name 'spree_taxjar' | ||
|
||
# use rspec for tests | ||
config.generators do |g| | ||
g.test_framework :rspec | ||
end | ||
|
||
def self.activate | ||
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c| | ||
Rails.configuration.cache_classes ? require(c) : load(c) | ||
end | ||
end | ||
|
||
config.to_prepare &method(:activate).to_proc | ||
end | ||
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 @@ | ||
FactoryGirl.define do | ||
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them. | ||
# | ||
# Example adding this to your spec_helper will load these Factories for use: | ||
# require 'spree_taxjar/factories' | ||
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,93 @@ | ||
# Run Coverage report | ||
require 'simplecov' | ||
SimpleCov.start do | ||
add_filter 'spec/dummy' | ||
add_group 'Controllers', 'app/controllers' | ||
add_group 'Helpers', 'app/helpers' | ||
add_group 'Mailers', 'app/mailers' | ||
add_group 'Models', 'app/models' | ||
add_group 'Views', 'app/views' | ||
add_group 'Libraries', 'lib' | ||
end | ||
|
||
# Configure Rails Environment | ||
ENV['RAILS_ENV'] = 'test' | ||
|
||
require File.expand_path('../dummy/config/environment.rb', __FILE__) | ||
|
||
require 'rspec/rails' | ||
require 'database_cleaner' | ||
require 'ffaker' | ||
|
||
# Requires supporting ruby files with custom matchers and macros, etc, | ||
# in spec/support/ and its subdirectories. | ||
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } | ||
|
||
# Requires factories and other useful helpers defined in spree_core. | ||
require 'spree/testing_support/authorization_helpers' | ||
require 'spree/testing_support/capybara_ext' | ||
require 'spree/testing_support/controller_requests' | ||
require 'spree/testing_support/factories' | ||
require 'spree/testing_support/url_helpers' | ||
|
||
# Requires factories defined in lib/spree_taxjar/factories.rb | ||
require 'spree_taxjar/factories' | ||
|
||
RSpec.configure do |config| | ||
config.include FactoryGirl::Syntax::Methods | ||
|
||
# Infer an example group's spec type from the file location. | ||
config.infer_spec_type_from_file_location! | ||
|
||
# == URL Helpers | ||
# | ||
# Allows access to Spree's routes in specs: | ||
# | ||
# visit spree.admin_path | ||
# current_path.should eql(spree.products_path) | ||
config.include Spree::TestingSupport::UrlHelpers | ||
|
||
# == Requests support | ||
# | ||
# Adds convenient methods to request Spree's controllers | ||
# spree_get :index | ||
config.include Spree::TestingSupport::ControllerRequests, type: :controller | ||
|
||
# == Mock Framework | ||
# | ||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: | ||
# | ||
# config.mock_with :mocha | ||
# config.mock_with :flexmock | ||
# config.mock_with :rr | ||
config.mock_with :rspec | ||
config.color = true | ||
|
||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures | ||
config.fixture_path = "#{::Rails.root}/spec/fixtures" | ||
|
||
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner | ||
# to cleanup after each test instead. Without transactional fixtures set to false the records created | ||
# to setup a test will be unavailable to the browser, which runs under a separate server instance. | ||
config.use_transactional_fixtures = false | ||
|
||
# Ensure Suite is set to use transactions for speed. | ||
config.before :suite do | ||
DatabaseCleaner.strategy = :transaction | ||
DatabaseCleaner.clean_with :truncation | ||
end | ||
|
||
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary. | ||
config.before :each do | ||
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction | ||
DatabaseCleaner.start | ||
end | ||
|
||
# After each spec clean the database. | ||
config.after :each do | ||
DatabaseCleaner.clean | ||
end | ||
|
||
config.fail_fast = ENV['FAIL_FAST'] || false | ||
config.order = "random" | ||
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,32 @@ | ||
# encoding: UTF-8 | ||
Gem::Specification.new do |s| | ||
s.platform = Gem::Platform::RUBY | ||
s.name = 'spree_taxjar' | ||
s.version = '3.1.0.rc3' | ||
s.summary = 'TODO: Add gem summary here' | ||
s.description = 'TODO: Add (optional) gem description here' | ||
s.required_ruby_version = '>= 2.1.0' | ||
|
||
# s.author = 'You' | ||
# s.email = '[email protected]' | ||
# s.homepage = 'http://www.spreecommerce.com' | ||
s.license = 'BSD-3' | ||
|
||
# s.files = `git ls-files`.split("\n") | ||
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.require_path = 'lib' | ||
s.requirements << 'none' | ||
|
||
s.add_dependency 'spree_core', '~> 3.1.0.rc3' | ||
|
||
s.add_development_dependency 'capybara', '~> 2.6' | ||
s.add_development_dependency 'coffee-rails' | ||
s.add_development_dependency 'database_cleaner' | ||
s.add_development_dependency 'factory_girl', '~> 4.5' | ||
s.add_development_dependency 'ffaker' | ||
s.add_development_dependency 'rspec-rails', '~> 3.4' | ||
s.add_development_dependency 'sass-rails', '~> 5.0.0' | ||
s.add_development_dependency 'selenium-webdriver' | ||
s.add_development_dependency 'simplecov' | ||
s.add_development_dependency 'sqlite3' | ||
end |