From f14f462eaf8dcf272db54cd513bf7ffe7dc6a6e3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 21 Mar 2016 18:26:47 +0100 Subject: Adding Turbolinks, adding status posting form on homepage --- spec/controllers/statuses_controller_spec.rb | 24 ++++++++++++++++++++++++ spec/helpers/statuses_helper_spec.rb | 15 +++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 spec/controllers/statuses_controller_spec.rb create mode 100644 spec/helpers/statuses_helper_spec.rb (limited to 'spec') diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb new file mode 100644 index 000000000..05566a30e --- /dev/null +++ b/spec/controllers/statuses_controller_spec.rb @@ -0,0 +1,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 diff --git a/spec/helpers/statuses_helper_spec.rb b/spec/helpers/statuses_helper_spec.rb new file mode 100644 index 000000000..db312abdd --- /dev/null +++ b/spec/helpers/statuses_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the StatusesHelper. For example: +# +# describe StatusesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe StatusesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end -- cgit