Merge branch 'master' into fixes/api
Conflicts: lib/api/projects.rb
This commit is contained in:
commit
61cfa2a7a6
146 changed files with 1562 additions and 859 deletions
|
@ -29,6 +29,11 @@ FactoryGirl.define do
|
|||
creator
|
||||
end
|
||||
|
||||
factory :redmine_project, parent: :project do
|
||||
issues_tracker { "redmine" }
|
||||
issues_tracker_id { "project_name_in_redmine" }
|
||||
end
|
||||
|
||||
factory :group do
|
||||
sequence(:name) { |n| "group#{n}" }
|
||||
path { name.downcase.gsub(/\s/, '_') }
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :user_team do
|
||||
sequence(:name) { |n| "team#{n}" }
|
||||
sequence(:description) { |n| "team_description#{n}" }
|
||||
path { name.downcase.gsub(/\s/, '_') }
|
||||
owner
|
||||
end
|
||||
|
|
|
@ -55,8 +55,8 @@ describe "Admin::Users" do
|
|||
user = User.last
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
email.subject.should have_content("Account was created")
|
||||
email.body.should have_content(user.email)
|
||||
email.body.should have_content(@password)
|
||||
email.text_part.body.should have_content(user.email)
|
||||
email.text_part.body.should have_content(@password)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,8 +67,8 @@ describe "Admin::Users" do
|
|||
user = User.last
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
email.subject.should have_content("Account was created")
|
||||
email.body.should have_content(user.email)
|
||||
email.body.should_not have_content(@password)
|
||||
email.text_part.body.should have_content(user.email)
|
||||
email.text_part.body.should_not have_content(@password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ require "spec_helper"
|
|||
|
||||
describe GitlabMarkdownHelper do
|
||||
include ApplicationHelper
|
||||
include IssuesHelper
|
||||
|
||||
let!(:project) { create(:project) }
|
||||
|
||||
|
|
79
spec/helpers/issues_helper_spec.rb
Normal file
79
spec/helpers/issues_helper_spec.rb
Normal file
|
@ -0,0 +1,79 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe IssuesHelper do
|
||||
let(:project) { create :project }
|
||||
let(:issue) { create :issue, project: project }
|
||||
let(:ext_project) { create :redmine_project }
|
||||
|
||||
describe :title_for_issue do
|
||||
it "should return issue title if used internal tracker" do
|
||||
@project = project
|
||||
title_for_issue(issue.id).should eq issue.title
|
||||
end
|
||||
|
||||
it "should always return empty string if used external tracker" do
|
||||
@project = ext_project
|
||||
title_for_issue(rand(100)).should eq ""
|
||||
end
|
||||
|
||||
it "should always return empty string if project nil" do
|
||||
@project = nil
|
||||
|
||||
title_for_issue(rand(100)).should eq ""
|
||||
end
|
||||
end
|
||||
|
||||
describe :url_for_project_issues do
|
||||
let(:project_url) { Gitlab.config.issues_tracker.redmine.project_url}
|
||||
let(:ext_expected) do
|
||||
project_url.gsub(':project_id', ext_project.id.to_s)
|
||||
.gsub(':issues_tracker_id', ext_project.issues_tracker_id.to_s)
|
||||
end
|
||||
let(:int_expected) { polymorphic_path([project]) }
|
||||
|
||||
it "should return internal path if used internal tracker" do
|
||||
@project = project
|
||||
url_for_project_issues.should match(int_expected)
|
||||
end
|
||||
|
||||
it "should return path to external tracker" do
|
||||
@project = ext_project
|
||||
|
||||
url_for_project_issues.should match(ext_expected)
|
||||
end
|
||||
|
||||
it "should return empty string if project nil" do
|
||||
@project = nil
|
||||
|
||||
url_for_project_issues.should eq ""
|
||||
end
|
||||
end
|
||||
|
||||
describe :url_for_issue do
|
||||
let(:issue_id) { 3 }
|
||||
let(:issues_url) { Gitlab.config.issues_tracker.redmine.issues_url}
|
||||
let(:ext_expected) do
|
||||
issues_url.gsub(':id', issue_id.to_s)
|
||||
.gsub(':project_id', ext_project.id.to_s)
|
||||
.gsub(':issues_tracker_id', ext_project.issues_tracker_id.to_s)
|
||||
end
|
||||
let(:int_expected) { polymorphic_path([project, issue]) }
|
||||
|
||||
it "should return internal path if used internal tracker" do
|
||||
@project = project
|
||||
url_for_issue(issue.id).should match(int_expected)
|
||||
end
|
||||
|
||||
it "should return path to external tracker" do
|
||||
@project = ext_project
|
||||
|
||||
url_for_issue(issue_id).should match(ext_expected)
|
||||
end
|
||||
|
||||
it "should return empty string if project nil" do
|
||||
@project = nil
|
||||
|
||||
url_for_issue(issue.id).should eq ""
|
||||
end
|
||||
end
|
||||
end
|
|
@ -60,6 +60,7 @@ describe Project do
|
|||
it { should ensure_inclusion_of(:wall_enabled).in_array([true, false]) }
|
||||
it { should ensure_inclusion_of(:merge_requests_enabled).in_array([true, false]) }
|
||||
it { should ensure_inclusion_of(:wiki_enabled).in_array([true, false]) }
|
||||
it { should ensure_length_of(:issues_tracker_id).is_within(0..255) }
|
||||
|
||||
it "should not allow new projects beyond user limits" do
|
||||
project.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 1))
|
||||
|
@ -190,4 +191,57 @@ describe Project do
|
|||
Project.new(path: "empty").repository.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe :issue_exists? do
|
||||
let(:project) { create(:project) }
|
||||
let(:existed_issue) { create(:issue, project: project) }
|
||||
let(:not_existed_issue) { create(:issue) }
|
||||
let(:ext_project) { create(:redmine_project) }
|
||||
|
||||
it "should be true or if used internal tracker and issue exists" do
|
||||
project.issue_exists?(existed_issue.id).should be_true
|
||||
end
|
||||
|
||||
it "should be false or if used internal tracker and issue not exists" do
|
||||
project.issue_exists?(not_existed_issue.id).should be_false
|
||||
end
|
||||
|
||||
it "should always be true if used other tracker" do
|
||||
ext_project.issue_exists?(rand(100)).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe :used_default_issues_tracker? do
|
||||
let(:project) { create(:project) }
|
||||
let(:ext_project) { create(:redmine_project) }
|
||||
|
||||
it "should be true if used internal tracker" do
|
||||
project.used_default_issues_tracker?.should be_true
|
||||
end
|
||||
|
||||
it "should be false if used other tracker" do
|
||||
ext_project.used_default_issues_tracker?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe :can_have_issues_tracker_id? do
|
||||
let(:project) { create(:project) }
|
||||
let(:ext_project) { create(:redmine_project) }
|
||||
|
||||
it "should be true for projects with external issues tracker if issues enabled" do
|
||||
ext_project.can_have_issues_tracker_id?.should be_true
|
||||
end
|
||||
|
||||
it "should be false for projects with internal issue tracker if issues enabled" do
|
||||
project.can_have_issues_tracker_id?.should be_false
|
||||
end
|
||||
|
||||
it "should be always false if issues disbled" do
|
||||
project.issues_enabled = false
|
||||
ext_project.issues_enabled = false
|
||||
|
||||
project.can_have_issues_tracker_id?.should be_false
|
||||
ext_project.can_have_issues_tracker_id?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
# dark_scheme :boolean default(FALSE), not null
|
||||
# theme_id :integer default(1), not null
|
||||
# bio :string(255)
|
||||
# blocked :boolean default(FALSE), not null
|
||||
# state :string(255) default(FALSE), not null
|
||||
# failed_attempts :integer default(0)
|
||||
# locked_at :datetime
|
||||
# extern_uid :string(255)
|
||||
|
@ -140,7 +140,7 @@ describe User do
|
|||
|
||||
it "should block user" do
|
||||
user.block
|
||||
user.blocked.should be_true
|
||||
user.blocked?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -149,7 +149,7 @@ describe User do
|
|||
User.delete_all
|
||||
@user = create :user
|
||||
@admin = create :user, admin: true
|
||||
@blocked = create :user, blocked: true
|
||||
@blocked = create :user, state: :blocked
|
||||
end
|
||||
|
||||
it { User.filter("admins").should == [@admin] }
|
||||
|
|
|
@ -15,7 +15,13 @@ describe UserObserver do
|
|||
create(:user)
|
||||
end
|
||||
|
||||
it 'no email for external' do
|
||||
Notify.should_not_receive(:new_user_email)
|
||||
create(:user, extern_uid: '32442eEfsafada')
|
||||
end
|
||||
|
||||
it 'trigger logger' do
|
||||
user = double(:user, id: 42, password: 'P@ssword!', name: 'John', email: 'u@mail.local', extern_uid?: false)
|
||||
Gitlab::AppLogger.should_receive(:info)
|
||||
create(:user)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue