Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved the belongs_to integration test to a cucumber feature

  • Loading branch information...
commit 6a4efe339cf48374de50a48596936666f239104d 1 parent a0d5828
@gregbell gregbell authored
View
27 features/belongs_to.feature
@@ -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
View
5 features/step_definitions/breadcrumb_steps.rb
@@ -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
View
7 features/step_definitions/factory_steps.rb
@@ -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
View
6 features/support/paths.rb
@@ -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:
#
View
42 spec/integration/belongs_to_spec.rb
@@ -1,42 +0,0 @@
-require 'spec_helper'
-
-describe_with_capybara "Belongs To" do
-
- let(:user){ User.create(:first_name => "John", :last_name => "Doe", :username => "johndoe") }
- let(:post){ user.posts.create :title => "Hello World", :body => "woot!"}
-
- before do
- # Make sure both are created
- user
- post
- end
-
- describe "the index page" do
- before do
- visit admin_user_posts_path(user)
- end
-
- describe "the main content" do
- it "should display the default table" do
- page.should have_content(post.title)
- end
- end
-
- describe "the breadcrumb" do
- it "should have a link to the parent's index" do
- page.body.should have_tag("a", "Users", :attributes => { :href => "/admin/users" })
- end
- it "should have a link to the parent" do
- page.body.should have_tag("a", user.id.to_s, :attributes => { :href => "/admin/users/#{user.id}" })
- end
- end
-
- describe "the view links" do
- it "should take you to the sub resource" do
- click_link "View"
- current_path.should == "/admin/users/#{user.id}/posts/#{post.id}"
- end
- end
- end
-
-end
Please sign in to comment.
Something went wrong with that request. Please try again.