diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/forked_project_link_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 31 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 67 |
4 files changed, 104 insertions, 1 deletions
diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index 472ddf1b59d..e719e3bfcc8 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -58,7 +58,7 @@ describe :forked_from_project do end def fork_project(from_project, user) - context = Projects::ForkContext.new(from_project, user) + context = Projects::ForkService.new(from_project, user) shell = double("gitlab_shell") shell.stub(fork_repository: true) context.stub(gitlab_shell: shell) diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 55b264ce8cf..b86603dd4ac 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -180,6 +180,31 @@ describe Note do end end + describe '#create_assignee_change_note' do + let(:project) { create(:project) } + let(:thing) { create(:issue, project: project) } + let(:author) { create(:user) } + let(:assignee) { create(:user) } + + subject { Note.create_assignee_change_note(thing, project, author, assignee) } + + context 'creates and saves a Note' do + it { should be_a Note } + its(:id) { should_not be_nil } + end + + its(:noteable) { should == thing } + its(:project) { should == thing.project } + its(:author) { should == author } + its(:note) { should =~ /Reassigned to @#{assignee.username}/ } + + context 'assignee is removed' do + let(:assignee) { nil } + + its(:note) { should =~ /Assignee removed/ } + end + end + describe '#create_cross_reference_note' do let(:project) { create(:project_with_code) } let(:author) { create(:user) } @@ -252,6 +277,7 @@ describe Note do let(:issue) { create(:issue, project: project) } let(:other) { create(:issue, project: project) } let(:author) { create(:user) } + let(:assignee) { create(:user) } it 'should recognize user-supplied notes as non-system' do @note = create(:note_on_issue) @@ -267,6 +293,11 @@ describe Note do @note = Note.create_cross_reference_note(issue, other, author, project) @note.should be_system end + + it 'should identify assignee-change notes as system notes' do + @note = Note.create_assignee_change_note(issue, project, author, assignee) + @note.should be_system + end end describe :authorization do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 8aa4c7fed1a..373accfe412 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -99,6 +99,11 @@ describe Project do project.web_url.should == "#{Gitlab.config.gitlab.url}/somewhere" end + it "returns the web URL without the protocol for this repo" do + project = Project.new(path: "somewhere") + project.web_url_without_protocol.should == "#{Gitlab.config.gitlab.host}/somewhere" + end + describe "last_activity methods" do let(:project) { create(:project) } let(:last_event) { double(created_at: Time.now) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 94bd19f5900..5e53ed09b58 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -41,6 +41,8 @@ # confirmed_at :datetime # confirmation_sent_at :datetime # unconfirmed_email :string(255) +# hide_no_ssh_key :boolean default(FALSE) +# website_url :string(255) default(""), not null # require 'spec_helper' @@ -74,6 +76,27 @@ describe User do it { should_not allow_value(-1).for(:projects_limit) } it { should ensure_length_of(:bio).is_within(0..255) } + + describe 'email' do + it 'accepts info@example.com' do + user = build(:user, email: 'info@example.com') + expect(user).to be_valid + end + it 'accepts info+test@example.com' do + user = build(:user, email: 'info+test@example.com') + expect(user).to be_valid + end + + it 'rejects test@test@example.com' do + user = build(:user, email: 'test@test@example.com') + expect(user).to be_invalid + end + + it 'rejects mailto:test@example.com' do + user = build(:user, email: 'mailto:test@example.com') + expect(user).to be_invalid + end + end end describe "Respond to" do @@ -293,4 +316,48 @@ describe User do user.avatar_type.should == ["only images allowed"] end end + + describe '#full_website_url' do + let(:user) { create(:user) } + + it 'begins with http if website url omits it' do + user.website_url = 'test.com' + + expect(user.full_website_url).to eq 'http://test.com' + end + + it 'begins with http if website url begins with http' do + user.website_url = 'http://test.com' + + expect(user.full_website_url).to eq 'http://test.com' + end + + it 'begins with https if website url begins with https' do + user.website_url = 'https://test.com' + + expect(user.full_website_url).to eq 'https://test.com' + end + end + + describe '#short_website_url' do + let(:user) { create(:user) } + + it 'does not begin with http if website url omits it' do + user.website_url = 'test.com' + + expect(user.short_website_url).to eq 'test.com' + end + + it 'does not begin with http if website url begins with http' do + user.website_url = 'http://test.com' + + expect(user.short_website_url).to eq 'test.com' + end + + it 'does not begin with https if website url begins with https' do + user.website_url = 'https://test.com' + + expect(user.short_website_url).to eq 'test.com' + end + end end |