mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Add initial tests for posts
This commit is contained in:
parent
99d2e56846
commit
af57fea633
2 changed files with 37 additions and 0 deletions
7
spec/factories/post.rb
Normal file
7
spec/factories/post.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :post do
|
||||
sequence(:text) { |n| "Post Body #{n}" }
|
||||
topic
|
||||
user
|
||||
end
|
||||
end
|
30
spec/models/post_spec.rb
Normal file
30
spec/models/post_spec.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: posts
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# text :text
|
||||
# topic_id :integer
|
||||
# user_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# text_parsed :text
|
||||
#
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe Post do
|
||||
let!(:user) { create :user }
|
||||
|
||||
describe "create" do
|
||||
let(:post) { build :post }
|
||||
|
||||
it "creates a new post" do
|
||||
# expect(post.valid?).to eq(true)
|
||||
post.topic = create :topic
|
||||
expect do
|
||||
post.save!
|
||||
end.to change(Post, :count).by(1)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue