Add initial forum tests

This commit is contained in:
Chris Blanchard 2015-08-20 15:48:19 +01:00
parent 8285f15587
commit 9fa1092ab9
2 changed files with 35 additions and 0 deletions

6
spec/factories/forum.rb Normal file
View file

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :forum do
sequence(:title) { |n| "Forum Title #{n}" }
sequence(:description) { |n| "Forum Description #{n}" }
end
end

29
spec/models/forum_spec.rb Normal file
View file

@ -0,0 +1,29 @@
# == Schema Information
#
# Table name: forums
#
# id :integer not null, primary key
# title :string(255)
# description :string(255)
# category_id :integer
# created_at :datetime
# updated_at :datetime
# position :integer
#
require "spec_helper"
describe Forum do
let!(:user) { create :user }
describe "create" do
let(:forum) { build :forum }
it "creates a new forum" do
expect(forum.valid?).to eq(true)
expect do
forum.save!
end.to change(Forum, :count).by(1)
end
end
end