Created
April 25, 2012 14:22
-
-
Save mwise/2490046 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
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 |
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
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