add payment mode to ticket schema
This commit is contained in:
parent
301ad1c722
commit
a8fd1a7903
5 changed files with 14 additions and 3 deletions
|
|
@ -9,7 +9,7 @@ class Ticket < ActiveRecord::Base
|
|||
# If we would allow different currencies per conference we also have to handle convertions between currencies!
|
||||
validate :tickets_of_conference_have_same_currency
|
||||
|
||||
validates :price_cents, :price_currency, :title, presence: true
|
||||
validates :price_cents, :price_currency, :payment_mode, :title, presence: true
|
||||
|
||||
validates_numericality_of :price_cents, greater_than: 0
|
||||
|
||||
|
|
|
|||
5
db/migrate/20160526142456_add_payment_mode_to_tickets.rb
Normal file
5
db/migrate/20160526142456_add_payment_mode_to_tickets.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddPaymentModeToTickets < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tickets, :payment_mode, :string
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160427104236) do
|
||||
ActiveRecord::Schema.define(version: 20160526142456) do
|
||||
|
||||
create_table "ahoy_events", force: :cascade do |t|
|
||||
t.uuid "visit_id", limit: 16
|
||||
|
|
@ -411,6 +411,7 @@ ActiveRecord::Schema.define(version: 20160427104236) do
|
|||
t.text "description"
|
||||
t.integer "price_cents", default: 0, null: false
|
||||
t.string "price_currency", default: "USD", null: false
|
||||
t.string "payment_mode"
|
||||
end
|
||||
|
||||
create_table "tracks", force: :cascade do |t|
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@ FactoryGirl.define do
|
|||
title { "#{Faker::Hipster.word} Ticket" }
|
||||
price_cents 1000
|
||||
price_currency 'USD'
|
||||
payment_mode 'Online'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Ticket do
|
||||
let(:conference) { create(:conference) }
|
||||
let(:ticket) { create(:ticket, price: 50, price_currency: 'USD', conference: conference) }
|
||||
let(:ticket) { create(:ticket, price: 50, price_currency: 'USD', payment_mode: 'Online', conference: conference) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'validation' do
|
||||
|
|
@ -22,6 +22,10 @@ describe Ticket do
|
|||
should validate_presence_of(:price_currency)
|
||||
end
|
||||
|
||||
it 'is not valid without a payment_mode' do
|
||||
should validate_presence_of(:payment_mode)
|
||||
end
|
||||
|
||||
it 'is not valid with a price_cents equals zero' do
|
||||
should_not allow_value(0).for(:price_cents)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue