summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAndrew8xx8 <avk@8xx8.ru>2013-02-11 15:41:12 +0400
committerAndrew8xx8 <avk@8xx8.ru>2013-02-28 16:10:00 +0400
commit68a7ecdaaf0959d5087d08ef3c94bb201e6dd166 (patch)
treed7f8c3cdc2e92d0d9d7bf4243d83aa7aac1fb2cd /spec
parent999fc2391b012a9de66ad089a3c3eafe8c8b02d8 (diff)
downloadgitlab-ce-68a7ecdaaf0959d5087d08ef3c94bb201e6dd166.tar.gz
Project issue tracker functions refactored
Diffstat (limited to 'spec')
-rw-r--r--spec/factories.rb4
-rw-r--r--spec/lib/issues_tracker_spec.rb16
-rw-r--r--spec/models/project_spec.rb33
3 files changed, 37 insertions, 16 deletions
diff --git a/spec/factories.rb b/spec/factories.rb
index b81984b5d53..b846f0a4325 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -29,6 +29,10 @@ FactoryGirl.define do
creator
end
+ factory :redmine_project, parent: :project do
+ issues_tracker { "redmine" }
+ end
+
factory :group do
sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') }
diff --git a/spec/lib/issues_tracker_spec.rb b/spec/lib/issues_tracker_spec.rb
deleted file mode 100644
index f0bbd8839ad..00000000000
--- a/spec/lib/issues_tracker_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'spec_helper'
-
-describe IssuesTracker do
- let(:project) { double('project') }
-
- before do
- @project = project
- project.stub(repository: stub(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']))
- project.stub(path_with_namespace: 'gitlab/gitlab-ci')
- end
-
- it 'returns url for issue' do
- ololo
- end
-end
-
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 48432eac147..c5603f52f6a 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -190,4 +190,37 @@ 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
+
end