This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
199 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class TockProject < ActiveRecord::Base | ||
validates :name, presence: true | ||
validates :tock_id, presence: true | ||
|
||
def to_s | ||
"#{name} - #{billable_to_s}" | ||
end | ||
|
||
private | ||
|
||
def billable_to_s | ||
if billable | ||
"Billable" | ||
else | ||
"Not billable" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class TockImporter | ||
TOCK_PROJECTS = "https://tock-app.18f.gov/api/projects.json".freeze | ||
|
||
def run | ||
projects.each do |project| | ||
tock_project = TockProject.find_or_initialize_by(tock_id: project["id"]) | ||
tock_project.name = project["name"] | ||
tock_project.billable = project["billable"] | ||
tock_project.save! | ||
end | ||
end | ||
|
||
private | ||
|
||
def projects | ||
@_projects ||= json["results"] | ||
end | ||
|
||
def json | ||
JSON.parse(data) | ||
end | ||
|
||
def data | ||
Net::HTTP.get(URI(TOCK_PROJECTS)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Rails.application.config.assets.version = (ENV["ASSETS_VERSION"] || "1.0") | ||
Rails.application.config.assets.precompile += %w( jquery.js ) | ||
Rails.application.config.assets.paths << Rails.root.join('app', 'assets', 'fonts') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateTockProjects < ActiveRecord::Migration | ||
def change | ||
create_table :tock_projects do |t| | ||
t.timestamps null: false | ||
t.string :name, null: false | ||
t.boolean :billable, null: false | ||
t.integer :tock_id, null: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Feature: Admin creates auctions in the admins panel | ||
As an admin | ||
I should be able to create auctions | ||
|
||
Scenario: Adding an auction | ||
Given I am an administrator | ||
And there is a tock project to bill to | ||
When I sign in | ||
And I visit the auctions admin page | ||
And I click on the "Create a new auction" link | ||
And I edit the new auction form | ||
And I click to create an auction | ||
Then I should see the auction's title | ||
And I should see the start time I set for the auction | ||
And I should see the end time I set for the auction | ||
|
||
Scenario: Creating an invalid auction | ||
Given I am an administrator | ||
And there is a tock project to bill to | ||
And I sign in | ||
And I visit the auctions admin page | ||
When I click on the "Create a new auction" link | ||
And I edit the new auction form | ||
And I set the auction start price to $24000 | ||
And I click to create an auction | ||
Then I should see an alert that | ||
""" | ||
You do not have permission to publish auctions with a start price over $3500 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Given(/^there is a tock project to bill to$/) do | ||
@billable = FactoryGirl.create(:tock_project) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :tock_project do | ||
name 'Tock project' | ||
billable true | ||
tock_id 123 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'rails_helper' | ||
|
||
describe TockImporter do | ||
it 'creates or updates tock projects' do | ||
TockImporter.new.run | ||
|
||
expect(TockProject.count).to eq 3 | ||
|
||
TockImporter.new.run | ||
|
||
expect(TockProject.count).to eq 3 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'sinatra/base' | ||
|
||
class FakeTockApi < Sinatra::Base | ||
get '/api/projects.json' do | ||
json_response 200, 'tock_projects.json' | ||
end | ||
|
||
private | ||
|
||
def json_response(response_code, file_name) | ||
content_type :json | ||
status response_code | ||
File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"count": 3, "next": null, "previous": null, "results": [ { "id": 120, "client":"General Services Administration - 18F (Non-Billable)", "name":"18F Branding", "description":"Working on branding for 18F—internal branding", "billable":false }, { "id":97, "client":"General Services Administration - 18F (Non-Billable)", "name":"18F EDU", "description":"Self-directed training materials and proctored workshops to develop the skill sets of 18F and our partners", "billable":false }, { "id":96, "client":"General Services Administration - 18F (Non-Billable)", "name":"18F Guides", "description":" Aims to disseminate software development and bureaucracy-hacking best practices across 18F and for our partners' digital service teams", "billable":false } ] } |