ensure services is an array in StatusMessagesController#create
This fixes posting to a single service for Ruby 1.9 For some reason Rails doesn't convert a single foo[]=bar not to the expected :foo => ["bar"] but to :foo => "bar" On Ruby 1.8 String#map exists and just yields self, on Ruby 1.9 String#map got removed
This commit is contained in:
parent
4797e8f2f8
commit
19785d909b
2 changed files with 11 additions and 0 deletions
|
|
@ -43,6 +43,9 @@ class StatusMessagesController < ApplicationController
|
|||
def create
|
||||
params[:status_message][:aspect_ids] = [*params[:aspect_ids]]
|
||||
normalize_public_flag!
|
||||
|
||||
# ensure services is an array since .map doesn't work on a string for ruby 1.9
|
||||
params[:services] = [params[:services]] if params[:services].is_a?(String)
|
||||
|
||||
@status_message = current_user.build_post(:status_message, params[:status_message])
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,14 @@ describe StatusMessagesController do
|
|||
post :create, status_message_hash
|
||||
end
|
||||
|
||||
it "works if services is a string" do
|
||||
s1 = Services::Facebook.new
|
||||
alice.services << s1
|
||||
status_message_hash[:services] = "facebook"
|
||||
alice.should_receive(:dispatch_post).with(anything(), hash_including(:services => [s1]))
|
||||
post :create, status_message_hash
|
||||
end
|
||||
|
||||
it "doesn't overwrite author_id" do
|
||||
status_message_hash[:status_message][:author_id] = bob.person.id
|
||||
post :create, status_message_hash
|
||||
|
|
|
|||
Loading…
Reference in a new issue