Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: drefined/spree_digital
base: 67b7067e07
...
head fork: drefined/spree_digital
compare: 2703005a98
  • 15 commits
  • 19 files changed
  • 0 commit comments
  • 5 contributors
View
5 .gitignore
@@ -9,7 +9,4 @@ nbproject
*.swp
spec/dummy
*.tmproj
-.bundle
-.rbenv-version
-vendor
-bin
+Gemfile.lock
View
37 Gemfile
@@ -1,36 +1,15 @@
source 'http://rubygems.org'
-gem 'spree_core', :path => '../spree/core'
-gem "sqlite3"
-gem "aws-s3"
-
group :test do
- gem 'rspec-rails', '= 2.6.1'
- gem 'factory_girl', '= 2.1.2'
- gem 'factory_girl_rails', '= 1.2.0'
- gem 'rcov'
- gem 'shoulda'
- gem 'faker'
- if RUBY_VERSION < "1.9"
- gem "ruby-debug"
- else
- gem "ruby-debug19"
- end
-end
+ # without ffaker in test it wont init
+ # https://github.com/spree/spree/pull/833
+ gem 'ffaker'
+ gem 'shoulda-matchers'
+ gem 'guard-rspec'
-group :cucumber do
- gem 'cucumber-rails'
- gem 'database_cleaner', '= 0.6.7'
- gem 'nokogiri'
- gem 'capybara', '1.0.1'
- gem 'factory_girl', '= 2.1.2'
- gem 'factory_girl_rails', '= 1.2.0'
- gem 'faker'
- gem 'launchy'
- if RUBY_VERSION < "1.9"
- gem "ruby-debug"
- else
- gem "ruby-debug19"
+ if RUBY_PLATFORM.downcase.include? "darwin"
+ gem 'rb-fsevent'
+ gem 'growl'
end
end
View
18 Guardfile
@@ -0,0 +1,18 @@
+
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+end
+
View
22 Rakefile
@@ -3,17 +3,11 @@ require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
-require 'cucumber/rake/task'
-require 'spree_core/testing_support/common_rake'
+require 'spree/core/testing_support/common_rake'
RSpec::Core::RakeTask.new
-Cucumber::Rake::Task.new do |t|
- t.cucumber_opts = %w{--format progress}
-end
-
-desc "Default Task"
-task :default => [:spec, :cucumber ]
+task :default => [:spec]
spec = eval(File.read('spree_digital.gemspec'))
@@ -28,8 +22,18 @@ task :release => :package do
Rake::Task['gem:push'].invoke
end
-desc "Generates a dummy app for testing"
+desc "Regenerates a rails 3 app for testing"
task :test_app do
ENV['LIB_NAME'] = 'spree_digital'
+
+ require File.join `bundle show spree_core`.chomp, 'lib/generators/spree/dummy/dummy_generator.rb'
+ Spree::DummyGenerator.class_eval do
+ def test_dummy_add_digital
+ # pulled from: http://jumph4x.net/post/20067515804/testing-spree-1-0-x-extensions-w-other-extension
+ puts "Installing #{ENV['LIB_NAME']} migrations [required for testing]"
+ directory File.join(`bundle show #{ENV['LIB_NAME']}`.chomp, 'db', 'migrate'), File.join(dummy_path, 'db')
+ end
+ end
+
Rake::Task['common:test_app'].invoke
end
View
8 Versionfile
@@ -1,6 +1,2 @@
-# This file is used to designate compatibilty with different versions of Spree
-# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
-
-# Currently this works with these both:
-
-"1.0.x" => { :branch => "master" }
+"0.7.x" => { :ref => "eddaea63959586d123007cbca3be5bf9c5edb1a7" }
+"1.0.x" => { :branch => "master" }
View
4 app/controllers/spree/digitals_controller.rb
@@ -11,11 +11,11 @@ def show
# return
# end
if link.authorize! and File.file?(attachment.path)
- send_file attachment.path :filename => attachment.original_filename, :type => attachment.content_type and return
+ send_file attachment.path, :filename => attachment.original_filename, :type => attachment.content_type and return
end
end
render :unauthorized
end
end
-end
+end
View
3  app/models/spree/digital_link.rb
@@ -4,6 +4,9 @@ class DigitalLink < ActiveRecord::Base
belongs_to :digital
belongs_to :line_item
+ validates_length_of :secret, :is => 30
+ validates :digital, :presence => true
+
before_validation :set_defaults, :on => :create
# Can this link stil be used? It is valid if it's less than 24 hours old and was not accessed more than 3 times
View
3  app/models/spree/line_item_decorator.rb
@@ -1,6 +1,6 @@
Spree::LineItem.class_eval do
- has_many :digital_links
+ has_many :digital_links, :dependent => :destroy
after_save :create_digital_links, :if => :digital?
after_destroy :check_shipping_method
@@ -15,6 +15,7 @@ def digital?
# Create the download link for this item if it is digital.
def create_digital_links
digital_links.delete_all
+
self.quantity.times do
digital_links.create!(:digital => variant.digital)
end
View
5 app/overrides/add_digital_versions_to_admin_product_tabs.rb
@@ -1,7 +1,8 @@
Deface::Override.new(:virtual_path => "spree/admin/shared/_product_tabs",
- :name => "converted_admin_product_tabs_986577829",
+ :name => "add_digital_versions_to_admin_product_tabs",
:insert_bottom => "[data-hook='admin_product_tabs'], #admin_product_tabs[data-hook]",
:text => " <li<%== ' class=\"active\"' if current == \"Digital Versions\" %>>
<%= link_to t(\"digital_versions\"), admin_product_digitals_path(@product) %>
</li>
-", :disabled => false)
+",
+ :disabled => false)
View
8 lib/generators/spree_digital/install/install_generator.rb
@@ -1,23 +1,23 @@
module SpreeDigital
module Generators
class InstallGenerator < Rails::Generators::Base
-
+
def add_javascripts
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_digital\n"
append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_digital\n"
end
-
+
def add_stylesheets
inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_digital\n",
:before => /\*\//, :verbose => true
inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_digital\n",
:before => /\*\//, :verbose => true
end
-
+
def add_migrations
run 'bundle exec rake railties:install:migrations FROM=spree_digital'
end
-
+
def run_migrations
res = ask "Would you like to run the migrations now? [Y/n]"
if res == "" || res.downcase == "y"
View
2  lib/spree_digital/engine.rb
@@ -10,7 +10,7 @@ class Engine < Rails::Engine
end
def self.activate
- Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator.rb")) do |c|
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)
end
View
2  spec/factories/digital_factory.rb
@@ -1,3 +1,3 @@
-Factory.define :digital do |f|
+Factory.define :digital, :class => Spree::Digital do |f|
f.variant { |p| p.association(:variant) }
end
View
2  spec/factories/digital_link_factory.rb
@@ -1,4 +1,4 @@
-Factory.define :digital_link do |f|
+Factory.define :digital_link, :class => Spree::DigitalLink do |f|
f.digital { |p| p.association(:digital) }
f.line_item { |p| p.association(:line_item) }
end
View
2  spec/models/digital_link_spec.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe DigitalLink do
+describe Spree::DigitalLink do
context 'validation' do
it { should belong_to(:digital) }
View
2  spec/models/digital_spec.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe Digital do
+describe Spree::Digital do
context 'validation' do
it { should belong_to(:variant) }
View
3  spec/models/line_item_spec.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe LineItem do
+describe Spree::LineItem do
context "#save" do
it "should create one link for a single digital Variant" do
@@ -17,6 +17,7 @@
links = digital_variant.digital.digital_links
links.all.size.should == 5
links.each { |link| link.line_item.should == line_item }
+
# quantity update
line_item.quantity = 8
line_item.save
View
2  spec/models/order_spec.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe Order do
+describe Spree::Order do
context 'validation' do
it { should have_valid_factory(:order) }
View
44 spec/spec_helper.rb
@@ -1,28 +1,16 @@
-require File.expand_path("../factories", __FILE__)
-
-
-
-########################################################################
-# NOTE: The rest of file is the same as spree/core/spec/spec_helper.rb #
-########################################################################
-
-
+# Configure Rails Environment
+ENV["RAILS_ENV"] = "test"
+require File.expand_path("../dummy/config/environment.rb", __FILE__)
-
-
-
-# This file is copied to ~/spec when you run 'ruby script/generate rspec'
-# from the project root directory.
-ENV["RAILS_ENV"] ||= 'test'
-require File.expand_path("../dummy/config/environment", __FILE__)
require 'rspec/rails'
-# Requires supporting files with custom matchers and macros, etc,
-# in ./support/ and its subdirectories.
-Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
+# 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 }
-require 'spree_core/testing_support/factories'
+# Requires factories defined in spree_core
+require 'spree/core/testing_support/factories'
RSpec.configure do |config|
# == Mock Framework
@@ -34,26 +22,18 @@
# config.mock_with :rr
config.mock_with :rspec
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
- #config.include Devise::TestHelpers, :type => :controller
# If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, comment the following line or assign false
+ # examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
end
-@configuration ||= AppConfiguration.find_or_create_by_name("Default configuration")
-
-PAYMENT_STATES = Payment.state_machine.states.keys unless defined? PAYMENT_STATES
-SHIPMENT_STATES = Shipment.state_machine.states.keys unless defined? SHIPMENT_STATES
-ORDER_STATES = Order.state_machine.states.keys unless defined? ORDER_STATES
+require File.expand_path("../factories", __FILE__)
-# Usage:
-#
-# context "factory" do
-# it { should have_valid_factory(:address) }
-# end
+# not sure if this really adds anything, but this existed in the intial version of the spree_digital rspec testing
RSpec::Matchers.define :have_valid_factory do |factory_name|
match do |model|
Factory(factory_name).new_record?.should be_false
View
12 spree_digital.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_digital'
- s.version = '1.0.rc1'
+ s.version = '1.0.0'
s.summary = ''
s.description = 'This gem is supposed to be used in connection with spree_core. It was tested with spree_core 0.66.99 but it might work with newer versions as well.'
s.author = 'funkensturm.'
@@ -11,5 +11,13 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
s.required_ruby_version = '>= 1.8.7'
- s.add_dependency('spree_core')
+ s.add_dependency('spree_core', '>= 1.0.0')
+
+ # test suite
+ s.add_development_dependency 'shoulda-matchers'
+ s.add_development_dependency 'capybara'
+ s.add_development_dependency 'factory_girl'
+ s.add_development_dependency 'ffaker'
+ s.add_development_dependency 'rspec-rails'
+ s.add_development_dependency 'sqlite3'
end

No commit comments for this range

Something went wrong with that request. Please try again.