diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-03 06:14:31 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-26 22:48:30 +0300 |
commit | 8773f339a33cf31f979013cf306e5fca5fe66a89 (patch) | |
tree | 967af00c09d604fae611e383f05e02f76d5c5680 /spec | |
parent | c0faf91ff23815404a95cf4510b43dcf5e331c4f (diff) |
Minor model spec cleanups
Snippet model was missing project association
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/issue_spec.rb | 7 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 21 | ||||
-rw-r--r-- | spec/models/snippet_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 3 |
4 files changed, 15 insertions, 26 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 4e4f816a26b..614b648bb52 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -60,11 +60,8 @@ describe Issue do describe '#is_being_reassigned?' do it 'returns issues assigned to user' do - user = create :user - - 2.times do - issue = create :issue, assignee: user - end + user = create(:user) + create_list(:issue, 2, assignee: user) expect(Issue.open_for(user).count).to eq 2 end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 757d8bdfae2..57b1b9dfcf0 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -26,6 +26,13 @@ require 'spec_helper' describe MergeRequest do 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 subject { described_class } @@ -36,22 +43,12 @@ describe MergeRequest do it { is_expected.to include_module(Taskable) } 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 it { is_expected.to validate_presence_of(:target_branch) } it { is_expected.to validate_presence_of(:source_branch) } end - describe "Mass assignment" do - end - - describe "Respond to" do + describe 'respond to' do it { is_expected.to respond_to(:unchecked?) } it { is_expected.to respond_to(:can_be_merged?) } it { is_expected.to respond_to(:cannot_be_merged?) } @@ -83,8 +80,6 @@ describe MergeRequest do end end - subject { create(:merge_request) } - describe '#is_being_reassigned?' do it 'returns true if the merge_request assignee has changed' do subject.assignee = create(:user) diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 252320b798e..c81dd36ef4b 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -30,22 +30,22 @@ describe Snippet do describe 'associations' do 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) } end - describe "Mass assignment" do - end - - describe "Validation" do + describe 'validation' do it { is_expected.to validate_presence_of(:author) } it { is_expected.to validate_presence_of(:title) } 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 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_inclusion_of(:visibility_level).in_array(Gitlab::VisibilityLevel.values) } end describe '#to_reference' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 87f95f9af87..e1205c18a85 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -89,9 +89,6 @@ describe User do it { is_expected.to have_many(:identities).dependent(:destroy) } end - describe "Mass assignment" do - end - describe 'validations' do it { is_expected.to validate_presence_of(:username) } it { is_expected.to validate_presence_of(:projects_limit) } |