RS IZ a good test to overwrite ids
This commit is contained in:
parent
6c0b187d40
commit
488df6eaa0
2 changed files with 21 additions and 15 deletions
|
|
@ -13,9 +13,7 @@ class StatusMessagesController < ApplicationController
|
||||||
public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false
|
public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false
|
||||||
params[:status_message][:public] = public_flag
|
params[:status_message][:public] = public_flag
|
||||||
|
|
||||||
data = clean_hash params[:status_message]
|
status_message = current_user.post(:status_message, params[:status_message])
|
||||||
message = params[:status_message][:message]
|
|
||||||
status_message = current_user.post(:status_message, data)
|
|
||||||
render :nothing => true
|
render :nothing => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -29,13 +27,4 @@ class StatusMessagesController < ApplicationController
|
||||||
@status_message = current_user.find_visible_post_by_id params[:id]
|
@status_message = current_user.find_visible_post_by_id params[:id]
|
||||||
respond_with @status_message
|
respond_with @status_message
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def clean_hash(params)
|
|
||||||
return {
|
|
||||||
:message => params[:message],
|
|
||||||
:to => params[:to],
|
|
||||||
:public => params[:public]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,12 @@ describe StatusMessagesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
let(:status_message_hash) {{"status_message"=>{"public"=>"true", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}}
|
let(:status_message_hash) {
|
||||||
|
{:status_message =>{
|
||||||
|
:public =>"true",
|
||||||
|
:message =>"facebook, is that you?",
|
||||||
|
:to =>"#{aspect.id}"}}
|
||||||
|
}
|
||||||
|
|
||||||
context "posting out to facebook" do
|
context "posting out to facebook" do
|
||||||
let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }
|
let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }
|
||||||
|
|
@ -27,10 +32,22 @@ describe StatusMessagesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not post to facebook when public is not set' do
|
it 'should not post to facebook when public is not set' do
|
||||||
status_message_hash['status_message']['public'] = 'false'
|
status_message_hash[:status_message][:public] = 'false'
|
||||||
user.should_not_receive(:post_to_facebook)
|
user.should_not_receive(:post_to_facebook)
|
||||||
post :create, status_message_hash
|
post :create, status_message_hash
|
||||||
end
|
end
|
||||||
|
it "doesn't overwrite person_id" do
|
||||||
|
new_user = make_user
|
||||||
|
status_message_hash[:status_message][:person_id] = new_user.person.id
|
||||||
|
post :create, status_message_hash
|
||||||
|
StatusMessage.find_by_message(status_message_hash[:status_message][:message]).person_id.should == user.person.id
|
||||||
|
end
|
||||||
|
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
|
||||||
|
old_status_message.reload.message.should == 'hello'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "posting to twitter" do
|
context "posting to twitter" do
|
||||||
|
|
@ -42,7 +59,7 @@ describe StatusMessagesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not post to twitter when public in not set' do
|
it 'should not post to twitter when public in not set' do
|
||||||
status_message_hash['status_message']['public'] = 'false'
|
status_message_hash[:status_message][:public] = 'false'
|
||||||
user.should_not_receive(:post_to_twitter)
|
user.should_not_receive(:post_to_twitter)
|
||||||
post :create, status_message_hash
|
post :create, status_message_hash
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue