Skip to content

Birth date #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
spec/examples.txt
/docs
.DS_Store

# Ignoring IntelliJ related stuff
.idea
*.iml

2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ class User < ActiveRecord::Base

validates :username, presence: true

validates :birth_date, presence: true

has_many :players
end
5 changes: 5 additions & 0 deletions db/migrate/20150917164853_add_birth_date_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddBirthDateToUsers < ActiveRecord::Migration
def change
add_column :users, :birth_date, :date
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150914233717) do
ActiveRecord::Schema.define(version: 20150917164853) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -210,6 +210,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "pit_boss", default: false, null: false
t.date "birth_date"
end

create_table "wagers", force: :cascade do |t|
Expand Down
8 changes: 8 additions & 0 deletions spec/acceptance/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
"drowssap"
end

parameter 'birth_date', <<-DESC, required: true, scope: :attributes
Date of birth.
DESC

let 'birth_date' do
Date.new(1975,3,5)
end

example_request "POST /v1/users" do
expect(status).to eq 201
parsed = JSON.parse(response_body)
Expand Down
3 changes: 2 additions & 1 deletion spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FactoryGirl.define do
factory :user do
username "sean"
password "drowssap"
password "drowssa"
birth_date Date.new(1975,3,5)
end
end
6 changes: 6 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
expect(subject.errors[:username]).to include "can't be blank"
end

it 'has a birth date attribute' do
birth_date = Date.new(1975,03,05)
subject.birth_date = birth_date
expect(subject.birth_date).to eq birth_date
end

it "has the pit_boss attribute" do
subject.pit_boss = true
expect(subject).to be_pit_boss
Expand Down
2 changes: 2 additions & 0 deletions spec/requests/end_to_end_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
)
wager_id = JSON.parse(response.body)["data"]["id"]

expect(wager_id).not_to be_nil

end

end