Skip to content

Instantly share code, notes, and snippets.

@flsafe
Created February 25, 2012 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flsafe/1910150 to your computer and use it in GitHub Desktop.
Save flsafe/1910150 to your computer and use it in GitHub Desktop.
Given /^I am an authorized publisher admin$/i do
@publisher = Factory.create(:publisher)
@mp_config = Factory.create(:marketplace_config,
:url => 'localhost',
:publisher => @publisher)
@admin = Factory.create :publisher_admin
@admin.publishers << @publisher
@admin.save
visit root_path
fill_in 'marketplace_user_login', :with => @admin.login
fill_in 'marketplace_user_password', :with => 'password'
click_on 'Log In'
end
Given /^There are some claimed and non\-claimed businesses in my account$/i do
@businesses = []
(0..4).each{ |i|
@businesses[i] = Factory.create(:business)
@businesses[i].publishers << @publisher
@businesses[i].save
}
(0..2).each{ |i|
@businesses[i].claimed = true;
@businesses[i].save
}
@businesses[0].listings[0].update(:featured_level => 2)
end
When /^I attempt to download a CSV of my businesses$/ do
visit path_to "business list"
click_on 'Download CSV'
end
Then /^I should get a CSV of all the claimed businesses in my account$/ do
page.response_headers['Content-Type'].should include 'text/csv'
@csv_rows = CSV.parse(page.source)
@csv_rows.count.should be >= @publisher.businesses.count(:claimed => true)
end
Then /^the CSV should contain all the data I need to use in external systems$/ do
pending "Need to add the 'contact_email' field before this step will be complete"
@fields = @csv_rows[0].map{|i| i.downcase}
@fields.should include 'directory level', 'business name', 'address', 'city', 'zip code', 'phone number', 'website', 'contact name', 'contact email', 'category', 'subcategory'
end
Feature: Export business data to a CSV
In order to use business data with external systems and databases
As a Publisher/Admin
I want to be able to download a CSV of all claimed and featured businesses
Background:
Given I am an authorized publisher admin
And there are some claimed and non-claimed businesses in my account
Scenario: Downloading the CSV file
When I attempt to download a CSV of my businesses
Then I should get a CSV of all the claimed businesses in my account
And the CSV should contain all the data I need to use in external systems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment