Commit f41731047f20ceb184b9ceb96f4174943af7736d
Exists in
master
and in
4 other branches
Merge pull request #5507 from jojosch/project-issue-tracker-selection
Preselect the current issue tracker with selected="selected"
Showing
5 changed files
with
64 additions
and
3 deletions
Show diff stats
app/helpers/projects_helper.rb
... | ... | @@ -83,7 +83,7 @@ module ProjectsHelper |
83 | 83 | @project.milestones.active.order("due_date, title ASC").all |
84 | 84 | end |
85 | 85 | |
86 | - def project_issues_trackers | |
86 | + def project_issues_trackers(current_tracker = nil) | |
87 | 87 | values = Project.issues_tracker.values.map do |tracker_key| |
88 | 88 | if tracker_key.to_sym == :gitlab |
89 | 89 | ['GitLab', tracker_key] |
... | ... | @@ -92,7 +92,7 @@ module ProjectsHelper |
92 | 92 | end |
93 | 93 | end |
94 | 94 | |
95 | - options_for_select(values) | |
95 | + options_for_select(values, current_tracker) | |
96 | 96 | end |
97 | 97 | |
98 | 98 | private | ... | ... |
app/views/projects/edit.html.haml
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | - if Project.issues_tracker.values.count > 1 |
68 | 68 | .control-group |
69 | 69 | = f.label :issues_tracker, "Issues tracker", class: 'control-label' |
70 | - .controls= f.select(:issues_tracker, project_issues_trackers, {}, { disabled: !@project.issues_enabled }) | |
70 | + .controls= f.select(:issues_tracker, project_issues_trackers(@project.issues_tracker), {}, { disabled: !@project.issues_enabled }) | |
71 | 71 | |
72 | 72 | .control-group |
73 | 73 | = f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label' | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +Feature: Project Issue Tracker | |
2 | + Background: | |
3 | + Given I sign in as a user | |
4 | + And I own project "Shop" | |
5 | + And project "Shop" has issues enabled | |
6 | + And I visit project "Shop" page | |
7 | + | |
8 | + Scenario: I set the issue tracker to "GitLab" | |
9 | + When I visit edit project "Shop" page | |
10 | + And change the issue tracker to "GitLab" | |
11 | + And I save project | |
12 | + Then I the project should have "GitLab" as issue tracker | |
13 | + | |
14 | + Scenario: I set the issue tracker to "Redmine" | |
15 | + When I visit edit project "Shop" page | |
16 | + And change the issue tracker to "Redmine" | |
17 | + And I save project | |
18 | + Then I the project should have "Redmine" as issue tracker | |
0 | 19 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +class ProjectIssueTracker < Spinach::FeatureSteps | |
2 | + include SharedAuthentication | |
3 | + include SharedProject | |
4 | + include SharedPaths | |
5 | + | |
6 | + step 'project "Shop" has issues enabled' do | |
7 | + @project = Project.find_by_name "Shop" | |
8 | + @project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace) | |
9 | + @project.issues_enabled = true | |
10 | + end | |
11 | + | |
12 | + step 'change the issue tracker to "GitLab"' do | |
13 | + select 'GitLab', from: 'project_issues_tracker' | |
14 | + end | |
15 | + | |
16 | + step 'I the project should have "GitLab" as issue tracker' do | |
17 | + find_field('project_issues_tracker').value.should == 'gitlab' | |
18 | + end | |
19 | + | |
20 | + step 'change the issue tracker to "Redmine"' do | |
21 | + select 'Redmine', from: 'project_issues_tracker' | |
22 | + end | |
23 | + | |
24 | + step 'I the project should have "Redmine" as issue tracker' do | |
25 | + find_field('project_issues_tracker').value.should == 'redmine' | |
26 | + end | |
27 | + | |
28 | + And 'I save project' do | |
29 | + click_button 'Save changes' | |
30 | + end | |
31 | +end | ... | ... |
spec/helpers/projects_helper_spec.rb
... | ... | @@ -7,5 +7,17 @@ describe ProjectsHelper do |
7 | 7 | "<option value=\"redmine\">Redmine</option>\n" \ |
8 | 8 | "<option value=\"gitlab\">GitLab</option>" |
9 | 9 | end |
10 | + | |
11 | + it "returns the correct issues trackers available with current tracker 'gitlab' selected" do | |
12 | + project_issues_trackers('gitlab').should == | |
13 | + "<option value=\"redmine\">Redmine</option>\n" \ | |
14 | + "<option value=\"gitlab\" selected=\"selected\">GitLab</option>" | |
15 | + end | |
16 | + | |
17 | + it "returns the correct issues trackers available with current tracker 'redmine' selected" do | |
18 | + project_issues_trackers('redmine').should == | |
19 | + "<option value=\"redmine\" selected=\"selected\">Redmine</option>\n" \ | |
20 | + "<option value=\"gitlab\">GitLab</option>" | |
21 | + end | |
10 | 22 | end |
11 | 23 | end | ... | ... |