Skip to content

Commit

Permalink
added passing cucumber tests for search (available in 'Images', 'File…
Browse files Browse the repository at this point in the history
…s', 'Inquiries' and 'Pages')
  • Loading branch information
ugisozols committed Aug 2, 2010
1 parent d311e04 commit abfad38
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
37 changes: 37 additions & 0 deletions features/refinery/search.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Feature: Search
In order find content more quickly
As an administrator
I want to use search

Background:
Given I am a logged in refinery user

Scenario Outline: Search Existing Item
Given I have test <item> titled "<title>"
When I go to the list of <location>
And I fill in "search" with "<title>"
And I press "Search"
Then I should see "<title>"

Examples:
| item | title | location |
|page |testitem|pages |
|image |testitem|images |
|file |testitem|files |
|inquiry |testitem|inquiries |
|inquiry |testitem|spam inquiries|

Scenario Outline: Search Nonexisting Item
Given I have no <item>
When I go to the list of <location>
And I fill in "search" with "nonexisting"
And I press "Search"
Then I should see "Sorry, no results found"

Examples:
| item | location |
|pages |pages |
|images |images |
|files |files |
|inquiries|inquiries |
|inquiries|spam inquiries|
4 changes: 4 additions & 0 deletions features/step_definitions/refinery/file_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Resource.delete_all
end

Given /^I have test file titled "([^"]*)"$/ do |file_name|
Resource.create(:content_type => 'application/x-debian-package', :filename => file_name, :size => 5000)
end

When /^I attach the file at "([^"]*)"$/ do |file_path|
attach_file('resource[uploaded_data]', File.join(Rails.root, file_path))
end
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/refinery/image_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Image.delete_all
end

Given /^I have test image titled "([^"]*)"$/ do |file_name|
Image.create(:content_type => 'image/jpeg', :filename => file_name, :size => 5000)
end

When /^I attach the image at "([^"]*)"$/ do |file_path|
attach_file('image[uploaded_data]', File.join(Rails.root, file_path))
end
Expand Down
12 changes: 12 additions & 0 deletions features/step_definitions/refinery/inquiry_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@
:email => email,
:message => message)
end

Given /^I have test inquiry titled "([^"]*)"$/ do |title|
Inquiry.create(:name => title,
:email => 'test@cukes.com',
:message => 'cuking ...',
:spam => false)

Inquiry.create(:name => title,
:email => 'test@cukes.com',
:message => 'cuking ...',
:spam => true)
end
4 changes: 4 additions & 0 deletions features/step_definitions/refinery/page_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
Page.delete_all
end

Given /^I have test page titled "([^"]*)"$/ do |title|
Page.create(:title => title)
end

Then /^I should have ([0-9]+) pages?$/ do |count|
Page.count.should == count.to_i
end
Expand Down
3 changes: 3 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def path_to(page_name)
when /the list of inquiries/
admin_inquiries_path

when /the list of spam inquiries/
spam_admin_inquiries_path

when /the (d|D)ashboard/
admin_dashboard_index_path

Expand Down

0 comments on commit abfad38

Please sign in to comment.