Skip to content

Instantly share code, notes, and snippets.

@mwise
Created April 25, 2012 14:22
Show Gist options
  • Save mwise/2490046 to your computer and use it in GitHub Desktop.
Save mwise/2490046 to your computer and use it in GitHub Desktop.
describe "Answer.for_parent_slug" do
before(:each) do
site = Factory(:site)
@page = Factory(:page)
@page2 = Factory(:page)
@answer = Factory(:answer, :parent_slug => @page.slug, :question => "Question 1", :site_id => site.id)
@answer2 = Factory(:answer, :parent_slug => @page2.slug, :question => "Question 2", :site_id => site.id)
end
it "should not include any answer without given parent_slug" do
Answer.for_parent_slug(@page.slug).should_not include(@answer2)
end
it "should include any answer that has the given parent_slug" do
Answer.for_parent_slug(@page.slug).should include(@answer)
end
end
describe "answer for specified slug" do
before(:each) do
site = Factory(:site)
@page = Factory(:page)
@page2 = Factory(:page)
answer = Factory(:answer, :parent_slug => @page.slug, :question => "Question 1", :site_id => site.id)
answer2 = Factory(:answer, :parent_slug => @page2.slug, :question => "Question 2", :site_id => site.id)
end
it "should not show answer for other pages" do
@answer = Answer.for_parent_slug(@page.slug)
@answer.first.question.should_not include("Question 2")
end
it "should show answer for requested page" do
@answer = Answer.for_parent_slug(@page.slug)
@answer.first.question.should include( "Question 1" )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment