Commit ef05423f47fdd970498d880cf18f282fa0205596
1 parent
10f14136
Exists in
master
and in
4 other branches
Finish select2-ajax for users. Added Select2Helper for tests
Showing
12 changed files
with
324 additions
and
290 deletions
Show diff stats
app/assets/javascripts/users_select.js.coffee
| @@ -19,7 +19,7 @@ $ -> | @@ -19,7 +19,7 @@ $ -> | ||
| 19 | multiple: $('.ajax-users-select').hasClass('multiselect') | 19 | multiple: $('.ajax-users-select').hasClass('multiselect') |
| 20 | minimumInputLength: 0 | 20 | minimumInputLength: 0 |
| 21 | ajax: # instead of writing the function to execute the request we use Select2's convenient helper | 21 | ajax: # instead of writing the function to execute the request we use Select2's convenient helper |
| 22 | - url: "/api/v3/users.json" | 22 | + url: "/api/" + gon.api_version + "/users.json" |
| 23 | dataType: "json" | 23 | dataType: "json" |
| 24 | data: (term, page) -> | 24 | data: (term, page) -> |
| 25 | search: term # search term | 25 | search: term # search term |
| @@ -33,11 +33,11 @@ $ -> | @@ -33,11 +33,11 @@ $ -> | ||
| 33 | initSelection: (element, callback) -> | 33 | initSelection: (element, callback) -> |
| 34 | id = $(element).val() | 34 | id = $(element).val() |
| 35 | if id isnt "" | 35 | if id isnt "" |
| 36 | - $.ajax("http://api.rottentomatoes.com/api/public/v1.0/users/" + id + ".json", | 36 | + $.ajax( |
| 37 | + "/api/" + gon.api_version + "/users/" + id + ".json", | ||
| 38 | + dataType: "json" | ||
| 37 | data: | 39 | data: |
| 38 | - apikey: "ju6z9mjyajq2djue3gbvv26t" | ||
| 39 | - | ||
| 40 | - dataType: "jsonp" | 40 | + private_token: gon.api_token |
| 41 | ).done (data) -> | 41 | ).done (data) -> |
| 42 | callback data | 42 | callback data |
| 43 | 43 |
app/assets/stylesheets/application.scss
| @@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
| 15 | @import "gitlab_bootstrap.scss"; | 15 | @import "gitlab_bootstrap.scss"; |
| 16 | 16 | ||
| 17 | @import "common.scss"; | 17 | @import "common.scss"; |
| 18 | -@import "ref_select.scss"; | 18 | +@import "selects.scss"; |
| 19 | 19 | ||
| 20 | @import "sections/header.scss"; | 20 | @import "sections/header.scss"; |
| 21 | @import "sections/nav.scss"; | 21 | @import "sections/nav.scss"; |
app/assets/stylesheets/common.scss
| @@ -555,17 +555,3 @@ img.emoji { | @@ -555,17 +555,3 @@ img.emoji { | ||
| 555 | display: none; | 555 | display: none; |
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | -.ajax-users-select { | ||
| 559 | - width: 400px; | ||
| 560 | -} | ||
| 561 | - | ||
| 562 | -.user-result { | ||
| 563 | - .user-image { | ||
| 564 | - float: left; | ||
| 565 | - } | ||
| 566 | - .user-name { | ||
| 567 | - } | ||
| 568 | - .user-username { | ||
| 569 | - color: #999; | ||
| 570 | - } | ||
| 571 | -} |
app/assets/stylesheets/ref_select.scss
| @@ -1,90 +0,0 @@ | @@ -1,90 +0,0 @@ | ||
| 1 | -/** Branch/tag selector **/ | ||
| 2 | -.project-refs-form { | ||
| 3 | - margin: 0; | ||
| 4 | - span { | ||
| 5 | - background:none !important; | ||
| 6 | - position:static !important; | ||
| 7 | - width:auto !important; | ||
| 8 | - height:auto !important; | ||
| 9 | - } | ||
| 10 | -} | ||
| 11 | -.project-refs-select { | ||
| 12 | - width: 120px; | ||
| 13 | -} | ||
| 14 | - | ||
| 15 | -.project-refs-form .chzn-container { | ||
| 16 | - position: relative; | ||
| 17 | - top: 0; | ||
| 18 | - left: 0; | ||
| 19 | - margin-right: 10px; | ||
| 20 | - | ||
| 21 | - .chzn-drop { | ||
| 22 | - min-width: 400px; | ||
| 23 | - .chzn-results { | ||
| 24 | - max-height: 300px; | ||
| 25 | - } | ||
| 26 | - .chzn-search input { | ||
| 27 | - min-width: 365px; | ||
| 28 | - } | ||
| 29 | - } | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | -/** Fix for Search Dropdown Border **/ | ||
| 33 | -.chzn-container { | ||
| 34 | - .chzn-search { | ||
| 35 | - input:focus { | ||
| 36 | - @include box-shadow(none); | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - .chzn-drop { | ||
| 41 | - margin: 7px 0; | ||
| 42 | - min-width: 200px; | ||
| 43 | - border: 1px solid #bbb; | ||
| 44 | - @include border-radius(0); | ||
| 45 | - | ||
| 46 | - .chzn-results { | ||
| 47 | - margin-top: 5px; | ||
| 48 | - max-height: 300px; | ||
| 49 | - | ||
| 50 | - .group-result { | ||
| 51 | - color: $style_color; | ||
| 52 | - border-bottom: 1px solid #EEE; | ||
| 53 | - padding: 8px; | ||
| 54 | - } | ||
| 55 | - .active-result { | ||
| 56 | - @include border-radius(0); | ||
| 57 | - | ||
| 58 | - &.highlighted { | ||
| 59 | - background: $hover; | ||
| 60 | - color: $style_color; | ||
| 61 | - } | ||
| 62 | - &.result-selected { | ||
| 63 | - background: #EEE; | ||
| 64 | - border-left: 4px solid #CCC; | ||
| 65 | - } | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - .chzn-search { | ||
| 70 | - @include bg-gray-gradient; | ||
| 71 | - input { | ||
| 72 | - min-width: 165px; | ||
| 73 | - border-color: #CCC; | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - .chzn-single { | ||
| 79 | - @include bg-light-gray-gradient; | ||
| 80 | - | ||
| 81 | - div { | ||
| 82 | - background: transparent; | ||
| 83 | - border-left: none; | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - span { | ||
| 87 | - font-weight: normal; | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | -} |
| @@ -0,0 +1,110 @@ | @@ -0,0 +1,110 @@ | ||
| 1 | +.ajax-users-select { | ||
| 2 | + width: 400px; | ||
| 3 | +} | ||
| 4 | + | ||
| 5 | +.user-result { | ||
| 6 | + .user-image { | ||
| 7 | + float: left; | ||
| 8 | + } | ||
| 9 | + .user-name { | ||
| 10 | + } | ||
| 11 | + .user-username { | ||
| 12 | + color: #999; | ||
| 13 | + } | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +.select2-no-results { | ||
| 17 | + padding: 7px; | ||
| 18 | + color: #666; | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +/** Branch/tag selector **/ | ||
| 22 | +.project-refs-form { | ||
| 23 | + margin: 0; | ||
| 24 | + span { | ||
| 25 | + background:none !important; | ||
| 26 | + position:static !important; | ||
| 27 | + width:auto !important; | ||
| 28 | + height:auto !important; | ||
| 29 | + } | ||
| 30 | +} | ||
| 31 | +.project-refs-select { | ||
| 32 | + width: 120px; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +.project-refs-form .chzn-container { | ||
| 36 | + position: relative; | ||
| 37 | + top: 0; | ||
| 38 | + left: 0; | ||
| 39 | + margin-right: 10px; | ||
| 40 | + | ||
| 41 | + .chzn-drop { | ||
| 42 | + min-width: 400px; | ||
| 43 | + .chzn-results { | ||
| 44 | + max-height: 300px; | ||
| 45 | + } | ||
| 46 | + .chzn-search input { | ||
| 47 | + min-width: 365px; | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +/** Fix for Search Dropdown Border **/ | ||
| 53 | +.chzn-container { | ||
| 54 | + .chzn-search { | ||
| 55 | + input:focus { | ||
| 56 | + @include box-shadow(none); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + .chzn-drop { | ||
| 61 | + margin: 7px 0; | ||
| 62 | + min-width: 200px; | ||
| 63 | + border: 1px solid #bbb; | ||
| 64 | + @include border-radius(0); | ||
| 65 | + | ||
| 66 | + .chzn-results { | ||
| 67 | + margin-top: 5px; | ||
| 68 | + max-height: 300px; | ||
| 69 | + | ||
| 70 | + .group-result { | ||
| 71 | + color: $style_color; | ||
| 72 | + border-bottom: 1px solid #EEE; | ||
| 73 | + padding: 8px; | ||
| 74 | + } | ||
| 75 | + .active-result { | ||
| 76 | + @include border-radius(0); | ||
| 77 | + | ||
| 78 | + &.highlighted { | ||
| 79 | + background: $hover; | ||
| 80 | + color: $style_color; | ||
| 81 | + } | ||
| 82 | + &.result-selected { | ||
| 83 | + background: #EEE; | ||
| 84 | + border-left: 4px solid #CCC; | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + .chzn-search { | ||
| 90 | + @include bg-gray-gradient; | ||
| 91 | + input { | ||
| 92 | + min-width: 165px; | ||
| 93 | + border-color: #CCC; | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + .chzn-single { | ||
| 99 | + @include bg-light-gray-gradient; | ||
| 100 | + | ||
| 101 | + div { | ||
| 102 | + background: transparent; | ||
| 103 | + border-left: none; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + span { | ||
| 107 | + font-weight: normal; | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | +} |
app/controllers/application_controller.rb
| @@ -152,9 +152,8 @@ class ApplicationController < ActionController::Base | @@ -152,9 +152,8 @@ class ApplicationController < ActionController::Base | ||
| 152 | 152 | ||
| 153 | def add_gon_variables | 153 | def add_gon_variables |
| 154 | gon.default_issues_tracker = Project.issues_tracker.default_value | 154 | gon.default_issues_tracker = Project.issues_tracker.default_value |
| 155 | - if current_user | ||
| 156 | - gon.api_token = current_user.private_token | ||
| 157 | - gon.gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url | ||
| 158 | - end | 155 | + gon.api_version = Gitlab::API.version |
| 156 | + gon.api_token = current_user.private_token if current_user | ||
| 157 | + gon.gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url | ||
| 159 | end | 158 | end |
| 160 | end | 159 | end |
features/project/team_management.feature
| @@ -11,6 +11,7 @@ Feature: Project Team management | @@ -11,6 +11,7 @@ Feature: Project Team management | ||
| 11 | Then I should be able to see myself in team | 11 | Then I should be able to see myself in team |
| 12 | And I should see "Sam" in team list | 12 | And I should see "Sam" in team list |
| 13 | 13 | ||
| 14 | + @javascript | ||
| 14 | Scenario: Add user to project | 15 | Scenario: Add user to project |
| 15 | Given I click link "New Team Member" | 16 | Given I click link "New Team Member" |
| 16 | And I select "Mike" as "Reporter" | 17 | And I select "Mike" as "Reporter" |
features/steps/project/project_team_management.rb
| @@ -2,6 +2,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps | @@ -2,6 +2,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps | ||
| 2 | include SharedAuthentication | 2 | include SharedAuthentication |
| 3 | include SharedProject | 3 | include SharedProject |
| 4 | include SharedPaths | 4 | include SharedPaths |
| 5 | + include Select2Helper | ||
| 5 | 6 | ||
| 6 | Then 'I should be able to see myself in team' do | 7 | Then 'I should be able to see myself in team' do |
| 7 | page.should have_content(@user.name) | 8 | page.should have_content(@user.name) |
| @@ -20,8 +21,9 @@ class ProjectTeamManagement < Spinach::FeatureSteps | @@ -20,8 +21,9 @@ class ProjectTeamManagement < Spinach::FeatureSteps | ||
| 20 | 21 | ||
| 21 | And 'I select "Mike" as "Reporter"' do | 22 | And 'I select "Mike" as "Reporter"' do |
| 22 | user = User.find_by_name("Mike") | 23 | user = User.find_by_name("Mike") |
| 24 | + | ||
| 25 | + select2(user.id, from: "#user_ids", multiple: true) | ||
| 23 | within "#new_team_member" do | 26 | within "#new_team_member" do |
| 24 | - select "#{user.name} (#{user.username})", :from => "user_ids" | ||
| 25 | select "Reporter", :from => "project_access" | 27 | select "Reporter", :from => "project_access" |
| 26 | end | 28 | end |
| 27 | click_button "Add users" | 29 | click_button "Add users" |
features/steps/userteams/userteams.rb
| @@ -2,238 +2,239 @@ class Userteams < Spinach::FeatureSteps | @@ -2,238 +2,239 @@ class Userteams < Spinach::FeatureSteps | ||
| 2 | include SharedAuthentication | 2 | include SharedAuthentication |
| 3 | include SharedPaths | 3 | include SharedPaths |
| 4 | include SharedProject | 4 | include SharedProject |
| 5 | + include Select2Helper | ||
| 5 | 6 | ||
| 6 | - When 'I do not have teams with me' do | ||
| 7 | - UserTeam.with_member(current_user).destroy_all | ||
| 8 | - end | 7 | + When 'I do not have teams with me' do |
| 8 | + UserTeam.with_member(current_user).destroy_all | ||
| 9 | + end | ||
| 9 | 10 | ||
| 10 | - Then 'I should see dashboard page without teams info block' do | ||
| 11 | - page.has_no_css?(".teams-box").must_equal true | ||
| 12 | - end | 11 | + Then 'I should see dashboard page without teams info block' do |
| 12 | + page.has_no_css?(".teams-box").must_equal true | ||
| 13 | + end | ||
| 13 | 14 | ||
| 14 | - When 'I have teams with my membership' do | ||
| 15 | - team = create :user_team, owner: current_user | ||
| 16 | - team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 17 | - end | 15 | + When 'I have teams with my membership' do |
| 16 | + team = create :user_team, owner: current_user | ||
| 17 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 18 | + end | ||
| 18 | 19 | ||
| 19 | - Then 'I should see dashboard page with teams information block' do | ||
| 20 | - page.should have_css(".teams-box") | ||
| 21 | - end | 20 | + Then 'I should see dashboard page with teams information block' do |
| 21 | + page.should have_css(".teams-box") | ||
| 22 | + end | ||
| 22 | 23 | ||
| 23 | - When 'exist user teams' do | ||
| 24 | - team = create :user_team | ||
| 25 | - team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 26 | - end | 24 | + When 'exist user teams' do |
| 25 | + team = create :user_team | ||
| 26 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 27 | + end | ||
| 27 | 28 | ||
| 28 | - And 'I click on "All teams" link' do | ||
| 29 | - click_link("All Teams") | ||
| 30 | - end | 29 | + And 'I click on "All teams" link' do |
| 30 | + click_link("All Teams") | ||
| 31 | + end | ||
| 31 | 32 | ||
| 32 | - Then 'I should see "All teams" page' do | ||
| 33 | - current_path.should == teams_path | ||
| 34 | - end | 33 | + Then 'I should see "All teams" page' do |
| 34 | + current_path.should == teams_path | ||
| 35 | + end | ||
| 35 | 36 | ||
| 36 | - And 'I should see exist teams in teams list' do | ||
| 37 | - team = UserTeam.last | ||
| 38 | - find_in_list(".teams_list tr", team).must_equal true | ||
| 39 | - end | 37 | + And 'I should see exist teams in teams list' do |
| 38 | + team = UserTeam.last | ||
| 39 | + find_in_list(".teams_list tr", team).must_equal true | ||
| 40 | + end | ||
| 40 | 41 | ||
| 41 | - When 'I click to "New team" link' do | ||
| 42 | - click_link("New Team") | ||
| 43 | - end | 42 | + When 'I click to "New team" link' do |
| 43 | + click_link("New Team") | ||
| 44 | + end | ||
| 44 | 45 | ||
| 45 | - And 'I submit form with new team info' do | ||
| 46 | - fill_in 'name', with: 'gitlab' | 46 | + And 'I submit form with new team info' do |
| 47 | + fill_in 'name', with: 'gitlab' | ||
| 47 | 48 | ||
| 48 | - fill_in 'user_team_description', with: 'team description' | ||
| 49 | - click_button 'Create team' | ||
| 50 | - end | 49 | + fill_in 'user_team_description', with: 'team description' |
| 50 | + click_button 'Create team' | ||
| 51 | + end | ||
| 51 | 52 | ||
| 52 | - And 'I should see newly created team' do | ||
| 53 | - page.should have_content "gitlab" | ||
| 54 | - page.should have_content "team description" | ||
| 55 | - end | 53 | + And 'I should see newly created team' do |
| 54 | + page.should have_content "gitlab" | ||
| 55 | + page.should have_content "team description" | ||
| 56 | + end | ||
| 56 | 57 | ||
| 57 | - Then 'I should be redirected to new team page' do | ||
| 58 | - team = UserTeam.last | ||
| 59 | - current_path.should == team_path(team) | ||
| 60 | - end | 58 | + Then 'I should be redirected to new team page' do |
| 59 | + team = UserTeam.last | ||
| 60 | + current_path.should == team_path(team) | ||
| 61 | + end | ||
| 61 | 62 | ||
| 62 | - When 'I have teams with projects and members' do | ||
| 63 | - team = create :user_team, owner: current_user | ||
| 64 | - @project = create :project | ||
| 65 | - team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 66 | - team.assign_to_project(@project, UserTeam.access_roles["Master"]) | ||
| 67 | - @event = create(:closed_issue_event, project: @project) | ||
| 68 | - end | 63 | + When 'I have teams with projects and members' do |
| 64 | + team = create :user_team, owner: current_user | ||
| 65 | + @project = create :project | ||
| 66 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 67 | + team.assign_to_project(@project, UserTeam.access_roles["Master"]) | ||
| 68 | + @event = create(:closed_issue_event, project: @project) | ||
| 69 | + end | ||
| 69 | 70 | ||
| 70 | - When 'I visit team page' do | ||
| 71 | - visit team_path(UserTeam.last) | ||
| 72 | - end | 71 | + When 'I visit team page' do |
| 72 | + visit team_path(UserTeam.last) | ||
| 73 | + end | ||
| 73 | 74 | ||
| 74 | - Then 'I should see projects list' do | ||
| 75 | - page.should have_css(".projects_box") | ||
| 76 | - projects_box = find(".projects_box") | ||
| 77 | - projects_box.should have_content(@project.name) | ||
| 78 | - end | 75 | + Then 'I should see projects list' do |
| 76 | + page.should have_css(".projects_box") | ||
| 77 | + projects_box = find(".projects_box") | ||
| 78 | + projects_box.should have_content(@project.name) | ||
| 79 | + end | ||
| 79 | 80 | ||
| 80 | - And 'project from team has issues assigned to me' do | ||
| 81 | - team = UserTeam.last | ||
| 82 | - team.projects.each do |project| | ||
| 83 | - project.issues << create(:issue, assignee: current_user) | ||
| 84 | - end | 81 | + And 'project from team has issues assigned to me' do |
| 82 | + team = UserTeam.last | ||
| 83 | + team.projects.each do |project| | ||
| 84 | + project.issues << create(:issue, assignee: current_user) | ||
| 85 | end | 85 | end |
| 86 | + end | ||
| 86 | 87 | ||
| 87 | - When 'I visit team issues page' do | ||
| 88 | - team = UserTeam.last | ||
| 89 | - visit issues_team_path(team) | ||
| 90 | - end | 88 | + When 'I visit team issues page' do |
| 89 | + team = UserTeam.last | ||
| 90 | + visit issues_team_path(team) | ||
| 91 | + end | ||
| 91 | 92 | ||
| 92 | - Then 'I should see issues from this team assigned to me' do | ||
| 93 | - team = UserTeam.last | ||
| 94 | - team.projects.each do |project| | ||
| 95 | - project.issues.assigned(current_user).each do |issue| | ||
| 96 | - page.should have_content issue.title | ||
| 97 | - end | 93 | + Then 'I should see issues from this team assigned to me' do |
| 94 | + team = UserTeam.last | ||
| 95 | + team.projects.each do |project| | ||
| 96 | + project.issues.assigned(current_user).each do |issue| | ||
| 97 | + page.should have_content issue.title | ||
| 98 | end | 98 | end |
| 99 | end | 99 | end |
| 100 | + end | ||
| 100 | 101 | ||
| 101 | - Given 'I have team with projects and members' do | ||
| 102 | - team = create :user_team, owner: current_user | ||
| 103 | - project = create :project | ||
| 104 | - user = create :user | ||
| 105 | - team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 106 | - team.add_member(user, UserTeam.access_roles["Developer"], false) | ||
| 107 | - team.assign_to_project(project, UserTeam.access_roles["Master"]) | ||
| 108 | - end | 102 | + Given 'I have team with projects and members' do |
| 103 | + team = create :user_team, owner: current_user | ||
| 104 | + project = create :project | ||
| 105 | + user = create :user | ||
| 106 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | ||
| 107 | + team.add_member(user, UserTeam.access_roles["Developer"], false) | ||
| 108 | + team.assign_to_project(project, UserTeam.access_roles["Master"]) | ||
| 109 | + end | ||
| 109 | 110 | ||
| 110 | - Given 'project from team has issues assigned to teams members' do | ||
| 111 | - team = UserTeam.last | ||
| 112 | - team.projects.each do |project| | ||
| 113 | - team.members.each do |member| | ||
| 114 | - project.issues << create(:issue, assignee: member) | ||
| 115 | - end | 111 | + Given 'project from team has issues assigned to teams members' do |
| 112 | + team = UserTeam.last | ||
| 113 | + team.projects.each do |project| | ||
| 114 | + team.members.each do |member| | ||
| 115 | + project.issues << create(:issue, assignee: member) | ||
| 116 | end | 116 | end |
| 117 | end | 117 | end |
| 118 | + end | ||
| 118 | 119 | ||
| 119 | - Then 'I should see issues from this team assigned to teams members' do | ||
| 120 | - team = UserTeam.last | ||
| 121 | - team.projects.each do |project| | ||
| 122 | - team.members.each do |member| | ||
| 123 | - project.issues.assigned(member).each do |issue| | ||
| 124 | - page.should have_content issue.title | ||
| 125 | - end | 120 | + Then 'I should see issues from this team assigned to teams members' do |
| 121 | + team = UserTeam.last | ||
| 122 | + team.projects.each do |project| | ||
| 123 | + team.members.each do |member| | ||
| 124 | + project.issues.assigned(member).each do |issue| | ||
| 125 | + page.should have_content issue.title | ||
| 126 | end | 126 | end |
| 127 | end | 127 | end |
| 128 | end | 128 | end |
| 129 | + end | ||
| 129 | 130 | ||
| 130 | - Given 'project from team has merge requests assigned to me' do | ||
| 131 | - team = UserTeam.last | ||
| 132 | - team.projects.each do |project| | ||
| 133 | - team.members.each do |member| | ||
| 134 | - 3.times { project.merge_requests << create(:merge_request, assignee: member) } | ||
| 135 | - end | 131 | + Given 'project from team has merge requests assigned to me' do |
| 132 | + team = UserTeam.last | ||
| 133 | + team.projects.each do |project| | ||
| 134 | + team.members.each do |member| | ||
| 135 | + 3.times { project.merge_requests << create(:merge_request, assignee: member) } | ||
| 136 | end | 136 | end |
| 137 | end | 137 | end |
| 138 | + end | ||
| 138 | 139 | ||
| 139 | - When 'I visit team merge requests page' do | ||
| 140 | - team = UserTeam.last | ||
| 141 | - visit merge_requests_team_path(team) | ||
| 142 | - end | 140 | + When 'I visit team merge requests page' do |
| 141 | + team = UserTeam.last | ||
| 142 | + visit merge_requests_team_path(team) | ||
| 143 | + end | ||
| 143 | 144 | ||
| 144 | - Then 'I should see merge requests from this team assigned to me' do | ||
| 145 | - team = UserTeam.last | ||
| 146 | - team.projects.each do |project| | ||
| 147 | - team.members.each do |member| | ||
| 148 | - project.issues.assigned(member).each do |merge_request| | ||
| 149 | - page.should have_content merge_request.title | ||
| 150 | - end | 145 | + Then 'I should see merge requests from this team assigned to me' do |
| 146 | + team = UserTeam.last | ||
| 147 | + team.projects.each do |project| | ||
| 148 | + team.members.each do |member| | ||
| 149 | + project.issues.assigned(member).each do |merge_request| | ||
| 150 | + page.should have_content merge_request.title | ||
| 151 | end | 151 | end |
| 152 | end | 152 | end |
| 153 | end | 153 | end |
| 154 | + end | ||
| 154 | 155 | ||
| 155 | - Given 'project from team has merge requests assigned to team members' do | ||
| 156 | - team = UserTeam.last | ||
| 157 | - team.projects.each do |project| | ||
| 158 | - team.members.each do |member| | ||
| 159 | - 3.times { project.merge_requests << create(:merge_request, assignee: member) } | ||
| 160 | - end | 156 | + Given 'project from team has merge requests assigned to team members' do |
| 157 | + team = UserTeam.last | ||
| 158 | + team.projects.each do |project| | ||
| 159 | + team.members.each do |member| | ||
| 160 | + 3.times { project.merge_requests << create(:merge_request, assignee: member) } | ||
| 161 | end | 161 | end |
| 162 | end | 162 | end |
| 163 | + end | ||
| 163 | 164 | ||
| 164 | - Then 'I should see merge requests from this team assigned to me' do | ||
| 165 | - team = UserTeam.last | ||
| 166 | - team.projects.each do |project| | ||
| 167 | - team.members.each do |member| | ||
| 168 | - project.issues.assigned(member).each do |merge_request| | ||
| 169 | - page.should have_content merge_request.title | ||
| 170 | - end | 165 | + Then 'I should see merge requests from this team assigned to me' do |
| 166 | + team = UserTeam.last | ||
| 167 | + team.projects.each do |project| | ||
| 168 | + team.members.each do |member| | ||
| 169 | + project.issues.assigned(member).each do |merge_request| | ||
| 170 | + page.should have_content merge_request.title | ||
| 171 | end | 171 | end |
| 172 | end | 172 | end |
| 173 | end | 173 | end |
| 174 | + end | ||
| 174 | 175 | ||
| 175 | - Given 'I have new user "John"' do | ||
| 176 | - create :user, name: "John" | ||
| 177 | - end | 176 | + Given 'I have new user "John"' do |
| 177 | + create :user, name: "John" | ||
| 178 | + end | ||
| 178 | 179 | ||
| 179 | - When 'I visit team people page' do | ||
| 180 | - team = UserTeam.last | ||
| 181 | - visit team_members_path(team) | ||
| 182 | - end | 180 | + When 'I visit team people page' do |
| 181 | + team = UserTeam.last | ||
| 182 | + visit team_members_path(team) | ||
| 183 | + end | ||
| 183 | 184 | ||
| 184 | - And 'I select user "John" from list with role "Reporter"' do | ||
| 185 | - user = User.find_by_name("John") | ||
| 186 | - within "#team_members" do | ||
| 187 | - select "#{user.name} (#{user.username})", from: "user_ids" | ||
| 188 | - select "Reporter", from: "default_project_access" | ||
| 189 | - end | ||
| 190 | - click_button "Add" | 185 | + And 'I select user "John" from list with role "Reporter"' do |
| 186 | + user = User.find_by_name("John") | ||
| 187 | + select2(user.id, from: "#user_ids", multiple: true) | ||
| 188 | + within "#team_members" do | ||
| 189 | + select "Reporter", from: "default_project_access" | ||
| 191 | end | 190 | end |
| 191 | + click_button "Add" | ||
| 192 | + end | ||
| 192 | 193 | ||
| 193 | - Then 'I should see user "John" in team list' do | ||
| 194 | - user = User.find_by_name("John") | ||
| 195 | - team_members_list = find(".team-table") | ||
| 196 | - team_members_list.should have_content user.name | ||
| 197 | - end | 194 | + Then 'I should see user "John" in team list' do |
| 195 | + user = User.find_by_name("John") | ||
| 196 | + team_members_list = find(".team-table") | ||
| 197 | + team_members_list.should have_content user.name | ||
| 198 | + end | ||
| 198 | 199 | ||
| 199 | - And 'I have my own project without teams' do | ||
| 200 | - @project = create :project, namespace: current_user.namespace | ||
| 201 | - end | 200 | + And 'I have my own project without teams' do |
| 201 | + @project = create :project, namespace: current_user.namespace | ||
| 202 | + end | ||
| 202 | 203 | ||
| 203 | - And 'I visit my team page' do | ||
| 204 | - team = UserTeam.where(owner_id: current_user.id).last | ||
| 205 | - visit team_path(team) | ||
| 206 | - end | 204 | + And 'I visit my team page' do |
| 205 | + team = UserTeam.where(owner_id: current_user.id).last | ||
| 206 | + visit team_path(team) | ||
| 207 | + end | ||
| 207 | 208 | ||
| 208 | - When 'I click on link "Projects"' do | ||
| 209 | - click_link "Projects" | ||
| 210 | - end | 209 | + When 'I click on link "Projects"' do |
| 210 | + click_link "Projects" | ||
| 211 | + end | ||
| 211 | 212 | ||
| 212 | - And 'I click link "Assign project to Team"' do | ||
| 213 | - click_link "Assign project to Team" | ||
| 214 | - end | 213 | + And 'I click link "Assign project to Team"' do |
| 214 | + click_link "Assign project to Team" | ||
| 215 | + end | ||
| 215 | 216 | ||
| 216 | - Then 'I should see form with my own project in avaliable projects list' do | ||
| 217 | - projects_select = find("#project_ids") | ||
| 218 | - projects_select.should have_content(@project.name) | ||
| 219 | - end | 217 | + Then 'I should see form with my own project in avaliable projects list' do |
| 218 | + projects_select = find("#project_ids") | ||
| 219 | + projects_select.should have_content(@project.name) | ||
| 220 | + end | ||
| 220 | 221 | ||
| 221 | - When 'I submit form with selected project and max access' do | ||
| 222 | - within "#assign_projects" do | ||
| 223 | - select @project.name_with_namespace, from: "project_ids" | ||
| 224 | - select "Reporter", from: "greatest_project_access" | ||
| 225 | - end | ||
| 226 | - click_button "Add" | 222 | + When 'I submit form with selected project and max access' do |
| 223 | + within "#assign_projects" do | ||
| 224 | + select @project.name_with_namespace, from: "project_ids" | ||
| 225 | + select "Reporter", from: "greatest_project_access" | ||
| 227 | end | 226 | end |
| 227 | + click_button "Add" | ||
| 228 | + end | ||
| 228 | 229 | ||
| 229 | - Then 'I should see my own project in team projects list' do | ||
| 230 | - projects = find(".projects-table") | ||
| 231 | - projects.should have_content(@project.name) | ||
| 232 | - end | 230 | + Then 'I should see my own project in team projects list' do |
| 231 | + projects = find(".projects-table") | ||
| 232 | + projects.should have_content(@project.name) | ||
| 233 | + end | ||
| 233 | 234 | ||
| 234 | - When 'I click link "New Team Member"' do | ||
| 235 | - click_link "New Team Member" | ||
| 236 | - end | 235 | + When 'I click link "New Team Member"' do |
| 236 | + click_link "New Team Member" | ||
| 237 | + end | ||
| 237 | 238 | ||
| 238 | protected | 239 | protected |
| 239 | 240 | ||
| @@ -257,5 +258,4 @@ class Userteams < Spinach::FeatureSteps | @@ -257,5 +258,4 @@ class Userteams < Spinach::FeatureSteps | ||
| 257 | end | 258 | end |
| 258 | entered | 259 | entered |
| 259 | end | 260 | end |
| 260 | - | ||
| 261 | end | 261 | end |
features/support/env.rb
| @@ -14,7 +14,7 @@ require 'spinach/capybara' | @@ -14,7 +14,7 @@ require 'spinach/capybara' | ||
| 14 | require 'sidekiq/testing/inline' | 14 | require 'sidekiq/testing/inline' |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | -%w(stubbed_repository valid_commit).each do |f| | 17 | +%w(stubbed_repository valid_commit select2_helper).each do |f| |
| 18 | require Rails.root.join('spec', 'support', f) | 18 | require Rails.root.join('spec', 'support', f) |
| 19 | end | 19 | end |
| 20 | 20 |
features/teams/team.feature
| @@ -46,6 +46,7 @@ Feature: UserTeams | @@ -46,6 +46,7 @@ Feature: UserTeams | ||
| 46 | When I visit team merge requests page | 46 | When I visit team merge requests page |
| 47 | Then I should see merge requests from this team assigned to me | 47 | Then I should see merge requests from this team assigned to me |
| 48 | 48 | ||
| 49 | + @javascript | ||
| 49 | Scenario: I should add user to projects in Team | 50 | Scenario: I should add user to projects in Team |
| 50 | Given I have team with projects and members | 51 | Given I have team with projects and members |
| 51 | Given I have new user "John" | 52 | Given I have new user "John" |
| @@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
| 1 | +# Select2 ajax programatic helper | ||
| 2 | +# It allows you to select value from select2 | ||
| 3 | +# | ||
| 4 | +# Params | ||
| 5 | +# value - real value of selected item | ||
| 6 | +# opts - options containing css selector | ||
| 7 | +# | ||
| 8 | +# Usage: | ||
| 9 | +# | ||
| 10 | +# select2(2, from: '#user_ids') | ||
| 11 | +# | ||
| 12 | + | ||
| 13 | +module Select2Helper | ||
| 14 | + def select2(value, options={}) | ||
| 15 | + raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from) | ||
| 16 | + | ||
| 17 | + selector = options[:from] | ||
| 18 | + | ||
| 19 | + if options[:multiple] | ||
| 20 | + page.execute_script("$('#{selector}').select2('val', ['#{value}']);") | ||
| 21 | + else | ||
| 22 | + page.execute_script("$('#{selector}').select2('val', '#{value}');") | ||
| 23 | + end | ||
| 24 | + end | ||
| 25 | +end |