Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

introduces shipped_at field to identify when issues have been shipped

  • Loading branch information...
commit 9b6e6a02bce1ba9703060905e1930d6ca8e10940 1 parent fce2585
@kennyadsl kennyadsl authored
View
5 app/models/spree/issue.rb
@@ -3,7 +3,7 @@ class Spree::Issue < ActiveRecord::Base
belongs_to :magazine_issue, :class_name => "Spree::Product"
has_many :shipped_issues
- attr_accessible :name, :published_at, :magazine, :magazine_issue_id
+ attr_accessible :name, :published_at, :shipped_at, :magazine, :magazine_issue_id
delegate :subscriptions,:to => :magazine
@@ -17,10 +17,11 @@ def name
def ship!
subscriptions.each{ |s| s.ship!(self) }
+ update_attribute(:shipped_at, Time.now)
end
def shipped?
- !shipped_issues.empty?
+ !shipped_at.nil?
end
end
View
5 db/migrate/20120801134107_add_shipped_to_spree_issue.rb
@@ -0,0 +1,5 @@
+class AddShippedToSpreeIssue < ActiveRecord::Migration
+ def change
+ add_column :spree_issues, :shipped_at, :datetime
+ end
+end
View
12 spec/models/spree/issue_spec.rb
@@ -36,4 +36,16 @@
issue = Factory.create(:issue, :magazine => subscription.magazine)
expect{ issue.ship! }.to change(issue.shipped_issues, :count).by(1)
end
+
+ it "should have shipped_at field to nil when not shipped" do
+ subscription = Factory.create(:paid_subscription)
+ issue = Factory.create(:issue, :magazine => subscription.magazine)
+ issue.shipped_at.should be_nil
+ end
+
+ it "should have shipped_at field not nil when shipped" do
+ subscription = Factory.create(:paid_subscription)
+ issue = Factory.create(:issue, :magazine => subscription.magazine)
+ expect{ issue.ship! }.to change{issue.shipped_at}
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.