From 6e699b2e8bb86c8ceddc78a3da332bbfd683f035 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 15 Oct 2014 11:52:04 +1100 Subject: [PATCH] Mailer tests --- spec/mailers/enterprise_mailer_spec.rb | 5 ++++ spec/models/enterprise_spec.rb | 35 ++++++++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/spec/mailers/enterprise_mailer_spec.rb b/spec/mailers/enterprise_mailer_spec.rb index 412870bad7..6b53d7d561 100644 --- a/spec/mailers/enterprise_mailer_spec.rb +++ b/spec/mailers/enterprise_mailer_spec.rb @@ -10,4 +10,9 @@ describe EnterpriseMailer do EnterpriseMailer.creation_confirmation(@enterprise).deliver ActionMailer::Base.deliveries.count.should == 1 end + + it "should send an email confirmation when given an enterprise" do + EnterpriseMailer.confirmation_instructions(@enterprise, 'token').deliver + ActionMailer::Base.deliveries.count.should == 1 + end end \ No newline at end of file diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 241d1fafc7..4861157d87 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -3,6 +3,15 @@ require 'spec_helper' describe Enterprise do include AuthenticationWorkflow + describe "creation" do + it "should send a confirmation email" do + mail_message = double "Mail::Message" + EnterpriseMailer.should_receive(:confirmation_instructions).and_return mail_message + mail_message.should_receive :deliver + create(:enterprise) + end + end + describe "associations" do it { should belong_to(:owner) } it { should have_many(:supplied_products) } @@ -507,40 +516,40 @@ describe Enterprise do # Swap type values full > sell_all, single > sell_own profile > sell_none # swap is_distributor for new can_supply flag. - let(:producer_sell_all_can_supply) { + let(:producer_sell_all_can_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: true) } - let(:producer_sell_all_cant_supply) { + let(:producer_sell_all_cant_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: false) } - let(:producer_sell_own_can_supply) { + let(:producer_sell_own_can_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: true) } - let(:producer_sell_own_cant_supply) { + let(:producer_sell_own_cant_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) } - let(:producer_sell_none_can_supply) { + let(:producer_sell_none_can_supply) { create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: true) } - let(:producer_sell_none_cant_supply) { + let(:producer_sell_none_cant_supply) { create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: false) } let(:non_producer_sell_all_can_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: true) } - let(:non_producer_sell_all_cant_supply) { + let(:non_producer_sell_all_cant_supply) { create(:enterprise, is_primary_producer: true, type: "full", is_distributor: false) } - let(:non_producer_sell_own_can_supply) { + let(:non_producer_sell_own_can_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: true) } - let(:non_producer_sell_own_cant_supply) { + let(:non_producer_sell_own_cant_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) } - let(:non_producer_sell_none_can_supply) { + let(:non_producer_sell_none_can_supply) { create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: true) } - let(:non_producer_sell_none_cant_supply) { + let(:non_producer_sell_none_cant_supply) { create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: false) } @@ -555,8 +564,8 @@ describe Enterprise do producer_sell_own_cant_supply.enterprise_category.should == "producer_shop" producer_sell_none_can_supply.enterprise_category.should == "producer" producer_sell_none_cant_supply.enterprise_category.should == "producer_profile" - non_producer_sell_all_can_supply.enterprise_category.should == "hub" - non_producer_sell_all_cant_supply.enterprise_category.should == "hub" + non_producer_sell_all_can_supply.enterprise_category.should == "hub" + non_producer_sell_all_cant_supply.enterprise_category.should == "hub" non_producer_sell_own_can_supply.enterprise_category.should == "hub" non_producer_sell_own_cant_supply.enterprise_category.should == "hub" non_producer_sell_none_can_supply.enterprise_category.should == "hub_profile"