Commit 9351997f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move roles statistic to separate page

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent e5d3d06a
......@@ -23,8 +23,9 @@
%h3.text-center
Users:
= number_with_delimiter(User.count)
.text-center
= link_to 'Users statistics', admin_dashboard_stats_path
%hr
= render "admin/dashboard/roles_stats"
= link_to 'New user', new_admin_user_path, class: "btn btn-new"
.col-sm-4
.info-well.dark-well
......
......@@ -138,6 +138,8 @@ namespace :admin do
get :status
end
end
get '/dashboard/stats', to: 'dashboard#stats'
## EE-specific
resources :labels
......
......@@ -4,13 +4,7 @@ module EE
module DashboardController
extend ActiveSupport::Concern
prepended do
before_action :set_roles_count, only: [:index]
end
private
def set_roles_count
def stats
@admin_count = ::User.admins.count
@roles_count = ::ProjectAuthorization.roles_stats
end
......
- if @admin_count
%p
Admin users
%span.light.pull-right
= @admin_count
- if @roles_count
- @roles_count.each do |row|
%p
Users with highest role
%strong
= row['kind']
%span.light.pull-right
= row['amount']
%h3 Users statistics
%table.table
%tr
%td Users total
%td
= User.count
- if @admin_count
%tr
%td Admin users
%td
= @admin_count
- if @roles_count
- @roles_count.each do |row|
%tr
%td
Users with highest role
%strong
= row['kind']
%td
= row['amount']
require 'spec_helper'
describe "Admin Dashboard" do
before do
3.times do
project = create(:project)
user = create(:user)
project.add_reporter(user)
end
describe 'Admin Dashboard' do
describe 'Users statistic' do
before do
3.times do
project = create(:project)
user = create(:user)
project.add_reporter(user)
end
2.times do
project = create(:project)
user = create(:user)
project.add_developer(user)
end
2.times do
project = create(:project)
user = create(:user)
project.add_developer(user)
end
# Add same user as Reporter and Developer to different projects
# and expect it to be counted once for the stats
user = create(:user)
project1 = Project.first
project2 = Project.last
project1.add_reporter(user)
project2.add_developer(user)
# Add same user as Reporter and Developer to different projects
# and expect it to be counted once for the stats
user = create(:user)
project1 = Project.first
project2 = Project.last
project1.add_reporter(user)
project2.add_developer(user)
sign_in(create(:admin))
end
sign_in(create(:admin))
end
describe 'Roles stats' do
it 'show correct amount of users per role' do
visit admin_root_path
describe 'Roles stats' do
it 'show correct amount of users per role' do
visit admin_dashboard_stats_path
expect(page).to have_content('Admin users 1')
expect(page).to have_content('Users with highest role developer 3')
expect(page).to have_content('Users with highest role reporter 3')
expect(page).to have_content('Admin users 1')
expect(page).to have_content('Users with highest role developer 3')
expect(page).to have_content('Users with highest role reporter 3')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment