forked from danielvlopes/railsmg
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Meeting::Content < ActiveRecord::Base | ||
# Table name | ||
set_table_name 'meeting_content' | ||
|
||
# Associations | ||
belongs_to :meeting | ||
|
||
# Validations | ||
validates_presence_of :meeting, :name, :url | ||
|
||
with_options :allow_blank => true do |c| | ||
c.validates_length_of :name, :in => 1..255 | ||
# FIXME: c.validates_as_uri :url | ||
end | ||
|
||
def to_s | ||
name | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class CreateMeetingContent < ActiveRecord::Migration | ||
def self.up | ||
create_table :meeting_content do |t| | ||
t.references :meeting | ||
t.string :name | ||
t.string :url | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :meeting_content, :meeting_id | ||
end | ||
|
||
def self.down | ||
drop_table :meeting_content | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
describe Meeting::Content do | ||
before do | ||
@meeting_content = Meeting::Content.make | ||
end | ||
|
||
# Database | ||
should_have_column :meeting_id, :type => :integer | ||
should_have_columns :name, :url, :type => :string | ||
should_have_index :meeting_id | ||
|
||
# Associations | ||
should_belong_to :meeting | ||
|
||
# Validations | ||
should_validate_presence_of :meeting, :name, :url | ||
|
||
with_options :allow_blank => true do |c| | ||
c.should_validate_length_of :name, :in => 1..255 | ||
# FIXME: c.should_validate_as_uri :url | ||
end | ||
|
||
it 'table_name should be meeting_content' do | ||
Meeting::Content.table_name.should be_eql('meeting_content') | ||
end | ||
|
||
it 'to_s should return name' do | ||
@meeting_content.to_s.should be_eql(@meeting_content.name) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters