Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

board-topics relation.

  • Loading branch information...
commit a142719a5254f43f2a93c45cabb8685edebf24d2 1 parent 8515886
@ruseel authored
View
2  app/models/topic.rb
@@ -3,7 +3,7 @@ class Topic < ActiveRecord::Base
belongs_to :admin
has_many :comments
- attr_accessible :body, :subject, :parent
+ attr_accessible :body, :subject, :parent, :board
before_save :set_boardish
composed_of :boardish,
View
13 test/fixtures/boards.yml
@@ -1,11 +1,12 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
- name: MyString
- acronym: MyString
- description: MyText
+ name: one
+ acronym: one
+ description: first board
two:
- name: MyString
- acronym: MyString
- description: MyText
+ name: two
+ acronym: two
+ description: first board
+
View
7 test/fixtures/topics.yml
@@ -2,4 +2,9 @@
one:
subject: fixture_one
- body: body of one
+ body: body of one
+
+topic_belongs_to_board_two:
+ subject: topic_belongs_to_board_two
+ body: some body
+ board: two
View
9 test/unit/topic_test.rb
@@ -3,6 +3,13 @@
class TopicTest < ActiveSupport::TestCase
setup do
@topic = topics(:one)
+ @board = boards(:one)
+ end
+
+ test "topic belongs to board" do
+ Topic.create(subject: @topic.subject, body: @topic.body, board: @board)
+
+ assert_equal 1, boards(:two).topics.count
end
test "create new topic without parent" do
@@ -60,6 +67,6 @@ class TopicTest < ActiveSupport::TestCase
one_two_one=Topic.create(subject: "one_two_one", body: "one_two_one", parent: one_two)
subjects = Topic.all.map(&:subject)
- assert_equal %w(two two_one one one_one one_one_one one_two one_two_one one_three fixture_one), subjects
+ assert_equal %w(two two_one one one_one one_one_one one_two one_two_one one_three topic_belongs_to_board_two fixture_one), subjects
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.