diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index a70b446d..2efee7b9 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -325,7 +325,7 @@ h1, h2, h3, h4, h5, h6, p { } a { - color: #00a6d2; + color: #0071bc; } a:visited { diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 72173815..c1f51604 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -3,7 +3,8 @@ class UsersController < ApplicationController before_filter :require_admin def index - @users = User.all.map {|user| Presenter::User.new(user)} + all_users = User.all.map {|user| Presenter::User.new(user)} + @admins, @users = all_users.partition {|u| u.is_admin?} end def show diff --git a/app/models/presenter/user.rb b/app/models/presenter/user.rb index 99ff3e00..d79061cb 100644 --- a/app/models/presenter/user.rb +++ b/app/models/presenter/user.rb @@ -3,5 +3,13 @@ class User < SimpleDelegator def github_json_url "https://api.github.com/user/#{github_id}" end + + def is_admin? + Admins.verify?(model.github_id) + end + + def model + __getobj__ + end end end diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index 501d1f07..6660e0ca 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,4 +1,27 @@ -

Users

+

Admins (<%= @admins.length %>)

+ + + + + + + + + + + + <% @admins.each do |user| %> + + + + + + + <% end %> + +
NameEmailDUNS NumberGitHub ID
<%= user.name %><%= user.email %><%= user.duns_number %><%= link_to(user.github_id, user.github_json_url) %>
+ +

Users (<%= @users.length %>)

diff --git a/db/seeds.rb b/db/seeds.rb index 70527406..13bf35ee 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,14 +6,9 @@ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) -auction = Auction.new({ +FactoryGirl.create( + :current_auction, issue_url: 'https://github.com/18F/mpt3500/issues/10', - start_price: 3500.0, - start_datetime: Chronic.parse("October 13 2015 at 2:15 PM"), - end_datetime: Chronic.parse("October 14 2015 at 3:00 PM"), title: 'Build a Placeholder for MPT 3500', description: 'This auction is a placeholder for MPT 3500. The MPT 3500 team needs to build the following ...', - github_repo: 'https://github.com/18F/mpt3500', - published: 0 -}) -auction.save + github_repo: 'https://github.com/18F/mpt3500') diff --git a/spec/factories/auctions.rb b/spec/factories/auctions.rb index 77964536..e5d49aa7 100644 --- a/spec/factories/auctions.rb +++ b/spec/factories/auctions.rb @@ -9,8 +9,8 @@ trait :with_bidders do after(:build) do |instance| - (1..4).each do |i| - amount = 3499 - (20 * i) - rand(10) + (1..rand(10)+1).each do |i| + amount = 3499 - (100 * i) - rand(30) instance.bids << FactoryGirl.create(:bid, auction: instance, amount: amount) end end diff --git a/spec/features/admin_users_spec.rb b/spec/features/admin_users_spec.rb index 4b83e81e..2dd1973e 100644 --- a/spec/features/admin_users_spec.rb +++ b/spec/features/admin_users_spec.rb @@ -2,11 +2,11 @@ RSpec.feature "AdminUsers", type: :feature do before do - create_user sign_in_admin end - scenario "visiting the admin users list and then a user" do + scenario "visiting the admin users list" do + create_user visit "/admin/users" expect(page).not_to have_text('must be an admin') user = Presenter::User.new(@user) @@ -16,4 +16,12 @@ expect(page).to have_text(user.name) expect(page).to have_text(user.github_id) end + + scenario "counting the number of users and admins" do + number_of_users = 11 + number_of_users.times { create_user } + visit "/admin/users" + expect(page).to have_text("Users (#{number_of_users}") + expect(page).to have_text("Admins (#{1}") + end end diff --git a/spec/models/place_bid_spec.rb b/spec/models/place_bid_spec.rb index 99141a7a..86017b0b 100644 --- a/spec/models/place_bid_spec.rb +++ b/spec/models/place_bid_spec.rb @@ -2,7 +2,7 @@ RSpec.describe PlaceBid do let(:place_bid) { PlaceBid.new(params, current_user) } - let(:current_user) { FactoryGirl.create(:user, id: 111) } + let(:current_user) { FactoryGirl.create(:user) } let(:amount) { 1005 } let(:params) { {