Commit c8b92a4be2d526a128e17c784bd9af93e5ee91f5

Authored by Sebastian Ziebell
2 parents c305eb31 ed3f4408

Merge branch 'master' into fixes/api

app/controllers/admin/users_controller.rb
@@ -9,8 +9,12 @@ class Admin::UsersController < Admin::ApplicationController @@ -9,8 +9,12 @@ class Admin::UsersController < Admin::ApplicationController
9 end 9 end
10 10
11 def show 11 def show
12 - @projects = Project.scoped  
13 - @projects = @projects.without_user(admin_user) if admin_user.authorized_projects.present? 12 + # Projects user can be added to
  13 + @not_in_projects = Project.scoped
  14 + @not_in_projects = @not_in_projects.without_user(admin_user) if admin_user.authorized_projects.present?
  15 +
  16 + # Projects he already own or joined
  17 + @projects = admin_user.authorized_projects.where('projects.id in (?)', admin_user.authorized_projects.map(&:id))
14 end 18 end
15 19
16 def team_update 20 def team_update
app/models/event.rb
@@ -20,15 +20,15 @@ class Event < ActiveRecord::Base @@ -20,15 +20,15 @@ class Event < ActiveRecord::Base
20 20
21 default_scope where("author_id IS NOT NULL") 21 default_scope where("author_id IS NOT NULL")
22 22
23 - Created = 1  
24 - Updated = 2  
25 - Closed = 3  
26 - Reopened = 4  
27 - Pushed = 5  
28 - Commented = 6  
29 - Merged = 7  
30 - Joined = 8 # User joined project  
31 - Left = 9 # User left project 23 + CREATED = 1
  24 + UPDATED = 2
  25 + CLOSED = 3
  26 + REOPENED = 4
  27 + PUSHED = 5
  28 + COMMENTED = 6
  29 + MERGED = 7
  30 + JOINED = 8 # User joined project
  31 + LEFT = 9 # User left project
32 32
33 delegate :name, :email, to: :author, prefix: true, allow_nil: true 33 delegate :name, :email, to: :author, prefix: true, allow_nil: true
34 delegate :title, to: :issue, prefix: true, allow_nil: true 34 delegate :title, to: :issue, prefix: true, allow_nil: true
@@ -43,15 +43,15 @@ class Event < ActiveRecord::Base @@ -43,15 +43,15 @@ class Event < ActiveRecord::Base
43 43
44 # Scopes 44 # Scopes
45 scope :recent, -> { order("created_at DESC") } 45 scope :recent, -> { order("created_at DESC") }
46 - scope :code_push, -> { where(action: Pushed) } 46 + scope :code_push, -> { where(action: PUSHED) }
47 scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } 47 scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent }
48 48
49 class << self 49 class << self
50 def determine_action(record) 50 def determine_action(record)
51 if [Issue, MergeRequest].include? record.class 51 if [Issue, MergeRequest].include? record.class
52 - Event::Created 52 + Event::CREATED
53 elsif record.kind_of? Note 53 elsif record.kind_of? Note
54 - Event::Commented 54 + Event::COMMENTED
55 end 55 end
56 end 56 end
57 end 57 end
@@ -79,19 +79,19 @@ class Event &lt; ActiveRecord::Base @@ -79,19 +79,19 @@ class Event &lt; ActiveRecord::Base
79 end 79 end
80 80
81 def push? 81 def push?
82 - action == self.class::Pushed && valid_push? 82 + action == self.class::PUSHED && valid_push?
83 end 83 end
84 84
85 def merged? 85 def merged?
86 - action == self.class::Merged 86 + action == self.class::MERGED
87 end 87 end
88 88
89 def closed? 89 def closed?
90 - action == self.class::Closed 90 + action == self.class::CLOSED
91 end 91 end
92 92
93 def reopened? 93 def reopened?
94 - action == self.class::Reopened 94 + action == self.class::REOPENED
95 end 95 end
96 96
97 def milestone? 97 def milestone?
@@ -111,11 +111,11 @@ class Event &lt; ActiveRecord::Base @@ -111,11 +111,11 @@ class Event &lt; ActiveRecord::Base
111 end 111 end
112 112
113 def joined? 113 def joined?
114 - action == Joined 114 + action == JOINED
115 end 115 end
116 116
117 def left? 117 def left?
118 - action == Left 118 + action == LEFT
119 end 119 end
120 120
121 def membership_changed? 121 def membership_changed?
app/models/merge_request.rb
@@ -133,11 +133,11 @@ class MergeRequest &lt; ActiveRecord::Base @@ -133,11 +133,11 @@ class MergeRequest &lt; ActiveRecord::Base
133 end 133 end
134 134
135 def merge_event 135 def merge_event
136 - self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::Merged).last 136 + self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::MERGED).last
137 end 137 end
138 138
139 def closed_event 139 def closed_event
140 - self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::Closed).last 140 + self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last
141 end 141 end
142 142
143 def commits 143 def commits
@@ -184,7 +184,7 @@ class MergeRequest &lt; ActiveRecord::Base @@ -184,7 +184,7 @@ class MergeRequest &lt; ActiveRecord::Base
184 self.mark_as_merged! 184 self.mark_as_merged!
185 Event.create( 185 Event.create(
186 project: self.project, 186 project: self.project,
187 - action: Event::Merged, 187 + action: Event::MERGED,
188 target_id: self.id, 188 target_id: self.id,
189 target_type: "MergeRequest", 189 target_type: "MergeRequest",
190 author_id: user_id 190 author_id: user_id
app/models/project.rb
@@ -103,7 +103,7 @@ class Project &lt; ActiveRecord::Base @@ -103,7 +103,7 @@ class Project &lt; ActiveRecord::Base
103 end 103 end
104 104
105 def with_push 105 def with_push
106 - includes(:events).where('events.action = ?', Event::Pushed) 106 + includes(:events).where('events.action = ?', Event::PUSHED)
107 end 107 end
108 108
109 def active 109 def active
@@ -336,7 +336,7 @@ class Project &lt; ActiveRecord::Base @@ -336,7 +336,7 @@ class Project &lt; ActiveRecord::Base
336 def observe_push(data) 336 def observe_push(data)
337 Event.create( 337 Event.create(
338 project: self, 338 project: self,
339 - action: Event::Pushed, 339 + action: Event::PUSHED,
340 data: data, 340 data: data,
341 author_id: data[:user_id] 341 author_id: data[:user_id]
342 ) 342 )
app/models/user.rb
@@ -138,7 +138,7 @@ class User &lt; ActiveRecord::Base @@ -138,7 +138,7 @@ class User &lt; ActiveRecord::Base
138 end 138 end
139 139
140 def search query 140 def search query
141 - where("name LIKE :query or email LIKE :query", query: "%#{query}%") 141 + where("name LIKE :query OR email LIKE :query OR username LIKE :query", query: "%#{query}%")
142 end 142 end
143 end 143 end
144 144
@@ -313,4 +313,8 @@ class User &lt; ActiveRecord::Base @@ -313,4 +313,8 @@ class User &lt; ActiveRecord::Base
313 UserTeam.where(id: ids) 313 UserTeam.where(id: ids)
314 end 314 end
315 end 315 end
  316 +
  317 + def owned_teams
  318 + UserTeam.where(owner_id: self.id)
  319 + end
316 end 320 end
app/observers/activity_observer.rb
@@ -26,7 +26,7 @@ class ActivityObserver &lt; ActiveRecord::Observer @@ -26,7 +26,7 @@ class ActivityObserver &lt; ActiveRecord::Observer
26 project: record.project, 26 project: record.project,
27 target_id: record.id, 27 target_id: record.id,
28 target_type: record.class.name, 28 target_type: record.class.name,
29 - action: (record.closed ? Event::Closed : Event::Reopened), 29 + action: (record.closed ? Event::CLOSED : Event::REOPENED),
30 author_id: record.author_id_of_changes 30 author_id: record.author_id_of_changes
31 ) 31 )
32 end 32 end
app/observers/users_project_observer.rb
@@ -7,7 +7,7 @@ class UsersProjectObserver &lt; ActiveRecord::Observer @@ -7,7 +7,7 @@ class UsersProjectObserver &lt; ActiveRecord::Observer
7 def after_create(users_project) 7 def after_create(users_project)
8 Event.create( 8 Event.create(
9 project_id: users_project.project.id, 9 project_id: users_project.project.id,
10 - action: Event::Joined, 10 + action: Event::JOINED,
11 author_id: users_project.user.id 11 author_id: users_project.user.id
12 ) 12 )
13 end 13 end
@@ -15,7 +15,7 @@ class UsersProjectObserver &lt; ActiveRecord::Observer @@ -15,7 +15,7 @@ class UsersProjectObserver &lt; ActiveRecord::Observer
15 def after_destroy(users_project) 15 def after_destroy(users_project)
16 Event.create( 16 Event.create(
17 project_id: users_project.project.id, 17 project_id: users_project.project.id,
18 - action: Event::Left, 18 + action: Event::LEFT,
19 author_id: users_project.user.id 19 author_id: users_project.user.id
20 ) 20 )
21 end 21 end
app/views/admin/users/index.html.haml
@@ -3,56 +3,60 @@ @@ -3,56 +3,60 @@
3 = link_to 'New User', new_admin_user_path, class: "btn btn-small pull-right" 3 = link_to 'New User', new_admin_user_path, class: "btn btn-small pull-right"
4 %br 4 %br
5 5
6 -= form_tag admin_users_path, method: :get, class: 'form-inline' do  
7 - = text_field_tag :name, params[:name], class: "xlarge"  
8 - = submit_tag "Search", class: "btn submit btn-primary"  
9 -%ul.nav.nav-tabs  
10 - %li{class: "#{'active' unless params[:filter]}"}  
11 - = link_to admin_users_path do  
12 - Active  
13 - %span.badge= User.active.count  
14 - %li{class: "#{'active' if params[:filter] == "admins"}"}  
15 - = link_to admin_users_path(filter: "admins") do  
16 - Admins  
17 - %span.badge= User.admins.count  
18 - %li{class: "#{'active' if params[:filter] == "blocked"}"}  
19 - = link_to admin_users_path(filter: "blocked") do  
20 - Blocked  
21 - %span.badge= User.blocked.count  
22 - %li{class: "#{'active' if params[:filter] == "wop"}"}  
23 - = link_to admin_users_path(filter: "wop") do  
24 - Without projects  
25 - %span.badge= User.without_projects.count 6 +.row
  7 + .span3
  8 + .admin-filter
  9 + = form_tag admin_users_path, method: :get, class: 'form-inline' do
  10 + = search_field_tag :name, params[:name], placeholder: 'Name, email or username', class: 'search-text-input span2'
  11 + = button_tag type: 'submit', class: 'btn' do
  12 + %i.icon-search
  13 + %ul.nav.nav-pills.nav-stacked
  14 + %li{class: "#{'active' unless params[:filter]}"}
  15 + = link_to admin_users_path do
  16 + Active
  17 + %small.pull-right= User.active.count
  18 + %li{class: "#{'active' if params[:filter] == "admins"}"}
  19 + = link_to admin_users_path(filter: "admins") do
  20 + Admins
  21 + %small.pull-right= User.admins.count
  22 + %li{class: "#{'active' if params[:filter] == "blocked"}"}
  23 + = link_to admin_users_path(filter: "blocked") do
  24 + Blocked
  25 + %small.pull-right= User.blocked.count
  26 + %li{class: "#{'active' if params[:filter] == "wop"}"}
  27 + = link_to admin_users_path(filter: "wop") do
  28 + Without projects
  29 + %small.pull-right= User.without_projects.count
  30 + %hr
  31 + = link_to 'Reset', admin_users_path, class: "btn btn-cancel"
26 32
27 -%table  
28 - %thead  
29 - %tr  
30 - %th Admin  
31 - %th  
32 - Name  
33 - %i.icon-sort-down  
34 - %th Username  
35 - %th Email  
36 - %th Projects  
37 - %th Edit  
38 - %th.cred Danger Zone!  
39 -  
40 - - @admin_users.each do |user|  
41 - %tr  
42 - %td= check_box_tag "admin", 1, user.admin, disabled: :disabled  
43 - %td= link_to user.name, [:admin, user]  
44 - %td= user.username  
45 - %td= user.email  
46 - %td= user.users_projects.count  
47 - %td= link_to 'Edit', edit_admin_user_path(user), id: "edit_#{dom_id(user)}", class: "btn btn-small"  
48 - %td.bgred  
49 - - if user == current_user  
50 - %span.cred It's you!  
51 - - else  
52 - - if user.blocked  
53 - = link_to 'Unblock', unblock_admin_user_path(user), method: :put, class: "btn btn-small success"  
54 - - else  
55 - = link_to 'Block', block_admin_user_path(user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove"  
56 - = link_to 'Destroy', [:admin, user], confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-small btn-remove"  
57 -  
58 -= paginate @admin_users, theme: "admin" 33 + .span9
  34 + .ui-box
  35 + %h5.title
  36 + Users (#{@admin_users.total_count})
  37 + %ul.well-list
  38 + - @admin_users.each do |user|
  39 + %li
  40 + - if user.blocked?
  41 + %i.icon-lock.cred
  42 + - else
  43 + %i.icon-user.cgreen
  44 + = link_to user.name, [:admin, user]
  45 + - if user.admin?
  46 + %strong.cred (Admin)
  47 + - if user == current_user
  48 + %span.cred It's you!
  49 + .pull-right
  50 + %span.light
  51 + %i.icon-envelope
  52 + = mail_to user.email, user.email, class: 'light'
  53 + &nbsp;
  54 + = link_to 'Edit', edit_admin_user_path(user), id: "edit_#{dom_id(user)}", class: "btn btn-small"
  55 + - unless user == current_user
  56 + - if user.blocked
  57 + = link_to 'Unblock', unblock_admin_user_path(user), method: :put, class: "btn btn-small success"
  58 + - else
  59 + = link_to 'Block', block_admin_user_path(user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove"
  60 + = link_to 'Destroy', [:admin, user], confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-small btn-remove"
  61 + %li.bottom
  62 + = paginate @admin_users, theme: "gitlab"
app/views/admin/users/show.html.haml
1 -%h3.page_title  
2 - User: #{@admin_user.name}  
3 - - if @admin_user.blocked  
4 - %small Blocked  
5 - - if @admin_user.admin  
6 - %small Administrator  
7 - = link_to edit_admin_user_path(@admin_user), class: "btn pull-right" do  
8 - %i.icon-edit  
9 - Edit  
10 -  
11 -%br  
12 -  
13 -%table.zebra-striped  
14 - %thead  
15 - %tr  
16 - %th Profile  
17 - %th  
18 - %tr  
19 - %td  
20 - %b  
21 - Email:  
22 - %td  
23 - = @admin_user.email  
24 - %tr  
25 - %td  
26 - %b  
27 - Username:  
28 - %td  
29 - = @admin_user.username  
30 - %tr  
31 - %td  
32 - %b  
33 - Admin:  
34 - %td= check_box_tag "admin", 1, @admin_user.admin, disabled: :disabled  
35 - %tr  
36 - %td  
37 - %b  
38 - Blocked:  
39 - %td= check_box_tag "blocked", 1, @admin_user.blocked, disabled: :disabled  
40 - %tr  
41 - %td  
42 - %b  
43 - Created at:  
44 - %td  
45 - = @admin_user.created_at.stamp("March 1, 1999")  
46 - %tr  
47 - %td  
48 - %b  
49 - Projects limit:  
50 - %td  
51 - = @admin_user.projects_limit  
52 - - unless @admin_user.skype.empty?  
53 - %tr  
54 - %td  
55 - %b  
56 - Skype:  
57 - %td  
58 - = @admin_user.skype  
59 - - unless @admin_user.linkedin.empty?  
60 - %tr  
61 - %td  
62 - %b  
63 - Linkedin:  
64 - %td  
65 - = @admin_user.linkedin  
66 - - unless @admin_user.twitter.empty?  
67 - %tr  
68 - %td  
69 - %b  
70 - Twitter:  
71 - %td  
72 - = @admin_user.twitter  
73 -  
74 -%br  
75 -%h5 Add User to Projects  
76 -%br  
77 -= form_tag team_update_admin_user_path(@admin_user), class: "bulk_import", method: :put do  
78 - %table  
79 - %thead  
80 - %tr  
81 - %th Projects  
82 - %th Project Access:  
83 -  
84 - %tr  
85 - %td= select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5'  
86 - %td= select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3"  
87 -  
88 - %tr  
89 - %td= submit_tag 'Add', class: "btn btn-primary"  
90 - %td 1 +.row
  2 + .span6
  3 + %h3.page_title
  4 + = image_tag gravatar_icon(@admin_user.email, 90), class: "avatar s90"
  5 + = @admin_user.name
  6 + - if @admin_user.blocked
  7 + %span.cred (Blocked)
  8 + - if @admin_user.admin
  9 + %span.cred (Admin)
  10 + .pull-right
  11 + = link_to edit_admin_user_path(@admin_user), class: "btn pull-right" do
  12 + %i.icon-edit
  13 + Edit
  14 + %br
  15 + %small @#{@admin_user.username}
  16 + %br
  17 + %small member since #{@admin_user.created_at.stamp("Nov 12, 2031")}
  18 + .clearfix
  19 + %hr
  20 + %h5
  21 + Add User to Projects
  22 + %small
91 Read more about project permissions 23 Read more about project permissions
92 %strong= link_to "here", help_permissions_path, class: "vlink" 24 %strong= link_to "here", help_permissions_path, class: "vlink"
93 -%br  
94 -  
95 -- if @admin_user.groups.present?  
96 - %h5 Owner of groups:  
97 - %br  
98 -  
99 - %table.zebra-striped  
100 - %thead  
101 - %tr  
102 - %th Name 25 + %br
  26 + = form_tag team_update_admin_user_path(@admin_user), class: "bulk_import", method: :put do
  27 + .control-group
  28 + = label_tag :project_ids, "Projects", class: 'control-label'
  29 + .controls
  30 + = select_tag :project_ids, options_from_collection_for_select(@not_in_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span3'
  31 + .control-group
  32 + = label_tag :project_access, "Project Access", class: 'control-label'
  33 + .controls
  34 + = select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3"
103 35
104 - - @admin_user.groups.each do |group|  
105 - %tr  
106 - %td= link_to group.name, admin_group_path(group) 36 + .form-actions
  37 + = submit_tag 'Add', class: "btn btn-create"
  38 + .pull-right
  39 + %br
107 40
  41 + - if @admin_user.owned_groups.present?
  42 + .ui-box
  43 + %h5.title Owned groups:
  44 + %ul.well-list
  45 + - @admin_user.groups.each do |group|
  46 + %li
  47 + %strong= link_to group.name, admin_group_path(group)
108 48
109 -- if @admin_user.authorized_projects.present?  
110 - %h5 Authorized Projects:  
111 - %br 49 + - if @admin_user.owned_teams.present?
  50 + .ui-box
  51 + %h5.title Owned teams:
  52 + %ul.well-list
  53 + - @admin_user.owned_teams.each do |team|
  54 + %li
  55 + %strong= link_to team.name, admin_team_path(team)
112 56
113 - %table.zebra-striped  
114 - %thead  
115 - %tr  
116 - %th Name  
117 - %th Project Access  
118 - %th  
119 - %th  
120 57
121 - - @admin_user.tm_in_authorized_projects.each do |tm|  
122 - - project = tm.project  
123 - %tr  
124 - %td= link_to project.name_with_namespace, admin_project_path(project)  
125 - %td= tm.project_access_human  
126 - %td= link_to 'Edit Access', edit_admin_project_member_path(project, tm.user), class: "btn btn-small"  
127 - %td= link_to 'Remove from team', admin_project_member_path(project, tm.user), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove" 58 + .span6
  59 + = render 'users/profile', user: @admin_user
  60 + .ui-box
  61 + %h5.title Projects (#{@projects.count})
  62 + %ul.well-list
  63 + - @projects.each do |project|
  64 + %li
  65 + = link_to admin_project_path(project), class: dom_class(project) do
  66 + - if project.namespace
  67 + = project.namespace.human_name
  68 + \/
  69 + %strong.well-title
  70 + = truncate(project.name, length: 45)
  71 + %span.pull-right.light
  72 + - if project.owner == @admin_user
  73 + %i.icon-wrench
  74 + - tm = project.team.get_tm(@admin_user.id)
  75 + - if tm
  76 + = tm.project_access_human
  77 + = link_to edit_admin_project_member_path(project, tm.user), class: "btn btn-small" do
  78 + %i.icon-edit
  79 + = link_to admin_project_member_path(project, tm.user), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove" do
  80 + %i.icon-remove
  81 + %p.light
  82 + %i.icon-wrench
  83 + &ndash; user is a project owner
app/views/projects/_new_form.html.haml
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 = f.label :import_url do 26 = f.label :import_url do
27 %span Import existing repo 27 %span Import existing repo
28 .input 28 .input
29 - = f.text_field :import_url, class: 'xlarge' 29 + = f.text_field :import_url, class: 'xlarge', placeholder: 'https://github.com/randx/six.git'
30 .light 30 .light
31 URL should be clonable 31 URL should be clonable
32 32
app/views/users/_profile.html.haml
@@ -4,20 +4,20 @@ @@ -4,20 +4,20 @@
4 %ul.well-list 4 %ul.well-list
5 %li 5 %li
6 %strong Email 6 %strong Email
7 - %span.pull-right= mail_to @user.email  
8 - - unless @user.skype.blank? 7 + %span.pull-right= mail_to user.email
  8 + - unless user.skype.blank?
9 %li 9 %li
10 %strong Skype 10 %strong Skype
11 - %span.pull-right= @user.skype  
12 - - unless @user.linkedin.blank? 11 + %span.pull-right= user.skype
  12 + - unless user.linkedin.blank?
13 %li 13 %li
14 %strong LinkedIn 14 %strong LinkedIn
15 - %span.pull-right= @user.linkedin  
16 - - unless @user.twitter.blank? 15 + %span.pull-right= user.linkedin
  16 + - unless user.twitter.blank?
17 %li 17 %li
18 %strong Twitter 18 %strong Twitter
19 - %span.pull-right= @user.twitter  
20 - - unless @user.bio.blank? 19 + %span.pull-right= user.twitter
  20 + - unless user.bio.blank?
21 %li 21 %li
22 %strong Bio 22 %strong Bio
23 - %span.pull-right= @user.bio 23 + %span.pull-right= user.bio
app/views/users/_projects.html.haml
@@ -10,9 +10,9 @@ @@ -10,9 +10,9 @@
10 %strong.well-title 10 %strong.well-title
11 = truncate(project.name, length: 45) 11 = truncate(project.name, length: 45)
12 %span.pull-right.light 12 %span.pull-right.light
13 - - if project.owner == @user 13 + - if project.owner == user
14 %i.icon-wrench 14 %i.icon-wrench
15 - - tm = project.team.get_tm(@user.id) 15 + - tm = project.team.get_tm(user.id)
16 - if tm 16 - if tm
17 = tm.project_access_human 17 = tm.project_access_human
18 %p.light 18 %p.light
app/views/users/show.html.haml
@@ -17,5 +17,5 @@ @@ -17,5 +17,5 @@
17 %h5 Recent events 17 %h5 Recent events
18 = render @events 18 = render @events
19 .span4 19 .span4
20 - = render 'profile'  
21 - = render 'projects' 20 + = render 'profile', user: @user
  21 + = render 'projects', user: @user
config/unicorn.rb.example
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # note that config/gitlab.yml web path should also be changed 2 # note that config/gitlab.yml web path should also be changed
3 # ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" 3 # ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
4 4
5 -app_dir = "/home/git/gitlab/" 5 +app_dir = File.expand_path '../../', __FILE__
6 worker_processes 2 6 worker_processes 2
7 working_directory app_dir 7 working_directory app_dir
8 8
features/steps/dashboard/dashboard.rb
@@ -33,7 +33,7 @@ class Dashboard &lt; Spinach::FeatureSteps @@ -33,7 +33,7 @@ class Dashboard &lt; Spinach::FeatureSteps
33 Event.create( 33 Event.create(
34 project: project, 34 project: project,
35 author_id: user.id, 35 author_id: user.id,
36 - action: Event::Joined 36 + action: Event::JOINED
37 ) 37 )
38 end 38 end
39 39
@@ -47,7 +47,7 @@ class Dashboard &lt; Spinach::FeatureSteps @@ -47,7 +47,7 @@ class Dashboard &lt; Spinach::FeatureSteps
47 Event.create( 47 Event.create(
48 project: project, 48 project: project,
49 author_id: user.id, 49 author_id: user.id,
50 - action: Event::Left 50 + action: Event::LEFT
51 ) 51 )
52 end 52 end
53 53
features/steps/dashboard/dashboard_event_filters.rb
@@ -45,7 +45,7 @@ class EventFilters &lt; Spinach::FeatureSteps @@ -45,7 +45,7 @@ class EventFilters &lt; Spinach::FeatureSteps
45 45
46 @event = Event.create( 46 @event = Event.create(
47 project: @project, 47 project: @project,
48 - action: Event::Pushed, 48 + action: Event::PUSHED,
49 data: data, 49 data: data,
50 author_id: @user.id 50 author_id: @user.id
51 ) 51 )
@@ -56,7 +56,7 @@ class EventFilters &lt; Spinach::FeatureSteps @@ -56,7 +56,7 @@ class EventFilters &lt; Spinach::FeatureSteps
56 Event.create( 56 Event.create(
57 project: @project, 57 project: @project,
58 author_id: user.id, 58 author_id: user.id,
59 - action: Event::Joined 59 + action: Event::JOINED
60 ) 60 )
61 end 61 end
62 62
@@ -64,7 +64,7 @@ class EventFilters &lt; Spinach::FeatureSteps @@ -64,7 +64,7 @@ class EventFilters &lt; Spinach::FeatureSteps
64 merge_request = create :merge_request, author: @user, project: @project 64 merge_request = create :merge_request, author: @user, project: @project
65 Event.create( 65 Event.create(
66 project: @project, 66 project: @project,
67 - action: Event::Merged, 67 + action: Event::MERGED,
68 target_id: merge_request.id, 68 target_id: merge_request.id,
69 target_type: "MergeRequest", 69 target_type: "MergeRequest",
70 author_id: @user.id 70 author_id: @user.id
features/steps/shared/project.rb
@@ -33,7 +33,7 @@ module SharedProject @@ -33,7 +33,7 @@ module SharedProject
33 33
34 @event = Event.create( 34 @event = Event.create(
35 project: @project, 35 project: @project,
36 - action: Event::Pushed, 36 + action: Event::PUSHED,
37 data: data, 37 data: data,
38 author_id: @user.id 38 author_id: @user.id
39 ) 39 )
lib/event_filter.rb
@@ -37,15 +37,15 @@ class EventFilter @@ -37,15 +37,15 @@ class EventFilter
37 filter = params.dup 37 filter = params.dup
38 38
39 actions = [] 39 actions = []
40 - actions << Event::Pushed if filter.include? 'push'  
41 - actions << Event::Merged if filter.include? 'merged' 40 + actions << Event::PUSHED if filter.include? 'push'
  41 + actions << Event::MERGED if filter.include? 'merged'
42 42
43 if filter.include? 'team' 43 if filter.include? 'team'
44 - actions << Event::Joined  
45 - actions << Event::Left 44 + actions << Event::JOINED
  45 + actions << Event::LEFT
46 end 46 end
47 47
48 - actions << Event::Commented if filter.include? 'comments' 48 + actions << Event::COMMENTED if filter.include? 'comments'
49 49
50 events = events.where(action: actions) 50 events = events.where(action: actions)
51 end 51 end
spec/factories.rb
@@ -123,7 +123,7 @@ FactoryGirl.define do @@ -123,7 +123,7 @@ FactoryGirl.define do
123 factory :event do 123 factory :event do
124 factory :closed_issue_event do 124 factory :closed_issue_event do
125 project 125 project
126 - action { Event::Closed } 126 + action { Event::CLOSED }
127 target factory: :closed_issue 127 target factory: :closed_issue
128 author factory: :user 128 author factory: :user
129 end 129 end
spec/models/event_spec.rb
@@ -52,7 +52,7 @@ describe Event do @@ -52,7 +52,7 @@ describe Event do
52 52
53 @event = Event.create( 53 @event = Event.create(
54 project: project, 54 project: project,
55 - action: Event::Pushed, 55 + action: Event::PUSHED,
56 data: data, 56 data: data,
57 author_id: @user.id 57 author_id: @user.id
58 ) 58 )
spec/models/project_hooks_spec.rb
@@ -19,7 +19,7 @@ describe Project, &quot;Hooks&quot; do @@ -19,7 +19,7 @@ describe Project, &quot;Hooks&quot; do
19 19
20 event.should_not be_nil 20 event.should_not be_nil
21 event.project.should == project 21 event.project.should == project
22 - event.action.should == Event::Pushed 22 + event.action.should == Event::PUSHED
23 event.data.should == data 23 event.data.should == data
24 end 24 end
25 end 25 end
spec/observers/activity_observer_spec.rb
@@ -17,7 +17,7 @@ describe ActivityObserver do @@ -17,7 +17,7 @@ describe ActivityObserver do
17 end 17 end
18 18
19 it_should_be_valid_event 19 it_should_be_valid_event
20 - it { @event.action.should == Event::Created } 20 + it { @event.action.should == Event::CREATED }
21 it { @event.target.should == @merge_request } 21 it { @event.target.should == @merge_request }
22 end 22 end
23 23
@@ -30,7 +30,7 @@ describe ActivityObserver do @@ -30,7 +30,7 @@ describe ActivityObserver do
30 end 30 end
31 31
32 it_should_be_valid_event 32 it_should_be_valid_event
33 - it { @event.action.should == Event::Created } 33 + it { @event.action.should == Event::CREATED }
34 it { @event.target.should == @issue } 34 it { @event.target.should == @issue }
35 end 35 end
36 36
@@ -44,7 +44,7 @@ describe ActivityObserver do @@ -44,7 +44,7 @@ describe ActivityObserver do
44 end 44 end
45 45
46 it_should_be_valid_event 46 it_should_be_valid_event
47 - it { @event.action.should == Event::Commented } 47 + it { @event.action.should == Event::COMMENTED }
48 it { @event.target.should == @note } 48 it { @event.target.should == @note }
49 end 49 end
50 end 50 end