Commit 0bc714c271174137431d9194d8f1567953f97a8b

Authored by Dmitriy Zaporozhets
1 parent 19d628dd

Remove form for adding user to several projects from admin area.

Remove unnecessary projects order on User#show
app/controllers/admin/users_controller.rb
... ... @@ -9,11 +9,6 @@ class Admin::UsersController < Admin::ApplicationController
9 9 end
10 10  
11 11 def show
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 12 @projects = admin_user.authorized_projects
18 13 end
19 14  
... ...
app/controllers/users_controller.rb
... ... @@ -3,7 +3,7 @@ class UsersController < ApplicationController
3 3  
4 4 def show
5 5 @user = User.find_by_username!(params[:username])
6   - @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)).order('namespace_id DESC')
  6 + @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id))
7 7 @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
8 8  
9 9 @title = @user.name
... ...
app/views/admin/users/show.html.haml
... ... @@ -63,28 +63,6 @@
63 63 %strong
64 64 = link_to @admin_user.created_by.name, [:admin, @admin_user.created_by]
65 65  
66   - %hr
67   - %h5
68   - Add User to Projects
69   - %small
70   - Read more about project permissions
71   - %strong= link_to "here", help_permissions_path, class: "vlink"
72   - %br
73   - = form_tag team_update_admin_user_path(@admin_user), class: "bulk_import", method: :put do
74   - .control-group
75   - = label_tag :project_ids, "Projects", class: 'control-label'
76   - .controls
77   - = 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'
78   - .control-group
79   - = label_tag :project_access, "Project Access", class: 'control-label'
80   - .controls
81   - = select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3"
82   -
83   - .form-actions
84   - = submit_tag 'Add', class: "btn btn-create"
85   - .pull-right
86   - %br
87   -
88 66 - if @admin_user.owned_groups.present?
89 67 .ui-box
90 68 %h5.title Owned groups:
... ...
app/views/dashboard/projects.html.haml
... ... @@ -24,6 +24,8 @@
24 24 .ui-box
25 25 %h5.title
26 26 Projects (#{@projects.total_count})
  27 + .pull-right.light
  28 + %small Last activity
27 29 %ul.well-list
28 30 - @projects.each do |project|
29 31 %li
... ... @@ -39,7 +41,7 @@
39 41 = truncate project.description, length: 80
40 42  
41 43 .pull-right.light
42   - %small Last activity #{project_last_activity(project)}
  44 + %small #{project_last_activity(project)}
43 45  
44 46 - if @projects.blank?
45 47 %li
... ...
spec/factories.rb
... ... @@ -27,6 +27,7 @@ FactoryGirl.define do
27 27 sequence(:name) { |n| "project#{n}" }
28 28 path { name.downcase.gsub(/\s/, '_') }
29 29 creator
  30 + namespace { creator.namespace }
30 31 end
31 32  
32 33 factory :redmine_project, parent: :project do
... ...
spec/features/admin/admin_users_spec.rb
... ... @@ -109,18 +109,4 @@ describe "Admin::Users" do
109 109 end
110 110 end
111 111 end
112   -
113   - describe "Add new project" do
114   - before do
115   - @new_project = create(:project)
116   - visit admin_user_path(@user)
117   - end
118   -
119   - it "should create new user" do
120   - select @new_project.name, from: "project_ids"
121   - expect { click_button "Add" }.to change { UsersProject.count }.by(1)
122   - page.should have_content @new_project.name
123   - current_path.should == admin_user_path(@user)
124   - end
125   - end
126 112 end
... ...
spec/models/user_spec.rb
... ... @@ -111,12 +111,8 @@ describe User do
111 111 @project_2 = create :project # Grant MASTER access to the user
112 112 @project_3 = create :project # Grant DEVELOPER access to the user
113 113  
114   - UsersProject.add_users_into_projects(
115   - [@project_2.id], [@user.id], UsersProject::MASTER
116   - )
117   - UsersProject.add_users_into_projects(
118   - [@project_3.id], [@user.id], UsersProject::DEVELOPER
119   - )
  114 + @project_2.team << [@user, :master]
  115 + @project_3.team << [@user, :developer]
120 116 end
121 117  
122 118 it { @user.authorized_projects.should include(@project) }
... ...