Created
November 25, 2010 18:01
-
-
Save cmrichards/715724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') | |
feature "Projects", %q{ | |
In order to allow a site to manage projects | |
As a site user | |
I want to.. | |
} do | |
background do | |
@site = create_site({:name=>"Company1"}, "username") | |
@company = @site.companies.create! :name=>"Nokia" | |
log_in_as @site.users.first | |
end | |
scenario "Create Project" do | |
visit "/jobs/index/#{@company.id}" | |
click_link "Create Project" | |
fill_in "Name", :with=>"Example Project" | |
fill_in "Description", :with=>"Example Description" | |
click_button "Save" | |
@company.jobs.where(:name=>"Example Project", :description=>"Example Description").count.should == 1 | |
end | |
scenario "Edit Project" do | |
job = @company.jobs.create! :name=>"Edit Project" | |
visit "/jobs/index/#{@company.id}" | |
within("##{job.id}") do | |
click_link "edit" | |
end | |
fill_in "Name", :with=>"New Project Name" | |
fill_in "Description", :with=>"New Description" | |
click_button "Save" | |
@company.jobs.where(:name=>"New Project Name", :description=>"New Description").count.should == 1 | |
@company.jobs.count.should == 1 | |
end | |
scenario "Filter Projects" do | |
visit "/jobs/index/#{@company.id}" | |
first_job = @company.jobs.create! :name=>"First", :created_at=>Time.parse( "1st Jan 2010 10:15" ) | |
middle_job = @company.jobs.create! :name=>"Middle", :created_at=>Time.parse("30st Jun 2010 14:50") | |
end_job = @company.jobs.create! :name=>"End", :created_at=>Time.parse( "31 Oct 2010 13:50") | |
select "January", :from=>"start_date[month]" | |
select "2010", :from=>"start_date[year]" | |
select "October", :from=>"end_date[month]" | |
select "2010", :from=>"end_date[year]" | |
click_button "Filter Projects" | |
page.should have_css("div.project", :count=>3) | |
select "February", :from=>"start_date[month]" | |
select "2010", :from=>"start_date[year]" | |
select "October", :from=>"end_date[month]" | |
select "2010", :from=>"end_date[year]" | |
click_button "Filter Projects" | |
page.should_not have_css("##{first_job.id}") | |
page.should have_css("##{middle_job.id}") | |
page.should have_css("##{end_job.id}") | |
page.should have_css("div.project", :count=>2) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment