From fd6d6350c8e9f357fca6780812f53ac526cb0abc Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 11 Feb 2011 18:00:23 -0800 Subject: [PATCH] make html status message create redirect, also correctly name status_messageS_controller_spec.rb --- .../status_message_controller_spec.rb | 120 ------------------ 1 file changed, 120 deletions(-) delete mode 100644 spec/controllers/status_message_controller_spec.rb diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb deleted file mode 100644 index 86c92d5ac..000000000 --- a/spec/controllers/status_message_controller_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -# 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 - render_views - - before do - @user1 = alice - @user2 = bob - - @aspect1 = @user1.aspects.first - @aspect2 = @user2.aspects.first - - request.env["HTTP_REFERER"] = "" - sign_in :user, @user1 - @controller.stub!(:current_user).and_return(@user1) - @user1.reload - end - - describe '#show' do - before do - @message = @user1.build_post :status_message, :message => "ohai", :to => @aspect1.id - @message.save! - - @user1.add_to_streams(@message, [@aspect1]) - @user1.dispatch_post @message, :to => @aspect1.id - end - - it 'succeeds' do - get :show, "id" => @message.id.to_s - response.should be_success - end - - it 'marks a corresponding notification as read' do - alice.comment("comment after me", :on => @message) - bob.comment("here you go", :on => @message) - note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first - lambda{ - get :show, :id => @message.id - note.reload - }.should change(note, :unread).from(true).to(false) - end - end - - describe '#create' do - let(:status_message_hash) { - { :status_message => { - :public => "true", - :message => "facebook, is that you?", - }, - :aspect_ids => [@aspect1.id.to_s] } - } - it 'responds to js requests' do - post :create, status_message_hash.merge(:format => 'js') - response.status.should == 201 - end - - it "doesn't overwrite person_id" do - status_message_hash[:status_message][:person_id] = @user2.person.id - post :create, status_message_hash - new_message = StatusMessage.find_by_message(status_message_hash[:status_message][:message]) - new_message.person_id.should == @user1.person.id - end - - it "doesn't overwrite id" do - old_status_message = @user1.post(:status_message, :message => "hello", :to => @aspect1.id) - status_message_hash[:status_message][:id] = old_status_message.id - post :create, status_message_hash - old_status_message.reload.message.should == 'hello' - end - - context 'with photos' do - before do - fixture_filename = 'button.png' - fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', fixture_filename) - - @photo1 = @user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => @aspect1.id) - @photo2 = @user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => @aspect1.id) - - @photo1.save! - @photo2.save! - - @hash = status_message_hash - @hash[:photos] = [@photo1.id.to_s, @photo2.id.to_s] - end - it "dispatches all referenced photos" do - @user1.should_receive(:dispatch_post).exactly(3).times - post :create, @hash - end - it "sets the pending bit of referenced photos" do - post :create, @hash - @photo1.reload.pending.should be_false - @photo2.reload.pending.should be_false - end - end - end - - describe '#destroy' do - let!(:message) {@user1.post(:status_message, :message => "hey", :to => @aspect1.id)} - let!(:message2) {@user2.post(:status_message, :message => "hey", :to => @aspect2.id)} - - it 'let a user delete his photos' do - delete :destroy, :id => message.id - StatusMessage.find_by_id(message.id).should be_nil - end - - it 'will not let you destroy posts visible to you' do - delete :destroy, :id => message2.id - StatusMessage.find_by_id(message2.id).should be_true - end - - it 'will not let you destory posts you do not own' do - delete :destroy, :id => message2.id - StatusMessage.find_by_id(message2.id).should be_true - end - end -end