summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schleifenbaum <johannes@js-webcoding.de>2013-11-01 15:33:47 +0100
committerJohannes Schleifenbaum <johannes@js-webcoding.de>2013-11-01 15:33:47 +0100
commitd9deb24f3a507933106b2c9a00a9bc73f9eee269 (patch)
tree387f1b540d7f4f86abf2368d1ffa8c34a7a3a5d4
parentc27e49e916cebf87a5dc9e6cf1669d33f7e8cd8c (diff)
downloadgitlab-ce-d9deb24f3a507933106b2c9a00a9bc73f9eee269.tar.gz
Preselect the current issue tracker with selected="selected"
The previous behavior was, that the first element of the select was preselected, thus upon saving the project, the previous selected could be overwritten.
-rw-r--r--app/helpers/projects_helper.rb4
-rw-r--r--app/views/projects/edit.html.haml2
-rw-r--r--features/project/edit_issuetracker.feature18
-rw-r--r--features/steps/project/project_issue_tracker.rb31
-rw-r--r--spec/helpers/projects_helper_spec.rb12
5 files changed, 64 insertions, 3 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 864f6c9af95..4f8615dc813 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 d13ae937be5..6ecb24fcf95 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 00000000000..b5477d3c7ab
--- /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 00000000000..a05d7a0bc37
--- /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 62f88dd522b..8156bcdd999 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -7,5 +7,17 @@ describe ProjectsHelper do
"<option value=\"redmine\">Redmine</option>\n" \
"<option value=\"gitlab\">GitLab</option>"
end
+
+ it "returns the correct issues trackers available with current tracker 'gitlab' selected" do
+ project_issues_trackers('gitlab').should ==
+ "<option value=\"redmine\">Redmine</option>\n" \
+ "<option value=\"gitlab\" selected=\"selected\">GitLab</option>"
+ end
+
+ it "returns the correct issues trackers available with current tracker 'redmine' selected" do
+ project_issues_trackers('redmine').should ==
+ "<option value=\"redmine\" selected=\"selected\">Redmine</option>\n" \
+ "<option value=\"gitlab\">GitLab</option>"
+ end
end
end