Permalink
Browse files

Includes InterestedParties' email addresses in CSV

  • Loading branch information...
1 parent e60faa5 commit 0f885aa08afb4017666bb7980c828b9502f095eb @coreyhaines committed Oct 28, 2011
@@ -1,5 +1,12 @@
module LaunchApp
class CreatesInterestedPartiesCSV
+ def self.for_all
+ ([header_line] + InterestedParty.all.map(&:email_address)).join("\n")
+ end
+
+ def self.header_line
+ "email_address"
+ end
end
end
@@ -0,0 +1,33 @@
+require 'creates_interested_parties_csv'
+class InterestedParty
+end
+
+describe LaunchApp::CreatesInterestedPartiesCSV do
+ describe ".header_line" do
+ it "is just the email_address" do
+ LaunchApp::CreatesInterestedPartiesCSV.header_line.should == "email_address"
+ end
+ end
+
+ describe ".for_all" do
+ before do
+ InterestedParty.stub(:all) { interested_parties }
+ end
+
+ context "with no interested parties" do
+ let(:interested_parties) { [] }
+ it "returns just the headers" do
+ LaunchApp::CreatesInterestedPartiesCSV.for_all.should == LaunchApp::CreatesInterestedPartiesCSV.header_line
+ end
+ end
+
+ context "with a single interested party" do
+ let(:address) { "qux@example.com" }
+ let(:interested_parties) { [stub(email_address: address)] }
+ it "includes their email address" do
+ InterestedParty.stub(:all) { interested_parties }
+ LaunchApp::CreatesInterestedPartiesCSV.for_all.split("\n")[1].should == address
+ end
+ end
+ end
+end

0 comments on commit 0f885aa

Please sign in to comment.