Broadcast message model + migrations
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
0a08c77519
commit
f1ecf53c1e
5 changed files with 44 additions and 1 deletions
5
app/models/broadcast_message.rb
Normal file
5
app/models/broadcast_message.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class BroadcastMessage < ActiveRecord::Base
|
||||
attr_accessible :alert_type, :ends_at, :message, :starts_at
|
||||
|
||||
validates :message, presence: true
|
||||
end
|
12
db/migrate/20131112114325_create_broadcast_messages.rb
Normal file
12
db/migrate/20131112114325_create_broadcast_messages.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class CreateBroadcastMessages < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :broadcast_messages do |t|
|
||||
t.text :message, null: false
|
||||
t.datetime :starts_at
|
||||
t.datetime :ends_at
|
||||
t.integer :alert_type
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/schema.rb
11
db/schema.rb
|
@ -11,7 +11,16 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20131106151520) do
|
||||
ActiveRecord::Schema.define(:version => 20131112114325) do
|
||||
|
||||
create_table "broadcast_messages", :force => true do |t|
|
||||
t.text "message", :null => false
|
||||
t.datetime "starts_at"
|
||||
t.datetime "ends_at"
|
||||
t.integer "alert_type"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "deploy_keys_projects", :force => true do |t|
|
||||
t.integer "deploy_key_id", :null => false
|
||||
|
|
10
spec/factories/broadcast_messages.rb
Normal file
10
spec/factories/broadcast_messages.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :broadcast_message do
|
||||
message "MyText"
|
||||
starts_at "2013-11-12 13:43:25"
|
||||
ends_at "2013-11-12 13:43:25"
|
||||
alert_type 1
|
||||
end
|
||||
end
|
7
spec/models/broadcast_message_spec.rb
Normal file
7
spec/models/broadcast_message_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe BroadcastMessage do
|
||||
subject { create(:broadcast_message) }
|
||||
|
||||
it { should be_valid }
|
||||
end
|
Loading…
Reference in a new issue