Sha256: f0dea9ca91ecead5280751d189b22c6cd7ca52223b332c7acc087065a005e520

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

# == Schema Information
#
# Table name: got_fixed_issues
#
#  id         :integer          not null, primary key
#  title      :string(255)
#  closed     :boolean
#  created_at :datetime
#  updated_at :datetime
#  number     :integer
#  vendor_id  :string(255)
#  vendor     :string(255)
#

require 'spec_helper'

module GotFixed
  describe Issue do
    before(:each) do
      @issue = FactoryGirl.create :got_fixed_issue
      ActionMailer::Base.deliveries = []  # Reset email queue
    end

    it "should not send any email on issue closing if no one is registered" do
      @issue.users.should be_blank
      @issue.closed = true
      @issue.save
      ActionMailer::Base.deliveries.last.should be_nil
    end

    it "should send an email on issue closing if one is registered" do
      user = FactoryGirl.create :got_fixed_user
      @issue.users << user
      @issue.save

      @issue.closed = true
      @issue.save
      ActionMailer::Base.deliveries.last.should_not be_nil
      ActionMailer::Base.deliveries.last.to.first.should eq user.email
    end

    it "should send 10 emails if 10 people are registered" do
      10.times { @issue.users << FactoryGirl.create(:got_fixed_user) }
      @issue.save

      @issue.closed = true
      @issue.save
      ActionMailer::Base.deliveries.size.should eq 10
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
got_fixed-0.1.0 spec/models/got_fixed/issue_spec.rb
got_fixed-0.0.6 spec/models/got_fixed/issue_spec.rb
got_fixed-0.0.5 spec/models/got_fixed/issue_spec.rb
got_fixed-0.0.4 spec/models/got_fixed/issue_spec.rb
got_fixed-0.0.3 spec/models/got_fixed/issue_spec.rb
got_fixed-0.0.2 spec/models/got_fixed/issue_spec.rb
got_fixed-0.0.1 spec/models/got_fixed/issue_spec.rb