Updating all tests. All tests are passing
This commit is contained in:
@@ -3,7 +3,10 @@ module Spree
|
||||
|
||||
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
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -14,6 +14,7 @@ Spree::LineItem.class_eval do
|
||||
# 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
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Factory.define :digital do |f|
|
||||
Factory.define :digital, :class => Spree::Digital do |f|
|
||||
f.variant { |p| p.association(:variant) }
|
||||
end
|
||||
@@ -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
|
||||
@@ -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) }
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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 @@ describe LineItem do
|
||||
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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
Reference in New Issue
Block a user