add payment mode to conferences schema
This commit is contained in:
parent
301ad1c722
commit
f14d470738
5 changed files with 25 additions and 1 deletions
|
|
@ -57,6 +57,9 @@ class Conference < ActiveRecord::Base
|
||||||
validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
|
validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
|
||||||
validates :registration_limit, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
validates :registration_limit, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||||
|
|
||||||
|
validates :payment_method, presence: true, null: false, inclusion: {in: %w(online offline),
|
||||||
|
message: "'%{value}' is not a valid payment method"}
|
||||||
|
|
||||||
# This validation is needed since a conference with a start date greater than the end date is not possible
|
# This validation is needed since a conference with a start date greater than the end date is not possible
|
||||||
validate :valid_date_range?
|
validate :valid_date_range?
|
||||||
before_create :generate_guid
|
before_create :generate_guid
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddPaymentMethodToConferences < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :conferences, :payment_method, :string, default: 'offline', null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20160427104236) do
|
ActiveRecord::Schema.define(version: 20160603043546) do
|
||||||
|
|
||||||
create_table "ahoy_events", force: :cascade do |t|
|
create_table "ahoy_events", force: :cascade do |t|
|
||||||
t.uuid "visit_id", limit: 16
|
t.uuid "visit_id", limit: 16
|
||||||
|
|
@ -102,6 +102,7 @@ ActiveRecord::Schema.define(version: 20160427104236) do
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.integer "registration_limit", default: 0
|
t.integer "registration_limit", default: 0
|
||||||
t.string "picture"
|
t.string "picture"
|
||||||
|
t.string "payment_method", default: "offline", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "conferences_questions", id: false, force: :cascade do |t|
|
create_table "conferences_questions", id: false, force: :cascade do |t|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ FactoryGirl.define do
|
||||||
end_date { 6.days.from_now }
|
end_date { 6.days.from_now }
|
||||||
registration_limit 0
|
registration_limit 0
|
||||||
description { Faker::Hipster.paragraph }
|
description { Faker::Hipster.paragraph }
|
||||||
|
payment_method 'offline'
|
||||||
|
|
||||||
after(:create) do |conference|
|
after(:create) do |conference|
|
||||||
Role.where(name: 'organizer', resource: conference).first_or_create(description: 'For the organizers of the conference (who shall have full access)')
|
Role.where(name: 'organizer', resource: conference).first_or_create(description: 'For the organizers of the conference (who shall have full access)')
|
||||||
|
|
|
||||||
|
|
@ -1545,6 +1545,20 @@ describe Conference do
|
||||||
should validate_presence_of(:end_date)
|
should validate_presence_of(:end_date)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'is not valid without payment mode' do
|
||||||
|
should validate_presence_of(:payment_method)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'is valid with payment mode as Online' do
|
||||||
|
should allow_value('online').for(:payment_method).
|
||||||
|
with_message("'%{value}' is not a valid payment method")
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'is valid with payment mode as Offline' do
|
||||||
|
should allow_value('offline').for(:payment_method).
|
||||||
|
with_message("'%{value}' is not a valid payment method")
|
||||||
|
end
|
||||||
|
|
||||||
it 'is not valid with a duplicate short title' do
|
it 'is not valid with a duplicate short title' do
|
||||||
should validate_uniqueness_of(:short_title)
|
should validate_uniqueness_of(:short_title)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue