# Copyright (c) 2010, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. require 'spec_helper' describe StatusMessagesController do before do @aspect1 = alice.aspects.first @aspect2 = bob.aspects.first request.env["HTTP_REFERER"] = "" sign_in :user, alice @controller.stub!(:current_user).and_return(alice) alice.reload end describe '#bookmarklet' do it 'succeeds' do get :bookmarklet response.should be_success end end describe '#new' do it 'succeeds' do get :new, :person_id => bob.person.id response.should be_success end it 'generates a jasmine fixture', :fixture => true do contact = alice.contact_for(bob.person) aspect = alice.aspects.create(:name => 'people') contact.aspects << aspect contact.save get :new, :person_id => bob.person.id, :layout => true save_fixture(html_for("body"), "status_message_new") end end describe '#create' do let(:status_message_hash) { { :status_message => { :public => "true", :text => "facebook, is that you?", }, :aspect_ids => [@aspect1.id.to_s] } } context 'js requests' do it 'responds' do post :create, status_message_hash.merge(:format => 'js') response.status.should == 201 end it 'responds with json' do post :create, status_message_hash.merge(:format => 'js') json = JSON.parse(response.body) json['post_id'].should_not be_nil json['html'].should_not be_nil end it 'escapes XSS' do xss = "" post :create, status_message_hash.merge(:format => 'js', :text => xss) json = JSON.parse(response.body) json['html'].should_not =~ /