This commit is contained in:
Gopesh Tulsyan 2014-06-05 11:14:15 +00:00
commit 4d3a5c6973
5 changed files with 78 additions and 10 deletions

View file

@ -0,0 +1,11 @@
class Organization < ActiveRecord::Base
attr_accessible :name, :logo, :description, :website_url
has_attached_file :logo,
styles: { thumb: '100x100>', large: '300x300>' }
validates_attachment_content_type :logo,
content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { in: 0..500.kilobytes }
validates_presence_of :name, :website_url
validates_uniqueness_of :website_url
end

View file

@ -0,0 +1,14 @@
class CreateOrganizations < ActiveRecord::Migration
def change
create_table :organizations do |t|
t.string :name
t.string :website_url
t.text :description
t.string :logo_file_name
t.string :logo_content_type
t.integer :logo_file_size
t.datetime :logo_updated_at
t.timestamps
end
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140604142949) do
ActiveRecord::Schema.define(version: 20140605101748) do
create_table "answers", force: true do |t|
t.string "title"
@ -50,15 +50,15 @@ ActiveRecord::Schema.define(version: 20140604142949) 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"
@ -186,6 +186,18 @@ ActiveRecord::Schema.define(version: 20140604142949) do
t.integer "event_id"
end
create_table "organizations", force: true do |t|
t.string "name"
t.string "website_url"
t.text "description"
t.string "logo_file_name"
t.string "logo_content_type"
t.integer "logo_file_size"
t.datetime "logo_updated_at"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "people", force: true do |t|
t.string "guid", null: false
t.string "first_name", default: ""
@ -308,9 +320,9 @@ ActiveRecord::Schema.define(version: 20140604142949) 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"

View file

@ -0,0 +1,9 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :organization do
name 'Example organization'
sequence(:website_url) { |n| "example#{n}@example.com" }
description 'Lorem Ipsum Dolor'
end
end

View file

@ -0,0 +1,22 @@
require 'spec_helper'
describe Organization do
describe 'validations' do
it 'has a valid factory' do
expect(build(:organization)).to be_valid
end
it 'is not valid without a name' do
should validate_presence_of(:name)
end
it 'is not valid without a website url' do
should validate_presence_of(:website_url)
end
it 'is not valid with a duplicate website_url' do
should validate_uniqueness_of(:website_url)
end
end
end