Skip to content

Commit

Permalink
Moved the belongs_to integration test to a cucumber feature
Browse files Browse the repository at this point in the history
  • Loading branch information
gregbell committed Dec 24, 2011
1 parent a0d5828 commit 6a4efe3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 42 deletions.
27 changes: 27 additions & 0 deletions features/belongs_to.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Feature: Belongs To

A resource belongs to another resource

Background:
Given a configuration of:
"""
ActiveAdmin.register User
ActiveAdmin.register Post do
belongs_to :user
end
"""
And I am logged in
And a post with the title "Hello World" written by "John Doe" exists
And a post with the title "Hello World" written by "Jane Doe" exists

Scenario: Viewing the child resource index page
When I go to the last author's posts
Then the "Users" tab should be selected
And I should see "Displaying 1 Post"
And I should see a link to "Users" in the breadcrumb

Scenario: Viewing a child resource page
When I go to the last author's posts
And I follow "View"
Then I should be on the last author's last post page
And the "Users" tab should be selected
5 changes: 5 additions & 0 deletions features/step_definitions/breadcrumb_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Then /^I should see a link to "([^"]*)" in the breadcrumb$/ do |text|
within ".breadcrumb" do
page.should have_css("a", :text => text)
end
end
7 changes: 7 additions & 0 deletions features/step_definitions/factory_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@
type = type.camelize.constantize
type.create! :first_name => first, :last_name => last, :username => name
end

Given /^I create a new post with the title "([^"]*)"$/ do |title|
click_link "Posts"
click_link "New Post"
fill_in :title, :with => title
click_button "Create Post"
end
6 changes: 6 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def path_to(page_name)
when /^the index page for (.*)$/
send(:"admin_#{$1}_path")

when /^the last author's posts$/
admin_user_posts_path(User.last)

when /^the last author's last post page$/
admin_user_post_path(User.last, Post.where(:author_id => User.last.id).last)

# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
#
Expand Down
42 changes: 0 additions & 42 deletions spec/integration/belongs_to_spec.rb

This file was deleted.

0 comments on commit 6a4efe3

Please sign in to comment.