2012-10-09 04:14:17 -04:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: snippets
|
|
|
|
#
|
2014-10-09 11:22:20 -04:00
|
|
|
# id :integer not null, primary key
|
|
|
|
# title :string(255)
|
|
|
|
# content :text
|
|
|
|
# author_id :integer not null
|
|
|
|
# project_id :integer
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
# file_name :string(255)
|
|
|
|
# expires_at :datetime
|
|
|
|
# type :string(255)
|
|
|
|
# visibility_level :integer default(0), not null
|
2012-10-09 04:14:17 -04:00
|
|
|
#
|
|
|
|
|
2011-10-16 17:07:10 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Snippet do
|
|
|
|
describe "Associations" do
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to belong_to(:author).class_name('User') }
|
|
|
|
it { is_expected.to have_many(:notes).dependent(:destroy) }
|
2011-10-16 17:07:10 -04:00
|
|
|
end
|
|
|
|
|
2012-09-26 14:17:17 -04:00
|
|
|
describe "Mass assignment" do
|
|
|
|
end
|
|
|
|
|
2011-10-16 17:07:10 -04:00
|
|
|
describe "Validation" do
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to validate_presence_of(:author) }
|
2012-08-29 11:36:02 -04:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to validate_presence_of(:title) }
|
|
|
|
it { is_expected.to ensure_length_of(:title).is_within(0..255) }
|
2012-08-29 11:36:02 -04:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to validate_presence_of(:file_name) }
|
|
|
|
it { is_expected.to ensure_length_of(:title).is_within(0..255) }
|
2012-08-29 11:36:02 -04:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { is_expected.to validate_presence_of(:content) }
|
2011-10-16 17:07:10 -04:00
|
|
|
end
|
|
|
|
end
|