Files
growstuff/spec/models/forum_spec.rb
Skud ec80b01c7a cleaning up tests on postgres
- still trying to make sure we explicitly use a real member, not just
assume there's one with id = 1

- also it looks like the tests for post activity are passing for obscure
reasons on sqlite when they shouldn't be. this is a known bug
(https://www.pivotaltracker.com/story/show/51280861) apparently
invisible to us under sqlite.
2013-07-08 12:18:51 +10:00

33 lines
806 B
Ruby

require 'spec_helper'
describe Forum do
before(:each) do
@forum = FactoryGirl.create(:forum)
end
it "belongs to an owner" do
@forum.owner.should be_an_instance_of Member
end
it "stringifies nicely" do
"#{@forum}".should eq @forum.name
end
it 'has a slug' do
@forum.slug.should eq 'permaculture'
end
it "has many posts" do
@post1 = FactoryGirl.create(:forum_post, :forum => @forum)
@post2 = FactoryGirl.create(:forum_post, :forum => @forum)
@forum.posts.length.should == 2
end
it "orders posts in reverse chron order" do
@post1 = FactoryGirl.create(:forum_post, :forum => @forum, :created_at => 2.days.ago)
@post2 = FactoryGirl.create(:forum_post, :forum => @forum, :created_at => 1.day.ago)
@forum.posts.first.should eq @post2
end
end