diff --git a/app/models/conference.rb b/app/models/conference.rb index b49a901e..3b6ff456 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -31,6 +31,7 @@ class Conference < ActiveRecord::Base has_many :vdays, :dependent => :destroy has_many :vpositions, :dependent => :destroy has_many :vchoices, :dependent => :destroy + has_many :sponsorship_levels, dependent: :destroy belongs_to :venue diff --git a/app/models/sponsorship_level.rb b/app/models/sponsorship_level.rb new file mode 100644 index 00000000..03f52ae8 --- /dev/null +++ b/app/models/sponsorship_level.rb @@ -0,0 +1,5 @@ +class SponsorshipLevel < ActiveRecord::Base + attr_accessible :title, :donation_amount + validates_presence_of :title + belongs_to :conference +end diff --git a/db/migrate/20140605055802_create_sponsorship_levels.rb b/db/migrate/20140605055802_create_sponsorship_levels.rb new file mode 100644 index 00000000..2f65e43d --- /dev/null +++ b/db/migrate/20140605055802_create_sponsorship_levels.rb @@ -0,0 +1,10 @@ +class CreateSponsorshipLevels < ActiveRecord::Migration + def change + create_table :sponsorship_levels do |t| + t.string :title + t.string :donation_amount + t.belongs_to :conference + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ef5c751..b110fc36 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -50,15 +50,15 @@ ActiveRecord::Schema.define(version: 20140605125153) do add_index "comments", ["user_id"], name: "index_comments_on_user_id" create_table "conferences", force: true do |t| - t.string "guid", null: false - t.string "title", null: false - t.string "short_title", null: false + t.string "guid", null: false + t.string "title", null: false + t.string "short_title", null: false t.string "social_tag" - t.string "contact_email", null: false - t.string "timezone", null: false + t.string "contact_email", null: false + t.string "timezone", null: false t.string "html_export_path" - t.date "start_date", null: false - t.date "end_date", null: false + t.date "start_date", null: false + t.date "end_date", null: false t.integer "venue_id" t.datetime "created_at" t.datetime "updated_at" @@ -288,6 +288,27 @@ ActiveRecord::Schema.define(version: 20140605125153) do t.date "date" end + create_table "sponsors", force: true do |t| + t.string "name" + t.text "description" + t.string "website_url" + t.string "logo_file_name" + t.string "logo_content_type" + t.integer "logo_file_size" + t.datetime "logo_updated_at" + t.integer "sponsorship_level_id" + t.integer "conference_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "sponsorship_levels", force: true do |t| + t.string "title" + t.integer "conference_id" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "supporter_levels", force: true do |t| t.integer "conference_id" t.string "title", null: false @@ -308,9 +329,9 @@ ActiveRecord::Schema.define(version: 20140605125153) do end create_table "tracks", force: true do |t| - t.string "guid", null: false + t.string "guid", null: false t.integer "conference_id" - t.string "name", null: false + t.string "name", null: false t.text "description" t.string "color" t.datetime "created_at" diff --git a/spec/factories/sponsorship_levels.rb b/spec/factories/sponsorship_levels.rb new file mode 100644 index 00000000..c640ce58 --- /dev/null +++ b/spec/factories/sponsorship_levels.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :sponsorship_level do + title 'Platin' + donation_amount '$100,000' + conference + end +end diff --git a/spec/models/sponsorship_level_spec.rb b/spec/models/sponsorship_level_spec.rb new file mode 100644 index 00000000..1ca073e1 --- /dev/null +++ b/spec/models/sponsorship_level_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe SponsorshipLevel do + describe 'validations' do + + it 'has a valid factory' do + expect(build(:sponsorship_level)).to be_valid + end + + it 'is not valid without a title' do + should validate_presence_of(:title) + end + end +end