conversations_spec.rb 1.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
require 'spec_helper'

describe ConversationsController, :type => :controller do
  describe '#index' do
    before do
      @person = alice.contacts.first.person
      hash = {
        :author => @person,
        :participant_ids => [alice.person.id, @person.id],
        :subject => 'not spam',
        :messages_attributes => [ {:author => @person, :text => 'cool stuff'} ]
      }
      @conv1 = Conversation.create(hash)
      Message.create(:author => @person, :created_at => Time.now + 100, :text => "message", :conversation_id => @conv1.id)
             .increase_unread(alice)
      Message.create(:author => @person, :created_at => Time.now + 200, :text => "another message", :conversation_id => @conv1.id)
             .increase_unread(alice)

      @conv2 = Conversation.create(hash)
      Message.create(:author => @person, :created_at => Time.now + 100, :text => "message", :conversation_id => @conv2.id)
             .increase_unread(alice)

cmrd Senya's avatar
cmrd Senya committed
23
      sign_in alice, scope: :user
24 25 26 27 28 29 30 31 32 33
    end

    it "generates a jasmine fixture", :fixture => true do
      get :index, :conversation_id => @conv1.id
      save_fixture(html_for("body"), "conversations_unread")

      get :index, :conversation_id => @conv1.id
      save_fixture(html_for("body"), "conversations_read")
    end
  end
34 35 36 37 38 39 40 41 42 43 44 45

  describe "#new" do
    before do
      sign_in alice, scope: :user
    end

    it "generates a jasmine fixture", fixture: true do
      session[:mobile_view] = true
      get :new, format: :mobile
      save_fixture(html_for("body"), "conversations_new_mobile")
    end
  end
46
end