added forum topic/post
This commit is contained in:
4
test/factories/forum_post.rb
Normal file
4
test/factories/forum_post.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
Factory.define(:forum_post) do |f|
|
||||
f.creator {|x| x.association(:user)}
|
||||
f.body {Faker::Lorem.sentences}
|
||||
end
|
||||
6
test/factories/forum_topic.rb
Normal file
6
test/factories/forum_topic.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
Factory.define(:forum_topic) do |f|
|
||||
f.creator {|x| x.association(:user)}
|
||||
f.title {Faker::Lorem.words}
|
||||
f.is_sticky false
|
||||
f.is_locked false
|
||||
end
|
||||
11
test/fixtures/forum_posts.yml
vendored
Normal file
11
test/fixtures/forum_posts.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
11
test/fixtures/forum_topics.yml
vendored
Normal file
11
test/fixtures/forum_topics.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
13
test/unit/forum_post_test.rb
Normal file
13
test/unit/forum_post_test.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class ForumPostTest < ActiveSupport::TestCase
|
||||
context "A forum post" do
|
||||
should "update its parent when saved" do
|
||||
topic = Factory.create(:forum_topic)
|
||||
sleep 2
|
||||
post = Factory.create(:forum_post, :topic_id => topic.id)
|
||||
topic.reload
|
||||
assert(topic.updated_at > 1.second.ago)
|
||||
end
|
||||
end
|
||||
end
|
||||
4
test/unit/forum_topic_test.rb
Normal file
4
test/unit/forum_topic_test.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class ForumTopicTest < ActiveSupport::TestCase
|
||||
end
|
||||
Reference in New Issue
Block a user