Adds organization model
This commit is contained in:
parent
a95a03c7e5
commit
b63f3fa7c9
5 changed files with 84 additions and 10 deletions
11
app/models/organization.rb
Normal file
11
app/models/organization.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
class Organization < ActiveRecord::Base
|
||||||
|
attr_accessible :name, :logo, :description, :phone_number, :email, :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 :email
|
||||||
|
end
|
||||||
16
db/migrate/20140605101748_create_organizations.rb
Normal file
16
db/migrate/20140605101748_create_organizations.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
class CreateOrganizations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :organizations do |t|
|
||||||
|
t.string :name
|
||||||
|
t.string :email
|
||||||
|
t.string :phone_number
|
||||||
|
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
|
||||||
34
db/schema.rb
34
db/schema.rb
|
|
@ -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: 20140604142949) do
|
ActiveRecord::Schema.define(version: 20140605101748) do
|
||||||
|
|
||||||
create_table "answers", force: true do |t|
|
create_table "answers", force: true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
|
@ -50,15 +50,15 @@ ActiveRecord::Schema.define(version: 20140604142949) do
|
||||||
add_index "comments", ["user_id"], name: "index_comments_on_user_id"
|
add_index "comments", ["user_id"], name: "index_comments_on_user_id"
|
||||||
|
|
||||||
create_table "conferences", force: true do |t|
|
create_table "conferences", force: true do |t|
|
||||||
t.string "guid", null: false
|
t.string "guid", null: false
|
||||||
t.string "title", null: false
|
t.string "title", null: false
|
||||||
t.string "short_title", null: false
|
t.string "short_title", null: false
|
||||||
t.string "social_tag"
|
t.string "social_tag"
|
||||||
t.string "contact_email", null: false
|
t.string "contact_email", null: false
|
||||||
t.string "timezone", null: false
|
t.string "timezone", null: false
|
||||||
t.string "html_export_path"
|
t.string "html_export_path"
|
||||||
t.date "start_date", null: false
|
t.date "start_date", null: false
|
||||||
t.date "end_date", null: false
|
t.date "end_date", null: false
|
||||||
t.integer "venue_id"
|
t.integer "venue_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
|
@ -186,6 +186,20 @@ ActiveRecord::Schema.define(version: 20140604142949) do
|
||||||
t.integer "event_id"
|
t.integer "event_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "organizations", force: true do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.string "email"
|
||||||
|
t.string "phone_number"
|
||||||
|
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|
|
create_table "people", force: true do |t|
|
||||||
t.string "guid", null: false
|
t.string "guid", null: false
|
||||||
t.string "first_name", default: ""
|
t.string "first_name", default: ""
|
||||||
|
|
@ -308,9 +322,9 @@ ActiveRecord::Schema.define(version: 20140604142949) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "tracks", force: true do |t|
|
create_table "tracks", force: true do |t|
|
||||||
t.string "guid", null: false
|
t.string "guid", null: false
|
||||||
t.integer "conference_id"
|
t.integer "conference_id"
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.string "color"
|
t.string "color"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
|
|
||||||
11
spec/factories/organizations.rb
Normal file
11
spec/factories/organizations.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :organization do
|
||||||
|
name 'Example organization'
|
||||||
|
sequence(:email) { |n| "example#{n}@example.com" }
|
||||||
|
website_url 'www.esxample.com'
|
||||||
|
description 'Lorem Ipsum Dolor'
|
||||||
|
phone_number '900099009'
|
||||||
|
end
|
||||||
|
end
|
||||||
22
spec/models/organization_spec.rb
Normal file
22
spec/models/organization_spec.rb
Normal 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 email' do
|
||||||
|
should validate_uniqueness_of(:email)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue