X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=spec%2Fcontrollers%2Fscrolls_controller_spec.rb;fp=spec%2Fcontrollers%2Fscrolls_controller_spec.rb;h=e828f7dfc8088c5523b65f01343d31b953023978;hp=487548d86143826ee002949e28b16cefa9131e48;hb=8a42b6e27d6579a7e824cd3e67c156dc4c6e583a;hpb=ec4f6aafda0ecc0de57c5de5e7c2c4337be839e7 diff --git a/spec/controllers/scrolls_controller_spec.rb b/spec/controllers/scrolls_controller_spec.rb index 487548d8..e828f7df 100644 --- a/spec/controllers/scrolls_controller_spec.rb +++ b/spec/controllers/scrolls_controller_spec.rb @@ -209,6 +209,103 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1 end end + describe 'コマフィルタ一覧及びカウント' do + before do + @panel = FactoryGirl.create :panel_hello_with_scroll_panels, author_id: @author_yas.id + @query = {:id => @panel.id} + @query_format_json = @query.merge(:format => :json) + end + + context '正常系' do + before do + sign_in @user_yas + end + context '共通処理' do + before do + get :by_panel, @query + end + it 'コントローラのマニフェストから操作モデルを導出している' do + set_model? @my_model_class + end + it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do + set_list? 'scroll', 'by_panel' + end + it '@itemsにリストを取得している' do + expect(assigns(:items).size).to be >= 3 + end + end + context 'html形式' do + before do + get :by_panel, @query + end + it 'ステータス OKを返して、ファイラーを描画している' do + return_ok? + render_filer? + end + it '@filerにファイラーを取得している' do + let_filer? + end + end + context 'json形式' do + before do + get :by_panel, @query_format_json + end + it 'ステータス OKを返して、jsonデータを返している' do + return_ok? + render_json? + end + it '@filerにファイラーをセットしていない' do + expect(assigns(:filer)).to be nil + end + end + end + context '件数取得' do + context 'html形式' do + it '必要ないので実装していない' do + sign_in @user_yas + get :count_by_panel, @query + expect(response.status).to eq(406) + end + end + context 'json形式' do + it 'jsonデータを返す' do + sign_in @user_yas + get :count_by_panel, @query_format_json + return_ok? + render_json? + end + end + context 'ゲスト(サインインしていない)' do + it '通常通り応答している' do + get :count_by_panel, @query_format_json + return_ok? + render_json? + end + end + end + context 'サインインの状態が例外的なとき' do + it 'ユーザではなく管理者でも通常通り応答している' do + sign_in @admin + get :by_panel, @query + return_ok? + get :by_panel, @query_format_json + render_json? + end + it '創作活動してないROM専の読者にも通常通り応答している' do + sign_in @user_rom + return_ok? + get :by_panel, @query_format_json + render_json? + end + it 'ゲスト(サインインしていない)はサインインページに遷移している' do + get :by_panel, @query + redirect? sign_in_url + get :by_panel, @query_format_json + render_unauthorized? + end + end + end + describe '単体表示に於いて' do before do @item = FactoryGirl.create :scroll_hello, author: @author_yas