Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing multiple emails when emails haven't been sent in a while :), g…

…etting cucumber and rspec tests running again
  • Loading branch information...
commit bcd2edafbdb1fe753e9f40aab10968191cce0398 1 parent 94f6722
@winton authored
View
2  Rakefile
@@ -2,7 +2,7 @@ require 'rubygems'
gems = [
[ 'active_wrapper', '=0.2.3' ],
- [ 'cucumber', '=0.4.4' ],
+ [ 'cucumber', '=0.6.1' ],
[ 'rspec', '=1.2.9' ]
]
View
2  gemspec.rb
@@ -23,7 +23,7 @@
# == CONFIGURE ==
s.add_dependency('active_wrapper', '=0.2.3')
s.add_dependency('email_spec', '=0.3.5')
- s.add_dependency('cucumber', '=0.4.4')
+ s.add_dependency('cucumber', '=0.6.1')
s.add_dependency('haml', '=2.2.14')
s.add_dependency('less', '=1.2.17')
s.add_dependency('whenever', '=0.4.0')
View
2  lib/sum/boot.rb
@@ -18,7 +18,7 @@
:stdout => environment != :test
)
$db.establish_connection
- if $mail.config
+ if environment == :production
ActionMailer::Base.raise_delivery_errors = true
imap = { :receiver => IncomingMail, :type => :imap }
$mail.config[:imap].merge!(imap)
View
2  lib/sum/model/incoming_mail.rb
@@ -2,7 +2,7 @@ class IncomingMail < ActionMailer::Base
class <<self
def process!
- if $mail.config
+ unless $testing
Fetcher.create($mail.config[:imap]).fetch
end
end
View
8 lib/sum/model/user.rb
@@ -285,12 +285,16 @@ def two_decimals(amount)
end
def update_reset_at
- self.reset_at = self.reset_at + 1.month
+ while Time.now.utc >= self.reset_at.utc
+ self.reset_at = self.reset_at + 1.month
+ end
end
def update_send_at
if self.send_at
- self.send_at = self.send_at + 1.day
+ while Time.now.utc >= self.send_at.utc
+ self.send_at = self.send_at + 1.day
+ end
else
self.send_at = local_12am_to_server_time
end
View
14 spec/sum/model/user_spec.rb
@@ -52,7 +52,7 @@
before(:all) do
@user = create_valid_user
@user.spend!(1500.53)
- @old_reset_at = @user.reset_at
+ @old_reset_at = @user.reset_at -= 1.month
@user.reset!
end
@@ -67,6 +67,12 @@
it "should add a month to reset_at" do
@user.reset_at.should == @old_reset_at + 1.month
end
+
+ it "should fix a reset_at that is too old" do
+ @user.reset_at -= 2.months
+ @user.reset!
+ @user.reset_at.should > Time.now
+ end
end
describe "reset_spent_today!" do
@@ -97,6 +103,12 @@
it "should add one day to send_at" do
@user.send_at.should == @old_send_at + 1.day
end
+
+ it "should fix a send_at that is too old" do
+ @user.send_at -= 2.days
+ @user.sent!
+ @user.send_at.should > Time.now
+ end
end
describe "spend!" do
Please sign in to comment.
Something went wrong with that request. Please try again.