mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Add initial topic tests
This commit is contained in:
parent
d4acc8ea3c
commit
d9b2df06a4
2 changed files with 35 additions and 0 deletions
5
spec/factories/topic.rb
Normal file
5
spec/factories/topic.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :topic do
|
||||||
|
sequence(:title) { |n| "Forum Title #{n}" }
|
||||||
|
end
|
||||||
|
end
|
30
spec/models/topic_spec.rb
Normal file
30
spec/models/topic_spec.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: topics
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# title :string(255)
|
||||||
|
# user_id :integer
|
||||||
|
# forum_id :integer
|
||||||
|
# created_at :datetime
|
||||||
|
# updated_at :datetime
|
||||||
|
# state :integer default(0), not null
|
||||||
|
#
|
||||||
|
|
||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe Topic do
|
||||||
|
let!(:user) { create :user }
|
||||||
|
let!(:forum) { create :forum }
|
||||||
|
|
||||||
|
describe "create" do
|
||||||
|
let(:topic) { build :topic, user: user, forum: forum }
|
||||||
|
|
||||||
|
it "creates a new topic" do
|
||||||
|
topic.first_post = "Foo"
|
||||||
|
expect do
|
||||||
|
topic.save!
|
||||||
|
end.to change(Topic, :count).by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue