about summary refs log tree commit diff
path: root/spec/controllers/statuses_controller_spec.rb
blob: 05566a30e0d421aeacf9f2540a8909676d8064b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'rails_helper'

RSpec.describe StatusesController, type: :controller do
  let(:user) { Fabricate(:user) }

  before do
    sign_in :user, user
  end

  describe 'POST #create' do
    before do
      stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
      post :create, status: { text: 'Hello world' }
    end

    it 'redirects back to homepage' do
      expect(response).to redirect_to(root_path)
    end

    it 'creates a new status' do
      expect(user.account.statuses.count).to eq 1
    end
  end
end