Commit 8773f339 authored by Robert Speicher's avatar Robert Speicher

Minor model spec cleanups

Snippet model was missing project association
parent c0faf91f
...@@ -24,7 +24,8 @@ class Snippet < ActiveRecord::Base ...@@ -24,7 +24,8 @@ class Snippet < ActiveRecord::Base
default_value_for :visibility_level, Snippet::PRIVATE default_value_for :visibility_level, Snippet::PRIVATE
belongs_to :author, class_name: "User" belongs_to :author, class_name: 'User'
belongs_to :project
has_many :notes, as: :noteable, dependent: :destroy has_many :notes, as: :noteable, dependent: :destroy
......
...@@ -60,11 +60,8 @@ describe Issue do ...@@ -60,11 +60,8 @@ describe Issue do
describe '#is_being_reassigned?' do describe '#is_being_reassigned?' do
it 'returns issues assigned to user' do it 'returns issues assigned to user' do
user = create :user user = create(:user)
create_list(:issue, 2, assignee: user)
2.times do
issue = create :issue, assignee: user
end
expect(Issue.open_for(user).count).to eq 2 expect(Issue.open_for(user).count).to eq 2
end end
......
...@@ -26,6 +26,13 @@ require 'spec_helper' ...@@ -26,6 +26,13 @@ require 'spec_helper'
describe MergeRequest do describe MergeRequest do
subject { create(:merge_request) } subject { create(:merge_request) }
describe 'associations' do
it { is_expected.to belong_to(:target_project).with_foreign_key(:target_project_id).class_name('Project') }
it { is_expected.to belong_to(:source_project).with_foreign_key(:source_project_id).class_name('Project') }
it { is_expected.to have_one(:merge_request_diff).dependent(:destroy) }
end
describe 'modules' do describe 'modules' do
subject { described_class } subject { described_class }
...@@ -36,22 +43,12 @@ describe MergeRequest do ...@@ -36,22 +43,12 @@ describe MergeRequest do
it { is_expected.to include_module(Taskable) } it { is_expected.to include_module(Taskable) }
end end
describe 'associations' do
it { is_expected.to belong_to(:target_project).with_foreign_key(:target_project_id).class_name('Project') }
it { is_expected.to belong_to(:source_project).with_foreign_key(:source_project_id).class_name('Project') }
it { is_expected.to have_one(:merge_request_diff).dependent(:destroy) }
end
describe 'validation' do describe 'validation' do
it { is_expected.to validate_presence_of(:target_branch) } it { is_expected.to validate_presence_of(:target_branch) }
it { is_expected.to validate_presence_of(:source_branch) } it { is_expected.to validate_presence_of(:source_branch) }
end end
describe "Mass assignment" do describe 'respond to' do
end
describe "Respond to" do
it { is_expected.to respond_to(:unchecked?) } it { is_expected.to respond_to(:unchecked?) }
it { is_expected.to respond_to(:can_be_merged?) } it { is_expected.to respond_to(:can_be_merged?) }
it { is_expected.to respond_to(:cannot_be_merged?) } it { is_expected.to respond_to(:cannot_be_merged?) }
...@@ -83,8 +80,6 @@ describe MergeRequest do ...@@ -83,8 +80,6 @@ describe MergeRequest do
end end
end end
subject { create(:merge_request) }
describe '#is_being_reassigned?' do describe '#is_being_reassigned?' do
it 'returns true if the merge_request assignee has changed' do it 'returns true if the merge_request assignee has changed' do
subject.assignee = create(:user) subject.assignee = create(:user)
......
...@@ -30,22 +30,22 @@ describe Snippet do ...@@ -30,22 +30,22 @@ describe Snippet do
describe 'associations' do describe 'associations' do
it { is_expected.to belong_to(:author).class_name('User') } it { is_expected.to belong_to(:author).class_name('User') }
it { is_expected.to belong_to(:project) }
it { is_expected.to have_many(:notes).dependent(:destroy) } it { is_expected.to have_many(:notes).dependent(:destroy) }
end end
describe "Mass assignment" do describe 'validation' do
end
describe "Validation" do
it { is_expected.to validate_presence_of(:author) } it { is_expected.to validate_presence_of(:author) }
it { is_expected.to validate_presence_of(:title) } it { is_expected.to validate_presence_of(:title) }
it { is_expected.to ensure_length_of(:title).is_within(0..255) } it { is_expected.to ensure_length_of(:title).is_within(0..255) }
it { is_expected.to validate_presence_of(:file_name) } it { is_expected.to validate_presence_of(:file_name) }
it { is_expected.to ensure_length_of(:title).is_within(0..255) } it { is_expected.to ensure_length_of(:file_name).is_within(0..255) }
it { is_expected.to validate_presence_of(:content) } it { is_expected.to validate_presence_of(:content) }
it { is_expected.to validate_inclusion_of(:visibility_level).in_array(Gitlab::VisibilityLevel.values) }
end end
describe '#to_reference' do describe '#to_reference' do
......
...@@ -89,9 +89,6 @@ describe User do ...@@ -89,9 +89,6 @@ describe User do
it { is_expected.to have_many(:identities).dependent(:destroy) } it { is_expected.to have_many(:identities).dependent(:destroy) }
end end
describe "Mass assignment" do
end
describe 'validations' do describe 'validations' do
it { is_expected.to validate_presence_of(:username) } it { is_expected.to validate_presence_of(:username) }
it { is_expected.to validate_presence_of(:projects_limit) } it { is_expected.to validate_presence_of(:projects_limit) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment