Skip to content
Browse files

Now showing actual number of interested parties

  • Loading branch information...
1 parent 35dc0c4 commit 3316164ea353142bef94b69044302bed246ce0cb @coreyhaines committed Oct 28, 2011
View
2 app/controllers/status_controller.rb
@@ -1,5 +1,5 @@
class StatusController < ApplicationController
def index
+ @total_addresses_collected = InterestedParty.total_collected
end
-
end
View
5 app/models/interested_party.rb
@@ -0,0 +1,5 @@
+class InterestedParty < ActiveRecord::Base
+ def self.total_collected
+ count
+ end
+end
View
2 app/views/status/index.html.haml
@@ -1,4 +1,4 @@
%h1 Email Results
-%p 0 email addresses collected
+%p #{@total_addresses_collected} email addresses collected
View
9 db/migrate/20111028083055_create_interested_parties.rb
@@ -0,0 +1,9 @@
+class CreateInterestedParties < ActiveRecord::Migration
+ def change
+ create_table :interested_parties do |t|
+ t.string :email_address
+
+ t.timestamps
+ end
+ end
+end
View
22 db/schema.rb
@@ -0,0 +1,22 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20111028083055) do
+
+ create_table "interested_parties", :force => true do |t|
+ t.string "email_address"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
View
5 features/status_results/viewing_email_counts.feature
@@ -8,3 +8,8 @@ Feature: Viewing the emails collected
Given nobody has given me their email address
When I go to see my collected results
Then I should see 0 email addresses collected
+
+ Scenario: Somebody is interested
+ Given somebody has given me their email address
+ When I go to see my collected results
+ Then I should see 1 email address collected
View
8 features/step_definitions/status_page_steps.rb
@@ -1,11 +1,15 @@
Given /^nobody has given me their email address$/ do
end
+Given /^somebody has given me their email address$/ do
+ InterestedParty.create email_address: "foo@example.com"
+end
+
When /^I go to see my collected results$/ do
visit '/status'
end
-Then /^I should see (\d+) email addresses collected$/ do |arg1|
- page.should have_content("0 email addresses collected")
+Then /^I should see (\d+) email address(?:es)? collected$/ do |count|
+ page.should have_content("#{count} email addresses collected")
end
View
8 spec/controllers/status_controller_spec.rb
@@ -3,10 +3,10 @@
describe StatusController do
describe "GET 'index'" do
- it "returns http success" do
- get 'index'
- response.should be_success
+ it "provides the number of email addresses collected" do
+ InterestedParty.stub(:total_collected) { 5 }
+ get :index
+ assigns[:total_addresses_collected].should == 5
end
end
-
end
View
13 spec/models/interested_party_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe InterestedParty do
+ describe ".total_collected" do
+ it "returns the number of interested parties" do
+ 10.times do |index|
+ InterestedParty.create email_address: "party#{index}@example.com"
+ end
+
+ InterestedParty.total_collected.should == 10
+ end
+ end
+end

0 comments on commit 3316164

Please sign in to comment.
Something went wrong with that request. Please try again.