From 8210d813812571b479d630ff61410347f8ebeb5b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 14 Sep 2014 19:51:54 +0300 Subject: Replace old references of users_project & users_group Signed-off-by: Dmitriy Zaporozhets --- app/controllers/profiles/notifications_controller.rb | 4 ++-- app/controllers/projects/team_members_controller.rb | 2 +- app/models/project.rb | 10 +++++----- app/models/user.rb | 6 +++--- app/views/admin/projects/show.html.haml | 2 +- app/views/groups/_new_group_member.html.haml | 2 +- app/views/groups/members.html.haml | 2 +- app/views/profiles/notifications/show.html.haml | 4 ++-- app/views/projects/team_members/_group_members.html.haml | 2 +- app/views/projects/team_members/index.html.haml | 2 +- lib/tasks/gitlab/check.rake | 4 ++-- spec/factories/users_groups.rb | 2 +- spec/models/group_member_spec.rb | 2 +- spec/models/group_spec.rb | 2 +- spec/models/project_member_spec.rb | 2 +- spec/models/project_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- 17 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb index 936fe071347..efed4a19ee3 100644 --- a/app/controllers/profiles/notifications_controller.rb +++ b/app/controllers/profiles/notifications_controller.rb @@ -3,8 +3,8 @@ class Profiles::NotificationsController < ApplicationController def show @notification = current_user.notification - @users_projects = current_user.project_members - @users_groups = current_user.group_members + @project_members = current_user.project_members + @group_members = current_user.group_members end def update diff --git a/app/controllers/projects/team_members_controller.rb b/app/controllers/projects/team_members_controller.rb index 575797d36dc..158661f66fc 100644 --- a/app/controllers/projects/team_members_controller.rb +++ b/app/controllers/projects/team_members_controller.rb @@ -6,7 +6,7 @@ class Projects::TeamMembersController < Projects::ApplicationController def index @group = @project.group - @users_projects = @project.project_members.order('access_level DESC') + @project_members = @project.project_members.order('access_level DESC') end def new diff --git a/app/models/project.rb b/app/models/project.rb index 114e40983f8..0adedaa8dcd 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -79,8 +79,8 @@ class Project < ActiveRecord::Base has_many :snippets, dependent: :destroy, class_name: "ProjectSnippet" has_many :hooks, dependent: :destroy, class_name: "ProjectHook" has_many :protected_branches, dependent: :destroy - has_many :users_projects, dependent: :destroy - has_many :users, through: :users_projects + has_many :project_members, dependent: :destroy, as: :source, class_name: 'ProjectMember' + has_many :users, through: :project_members has_many :deploy_keys_projects, dependent: :destroy has_many :deploy_keys, through: :deploy_keys_projects has_many :users_star_projects, dependent: :destroy @@ -353,12 +353,12 @@ class Project < ActiveRecord::Base def team_member_by_name_or_email(name = nil, email = nil) user = users.where("name like ? or email like ?", name, email).first - users_projects.where(user: user) if user + project_members.where(user: user) if user end # Get Team Member record by user id def team_member_by_id(user_id) - users_projects.find_by(user_id: user_id) + project_members.find_by(user_id: user_id) end def name_with_namespace @@ -555,7 +555,7 @@ class Project < ActiveRecord::Base end def project_member(user) - users_projects.where(user_id: user).first + project_members.where(user_id: user).first end def default_branch diff --git a/app/models/user.rb b/app/models/user.rb index b235437817a..ef006e07b64 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -91,13 +91,13 @@ class User < ActiveRecord::Base # Projects has_many :groups_projects, through: :groups, source: :projects has_many :personal_projects, through: :namespace, source: :projects - has_many :projects, through: :users_projects + has_many :projects, through: :project_members has_many :created_projects, foreign_key: :creator_id, class_name: 'Project' has_many :users_star_projects, dependent: :destroy has_many :starred_projects, through: :users_star_projects, source: :project has_many :snippets, dependent: :destroy, foreign_key: :author_id, class_name: "Snippet" - has_many :users_projects, dependent: :destroy + has_many :project_members, dependent: :destroy has_many :issues, dependent: :destroy, foreign_key: :author_id has_many :notes, dependent: :destroy, foreign_key: :author_id has_many :merge_requests, dependent: :destroy, foreign_key: :author_id @@ -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 users_projects)') } + scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM project_members)') } scope :ldap, -> { where(provider: 'ldap') } scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active } diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 7a1fc06d3ac..52fc5cea887 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 'users_groups/users_group', member: member, show_controls: false + = render 'group_members/users_group', member: member, show_controls: false .panel-footer = paginate @group_members, param_name: 'group_members_page', theme: 'gitlab' diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml index 2938a15c608..e590ddbf931 100644 --- a/app/views/groups/_new_group_member.html.haml +++ b/app/views/groups/_new_group_member.html.haml @@ -1,4 +1,4 @@ -= form_for @users_group, url: group_users_groups_path(@group), html: { class: 'form-horizontal users-group-form' } do |f| += form_for @users_group, url: group_group_members_path(@group), html: { class: 'form-horizontal users-group-form' } do |f| .form-group = f.label :user_ids, "People", class: 'control-label' .col-sm-10= users_select_tag(:user_ids, multiple: true, class: 'input-large') diff --git a/app/views/groups/members.html.haml b/app/views/groups/members.html.haml index 19819c96124..7035cb95092 100644 --- a/app/views/groups/members.html.haml +++ b/app/views/groups/members.html.haml @@ -32,7 +32,7 @@ (#{@members.total_count}) %ul.well-list - @members.each do |member| - = render 'users_groups/users_group', member: member, show_roles: show_roles, show_controls: true + = render 'group_members/users_group', member: member, show_roles: show_roles, show_controls: true = paginate @members, theme: 'gitlab' :coffeescript diff --git a/app/views/profiles/notifications/show.html.haml b/app/views/profiles/notifications/show.html.haml index efe9c032190..3e28f2f5f90 100644 --- a/app/views/profiles/notifications/show.html.haml +++ b/app/views/profiles/notifications/show.html.haml @@ -39,13 +39,13 @@ .col-md-6 %h4 Groups: %ul.bordered-list - - @users_groups.each do |users_group| + - @group_members.each do |users_group| - notification = Notification.new(users_group) = render 'settings', type: 'group', membership: users_group, notification: notification .col-md-6 %h4 Projects: %ul.bordered-list - - @users_projects.each do |users_project| + - @project_members.each do |users_project| - notification = Notification.new(users_project) = render 'settings', type: 'project', membership: users_project, 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 c86648138c7..837f2f5c932 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 'users_groups/users_group', member: member, show_controls: false + = render 'group_members/users_group', 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/app/views/projects/team_members/index.html.haml b/app/views/projects/team_members/index.html.haml index ddb3b9d4a9d..ecb7c689e8a 100644 --- a/app/views/projects/team_members/index.html.haml +++ b/app/views/projects/team_members/index.html.haml @@ -11,6 +11,6 @@ %p.light Read more about project permissions %strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink" -= render "team", members: @users_projects += render "team", members: @project_members - if @group = render "group_members" diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 3629f1d5353..e00844227a8 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -17,7 +17,7 @@ namespace :gitlab do check_database_config_exists check_database_is_not_sqlite check_migrations_are_up - check_orphaned_users_groups + check_orphaned_group_members check_gitlab_config_exists check_gitlab_config_not_outdated check_log_writable @@ -194,7 +194,7 @@ namespace :gitlab do end end - def check_orphaned_users_groups + def check_orphaned_group_members print "Database contains orphaned GroupMembers? ... " if GroupMember.where("user_id not in (select id from users)").count > 0 puts "yes".red diff --git a/spec/factories/users_groups.rb b/spec/factories/users_groups.rb index 931f6a25575..450a0d88b76 100644 --- a/spec/factories/users_groups.rb +++ b/spec/factories/users_groups.rb @@ -1,6 +1,6 @@ # == Schema Information # -# Table name: users_groups +# Table name: group_members # # id :integer not null, primary key # group_access :integer not null diff --git a/spec/models/group_member_spec.rb b/spec/models/group_member_spec.rb index 9eb4859ebd5..58205e599fe 100644 --- a/spec/models/group_member_spec.rb +++ b/spec/models/group_member_spec.rb @@ -1,6 +1,6 @@ # == Schema Information # -# Table name: users_groups +# Table name: group_members # # id :integer not null, primary key # group_access :integer not null diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 006a8402d00..1d4ba8a2b85 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -20,7 +20,7 @@ describe Group do describe "Associations" do it { should have_many :projects } - it { should have_many :users_groups } + it { should have_many :group_members } end it { should validate_presence_of :name } diff --git a/spec/models/project_member_spec.rb b/spec/models/project_member_spec.rb index 76c5437a555..0178d065e57 100644 --- a/spec/models/project_member_spec.rb +++ b/spec/models/project_member_spec.rb @@ -1,6 +1,6 @@ # == Schema Information # -# Table name: users_projects +# Table name: project_members # # id :integer not null, primary key # user_id :integer not null diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 1c11ac39567..21800ab98ff 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -38,7 +38,7 @@ describe Project do it { should have_many(:merge_requests).dependent(:destroy) } it { should have_many(:issues).dependent(:destroy) } it { should have_many(:milestones).dependent(:destroy) } - it { should have_many(:users_projects).dependent(:destroy) } + it { should have_many(:project_members).dependent(:destroy) } it { should have_many(:notes).dependent(:destroy) } it { should have_many(:snippets).class_name('ProjectSnippet').dependent(:destroy) } it { should have_many(:deploy_keys_projects).dependent(:destroy) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f5c42f7cb2d..0250014bc21 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -52,7 +52,7 @@ describe User do describe "Associations" do it { should have_one(:namespace) } it { should have_many(:snippets).class_name('Snippet').dependent(:destroy) } - it { should have_many(:users_projects).dependent(:destroy) } + it { should have_many(:project_members).dependent(:destroy) } it { should have_many(:groups) } it { should have_many(:keys).dependent(:destroy) } it { should have_many(:events).class_name('Event').dependent(:destroy) } -- cgit v1.2.1