Welcome to mirror list, hosted at ThFree Co, Russian Federation.

status_message_controller_spec.rb « controllers « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8b96e49cb89a78727e95238144924b9888191fc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#   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

  let!(:user) { make_user }
  let!(:aspect) { user.aspect(:name => "lame-os") }

  before do
    sign_in :user, user
    @controller.stub!(:current_user).and_return(user)
  end

  describe '#create' do
    let(:status_message_hash) {{"status_message"=>{"public"=>"true", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}}

    context "posting out to facebook" do
      let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }

      it 'should post to facebook when public is set' do
        user.should_receive(:post_to_facebook)
        post :create, status_message_hash
      end

      it 'should not post to facebook when public is not set' do
        status_message_hash['status_message']['public'] = 'false'
        user.should_not_receive(:post_to_facebook)
        post :create, status_message_hash
      end
    end

    context "posting to twitter" do
      let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s }

      it 'should post to twitter if public is set' do
        user.should_receive(:post_to_twitter).and_return(true)
        post :create, status_message_hash
      end

      it 'should not post to twitter when public in not set' do
        status_message_hash['status_message']['public'] = 'false'
        user.should_not_receive(:post_to_twitter)
        post :create, status_message_hash
      end
    end
  end
end