diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 864f6c9af9..4f8615dc81 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -80,7 +80,7 @@ module ProjectsHelper
@project.milestones.active.order("due_date, title ASC").all
end
- def project_issues_trackers
+ def project_issues_trackers(current_tracker = nil)
values = Project.issues_tracker.values.map do |tracker_key|
if tracker_key.to_sym == :gitlab
['GitLab', tracker_key]
@@ -89,7 +89,7 @@ module ProjectsHelper
end
end
- options_for_select(values)
+ options_for_select(values, current_tracker)
end
private
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index d13ae937be..6ecb24fcf9 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -67,7 +67,7 @@
- if Project.issues_tracker.values.count > 1
.control-group
= f.label :issues_tracker, "Issues tracker", class: 'control-label'
- .controls= f.select(:issues_tracker, project_issues_trackers, {}, { disabled: !@project.issues_enabled })
+ .controls= f.select(:issues_tracker, project_issues_trackers(@project.issues_tracker), {}, { disabled: !@project.issues_enabled })
.control-group
= f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label'
diff --git a/features/project/edit_issuetracker.feature b/features/project/edit_issuetracker.feature
new file mode 100644
index 0000000000..b5477d3c7a
--- /dev/null
+++ b/features/project/edit_issuetracker.feature
@@ -0,0 +1,18 @@
+Feature: Project Issue Tracker
+ Background:
+ Given I sign in as a user
+ And I own project "Shop"
+ And project "Shop" has issues enabled
+ And I visit project "Shop" page
+
+ Scenario: I set the issue tracker to "GitLab"
+ When I visit edit project "Shop" page
+ And change the issue tracker to "GitLab"
+ And I save project
+ Then I the project should have "GitLab" as issue tracker
+
+ Scenario: I set the issue tracker to "Redmine"
+ When I visit edit project "Shop" page
+ And change the issue tracker to "Redmine"
+ And I save project
+ Then I the project should have "Redmine" as issue tracker
\ No newline at end of file
diff --git a/features/steps/project/project_issue_tracker.rb b/features/steps/project/project_issue_tracker.rb
new file mode 100644
index 0000000000..a05d7a0bc3
--- /dev/null
+++ b/features/steps/project/project_issue_tracker.rb
@@ -0,0 +1,31 @@
+class ProjectIssueTracker < Spinach::FeatureSteps
+ include SharedAuthentication
+ include SharedProject
+ include SharedPaths
+
+ step 'project "Shop" has issues enabled' do
+ @project = Project.find_by_name "Shop"
+ @project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace)
+ @project.issues_enabled = true
+ end
+
+ step 'change the issue tracker to "GitLab"' do
+ select 'GitLab', from: 'project_issues_tracker'
+ end
+
+ step 'I the project should have "GitLab" as issue tracker' do
+ find_field('project_issues_tracker').value.should == 'gitlab'
+ end
+
+ step 'change the issue tracker to "Redmine"' do
+ select 'Redmine', from: 'project_issues_tracker'
+ end
+
+ step 'I the project should have "Redmine" as issue tracker' do
+ find_field('project_issues_tracker').value.should == 'redmine'
+ end
+
+ And 'I save project' do
+ click_button 'Save changes'
+ end
+end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 62f88dd522..8156bcdd99 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -7,5 +7,17 @@ describe ProjectsHelper do
"\n" \
""
end
+
+ it "returns the correct issues trackers available with current tracker 'gitlab' selected" do
+ project_issues_trackers('gitlab').should ==
+ "\n" \
+ ""
+ end
+
+ it "returns the correct issues trackers available with current tracker 'redmine' selected" do
+ project_issues_trackers('redmine').should ==
+ "\n" \
+ ""
+ end
end
end