Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #179 from 18F/develop
Browse files Browse the repository at this point in the history
Deploy to production 12/30
  • Loading branch information
adelevie committed Dec 30, 2015
2 parents c1090e4 + 92095d3 commit a62b0c4
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ h1, h2, h3, h4, h5, h6, p {
}

a {
color: #00a6d2;
color: #0071bc;
}

a:visited {
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/models/presenter/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 24 additions & 1 deletion app/views/admin/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<h1>Users</h1>
<h2>Admins (<%= @admins.length %>)</h2>

<table class="usa-table-borderless">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">DUNS Number</th>
<th scope="col">GitHub ID</th>
</tr>
</thead>
<tbody>
<% @admins.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<td><%= user.duns_number %></td>
<td><%= link_to(user.github_id, user.github_json_url) %></td>
</tr>
<% end %>
</tbody>
</table>

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

<table class="usa-table-borderless">
<thead>
Expand Down
11 changes: 3 additions & 8 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
4 changes: 2 additions & 2 deletions spec/factories/auctions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions spec/features/admin_users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
2 changes: 1 addition & 1 deletion spec/models/place_bid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
{
Expand Down

0 comments on commit a62b0c4

Please sign in to comment.