Commit 60a41a5b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add more tests to users stats feature

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d31477f1
require 'spec_helper'
describe ProjectAuthorization do
describe '.roles_stats' do
before do
project1 = create(:project_empty_repo)
project1.add_reporter(create(:user))
project2 = create(:project_empty_repo)
project2.add_developer(create(: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.add_reporter(user)
project2.add_developer(user)
end
subject { ProjectAuthorization.roles_stats.to_a }
it do
expect(subject).to include({ 'kind' => 'reporter', 'amount' => '1' })
expect(subject).to include({ 'kind' => 'developer', 'amount' => '2' })
expect(subject).to include({ 'kind' => 'master', 'amount' => '2' })
end
end
end
......@@ -3,23 +3,15 @@ require 'spec_helper'
describe 'Admin Dashboard' do
describe 'Users statistic' do
before do
3.times do
project = create(:project)
user = create(:user)
project.add_reporter(user)
end
project1 = create(:project_empty_repo)
project1.add_reporter(create(:user))
2.times do
project = create(:project)
user = create(:user)
project.add_developer(user)
end
project2 = create(:project_empty_repo)
project2.add_developer(create(: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)
......@@ -31,8 +23,8 @@ describe 'Admin Dashboard' 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('Users with highest role developer 2')
expect(page).to have_content('Users with highest role reporter 1')
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