introduce organizations
This commit is contained in:
parent
008ccf8b6d
commit
a06dc84eb0
9 changed files with 67 additions and 3 deletions
|
|
@ -7,6 +7,8 @@ class Conference < ActiveRecord::Base
|
||||||
|
|
||||||
default_scope { order('start_date DESC') }
|
default_scope { order('start_date DESC') }
|
||||||
|
|
||||||
|
belongs_to :organization
|
||||||
|
|
||||||
has_paper_trail ignore: %i(updated_at guid revision events_per_week), meta: { conference_id: :id }
|
has_paper_trail ignore: %i(updated_at guid revision events_per_week), meta: { conference_id: :id }
|
||||||
|
|
||||||
has_and_belongs_to_many :questions
|
has_and_belongs_to_many :questions
|
||||||
|
|
@ -53,7 +55,8 @@ class Conference < ActiveRecord::Base
|
||||||
:start_date,
|
:start_date,
|
||||||
:end_date,
|
:end_date,
|
||||||
:start_hour,
|
:start_hour,
|
||||||
:end_hour, presence: true
|
:end_hour,
|
||||||
|
:organization, presence: true
|
||||||
|
|
||||||
validates :short_title, uniqueness: true
|
validates :short_title, uniqueness: true
|
||||||
validates :short_title, format: { with: /\A[a-zA-Z0-9_-]*\z/ }
|
validates :short_title, format: { with: /\A[a-zA-Z0-9_-]*\z/ }
|
||||||
|
|
|
||||||
7
app/models/organization.rb
Normal file
7
app/models/organization.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
class Organization < ActiveRecord::Base
|
||||||
|
has_many :conferences, dependent: :destroy
|
||||||
|
|
||||||
|
validates :name, presence: true
|
||||||
|
|
||||||
|
mount_uploader :picture, PictureUploader, mount_on: :picture
|
||||||
|
end
|
||||||
|
|
@ -102,7 +102,7 @@ Osem::Application.routes.draw do
|
||||||
get '/revision_history/:id/revert_object' => 'versions#revert_object', as: 'revision_history_revert_object'
|
get '/revision_history/:id/revert_object' => 'versions#revert_object', as: 'revision_history_revert_object'
|
||||||
get '/revision_history/:id/revert_attribute' => 'versions#revert_attribute', as: 'revision_history_revert_attribute'
|
get '/revision_history/:id/revert_attribute' => 'versions#revert_attribute', as: 'revision_history_revert_attribute'
|
||||||
end
|
end
|
||||||
|
resources :organizations
|
||||||
resources :conferences, only: [:index, :show] do
|
resources :conferences, only: [:index, :show] do
|
||||||
resource :program, only: [] do
|
resource :program, only: [] do
|
||||||
resources :proposals, except: :destroy do
|
resources :proposals, except: :destroy do
|
||||||
|
|
|
||||||
9
db/migrate/20170529215453_create_organizations.rb
Normal file
9
db/migrate/20170529215453_create_organizations.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
class CreateOrganizations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :organizations do |t|
|
||||||
|
t.string :name
|
||||||
|
t.text :description
|
||||||
|
t.string :picture
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddOrganizatonIdToConference < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :conferences, :organization_id, :integer
|
||||||
|
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: 20170302145716) do
|
ActiveRecord::Schema.define(version: 20170531094817) 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
|
||||||
|
|
@ -100,6 +100,7 @@ ActiveRecord::Schema.define(version: 20170302145716) do
|
||||||
t.string "picture"
|
t.string "picture"
|
||||||
t.integer "start_hour", default: 9
|
t.integer "start_hour", default: 9
|
||||||
t.integer "end_hour", default: 20
|
t.integer "end_hour", default: 20
|
||||||
|
t.integer "organization_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "conferences_questions", id: false, force: :cascade do |t|
|
create_table "conferences_questions", id: false, force: :cascade do |t|
|
||||||
|
|
@ -266,6 +267,12 @@ ActiveRecord::Schema.define(version: 20170302145716) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "organizations", force: :cascade do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.text "description"
|
||||||
|
t.string "picture"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "payments", force: :cascade do |t|
|
create_table "payments", force: :cascade do |t|
|
||||||
t.string "last4"
|
t.string "last4"
|
||||||
t.integer "amount"
|
t.integer "amount"
|
||||||
|
|
|
||||||
0
spec/controllers/organizations_controller_spec.rb
Normal file
0
spec/controllers/organizations_controller_spec.rb
Normal file
13
spec/factories/organizations.rb
Normal file
13
spec/factories/organizations.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :organization do
|
||||||
|
name { Faker::Company.name }
|
||||||
|
description { Faker::Lorem.paragraph }
|
||||||
|
|
||||||
|
# after(:create) do |organization|
|
||||||
|
# File.open("spec/support/logos/#{1 + rand(13)}.png") do |file|
|
||||||
|
# organization.picture = file
|
||||||
|
# end
|
||||||
|
# organization.save!
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
20
spec/models/organization_spec.rb
Normal file
20
spec/models/organization_spec.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Organization do
|
||||||
|
let(:organization) { create(:organization) }
|
||||||
|
|
||||||
|
describe 'validation' 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
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'associations' do
|
||||||
|
it { should have_many(:conferences).dependent(:destroy) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue