diff --git a/ruby/lib/jam_ruby/models/email_batch.rb b/ruby/lib/jam_ruby/models/email_batch.rb index 104eae30f..f7ca64ddc 100644 --- a/ruby/lib/jam_ruby/models/email_batch.rb +++ b/ruby/lib/jam_ruby/models/email_batch.rb @@ -21,13 +21,13 @@ module JamRuby event :enable do transitions :from => :disabled, :to => :pending end - event :do_test_run, :after => :running_tests do + event :do_test_run, :before => :running_tests do transitions :from => [:pending, :tested, :batched], :to => :testing end event :did_test_run do transitions :from => :testing, :to => :tested end - event :do_batch_run, :after => Proc.new { running_batch } do + event :do_batch_run, :before => :running_batch do transitions :from => [:tested, :pending, :batched], :to => :batching end event :did_batch_run do @@ -51,6 +51,10 @@ module JamRuby BatchMailer.send_batch_email(self.id, user_ids).deliver end end + + def test_count + self.test_emails.split(',').count + end def test_users self.test_emails.split(',').collect do |ee| diff --git a/ruby/spec/mailers/batch_mailer_spec.rb b/ruby/spec/mailers/batch_mailer_spec.rb index f7b1349b8..fda7ed191 100644 --- a/ruby/spec/mailers/batch_mailer_spec.rb +++ b/ruby/spec/mailers/batch_mailer_spec.rb @@ -16,6 +16,10 @@ describe BatchMailer do it { mail.multipart?.should == true } # because we send plain + html it { mail.text_part.decode_body.should match(/#{Regexp.escape(batch.body)}/) } + + it { batch.testing?.should == true } + binding.pry + it { batch.qualified_count.should == batch.test_count } end end