summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorSabba Petri <sabbap@gmail.com>2015-02-24 09:55:25 -0800
committerSabba Petri <sabbap@gmail.com>2015-02-24 09:55:25 -0800
commita33e615b471f8c9b49b1a1baf79f7380ce606790 (patch)
tree13e90fbb81aa60d8a2ee5540742d40d9438b0b99 /spec/models
parent846f83177448832bd04ea0167b34541b5d3b71c6 (diff)
parent428df28cda4b31a70d908e612bbad627b32c3426 (diff)
downloadgitlab-ce-a33e615b471f8c9b49b1a1baf79f7380ce606790.tar.gz
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq into small_profile_changes
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_services/gitlab_issue_tracker_service_spec.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
new file mode 100644
index 00000000000..c474f4a2d95
--- /dev/null
+++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
@@ -0,0 +1,60 @@
+# == Schema Information
+#
+# Table name: services
+#
+# id :integer not null, primary key
+# type :string(255)
+# title :string(255)
+# project_id :integer
+# created_at :datetime
+# updated_at :datetime
+# active :boolean default(FALSE), not null
+# properties :text
+# template :boolean default(FALSE)
+#
+require 'spec_helper'
+
+describe GitlabIssueTrackerService do
+ describe "Associations" do
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
+ end
+
+
+ describe 'project and issue urls' do
+ let(:project) { create(:project) }
+
+ context 'with absolute urls' do
+ before do
+ @service = project.create_gitlab_issue_tracker_service(active: true)
+ end
+
+ after do
+ @service.destroy!
+ end
+
+ it 'should give the correct path' do
+ expect(@service.project_url).to eq("/#{project.path_with_namespace}/issues")
+ expect(@service.new_issue_url).to eq("/#{project.path_with_namespace}/issues/new")
+ expect(@service.issue_url(432)).to eq("/#{project.path_with_namespace}/issues/432")
+ end
+ end
+
+ context 'with enabled relative urls' do
+ before do
+ Settings.gitlab.stub(:relative_url_root).and_return("/gitlab/root")
+ @service = project.create_gitlab_issue_tracker_service(active: true)
+ end
+
+ after do
+ @service.destroy!
+ end
+
+ it 'should give the correct path' do
+ expect(@service.project_url).to eq("/gitlab/root/#{project.path_with_namespace}/issues")
+ expect(@service.new_issue_url).to eq("/gitlab/root/#{project.path_with_namespace}/issues/new")
+ expect(@service.issue_url(432)).to eq("/gitlab/root/#{project.path_with_namespace}/issues/432")
+ end
+ end
+ end
+end