BigW Consortium Gitlab

snippet_spec.rb 988 Bytes
Newer Older
Dmitriy Zaporozhets committed
1 2 3 4
# == Schema Information
#
# Table name: snippets
#
5
#  id         :integer          not null, primary key
Dmitriy Zaporozhets committed
6
#  title      :string(255)
Dmitriy Zaporozhets committed
7
#  content    :text
8
#  author_id  :integer          not null
Dmitriy Zaporozhets committed
9
#  project_id :integer
Dmitriy Zaporozhets committed
10 11
#  created_at :datetime
#  updated_at :datetime
Dmitriy Zaporozhets committed
12 13
#  file_name  :string(255)
#  expires_at :datetime
Dmitriy Zaporozhets committed
14 15
#  private    :boolean          default(TRUE), not null
#  type       :string(255)
Dmitriy Zaporozhets committed
16 17
#

gitlabhq committed
18 19 20 21
require 'spec_helper'

describe Snippet do
  describe "Associations" do
22 23
    it { should belong_to(:author).class_name('User') }
    it { should have_many(:notes).dependent(:destroy) }
gitlabhq committed
24 25
  end

26 27 28
  describe "Mass assignment" do
  end

gitlabhq committed
29
  describe "Validation" do
Andrey Kumanyaev committed
30
    it { should validate_presence_of(:author) }
31 32 33 34

    it { should validate_presence_of(:title) }
    it { should ensure_length_of(:title).is_within(0..255) }

gitlabhq committed
35
    it { should validate_presence_of(:file_name) }
36 37
    it { should ensure_length_of(:title).is_within(0..255) }

gitlabhq committed
38 39 40
    it { should validate_presence_of(:content) }
  end
end