diff options
-rw-r--r-- | app/controllers/profiles/notifications_controller.rb | 6 | ||||
-rw-r--r-- | app/mailers/emails/groups.rb | 2 | ||||
-rw-r--r-- | app/mailers/emails/projects.rb | 8 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/services/notification_service.rb | 24 | ||||
-rw-r--r-- | app/views/admin/groups/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/admin/projects/show.html.haml | 10 | ||||
-rw-r--r-- | app/views/notify/project_access_granted_email.html.haml | 2 | ||||
-rw-r--r-- | app/views/notify/project_access_granted_email.text.erb | 2 | ||||
-rw-r--r-- | app/views/profiles/notifications/show.html.haml | 6 | ||||
-rw-r--r-- | app/views/projects/team_members/_group_members.html.haml | 2 | ||||
-rw-r--r-- | spec/factories.rb | 4 | ||||
-rw-r--r-- | spec/factories/users_groups.rb | 4 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/branches_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/commits_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/project_members_spec.rb | 16 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 8 | ||||
-rw-r--r-- | spec/requests/api/repositories_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/system_hooks_service_spec.rb | 10 |
20 files changed, 63 insertions, 63 deletions
diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb index efed4a19ee3..638d1f9789b 100644 --- a/app/controllers/profiles/notifications_controller.rb +++ b/app/controllers/profiles/notifications_controller.rb @@ -18,9 +18,9 @@ class Profiles::NotificationsController < ApplicationController users_group.notification_level = params[:notification_level] users_group.save else - users_project = current_user.project_members.find(params[:notification_id]) - users_project.notification_level = params[:notification_level] - users_project.save + project_member = current_user.project_members.find(params[:notification_id]) + project_member.notification_level = params[:notification_level] + project_member.save end end end diff --git a/app/mailers/emails/groups.rb b/app/mailers/emails/groups.rb index 3f7c1d27350..8c09389985e 100644 --- a/app/mailers/emails/groups.rb +++ b/app/mailers/emails/groups.rb @@ -1,6 +1,6 @@ module Emails module Groups - def access_level_granted_email(user_group_id) + def group_access_granted_email(user_group_id) @membership = GroupMember.find(user_group_id) @group = @membership.group @target_url = group_url(@group) diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 152d5aa9959..d6edfd7059f 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -1,10 +1,10 @@ module Emails module Projects - def access_level_granted_email(user_project_id) - @users_project = ProjectMember.find user_project_id - @project = @users_project.project + def project_access_granted_email(user_project_id) + @project_member = ProjectMember.find user_project_id + @project = @project_member.project @target_url = project_url(@project) - mail(to: @users_project.user.email, + mail(to: @project_member.user.email, subject: subject("Access to project was granted")) end diff --git a/app/models/user.rb b/app/models/user.rb index d5a6b468fcd..ed3eba4cdf0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,7 +177,7 @@ class User < ActiveRecord::Base scope :in_team, ->(team){ where(id: team.member_ids) } scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) } scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } - scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM project_members)') } + scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members)') } scope :ldap, -> { where(provider: 'ldap') } scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active } diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index ca483e2f109..fe39f83b400 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -157,20 +157,20 @@ class NotificationService end end - def new_team_member(users_project) - mailer.access_level_granted_email(users_project.id) + def new_team_member(project_member) + mailer.project_access_granted_email(project_member.id) end - def update_team_member(users_project) - mailer.access_level_granted_email(users_project.id) + def update_team_member(project_member) + mailer.project_access_granted_email(project_member.id) end def new_group_member(users_group) - mailer.access_level_granted_email(users_group.id) + mailer.group_access_granted_email(users_group.id) end def update_group_member(users_group) - mailer.access_level_granted_email(users_group.id) + mailer.group_access_granted_email(users_group.id) end def project_was_moved(project) @@ -186,19 +186,19 @@ class NotificationService # Get project users with WATCH notification level def project_watchers(project) - project_members = users_project_notification(project) + project_members = project_member_notification(project) - users_with_project_level_global = users_project_notification(project, Notification::N_GLOBAL) + users_with_project_level_global = project_member_notification(project, Notification::N_GLOBAL) users_with_group_level_global = users_group_notification(project, Notification::N_GLOBAL) users = users_with_global_level_watch([users_with_project_level_global, users_with_group_level_global].flatten.uniq) - users_with_project_setting = select_users_project_setting(project, users_with_project_level_global, users) + users_with_project_setting = select_project_member_setting(project, users_with_project_level_global, users) users_with_group_setting = select_users_group_setting(project, project_members, users_with_group_level_global, users) User.where(id: users_with_project_setting.concat(users_with_group_setting).uniq).to_a end - def users_project_notification(project, notification_level=nil) + def project_member_notification(project, notification_level=nil) project_members = project.project_members if notification_level @@ -224,8 +224,8 @@ class NotificationService end # Build a list of users based on project notifcation settings - def select_users_project_setting(project, global_setting, users_global_level_watch) - users = users_project_notification(project, Notification::N_WATCH) + def select_project_member_setting(project, global_setting, users_global_level_watch) + users = project_member_notification(project, Notification::N_WATCH) # If project setting is global, add to watch list if global setting is watch global_setting.each do |user_id| diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index d7ccd67dac7..d59d2a23179 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -80,7 +80,7 @@ = link_to user.name, admin_user_path(user) %span.pull-right.light = member.human_access - = link_to group_users_group_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + = link_to group_group_members_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do %i.icon-minus.icon-white .panel-footer = paginate @members, param_name: 'members_page', theme: 'gitlab' diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 52fc5cea887..8413f0cb7f9 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -101,7 +101,7 @@ %i.icon-edit %ul.well-list - @group_members.each do |member| - = render 'group_members/users_group', member: member, show_controls: false + = render 'groups/group_members/group_member', member: member, show_controls: false .panel-footer = paginate @group_members, param_name: 'group_members_page', theme: 'gitlab' @@ -115,17 +115,17 @@ %i.icon-edit Manage Access %ul.well-list.team_members - - @project_members.each do |users_project| - - user = users_project.user + - @project_members.each do |project_member| + - user = project_member.user %li.project_member .list-item-name %strong = link_to user.name, admin_user_path(user) .pull-right - - if users_project.owner? + - if project_member.owner? %span.light Owner - else - %span.light= users_project.human_access + %span.light= project_member.human_access = link_to project_team_member_path(@project, user), data: { confirm: remove_from_project_team_message(@project, user)}, method: :delete, remote: true, class: "btn btn-small btn-remove" do %i.icon-remove .panel-footer diff --git a/app/views/notify/project_access_granted_email.html.haml b/app/views/notify/project_access_granted_email.html.haml index ce34f825358..4596205f39b 100644 --- a/app/views/notify/project_access_granted_email.html.haml +++ b/app/views/notify/project_access_granted_email.html.haml @@ -1,5 +1,5 @@ %p - = "You have been granted #{@users_project.human_access} access to project" + = "You have been granted #{@project_member.human_access} access to project" %p = link_to project_url(@project) do = @project.name_with_namespace diff --git a/app/views/notify/project_access_granted_email.text.erb b/app/views/notify/project_access_granted_email.text.erb index 66c57def375..de24feb802f 100644 --- a/app/views/notify/project_access_granted_email.text.erb +++ b/app/views/notify/project_access_granted_email.text.erb @@ -1,4 +1,4 @@ -You have been granted <%= @users_project.human_access %> access to project <%= @project.name_with_namespace %> +You have been granted <%= @project_member.human_access %> access to project <%= @project.name_with_namespace %> <%= url_for(project_url(@project)) %> diff --git a/app/views/profiles/notifications/show.html.haml b/app/views/profiles/notifications/show.html.haml index 3e28f2f5f90..f84de4430cc 100644 --- a/app/views/profiles/notifications/show.html.haml +++ b/app/views/profiles/notifications/show.html.haml @@ -46,6 +46,6 @@ .col-md-6 %h4 Projects: %ul.bordered-list - - @project_members.each do |users_project| - - notification = Notification.new(users_project) - = render 'settings', type: 'project', membership: users_project, notification: notification + - @project_members.each do |project_member| + - notification = Notification.new(project_member) + = render 'settings', type: 'project', membership: project_member, notification: notification diff --git a/app/views/projects/team_members/_group_members.html.haml b/app/views/projects/team_members/_group_members.html.haml index 837f2f5c932..77ffab89f37 100644 --- a/app/views/projects/team_members/_group_members.html.haml +++ b/app/views/projects/team_members/_group_members.html.haml @@ -8,7 +8,7 @@ %i.icon-edit %ul.well-list - @group.group_members.order('access_level DESC').limit(20).each do |member| - = render 'group_members/users_group', member: member, show_controls: false + = render 'groups/group_members/group_member', member: member, show_controls: false - if group_users_count > 20 %li and #{group_users_count - 20} more. For full list visit #{link_to 'group members page', members_group_path(@group)} diff --git a/spec/factories.rb b/spec/factories.rb index 0bf56fe84d6..a960571206c 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -39,10 +39,10 @@ FactoryGirl.define do owner end - factory :users_project do + factory :project_member do user project - project_access { ProjectMember::MASTER } + access_level { ProjectMember::MASTER } end factory :issue do diff --git a/spec/factories/users_groups.rb b/spec/factories/users_groups.rb index 450a0d88b76..debb86d997f 100644 --- a/spec/factories/users_groups.rb +++ b/spec/factories/users_groups.rb @@ -12,8 +12,8 @@ # FactoryGirl.define do - factory :users_group do - group_access { GroupMember::OWNER } + factory :group_member do + access_level { GroupMember::OWNER } group user end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 702431e0712..4b64cefa852 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -402,10 +402,10 @@ describe Notify do describe 'project access changed' do let(:project) { create(:project) } let(:user) { create(:user) } - let(:users_project) { create(:users_project, + let(:project_member) { create(:project_member, project: project, user: user) } - subject { Notify.project_access_granted_email(users_project.id) } + subject { Notify.project_access_granted_email(project_member.id) } it_behaves_like 'an email sent from GitLab' @@ -416,7 +416,7 @@ describe Notify do should have_body_text /#{project.name}/ end it 'contains new user role' do - should have_body_text /#{users_project.human_access}/ + should have_body_text /#{project_member.human_access}/ end end diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index 1690146aea7..5f6258488a4 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -7,8 +7,8 @@ describe API::API, api: true do let(:user) { create(:user) } let(:user2) { create(:user) } let!(:project) { create(:project, creator_id: user.id) } - let!(:master) { create(:users_project, user: user, project: project, project_access: ProjectMember::MASTER) } - let!(:guest) { create(:users_project, user: user2, project: project, project_access: ProjectMember::GUEST) } + let!(:master) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } + let!(:guest) { create(:project_member, user: user2, project: project, project_access: ProjectMember::GUEST) } let!(:branch_name) { 'feature' } let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 21c0329e60f..3a5a2efdb0f 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -6,8 +6,8 @@ describe API::API, api: true do let(:user) { create(:user) } let(:user2) { create(:user) } let!(:project) { create(:project, creator_id: user.id) } - let!(:master) { create(:users_project, user: user, project: project, project_access: ProjectMember::MASTER) } - let!(:guest) { create(:users_project, user: user2, project: project, project_access: ProjectMember::GUEST) } + let!(:master) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } + let!(:guest) { create(:project_member, user: user2, project: project, project_access: ProjectMember::GUEST) } before { project.team << [user, :reporter] } diff --git a/spec/requests/api/project_members_spec.rb b/spec/requests/api/project_members_spec.rb index e101f871ff0..626da6196d5 100644 --- a/spec/requests/api/project_members_spec.rb +++ b/spec/requests/api/project_members_spec.rb @@ -6,12 +6,12 @@ describe API::API, api: true do let(:user2) { create(:user) } let(:user3) { create(:user) } let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } - let(:users_project) { create(:users_project, user: user, project: project, project_access: ProjectMember::MASTER) } - let(:users_project2) { create(:users_project, user: user3, project: project, project_access: ProjectMember::DEVELOPER) } + let(:project_member) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } + let(:project_member2) { create(:project_member, user: user3, project: project, project_access: ProjectMember::DEVELOPER) } describe "GET /projects/:id/members" do - before { users_project } - before { users_project2 } + before { project_member } + before { project_member2 } it "should return project team members" do get api("/projects/#{project.id}/members", user) @@ -36,7 +36,7 @@ describe API::API, api: true do end describe "GET /projects/:id/members/:user_id" do - before { users_project } + before { project_member } it "should return project team member" do get api("/projects/#{project.id}/members/#{user.id}", user) @@ -93,7 +93,7 @@ describe API::API, api: true do end describe "PUT /projects/:id/members/:user_id" do - before { users_project2 } + before { project_member2 } it "should update project team member" do put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: ProjectMember::MASTER @@ -119,8 +119,8 @@ describe API::API, api: true do end describe "DELETE /projects/:id/members/:user_id" do - before { users_project } - before { users_project2 } + before { project_member } + before { project_member2 } it "should remove user from project team" do expect { diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 7d36043e3d8..59a20c37489 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -8,8 +8,8 @@ describe API::API, api: true do let(:admin) { create(:admin) } let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } - let(:users_project) { create(:users_project, user: user, project: project, project_access: ProjectMember::MASTER) } - let(:users_project2) { create(:users_project, user: user3, project: project, project_access: ProjectMember::DEVELOPER) } + let(:project_member) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } + let(:project_member2) { create(:project_member, user: user3, project: project, project_access: ProjectMember::DEVELOPER) } describe "GET /projects" do before { project } @@ -254,7 +254,7 @@ describe API::API, api: true do describe "GET /projects/:id" do before { project } - before { users_project } + before { project_member } it "should return a project by id" do get api("/projects/#{project.id}", user) @@ -305,7 +305,7 @@ describe API::API, api: true do end describe "GET /projects/:id/events" do - before { users_project } + before { project_member } it "should return a project events" do get api("/projects/#{project.id}/events", user) diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index ba404901a49..6618ce0e378 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -8,8 +8,8 @@ describe API::API, api: true do let(:user) { create(:user) } let(:user2) { create(:user) } let!(:project) { create(:project, creator_id: user.id) } - let!(:master) { create(:users_project, user: user, project: project, project_access: ProjectMember::MASTER) } - let!(:guest) { create(:users_project, user: user2, project: project, project_access: ProjectMember::GUEST) } + let!(:master) { create(:project_member, user: user, project: project, project_access: ProjectMember::MASTER) } + let!(:guest) { create(:project_member, user: user2, project: project, project_access: ProjectMember::GUEST) } before { project.team << [user, :reporter] } diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb index 7497bdb0b3c..573446d3a19 100644 --- a/spec/services/system_hooks_service_spec.rb +++ b/spec/services/system_hooks_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe SystemHooksService do let (:user) { create :user } let (:project) { create :project } - let (:users_project) { create :users_project } + let (:project_member) { create :project_member } let (:key) { create(:key, user: user) } context 'event data' do @@ -11,8 +11,8 @@ describe SystemHooksService do it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) } it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } - it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access, :project_visibility) } - it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access, :project_visibility) } + it { event_data(project_member, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) } + it { event_data(project_member, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) } it { event_data(key, :create).should include(:username, :key, :id) } it { event_data(key, :destroy).should include(:username, :key, :id) } end @@ -22,8 +22,8 @@ describe SystemHooksService do it { event_name(user, :destroy).should eq "user_destroy" } it { event_name(project, :create).should eq "project_create" } it { event_name(project, :destroy).should eq "project_destroy" } - it { event_name(users_project, :create).should eq "user_add_to_team" } - it { event_name(users_project, :destroy).should eq "user_remove_from_team" } + it { event_name(project_member, :create).should eq "user_add_to_team" } + it { event_name(project_member, :destroy).should eq "user_remove_from_team" } it { event_name(key, :create).should eq 'key_create' } it { event_name(key, :destroy).should eq 'key_destroy' } end |