Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
ef05423f
Commit
ef05423f
authored
Mar 14, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish select2-ajax for users. Added Select2Helper for tests
parent
10f14136
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
234 additions
and
200 deletions
+234
-200
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+5
-5
app/assets/stylesheets/application.scss
app/assets/stylesheets/application.scss
+1
-1
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+0
-14
app/assets/stylesheets/selects.scss
app/assets/stylesheets/selects.scss
+20
-0
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+3
-4
features/project/team_management.feature
features/project/team_management.feature
+1
-0
features/steps/project/project_team_management.rb
features/steps/project/project_team_management.rb
+3
-1
features/steps/userteams/userteams.rb
features/steps/userteams/userteams.rb
+174
-174
features/support/env.rb
features/support/env.rb
+1
-1
features/teams/team.feature
features/teams/team.feature
+1
-0
spec/support/select2_helper.rb
spec/support/select2_helper.rb
+25
-0
No files found.
app/assets/javascripts/users_select.js.coffee
View file @
ef05423f
...
@@ -19,7 +19,7 @@ $ ->
...
@@ -19,7 +19,7 @@ $ ->
multiple
:
$
(
'.ajax-users-select'
).
hasClass
(
'multiselect'
)
multiple
:
$
(
'.ajax-users-select'
).
hasClass
(
'multiselect'
)
minimumInputLength
:
0
minimumInputLength
:
0
ajax
:
# instead of writing the function to execute the request we use Select2's convenient helper
ajax
:
# instead of writing the function to execute the request we use Select2's convenient helper
url
:
"/api/
v3
/users.json"
url
:
"/api/
"
+
gon
.
api_version
+
"
/users.json"
dataType
:
"json"
dataType
:
"json"
data
:
(
term
,
page
)
->
data
:
(
term
,
page
)
->
search
:
term
# search term
search
:
term
# search term
...
@@ -33,11 +33,11 @@ $ ->
...
@@ -33,11 +33,11 @@ $ ->
initSelection
:
(
element
,
callback
)
->
initSelection
:
(
element
,
callback
)
->
id
=
$
(
element
).
val
()
id
=
$
(
element
).
val
()
if
id
isnt
""
if
id
isnt
""
$
.
ajax
(
"http://api.rottentomatoes.com/api/public/v1.0/users/"
+
id
+
".json"
,
$
.
ajax
(
"/api/"
+
gon
.
api_version
+
"/users/"
+
id
+
".json"
,
dataType
:
"json"
data
:
data
:
apikey
:
"ju6z9mjyajq2djue3gbvv26t"
private_token
:
gon
.
api_token
dataType
:
"jsonp"
).
done
(
data
)
->
).
done
(
data
)
->
callback
data
callback
data
...
...
app/assets/stylesheets/application.scss
View file @
ef05423f
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
@import
"gitlab_bootstrap.scss"
;
@import
"gitlab_bootstrap.scss"
;
@import
"common.scss"
;
@import
"common.scss"
;
@import
"
ref_select
.scss"
;
@import
"
selects
.scss"
;
@import
"sections/header.scss"
;
@import
"sections/header.scss"
;
@import
"sections/nav.scss"
;
@import
"sections/nav.scss"
;
...
...
app/assets/stylesheets/common.scss
View file @
ef05423f
...
@@ -555,17 +555,3 @@ img.emoji {
...
@@ -555,17 +555,3 @@ img.emoji {
display
:
none
;
display
:
none
;
}
}
.ajax-users-select
{
width
:
400px
;
}
.user-result
{
.user-image
{
float
:
left
;
}
.user-name
{
}
.user-username
{
color
:
#999
;
}
}
app/assets/stylesheets/
ref_select
.scss
→
app/assets/stylesheets/
selects
.scss
View file @
ef05423f
.ajax-users-select
{
width
:
400px
;
}
.user-result
{
.user-image
{
float
:
left
;
}
.user-name
{
}
.user-username
{
color
:
#999
;
}
}
.select2-no-results
{
padding
:
7px
;
color
:
#666
;
}
/** Branch/tag selector **/
/** Branch/tag selector **/
.project-refs-form
{
.project-refs-form
{
margin
:
0
;
margin
:
0
;
...
...
app/controllers/application_controller.rb
View file @
ef05423f
...
@@ -152,9 +152,8 @@ class ApplicationController < ActionController::Base
...
@@ -152,9 +152,8 @@ class ApplicationController < ActionController::Base
def
add_gon_variables
def
add_gon_variables
gon
.
default_issues_tracker
=
Project
.
issues_tracker
.
default_value
gon
.
default_issues_tracker
=
Project
.
issues_tracker
.
default_value
if
current_user
gon
.
api_version
=
Gitlab
::
API
.
version
gon
.
api_token
=
current_user
.
private_token
gon
.
api_token
=
current_user
.
private_token
if
current_user
gon
.
gravatar_url
=
request
.
ssl?
?
Gitlab
.
config
.
gravatar
.
ssl_url
:
Gitlab
.
config
.
gravatar
.
plain_url
gon
.
gravatar_url
=
request
.
ssl?
?
Gitlab
.
config
.
gravatar
.
ssl_url
:
Gitlab
.
config
.
gravatar
.
plain_url
end
end
end
end
end
features/project/team_management.feature
View file @
ef05423f
...
@@ -11,6 +11,7 @@ Feature: Project Team management
...
@@ -11,6 +11,7 @@ Feature: Project Team management
Then
I should be able to see myself in team
Then
I should be able to see myself in team
And
I should see
"Sam"
in team list
And
I should see
"Sam"
in team list
@javascript
Scenario
:
Add user to project
Scenario
:
Add user to project
Given
I click link
"New Team Member"
Given
I click link
"New Team Member"
And
I select
"Mike"
as
"Reporter"
And
I select
"Mike"
as
"Reporter"
...
...
features/steps/project/project_team_management.rb
View file @
ef05423f
...
@@ -2,6 +2,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
...
@@ -2,6 +2,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
include
SharedAuthentication
include
SharedAuthentication
include
SharedProject
include
SharedProject
include
SharedPaths
include
SharedPaths
include
Select2Helper
Then
'I should be able to see myself in team'
do
Then
'I should be able to see myself in team'
do
page
.
should
have_content
(
@user
.
name
)
page
.
should
have_content
(
@user
.
name
)
...
@@ -20,8 +21,9 @@ class ProjectTeamManagement < Spinach::FeatureSteps
...
@@ -20,8 +21,9 @@ class ProjectTeamManagement < Spinach::FeatureSteps
And
'I select "Mike" as "Reporter"'
do
And
'I select "Mike" as "Reporter"'
do
user
=
User
.
find_by_name
(
"Mike"
)
user
=
User
.
find_by_name
(
"Mike"
)
select2
(
user
.
id
,
from:
"#user_ids"
,
multiple:
true
)
within
"#new_team_member"
do
within
"#new_team_member"
do
select
"
#{
user
.
name
}
(
#{
user
.
username
}
)"
,
:from
=>
"user_ids"
select
"Reporter"
,
:from
=>
"project_access"
select
"Reporter"
,
:from
=>
"project_access"
end
end
click_button
"Add users"
click_button
"Add users"
...
...
features/steps/userteams/userteams.rb
View file @
ef05423f
This diff is collapsed.
Click to expand it.
features/support/env.rb
View file @
ef05423f
...
@@ -14,7 +14,7 @@ require 'spinach/capybara'
...
@@ -14,7 +14,7 @@ require 'spinach/capybara'
require
'sidekiq/testing/inline'
require
'sidekiq/testing/inline'
%w(stubbed_repository valid_commit)
.
each
do
|
f
|
%w(stubbed_repository valid_commit
select2_helper
)
.
each
do
|
f
|
require
Rails
.
root
.
join
(
'spec'
,
'support'
,
f
)
require
Rails
.
root
.
join
(
'spec'
,
'support'
,
f
)
end
end
...
...
features/teams/team.feature
View file @
ef05423f
...
@@ -46,6 +46,7 @@ Feature: UserTeams
...
@@ -46,6 +46,7 @@ Feature: UserTeams
When
I visit team merge requests page
When
I visit team merge requests page
Then
I should see merge requests from this team assigned to me
Then
I should see merge requests from this team assigned to me
@javascript
Scenario
:
I
should add user to projects in Team
Scenario
:
I
should add user to projects in Team
Given
I have team with projects and members
Given
I have team with projects and members
Given
I have new user
"John"
Given
I have new user
"John"
...
...
spec/support/select2_helper.rb
0 → 100644
View file @
ef05423f
# Select2 ajax programatic helper
# It allows you to select value from select2
#
# Params
# value - real value of selected item
# opts - options containing css selector
#
# Usage:
#
# select2(2, from: '#user_ids')
#
module
Select2Helper
def
select2
(
value
,
options
=
{})
raise
"Must pass a hash containing 'from'"
if
not
options
.
is_a?
(
Hash
)
or
not
options
.
has_key?
(
:from
)
selector
=
options
[
:from
]
if
options
[
:multiple
]
page
.
execute_script
(
"$('
#{
selector
}
').select2('val', ['
#{
value
}
']);"
)
else
page
.
execute_script
(
"$('
#{
selector
}
').select2('val', '
#{
value
}
');"
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment