fixed migrations, added unread to PrivateMessageVisibilities

This commit is contained in:
danielvincent 2011-02-25 16:23:54 -08:00
parent 979d9d7fb4
commit a179bac689
6 changed files with 21 additions and 38 deletions

View file

@ -80,7 +80,7 @@ class StatusMessagesController < ApplicationController
def show def show
@status_message = current_user.find_visible_post_by_id params[:id] @status_message = current_user.find_visible_post_by_id params[:id]
if @status_messag if @status_message
@object_aspect_ids = @status_message.aspects.map{|a| a.id} @object_aspect_ids = @status_message.aspects.map{|a| a.id}
# mark corresponding notification as read # mark corresponding notification as read

View file

@ -1,18 +0,0 @@
class CreatePrivateMessages < ActiveRecord::Migration
def self.up
create_table :private_messages do |t|
t.integer :author_id, :null => false
t.boolean :unread, :null => false, :default => true
t.string :guid, :null => false
t.text :message, :null => false
t.timestamps
end
add_index :private_messages, :author_id
end
def self.down
drop_table :private_messages
end
end

View file

@ -1,8 +1,18 @@
class CreatePrivateMessageVisibilities < ActiveRecord::Migration class CreatePrivateMessagesAndVisibilities < ActiveRecord::Migration
def self.up def self.up
create_table :private_messages do |t|
t.integer :author_id, :null => false
t.string :guid, :null => false
t.text :message, :null => false
t.timestamps
end
create_table :private_message_visibilities do |t| create_table :private_message_visibilities do |t|
t.integer :private_message_id t.integer :private_message_id
t.integer :person_id t.integer :person_id
t.boolean :unread, :null => false, :default => true
t.timestamps t.timestamps
end end
@ -10,9 +20,11 @@ class CreatePrivateMessageVisibilities < ActiveRecord::Migration
add_index :private_message_visibilities, :person_id add_index :private_message_visibilities, :person_id
add_index :private_message_visibilities, :private_message_id add_index :private_message_visibilities, :private_message_id
add_index :private_message_visibilities, [:private_message_id, :person_id], :name => 'pm_visibilities_on_pm_id_and_person_id', :unique => true add_index :private_message_visibilities, [:private_message_id, :person_id], :name => 'pm_visibilities_on_pm_id_and_person_id', :unique => true
add_index :private_messages, :author_id
end end
def self.down def self.down
drop_table :private_messages
drop_table :private_message_visibilities drop_table :private_message_visibilities
end end
end end

View file

@ -10,11 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
<<<<<<< HEAD
ActiveRecord::Schema.define(:version => 20110228201109) do ActiveRecord::Schema.define(:version => 20110228201109) do
=======
ActiveRecord::Schema.define(:version => 20110225193130) do
>>>>>>> added PrivateMessage and PrivateMessageVisibility models and migrations
create_table "aspect_memberships", :force => true do |t| create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false t.integer "aspect_id", :null => false
@ -390,6 +386,7 @@ ActiveRecord::Schema.define(:version => 20110225193130) do
create_table "private_message_visibilities", :force => true do |t| create_table "private_message_visibilities", :force => true do |t|
t.integer "private_message_id" t.integer "private_message_id"
t.integer "person_id" t.integer "person_id"
t.boolean "unread", :default => true, :null => false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
@ -399,10 +396,9 @@ ActiveRecord::Schema.define(:version => 20110225193130) do
add_index "private_message_visibilities", ["private_message_id"], :name => "index_private_message_visibilities_on_private_message_id" add_index "private_message_visibilities", ["private_message_id"], :name => "index_private_message_visibilities_on_private_message_id"
create_table "private_messages", :force => true do |t| create_table "private_messages", :force => true do |t|
t.integer "author_id", :null => false t.integer "author_id", :null => false
t.boolean "unread", :default => true, :null => false t.string "guid", :null => false
t.string "guid", :null => false t.text "message", :null => false
t.text "message", :null => false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end

View file

@ -23,13 +23,6 @@ describe AspectMembershipsController do
request.env["HTTP_REFERER"] = 'http://' + request.host request.env["HTTP_REFERER"] = 'http://' + request.host
end end
describe "#new" do
it 'succeeds' do
get :new
response.should be_success
end
end
describe '#create' do describe '#create' do
it 'creates an aspect membership' do it 'creates an aspect membership' do
@user.should_receive(:add_contact_to_aspect) @user.should_receive(:add_contact_to_aspect)