From 63b05096c78521560516b0f5c7e900f33957fb8f Mon Sep 17 00:00:00 2001 From: Shuhei Kitagawa Date: Mon, 18 Jun 2018 10:45:20 +0900 Subject: [PATCH] Add tests for shares_controller (#7835) --- spec/controllers/shares_controller_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 spec/controllers/shares_controller_spec.rb diff --git a/spec/controllers/shares_controller_spec.rb b/spec/controllers/shares_controller_spec.rb new file mode 100644 index 000000000..a74e9af56 --- /dev/null +++ b/spec/controllers/shares_controller_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +describe SharesController do + render_views + + let(:user) { Fabricate(:user) } + before { sign_in user } + + describe 'GTE #show' do + subject(:initial_state_json) { JSON.parse(assigns(:initial_state_json), symbolize_names: true) } + subject(:body_classes) { assigns(:body_classes) } + + before { get :show, params: { title: 'test title', text: 'test text', url: 'url1 url2' } } + + it 'assigns json' do + expect(response).to have_http_status :ok + expect(initial_state_json[:compose][:text]).to eq 'test title test text url1 url2' + expect(initial_state_json[:meta][:me]).to eq user.account.id.to_s + expect(body_classes).to eq 'modal-layout compose-standalone' + end + end +end