Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Downloading csv of interested parties configured

  • Loading branch information...
commit a8f9652f602843be126170bffac88bd7e930f9de 1 parent dd45740
@coreyhaines authored
View
1  Gemfile
@@ -17,6 +17,7 @@ group :development, :test do
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'spork'
+ gem 'launchy'
end
# Gems used only for assets and not required
View
4 Gemfile.lock
@@ -29,6 +29,7 @@ GEM
activesupport (= 3.1.1)
activesupport (3.1.1)
multi_json (~> 1.0)
+ addressable (2.2.6)
arel (2.2.1)
builder (3.0.0)
capybara (1.1.1)
@@ -73,6 +74,8 @@ GEM
thor (~> 0.14)
json (1.6.1)
json_pure (1.6.1)
+ launchy (2.0.5)
+ addressable (~> 2.2.6)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -163,6 +166,7 @@ DEPENDENCIES
database_cleaner
haml
jquery-rails
+ launchy
rails (= 3.1.1)
rspec
rspec-rails
View
5 app/controllers/status_controller.rb
@@ -1,5 +1,10 @@
class StatusController < ApplicationController
def index
@total_addresses_collected = InterestedParty.total_collected
+
+ respond_to do |format|
+ format.html
+ format.csv { send_data "email_address", type: "text/csv", filename: "foo.csv", }
+ end
end
end
View
2  app/views/status/index.html.haml
@@ -2,3 +2,5 @@
%p #{@total_addresses_collected} email addresses collected
+%p=link_to "Download", status_url(format: :csv)
+
View
2  config/cucumber.yml
@@ -1,7 +1,7 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
-std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
+std_opts = "-r features --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
View
2  config/routes.rb
@@ -1,6 +1,4 @@
Launchapp::Application.routes.draw do
- get "status/index"
-
get '/status' => "status#index"
# The priority is based upon order of creation:
View
10 features/status_results/downloading_interested_party_details.feature
@@ -0,0 +1,10 @@
+Feature: Downloading details about interested parties
+ In order to spam people about my new awesome product
+ As an entrepreneur
+ I want to download details about interested parties
+
+ Scenario: Nobody is interested
+ Given nobody has given me their email address
+ When I download the interested party details as csv
+ Then I should have an empty csv
+
View
13 features/step_definitions/status_page_steps.rb
@@ -9,7 +9,20 @@
visit '/status'
end
+When /^I download the interested party details as csv$/ do
+ visit '/status'
+ click_link 'Download'
+end
+
Then /^I should see (\d+) email address(?:es)? collected$/ do |count|
page.should have_content("#{count} email addresses collected")
end
+Then /^I should have an empty csv$/ do
+ # expected_lines = expected_csv.split("\n").map(&:strip)
+ page.response_headers['Content-Type'].should == "text/csv"
+ actual_lines = page.text.split("\n")
+ actual_lines.length.should == 1
+ actual_lines.should == ["email_address"]
+end
+
View
8 spec/controllers/status_controller_spec.rb
@@ -8,5 +8,13 @@
get :index
assigns[:total_addresses_collected].should == 5
end
+
+ context "as a csv file" do
+ it "supports it" do
+ get :index, format: :csv
+ response.should be_success
+ response.content_type.should == 'text/csv'
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.