Now expecting a 500 on someone passing an id to create, should really be a 422
This commit is contained in:
parent
354f6d13c2
commit
9d273c6d24
5 changed files with 13 additions and 7 deletions
|
|
@ -29,9 +29,9 @@ class Photo < Post
|
|||
|
||||
validates_with PhotoAlbumValidator
|
||||
|
||||
before_destroy :ensure_user_picture
|
||||
attr_accessible :caption
|
||||
|
||||
attr_protected :person
|
||||
before_destroy :ensure_user_picture
|
||||
|
||||
def self.instantiate(params = {})
|
||||
image_file = params.delete(:user_file)
|
||||
|
|
|
|||
|
|
@ -32,11 +32,12 @@ class Post
|
|||
before_destroy :propogate_retraction
|
||||
after_destroy :destroy_comments
|
||||
|
||||
attr_accessible :user_refs
|
||||
def self.instantiate params
|
||||
new_post = self.new params.to_hash
|
||||
new_post.person = params[:person]
|
||||
new_post.public = params[:public]
|
||||
new_post.save
|
||||
new_post.diaspora_handle = new_post.person.diaspora_handle
|
||||
new_post
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class StatusMessage < Post
|
|||
key :message, String
|
||||
validates_presence_of :message
|
||||
|
||||
attr_accessible :message
|
||||
|
||||
def to_activity
|
||||
<<-XML
|
||||
<entry>
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ class User
|
|||
aspect_ids = validate_aspect_permissions(aspect_ids)
|
||||
|
||||
post = build_post(class_name, options)
|
||||
|
||||
post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid)
|
||||
push_to_aspects(post, aspect_ids)
|
||||
|
||||
|
|
@ -201,9 +202,11 @@ class User
|
|||
|
||||
model_class = class_name.to_s.camelize.constantize
|
||||
post = model_class.instantiate(options)
|
||||
post.save
|
||||
self.raw_visible_posts << post
|
||||
self.save
|
||||
if post.save
|
||||
raise 'MongoMapper failed to catch a failed save' unless post.id
|
||||
self.raw_visible_posts << post
|
||||
self.save
|
||||
end
|
||||
post
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ describe StatusMessagesController do
|
|||
it "doesn't overwrite id" do
|
||||
old_status_message = user.post(:status_message, :message => "hello", :to => aspect.id)
|
||||
status_message_hash[:status_message][:id] = old_status_message.id
|
||||
post :create, status_message_hash
|
||||
lambda {post :create, status_message_hash}.should raise_error /failed save/
|
||||
old_status_message.reload.message.should == 'hello'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue