From 305f415a00ff3da658a5ee77cf966e7f76f8230f Mon Sep 17 00:00:00 2001 From: yasushiito Date: Fri, 13 Sep 2013 11:36:34 +0900 Subject: [PATCH] t#32025:comic rename --- app/assets/images/scroll.gif | Bin 0 -> 1370 bytes app/assets/images/scroll_panel.gif | Bin 0 -> 1338 bytes app/controllers/authors_controller.rb | 22 +- app/controllers/comics_controller.rb | 131 -- app/controllers/panels_controller.rb | 4 +- app/controllers/stories_controller.rb | 157 -- app/helpers/application_helper.rb | 8 +- app/helpers/comics_helper.rb | 2 - app/helpers/stories_helper.rb | 2 - app/models/comic.rb | 165 -- app/models/story.rb | 315 ---- app/models/user.rb | 4 +- app/views/authors/_list_item.html.erb | 18 +- app/views/authors/comics.html.erb | 28 - app/views/authors/scroll_panels.html.erb | 9 + app/views/authors/scrolls.html.erb | 28 + app/views/authors/show.html.erb | 4 +- app/views/authors/stories.html.erb | 9 - app/views/comics/_form.html.erb | 23 - app/views/comics/_list_item.html.erb | 25 - app/views/comics/browse.html.erb | 34 - app/views/comics/edit.html.erb | 4 - app/views/comics/edit.js.erb | 1 - app/views/comics/index.atom.builder | 25 - app/views/comics/index.html.erb | 9 - app/views/comics/index.rss.builder | 24 - app/views/comics/list.html.erb | 24 - app/views/comics/new.html.erb | 5 - app/views/comics/new.js.erb | 1 - app/views/comics/show.atom.builder | 25 - app/views/comics/show.html.erb | 35 - app/views/comics/show.rss.builder | 24 - app/views/home/index.html.erb | 6 +- app/views/home/scroll_panels.html.erb | 6 +- app/views/home/scrolls.html.erb | 6 +- app/views/layouts/system.html.erb | 6 +- app/views/layouts/test.html.erb | 4 +- app/views/panels/_append_comic.html.erb | 32 - app/views/panels/_append_scroll.html.erb | 32 + app/views/panels/show.html.erb | 12 +- app/views/scroll_panels/_append_panel.html.erb | 10 +- app/views/scroll_panels/_footer.html.erb | 20 +- app/views/scroll_panels/_form.html.erb | 8 +- app/views/scroll_panels/_list_item.html.erb | 18 +- app/views/scroll_panels/_order.html.erb | 6 +- app/views/scroll_panels/_scroll_header.html.erb | 26 +- app/views/scroll_panels/browse.html.erb | 12 +- app/views/scroll_panels/edit.html.erb | 2 +- app/views/scroll_panels/edit.js.erb | 2 +- app/views/scroll_panels/index.html.erb | 6 +- app/views/scroll_panels/list.html.erb | 20 +- app/views/scroll_panels/scroll.html.erb | 28 +- app/views/scroll_panels/show.html.erb | 36 +- app/views/scrolls/_form.html.erb | 6 +- app/views/scrolls/_list_item.html.erb | 20 +- app/views/scrolls/browse.html.erb | 28 +- app/views/scrolls/edit.js.erb | 2 +- app/views/scrolls/index.html.erb | 6 +- app/views/scrolls/list.html.erb | 26 +- app/views/scrolls/new.html.erb | 2 +- app/views/scrolls/new.js.erb | 2 +- app/views/scrolls/show.html.erb | 28 +- app/views/stories/_append_panel.html.erb | 21 - app/views/stories/_comic_header.html.erb | 40 - app/views/stories/_footer.html.erb | 23 - app/views/stories/_form.html.erb | 20 - app/views/stories/_licensed_pictures.html.erb | 14 - app/views/stories/_list_item.html.erb | 28 - app/views/stories/_order.html.erb | 15 - app/views/stories/browse.html.erb | 28 - app/views/stories/comic.html.erb | 33 - app/views/stories/edit.html.erb | 5 - app/views/stories/edit.js.erb | 1 - app/views/stories/index.html.erb | 8 - app/views/stories/list.html.erb | 29 - app/views/stories/new.html.erb | 3 - app/views/stories/show.html.erb | 41 - app/views/system/browse.html.erb | 4 +- app/views/top/index.html.erb | 4 +- config/locales/pettanr.ja.yml | 38 +- config/magic_number.yml | 6 +- config/routes.rb | 36 - db/migrate/20130911043458_copy_to_scroll.rb | 20 + spec/controllers/authors_controller_spec.rb | 186 +- spec/controllers/comics_controller_spec.rb | 1301 ------------- .../speech_balloon_templates_controller_spec.rb | 4 +- spec/controllers/stories_controller_spec.rb | 1456 --------------- spec/factories.rb | 20 +- spec/helpers/comics_helper_spec.rb | 16 - spec/models/comic_spec.rb | 840 --------- spec/models/ground_color_spec.rb | 4 +- spec/models/ground_picture_spec.rb | 4 +- spec/models/license_group_spec.rb | 8 +- spec/models/original_picture_spec.rb | 8 +- spec/models/panel_spec.rb | 6 +- spec/models/resource_picture_spec.rb | 8 +- spec/models/speech_balloon_spec.rb | 8 +- spec/models/story_spec.rb | 1940 -------------------- 98 files changed, 442 insertions(+), 7367 deletions(-) create mode 100644 app/assets/images/scroll.gif create mode 100644 app/assets/images/scroll_panel.gif delete mode 100644 app/controllers/comics_controller.rb delete mode 100644 app/controllers/stories_controller.rb delete mode 100644 app/helpers/comics_helper.rb delete mode 100644 app/helpers/stories_helper.rb delete mode 100644 app/views/authors/comics.html.erb create mode 100644 app/views/authors/scroll_panels.html.erb create mode 100644 app/views/authors/scrolls.html.erb delete mode 100644 app/views/authors/stories.html.erb delete mode 100644 app/views/comics/_form.html.erb delete mode 100644 app/views/comics/_list_item.html.erb delete mode 100644 app/views/comics/browse.html.erb delete mode 100644 app/views/comics/edit.html.erb delete mode 100644 app/views/comics/edit.js.erb delete mode 100644 app/views/comics/index.atom.builder delete mode 100644 app/views/comics/index.html.erb delete mode 100644 app/views/comics/index.rss.builder delete mode 100644 app/views/comics/list.html.erb delete mode 100644 app/views/comics/new.html.erb delete mode 100644 app/views/comics/new.js.erb delete mode 100644 app/views/comics/show.atom.builder delete mode 100644 app/views/comics/show.html.erb delete mode 100644 app/views/comics/show.rss.builder delete mode 100644 app/views/panels/_append_comic.html.erb create mode 100644 app/views/panels/_append_scroll.html.erb delete mode 100644 app/views/stories/_append_panel.html.erb delete mode 100644 app/views/stories/_comic_header.html.erb delete mode 100644 app/views/stories/_footer.html.erb delete mode 100644 app/views/stories/_form.html.erb delete mode 100644 app/views/stories/_licensed_pictures.html.erb delete mode 100644 app/views/stories/_list_item.html.erb delete mode 100644 app/views/stories/_order.html.erb delete mode 100644 app/views/stories/browse.html.erb delete mode 100644 app/views/stories/comic.html.erb delete mode 100644 app/views/stories/edit.html.erb delete mode 100644 app/views/stories/edit.js.erb delete mode 100644 app/views/stories/index.html.erb delete mode 100644 app/views/stories/list.html.erb delete mode 100644 app/views/stories/new.html.erb delete mode 100644 app/views/stories/show.html.erb create mode 100644 db/migrate/20130911043458_copy_to_scroll.rb delete mode 100644 spec/controllers/comics_controller_spec.rb delete mode 100644 spec/controllers/stories_controller_spec.rb delete mode 100644 spec/helpers/comics_helper_spec.rb delete mode 100644 spec/models/comic_spec.rb delete mode 100644 spec/models/story_spec.rb diff --git a/app/assets/images/scroll.gif b/app/assets/images/scroll.gif new file mode 100644 index 0000000000000000000000000000000000000000..cff7dfad9417125c7d0a52bb24a0d0314ca91184 GIT binary patch literal 1370 zcmXYweN5L?6vhu*Hf+mWgl|!5D5*D>cCsx0N*5x&l<9Q}VJ3D|)Li@dBe2q&2KZ9a z0(GZgibm)~n{SxO(rK9*CtWXBQ4^Dt%m%gLWIDIgm+Jm=ckkKmdCuo~?$~kZBcFLS z9nzr#{#yt@01O}i3I@O+7y`p!1dM_Oun3mGGFSnt-~b$gBXA5(z$thDkKhSBgBS1$ z0U#g*g1`_2f<|wHA}E0}sDMTXKtKdSU<8S3XaEhOAvBCe&?s6!i)aZgqZPD@4$vVw zLdWO?ouUWyh@Q|hdO@!k00Uwm42(fAC@P>LDxor}phh~Pv5|lXm_Q;~WPl8kAu>!x z$S7GLi)4u`lNGW`4#*)nBFE%}oRSCfNS??uc_FV9fC5q=3QR#LC@GL4DUmX%kVXh1 z;>bV@%pegFHoyki5F2JAY?LjqMYhD2*$P`_2kej?v14|^PT2!{WKZmwy|7mfzyUcB z2j(CgloeQ!l~|coSR?w8*(g8)EFh5?Vn7UvAu%jQ#Hd&hi(*MEixsgd4#c5263601 zoQenWD4xW#coDA>Kmtl22`oV*s3?e{D2cMDh-zmLA~zx=k*=s1MZtg?R6}Z5ji^zz zpcd7VT2?D+RUN29b)=5fi8@se>QOzZXZ509HGl@xKpI$sXy|Mf1ub$rLLSZiZ}b0i zA8q|_-IV}v2OjIZ>iiRssL;_hC1cm-BP$b=hP-@YSJl@g-BU9wGInn{wze1M{c>XW z*5jr9#;i#>*WH~g8ek9KK!a%B7EhLt0x9GrS9HtU5I zV|(}b;6TzJ4Vz!wm^L9Z_WOj|iSK6S^cvw$efGrR^AFU=ub-|RUAQHAZM&aT{rvW} z2eWq#%-J7baLRsHw&2J5>1X>?jxS%_v?qPzov~t3^-5cB0dURt_cDG3>bLV`% zwJg>)zA^UKg@c<8<&Wy!9=k?`UnIYNv1ak%x<#par{Tt1H_kj4e{<8tq=Nj$lDcP4 zWpdrZtG^|WUq5mA+wC1~y*Hd&UQtwZVafNa$5zZ9wz~M0ndc{O=#_Uhr+8Lwx9XN( zn02r>!~ET9ftKkUoPhEm>Zferau0b@Jw{`&v%q#IGGI zpPk$DpFixeCE;Bk5ndYPrLZu((83;={4_cxU@KB;Na@{ z`FV4iw~kqT{NaV`TDI3@B|cTKt#JC?z5ABt?#Y;+KYT@ecIC`zT`t#dyZ`CDGu5LH z%}bp+x9wz;TiblQ@48Jt+>=%_Z_$ti#T%Quq~+9R?fY}b-#Z7i?)!P#g4Vi5s@<89 IkN~6p0hK78_5c6? literal 0 HcmV?d00001 diff --git a/app/assets/images/scroll_panel.gif b/app/assets/images/scroll_panel.gif new file mode 100644 index 0000000000000000000000000000000000000000..0707502972d5f76a4eeec9e4b1f5f49aa3f5c0e9 GIT binary patch literal 1338 zcmXYweN5L?6vmIuRBW!c@@-ShsU=^E7ik+Fdu4yJ2zJM~F)0CO6)0gW0b9e9A?s?AVd2ZU|)Z~=e zsgMd?@ZUlJ0$>0EP%r=n!4Mb*BVZIPfJLwbmca^G1qa{|9D!qS0#3mLcmz-28N7g3 z2mk>g5Cn!G5Hxxl6hR4;K?O8A00JTq0wYLNLj!0K4WVH)f=1B-T0~1|8LgmIbbt=g z5jsXE=oCGmNA!fA(F=OT02mMhVPFh`K~Vt}Q3;h%1vSzUjg16EzyuP>A_HWQ43S|n zLPp5~StLtjnXHgiazGBr5jiF&uBYR@c?1jB@01n83 zI4}p{psc`(ti;N!!Wz+!%tiqcU;&BD5CdXR42fYeB1Xl6SQJZQS*(avaUc%GkvJA7 z;#53{NAV<{#fx~A01{9FNni;gK}A6nMM;!JMO3?k5V;W{iF8H9C<+GDpc+!cYDA5y z1+}P_)UsMptLi`ssS{h2GYP9L_>G8C}@$}5%Os6f1CfG z`)C_}w`UK4`;gdu)%_=+k3v`6kV(5X?_1jE(Wj;#*|lYV=_4c3t0vXQ4u0CVN5OAL z>bD+V{rJm8RinS%*0MH!RBU?7&8~1*^wYxZ+I58|>gV^~ zTTd3kzWZSjKa ziuZS(yq5mljrMh0+W%_$anp{>pI6^az4I#Hx^k$Z>FBe2GIwVjum8AfOj+gi8GqDH z`=wXE#w*uP%t=@@@7(?5!j4|0?Z@hx?tLJwN#itWM)Iw59aYU0Pd>bNan7ZrGo34T zR9-Fq^V-m}!yXDHg{x-O9L`RkwxjpV4;yc%ZJzqTn9^a3;xoC7!$!`>3m?Ahzi8@{Nz>jgNKY zW*t~xw6VPTMAF6OrGp!C7XICDbnb!|pNJc=J}Il_!urN}Ef<$eq3^Pn4opZHwzBPw z{O#)&mrTl?_}=A$sx@h+vSzN$D@u8HVSHQH$W4V`v=1!*WY3`7>X&|P$p5nB*vb*r z%Ujdhs&Pe1{HEhg30YG&Y=66>a@EZ_gJZ9>PClElAl~P{mQ$CWSzFgIaNDeJ5+@!Q XwQ)|H@2qRQbG38l54}v`1Q_=Zi{q24 literal 0 HcmV?d00001 diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 47739849..75fa2d01 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -4,7 +4,7 @@ class AuthorsController < ApplicationController before_filter :authenticate_user, :only => [:new, :create, :edit, :update] before_filter :authenticate_author, :only => [:edit, :update] else - before_filter :authenticate_reader, :only => [:index, :show, :comics, :stories, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors] + before_filter :authenticate_reader, :only => [:index, :show, :scrolls, :scroll_panels, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors] before_filter :authenticate_user, :only => [:new, :create, :edit, :update] before_filter :authenticate_author, :only => [:edit, :update] end @@ -32,33 +32,33 @@ class AuthorsController < ApplicationController end end - def comics + def scrolls @au = Author.show(params[:id], [@user, @admin]) @page = Author.page params[:page] - @page_size = Author.comic_page_size params[:page_size] - @comics = Comic.himlist(@au, @page, @page_size) + @page_size = Author.scroll_page_size params[:page_size] + @scrolls = Scroll.himlist(@au, @page, @page_size) respond_to do |format| format.html { - @paginate = Comic.himlist_paginate(@au, @page, @page_size) + @paginate = Scroll.himlist_paginate(@au, @page, @page_size) } - format.json { render json: @comics.to_json(Comic.list_json_opt) } + format.json { render json: @scrolls.to_json(Scroll.list_json_opt) } end end - def stories + def scroll_panels @au = Author.show(params[:id], [@user, @admin]) @page = Author.page params[:page] - @page_size = Author.comic_page_size params[:page_size] - @stories = Story.himlist(@au, @page, @page_size) + @page_size = Author.scroll_page_size params[:page_size] + @scroll_panels = ScrollPanel.himlist(@au, @page, @page_size) respond_to do |format| format.html { - @paginate = Story.himlist_paginate(@au, @page, @page_size) + @paginate = ScrollPanel.himlist_paginate(@au, @page, @page_size) } - format.json { render json: @stories.to_json(Story.list_json_opt) } + format.json { render json: @scroll_panels.to_json(ScrollPanel.list_json_opt) } end end diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb deleted file mode 100644 index c5f85468..00000000 --- a/app/controllers/comics_controller.rb +++ /dev/null @@ -1,131 +0,0 @@ -class ComicsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] - else - before_filter :authenticate_reader, :only => [:top, :index, :show] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] - end - before_filter :authenticate_admin!, :only => [:list, :browse] - - def index - @page = Comic.page params[:page] - @page_size = Comic.page_size params[:page_size] - @comics = Comic.list(@page, @page_size) - respond_to do |format| - format.html { - @paginate = Comic.list_paginate(@page, @page_size) - } - format.json { render json: @comics.to_json(Comic.list_json_opt) } - format.atom - format.rss - end - end - - def show - @comic = Comic.show(params[:id], [@user, @admin]) - - respond_to do |format| - format.html # show.html.erb - format.json { render json: @comic.to_json(Comic.show_json_opt) } - format.atom - format.rss - end - end - - def count - @comic = {:count => Comic.visible_count} - respond_to do |format| - format.json { render json: @comic.to_json } - end - end - - def list - @comics = Comic.all - - respond_to do |format| - format.html { render layout: 'system' }# index.html.erb - format.json { render json: @comics } - end - end - - def browse - @comic = Comic.find(params[:id]) - - respond_to do |format| - format.html { render layout: 'system' } # show.html.erb - format.json { render json: @comic } - end - end - - def new - @comic = Comic.new - @comic.supply_default - respond_to do |format| - format.html # new.html.erb - format.js - format.json { render json: @comic.to_json(Comic.show_json_opt) } - end - end - - def edit - @comic = Comic.edit(params[:id], @author) - respond_to do |format| - format.html - format.js - end - end - - def create - @comic = Comic.new - @comic.supply_default - @comic.attributes = params[:comic] - @comic.overwrite @author - - respond_to do |format| - if @comic.save - flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human) - format.html { redirect_to @comic } - format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic } - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human) - format.html { render action: "new" } - format.json { render json: @comic.errors, status: :unprocessable_entity } - end - end - end - - def update - @comic = Comic.edit(params[:id], @author) - @comic.attributes = params[:comic] - @comic.overwrite @author - respond_to do |format| - if @comic.save - flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human) - format.html { redirect_to @comic } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human) - format.html { render action: "edit" } - format.json { render json: @comic.errors, status: :unprocessable_entity } - end - end - end - - def destroy - @comic = Comic.edit(params[:id], @author) - respond_to do |format| - if @comic.destroy_with_story - flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human) - format.html { redirect_to '/home/comics' } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human) - format.html { redirect_to @comic } - format.json { render json: @comic.errors, status: :unprocessable_entity } - end - end - end -end diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index 0a2e0cf3..8f558273 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -33,8 +33,8 @@ class PanelsController < ApplicationController respond_to do |format| format.html { if @author - @new_comics = Comic.mylist(@author, 1, 5) - @fresh_comics = Story.mylist(@author, 1, 5).map {|s| s.comic} + @new_scrolls = Scroll.mylist(@author, 1, 5) + @fresh_scrolls = ScrollPanel.mylist(@author, 1, 5).map {|sp| sp.scroll} end } format.json { render json: @panel.panel_elements_as_json } diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb deleted file mode 100644 index ca77f0d6..00000000 --- a/app/controllers/stories_controller.rb +++ /dev/null @@ -1,157 +0,0 @@ -class StoriesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] - else - before_filter :authenticate_reader, :only => [:index, :show, :comic] - before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] - end - before_filter :authenticate_admin!, :only => [:list, :browse] - - def index - @page = Story.page params[:page] - @page_size = Story.page_size params[:page_size] - @stories = Story.list(@page, @page_size) - - respond_to do |format| - format.html { - @paginate = Story.list_paginate(@page, @page_size) - } - format.json { render :json => @stories.to_json(Story.list_json_opt) } - end - end - - def show - @story = Story.show(params[:id], [@user, @admin]) - - respond_to do |format| - format.html # show.html.erb - format.json { render json: @story.story_as_json(@author) } - end - end - - def comic - @comic = Comic.show(params[:id], [@user, @admin]) - cnt = Story.count(:conditions => ['comic_id = ?', @comic.id]).to_i - @offset = Story.offset cnt, params[:offset] - @panel_count = Story.panel_count cnt, params[:count] - @stories = Story.play_list(@comic, @author, @offset, @panel_count) - respond_to do |format| - format.html { - @prev_offset = if @offset > 0 - if @offset - @panel_count < 0 - 0 - else - @offset - @panel_count - end - else - nil - end - @next_offset = if @offset + @panel_count > cnt - nil - else - @offset + @panel_count - end - if @author - @new_panels = Panel.mylist(@author, 1, 5) - end - } - format.json {render text: Story.list_as_json_text(@stories, @author)} - format.jsonp { - render :json => "callback(" + @stories.to_json_list + ");" - } - end - end - - def list - @stories = Story.all - - respond_to do |format| - format.html { render layout: 'system' }# index.html.erb - format.json { render json: @stories } - end - end - - def browse - @story = Story.find(params[:id]) - - respond_to do |format| - format.html { render layout: 'system' } # show.html.erb - format.json { render json: @story } - end - end - - def new - @story = Story.new - @story.supply_default - respond_to do |format| - format.html # new.html.erb - format.js - format.json { render json: @story.story_as_json(@author) } - end - end - - def edit - @story = Story.edit(params[:id], @author) - respond_to do |format| - format.html - format.js - end - end - - def create - @story = Story.new - @story.supply_default - @story.attributes = params[:story] - @story.overwrite @author - @comic = Comic.edit(@story.comic_id, @author) if @story.comic_id - @panel = Panel.show(@story.panel_id, @author) if @story.panel_id - - respond_to do |format| - if @story.store - flash[:notice] = I18n.t('flash.notice.created', :model => Story.model_name.human) - format.html { redirect_to action: :comic, id: @story.comic_id } - format.json { render json: @story.story_as_json(@author) } - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => Story.model_name.human) - format.html { render action: "new" } - format.json { render json: @story.errors, status: :unprocessable_entity } - end - end - end - - def update - @story = Story.edit(params[:id], @author) - ot = @story.t - @story.attributes = params[:story] - @story.overwrite @author - respond_to do |format| - if @story.store ot - flash[:notice] = I18n.t('flash.notice.updated', :model => Story.model_name.human) - format.html { redirect_to action: :comic, id: @story.comic_id } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => Story.model_name.human) - format.html { render action: "edit" } - format.json { render json: @story.errors, status: :unprocessable_entity } - end - end - end - - def destroy - @story = Story.edit(params[:id], @author) - respond_to do |format| - if @story.destroy_and_shorten - flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human) - format.html { redirect_to :controller => 'stories', :action => :comic, :id => @story.comic_id } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human) - format.html { redirect_to story_path(@story) } - format.json { render json: @story.errors, status: :unprocessable_entity } - end - end - end -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 953c54ba..b513ed1c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -38,12 +38,12 @@ module ApplicationHelper icon_tag :Artist, opt end - def comic_icon opt = {} - icon_tag :Comic, opt + def scroll_icon opt = {} + icon_tag :Scroll, opt end - def story_icon opt = {} - icon_tag :Story, opt + def scroll_panel_icon opt = {} + icon_tag :ScrollPanel, opt end def panel_icon opt = {} diff --git a/app/helpers/comics_helper.rb b/app/helpers/comics_helper.rb deleted file mode 100644 index 597e65aa..00000000 --- a/app/helpers/comics_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ComicsHelper -end diff --git a/app/helpers/stories_helper.rb b/app/helpers/stories_helper.rb deleted file mode 100644 index 43e5cd8f..00000000 --- a/app/helpers/stories_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module StoriesHelper -end diff --git a/app/models/comic.rb b/app/models/comic.rb index 738d4383..49cce7b6 100644 --- a/app/models/comic.rb +++ b/app/models/comic.rb @@ -1,168 +1,3 @@ #コミック class Comic < ActiveRecord::Base - has_many :stories - belongs_to :author - - validates :title, :presence => true, :length => {:maximum => 100} - validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1} - before_validation :valid_encode - - def valid_encode - ['title', 'description'].each do |a| - next if attributes[a] == nil - raise Pettanr::BadRequest unless attributes[a].valid_encoding? - end - end - - def supply_default - self.visible = 0 if self.visible.blank? - end - - def overwrite au - return false unless au - self.author_id = au.id - end - - def own? roles - roles = [roles] unless roles.respond_to?(:each) - au = Comic.get_author_from_roles roles - return false unless au - self.author_id == au.id - end - - def visible? roles - if MagicNumber['run_mode'] == 0 - return false unless guest_role_check(roles) - else - return false unless reader_role_check(roles) - end - return true if self.own?(roles) - self.visible > 0 - end - - def self.default_page_size - 25 - end - - def self.max_page_size - 100 - end - - def self.default_panel_size - 30 - end - - def self.max_panel_size - 200 - end - - def self.page prm = nil - page = prm.to_i - page = 1 if page < 1 - page - end - - def self.page_size prm = self.default_page_size - page_size = prm.to_i - page_size = self.max_page_size if page_size > self.max_page_size - page_size = self.default_page_size if page_size < 1 - page_size - end - - def self.list_where - 'comics.visible > 0' - end - - def self.mylist_where au - ['comics.author_id = ?', au.id] - end - - def self.himlist_where au - ['comics.author_id = ? and comics.visible > 0', au.id] - end - - def self.list page = 1, page_size = self.default_page_size - Comic.where(self.list_where()).includes(Comic.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size) - end - - def self.mylist au, page = 1, page_size = Author.default_comic_page_size - Comic.where(self.mylist_where(au)).includes(Comic.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size) - end - - def self.himlist au, page = 1, page_size = Author.default_comic_page_size - Comic.where(self.himlist_where(au)).includes(Comic.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size) - end - - def self.list_paginate page = 1, page_size = self.default_page_size - Kaminari.paginate_array(Array.new(Comic.where(self.list_where()).count, nil)).page(page).per(page_size) - end - - def self.mylist_paginate au, page = 1, page_size = Author.default_comic_page_size - Kaminari.paginate_array(Array.new(Comic.where(self.mylist_where(au)).count, nil)).page(page).per(page_size) - end - - def self.himlist_paginate au, page = 1, page_size = Author.default_comic_page_size - Kaminari.paginate_array(Array.new(Comic.where(self.himlist_where(au)).count, nil)).page(page).per(page_size) - end - - def self.list_opt - {:stories => {:panel => {}}, :author => {} } - end - - def self.list_json_opt - {:include => {:stories => {:include => {:panel => {}}}, :author => {}}} - end - - def self.show cid, roles - opt = {} - opt.merge!(Comic.show_opt) - res = Comic.find(cid, opt) - raise ActiveRecord::Forbidden unless res.visible?(roles) - res - end - - def self.edit cid, au - opt = {} - opt.merge!(Comic.show_opt) - res = Comic.find(cid, opt) - raise ActiveRecord::Forbidden unless res.own?(au) - res - end - - def self.show_opt - {:include => {:stories => {:panel => {}}, :author => {}}} - end - - def self.show_json_opt - {:include => {:stories => {:include => {:panel => {}}}, :author => {}}} - end - - def self.visible_count - Comic.count 'visible > 0' - end - - def destroy_with_story - res = false - Comic.transaction do - self.stories.each do |story| - raise ActiveRecord::Rollback unless story.destroy - end - raise ActiveRecord::Rollback unless self.destroy - res = true - end - res - end - - def scenario - panels.map {|panel| - panel.scenario - }.join - end - - def plain_scenario - panels.map {|panel| - panel.plain_scenario - }.join - end - end diff --git a/app/models/story.rb b/app/models/story.rb index cd67cc3a..7f646f85 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -1,318 +1,3 @@ #ストーリー class Story < ActiveRecord::Base - belongs_to :author - belongs_to :panel - belongs_to :comic - - validates :comic_id, :presence => true, :numericality => true, :existence => {:both => false} - validates :panel_id, :presence => true, :numericality => true, :existence => {:both => false} - validates :author_id, :presence => true, :numericality => true, :existence => {:both => false} - validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0} - - def supply_default - self.comic_id = nil - self.panel_id = nil - self.t = nil - end - - def overwrite au - return false unless au - self.author_id = au.id - end - - def own? roles - roles = [roles] unless roles.respond_to?(:each) - au = Story.get_author_from_roles roles - return false unless au - self.author_id == au.id - end - - def visible? roles - if MagicNumber['run_mode'] == 0 - return false unless guest_role_check(roles) - else - return false unless reader_role_check(roles) - end - return true if self.comic.own?(roles) - self.comic.visible? roles - end - - def self.default_panel_size - 30 - end - - def self.max_panel_size - 200 - end - - def self.offset cnt, prm = nil - offset = prm.to_i - offset = cnt - 1 if offset >= cnt - offset = cnt - offset.abs if offset < 0 - offset = 0 if offset < 0 - offset - end - - def self.panel_count cnt, prm = self.default_panel_size - count = prm.to_i - count = self.max_panel_size if count > self.max_panel_size - count = self.default_panel_size if count < 1 - count - end - - def self.default_page_size - 25 - end - - def self.max_page_size - 100 - end - - def self.page prm = nil - page = prm.to_i - page = 1 if page < 1 - page - end - - def self.page_size prm = self.default_page_size - page_size = prm.to_i - page_size = self.max_page_size if page_size > self.max_page_size - page_size = self.default_page_size if page_size < 1 - page_size - end - - def self.play_list_where cid - ['stories.comic_id = ?', cid] - end - - def self.list_where - 'comics.visible > 0' - end - - def self.mylist_where au - ['stories.author_id = ?', au.id] - end - - def self.himlist_where au - ['stories.author_id = ? and comics.visible > 0', au.id] - end - - def self.play_list comic, author, offset = 0, limit = Story.default_panel_size - Story.where(self.play_list_where(comic.id)).includes(Story.list_opt).order('stories.t').offset(offset).limit(limit) - end - - def self.list page = 1, page_size = self.default_page_size - Story.where(self.list_where()).includes(Story.list_opt).order('stories.updated_at desc').offset((page -1) * page_size).limit(page_size) - end - - def self.mylist au, page = 1, page_size = Author.default_story_page_size - Story.where(self.mylist_where(au)).includes(Story.list_opt).order('stories.updated_at desc').offset((page -1) * page_size).limit(page_size) - end - - def self.himlist au, page = 1, page_size = Author.default_story_page_size - Story.where(self.himlist_where(au)).includes(Story.list_opt).order('stories.updated_at desc').offset((page -1) * page_size).limit(page_size) - end - - def self.list_paginate page = 1, page_size = self.default_page_size - Kaminari.paginate_array(Array.new(Story.where(self.list_where()).includes(Story.list_opt).count, nil)).page(page).per(page_size) - end - - def self.mylist_paginate au, page = 1, page_size = Author.default_story_page_size - Kaminari.paginate_array(Array.new(Story.where(self.mylist_where(au)).includes(Story.list_opt).count, nil)).page(page).per(page_size) - end - - def self.himlist_paginate au, page = 1, page_size = Author.default_story_page_size - Kaminari.paginate_array(Array.new(Story.where(self.himlist_where(au)).includes(Story.list_opt).count, nil)).page(page).per(page_size) - end - - def self.list_opt - { - :author => {}, - :comic => { - :author => {} - }, - :panel => { - :author => {}, - :panel_pictures => {:picture => {:artist => {}, :license => {}}}, - :speech_balloons =>{:balloon => {}, :speech => {}} - } - } - end - - def self.list_json_opt - {:include => { - :author => {}, - :comic => { - :author => {} - }, - :panel => { - :author => {}, - :panel_pictures => {:picture => {:artist => {}, :license => {}}}, - :speech_balloons =>{:balloon => {}, :speech => {}} - } - }} - end - - def self.show sid, roles - opt = {} - opt.merge!(Story.show_opt) - res = Story.find sid, opt - raise ActiveRecord::Forbidden unless res.visible?(roles) - res - end - - def self.edit sid, au - opt = {} - opt.merge!(Story.show_opt) - res = Story.find sid, opt - raise ActiveRecord::Forbidden unless res.own?(au) - res - end - - def self.show_opt - {:include => { - :author => {}, - :comic => { - :author => {} - }, - :panel => { - :author => {}, - :panel_pictures => {:picture => {:artist => {}, :license => {}}}, - :speech_balloons =>{:balloon => {}, :speech => {}} - } - }} - end - - def elements - self.panel.elements - end - - def story_as_json au - panel_include = if self.panel and self.panel.visible?(au) - {:include => {:author => {}}, :methods => :elements} - else - {:include => {:author => {}}} - end - self.to_json({:include => {:comic => {:include => {:author => {}}}, :author => {}, :panel => panel_include}}) - end - - def self.list_as_json_text ary, au - '[' + ary.map {|i| i.story_as_json(au) }.join(',') + ']' - end - - def self.licensed_pictures stories - r = {} - stories.each do |story| - r.merge!(story.panel.licensed_pictures) if story.panel - end - r - end - - def self.new_t comic_id - r = Story.max_t(comic_id) - r.blank? ? 0 : r.to_i + 1 - end - - def self.max_t comic_id - Story.maximum(:t, :conditions => ['comic_id = ?', comic_id]) - end - - def self.find_t comic_id, t - Story.find(:first, :conditions => ['comic_id = ? and t = ?', comic_id, t]) - end - - def self.collect_t story - r = Story.find(:all, :conditions => ['comic_id = ?', story.comic_id], :order => 't') - r.map {|s| s.t} - end - - def self.serial? ary - i = 0 - ary.compact.sort.each do |t| - break false unless t == i - i += 1 - end - ary.compact.size == i - end - - def self.validate_t story - Story.serial?(Story.collect_t(story)) - end - - def insert_shift - Story.update_all('t = t + 1', ['comic_id = ? and t >= ?', self.comic_id, self.t]) - end - - def lesser_shift old_t - self.t = 0 if self.t < 0 - Story.update_all('t = t + 1', ['comic_id = ? and (t >= ? and t < ?)', self.comic_id, self.t, old_t]) - end - - def higher_shift old_t - nf = Story.find_t(self.comic_id, self.t) - max_t = Story.max_t(self.comic_id).to_i - self.t = max_t if self.t > max_t - Story.update_all('t = t - 1', ['comic_id = ? and (t > ? and t <= ?)', self.comic_id, old_t, self.t]) - end - - def update_shift old_t - if self.t > old_t - higher_shift old_t - else - lesser_shift old_t - end - end - - def rotate old_t = nil - if self.new_record? - if self.t.blank? - self.t = Story.new_t self.comic_id - else - self.insert_shift - end - else - if self.t.blank? - else - self.update_shift old_t - end - end - end - - def allow? - return nil if self.comic_id == nil or self.panel_id == nil - self.comic.own?(self.author) and self.panel.usable?(self.author) - end - - def store old_t = nil - res = false - Story.transaction do - case self.allow? - when true - self.rotate old_t - when false - raise ActiveRecord::Forbidden - else - end - res = self.save - raise ActiveRecord::Rollback unless res - res = Story.validate_t(self) - unless res - self.errors.add :t, 'unserialized' - raise ActiveRecord::Rollback - end - end - res - end - - def destroy_and_shorten - res = false - Story.transaction do - Story.update_all('t = t - 1', ['comic_id = ? and (t > ?)', self.comic_id, self.t]) - raise ActiveRecord::Rollback unless self.destroy - res = true - end - res - end - - end diff --git a/app/models/user.rb b/app/models/user.rb index 5c809602..48a344c8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,8 +22,8 @@ class User < ActiveRecord::Base def destroy res = false User.transaction do - self.author.comics.each do |comic| - raise ActiveRecord::Rollback unless comic.destroy_with_story + self.author.scrolls.each do |scroll| + raise ActiveRecord::Rollback unless scroll.destroy_with_scroll_panel end self.author.panels.each do |panel| raise ActiveRecord::Rollback unless panel.destroy_with_elements diff --git a/app/views/authors/_list_item.html.erb b/app/views/authors/_list_item.html.erb index 1bf947a0..db101bf9 100644 --- a/app/views/authors/_list_item.html.erb +++ b/app/views/authors/_list_item.html.erb @@ -1,20 +1,20 @@ - <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %> - <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> - (<%= comic.stories.size -%>) + <%= link_to scroll_icon(:object => scroll, :size => 25), scroll_path(scroll) %> + <%= link_to h(truncate(scroll.title, :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %> + (<%= scroll.scroll_panels.size -%>) - <%= distance_of_time_in_words_to_now comic.updated_at %> + <%= distance_of_time_in_words_to_now scroll.updated_at %> - <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %> - <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %> + <%= link_to author_icon(:object => scroll.author, :size => 25), scroll_path(scroll.author) %> + <%= link_to h(truncate(scroll.author.name, :length => 12)), author_path(scroll.author) %> - <% if comic.own? author %> - <%= link_to t('link.edit'), edit_comic_path(comic) %> - <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %> + <% if scroll.own? author %> + <%= link_to t('link.edit'), edit_scroll_path(scroll) %> + <%= link_to t('link.destroy'), scroll_path(scroll), :method => :delete %> <% end %> diff --git a/app/views/authors/comics.html.erb b/app/views/authors/comics.html.erb deleted file mode 100644 index 8aca58d1..00000000 --- a/app/views/authors/comics.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -

<%= t '.title' -%>

- - - <% @comics.each do |comic| %> - - - - - - - <% end %> -
- <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %> - <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> - (<%= comic.stories.size -%>) - - <%= distance_of_time_in_words_to_now comic.updated_at %> - - <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %> - <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %> - - <% if comic.own? @author %> - <%= link_to t('link.edit'), edit_comic_path(comic) %> - <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %> - <% end %> -
-<%= paginate(@paginate) %> -<%= link_to t('comics.new.title'), new_comic_path %> diff --git a/app/views/authors/scroll_panels.html.erb b/app/views/authors/scroll_panels.html.erb new file mode 100644 index 00000000..3d75a57d --- /dev/null +++ b/app/views/authors/scroll_panels.html.erb @@ -0,0 +1,9 @@ +

<%= t '.title' -%>

+ + + <% @scroll_panels.each do |scroll_panel| %> + <%= render 'scroll_panels/list_item', :scroll_panel => scroll_panel, :author => @author %> + <% end %> +
+<%= paginate(@paginate) %> +<%= link_to t('scroll_panels.new.title'), new_scroll_panel_path %> diff --git a/app/views/authors/scrolls.html.erb b/app/views/authors/scrolls.html.erb new file mode 100644 index 00000000..73db7bfe --- /dev/null +++ b/app/views/authors/scrolls.html.erb @@ -0,0 +1,28 @@ +

<%= t '.title' -%>

+ + + <% @scrolls.each do |scroll| %> + + + + + + + <% end %> +
+ <%= link_to scroll_icon(:object => scroll, :size => 25), scroll_path(scroll) %> + <%= link_to h(truncate(scroll.title, :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %> + (<%= scroll.scroll_panels.size -%>) + + <%= distance_of_time_in_words_to_now scroll.updated_at %> + + <%= link_to author_icon(:object => scroll.author, :size => 25), scroll_path(scroll.author) %> + <%= link_to h(truncate(scroll.author.name, :length => 12)), author_path(scroll.author) %> + + <% if scroll.own? @author %> + <%= link_to t('link.edit'), edit_scroll_path(scroll) %> + <%= link_to t('link.destroy'), scroll_path(scroll), :method => :delete %> + <% end %> +
+<%= paginate(@paginate) %> +<%= link_to t('scrolls.new.title'), new_scroll_path %> diff --git a/app/views/authors/show.html.erb b/app/views/authors/show.html.erb index aea2597a..9f2d3f2d 100644 --- a/app/views/authors/show.html.erb +++ b/app/views/authors/show.html.erb @@ -18,11 +18,11 @@

- <%= link_to t('authors.show.to_comics'), comics_author_path(@au) %> + <%= link_to t('authors.show.to_scrolls'), scrolls_author_path(@au) %>

- <%= link_to t('authors.show.to_stories'), stories_author_path(@au) %> + <%= link_to t('authors.show.to_scroll_panels'), scroll_panels_author_path(@au) %>

diff --git a/app/views/authors/stories.html.erb b/app/views/authors/stories.html.erb deleted file mode 100644 index a99f490f..00000000 --- a/app/views/authors/stories.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -

<%= t '.title' -%>

- - - <% @stories.each do |story| %> - <%= render 'stories/list_item', :story => story, :author => @author %> - <% end %> -
-<%= paginate(@paginate) %> -<%= link_to t('stories.new.title'), new_story_path %> diff --git a/app/views/comics/_form.html.erb b/app/views/comics/_form.html.erb deleted file mode 100644 index 84b983cc..00000000 --- a/app/views/comics/_form.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<%= form_for(@comic) do |f| %> - <%= render 'system/error_explanation', :obj => @comic %> - -
- <%= f.label :title %>
- <%= f.text_field :title %> -
-
- <%= f.label :description %>
- <%= f.text_area :description %> -
-
- <%= f.label :visible %>
- <%= f.collection_select :visible, t_select_items(MagicNumber['comic_visible_items']), :last, :first, :html => {:selected => @comic.visible} %> -
-
- <%= f.label :author_id %>
- <%= h @author.name %> -
-
- <%= f.submit %> -
-<% end %> diff --git a/app/views/comics/_list_item.html.erb b/app/views/comics/_list_item.html.erb deleted file mode 100644 index 2e9d719a..00000000 --- a/app/views/comics/_list_item.html.erb +++ /dev/null @@ -1,25 +0,0 @@ - - - <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %> - <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> - (<%= comic.stories.size -%>) - - - <%= distance_of_time_in_words_to_now comic.updated_at %> - - - <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %> - <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %> - - - <% if comic.own? author %> - <%= link_to t('link.edit'), edit_comic_path(comic) %> - <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %> - <% end %> - - - - - <%= h(truncate(comic.description, :length => 40)) %> - - diff --git a/app/views/comics/browse.html.erb b/app/views/comics/browse.html.erb deleted file mode 100644 index c93e6224..00000000 --- a/app/views/comics/browse.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -

<%= t '.title' -%>

-

- <%= t_m 'Comic.id' -%>: - <%= h @comic.id %> -

- -

- <%= t_m 'Comic.title' -%>: - <%= h @comic.title %> -

- -

- <%= t_m 'Comic.visible' -%>: - <%= @comic.visible %> - <%= t_selected_item('comic_visible_items', @comic.visible) %> -

- -

- <%= t_m 'Comic.author_id' -%>: - <%= @comic.author_id %> - <%= link_to h(@comic.author.name), browse_author_path(@comic.author) %> -

- -

- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> -

- -

- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> -

- -<%= link_to t('link.back'), :action => :list %> diff --git a/app/views/comics/edit.html.erb b/app/views/comics/edit.html.erb deleted file mode 100644 index 1d67f75e..00000000 --- a/app/views/comics/edit.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -

<%= t('.title') %>

-

<%= notice %>

- -<%= render 'form' %> diff --git a/app/views/comics/edit.js.erb b/app/views/comics/edit.js.erb deleted file mode 100644 index ab2a7d24..00000000 --- a/app/views/comics/edit.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#newcomic").html("<%= escape_javascript(render('form')) -%>"); diff --git a/app/views/comics/index.atom.builder b/app/views/comics/index.atom.builder deleted file mode 100644 index a1e9b0c0..00000000 --- a/app/views/comics/index.atom.builder +++ /dev/null @@ -1,25 +0,0 @@ -atom_feed( - :language => 'ja-JP', - :root_url => root_url, - :url => root_url(:format => :atom), - :id => root_url -) do |feed| - feed.title MagicNumber['profile']['users']['caption'] - feed.subtitle sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br)) - feed.updated Time.now - feed.author {|author| author.name(MagicNumber['profile']['web_master'])} - - @comics.each do |comic| - feed.entry( - comic, - :url => comic_url(comic), - :id => comic_url(comic), - :published => comic.updated_at, - :updated => comic.updated_at - ) do |item| - item.title(comic.title) - item.content(comic.description, :type => 'html') - item.author {|author| author.name(comic.author.name)} - end - end -end diff --git a/app/views/comics/index.html.erb b/app/views/comics/index.html.erb deleted file mode 100644 index cef2ab93..00000000 --- a/app/views/comics/index.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -

<%= t '.title' -%>

- - - <% @comics.each do |comic| %> - <%= render 'list_item', :comic => comic, :author => @author %> - <% end %> -
-<%= paginate(@paginate) %> -<%= link_to t('comics.new.title'), new_comic_path %> diff --git a/app/views/comics/index.rss.builder b/app/views/comics/index.rss.builder deleted file mode 100644 index b319a9d0..00000000 --- a/app/views/comics/index.rss.builder +++ /dev/null @@ -1,24 +0,0 @@ -xml.instruct! - -xml.rss("version" => "2.0", - "xmlns:dc" => "http://purl.org/dc/elements/1.1/", - "xmlns:atom" => "http://www.w3.org/2005/Atom") do - xml.channel do - xml.title MagicNumber['profile']['users']['caption'] - xml.link root_url - xml.pubDate Time.now.rfc822 - xml.description sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br)) - xml.atom :link, "href" => @rss_url, "rel" => "self", "type" => "application/rss+xml" - - @comics.each do |comic| - xml.item do - xml.title comic.title - xml.link comic_url(comic) - xml.guid comic_url(comic) - xml.description comic.description - xml.pubDate comic.updated_at.to_formatted_s(:rfc822) - xml.dc :creator, comic.author.name - end - end - end -end diff --git a/app/views/comics/list.html.erb b/app/views/comics/list.html.erb deleted file mode 100644 index 43fdf7e5..00000000 --- a/app/views/comics/list.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -

<%= t '.title' -%>

- - - - - - - - - - - -<% @comics.each do |comic| %> - - - - - - - - -<% end %> -
<%= t_m 'Comic.id' -%><%= t_m 'Comic.title' -%><%= t_m 'Comic.visible' -%><%= t_m 'Comic.author_id' -%><%= t_m 'Comic.created_at' -%><%= t_m 'Comic.updated_at' -%>
<%= link_to comic.id, browse_comic_path(comic) %><%= h(truncate(comic.title, :length => 12)) %><%= comic.visible %><%= link_to comic.author_id, browse_author_path(comic.author) %><%= l comic.created_at %><%= l comic.updated_at %>
- diff --git a/app/views/comics/new.html.erb b/app/views/comics/new.html.erb deleted file mode 100644 index 7142b57d..00000000 --- a/app/views/comics/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

<%= t('.title') %>

- -<%= render 'form' %> - -<%= link_to t('link.back'), comics_path %> diff --git a/app/views/comics/new.js.erb b/app/views/comics/new.js.erb deleted file mode 100644 index ab2a7d24..00000000 --- a/app/views/comics/new.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#newcomic").html("<%= escape_javascript(render('form')) -%>"); diff --git a/app/views/comics/show.atom.builder b/app/views/comics/show.atom.builder deleted file mode 100644 index 6f5c967f..00000000 --- a/app/views/comics/show.atom.builder +++ /dev/null @@ -1,25 +0,0 @@ -atom_feed( - :language => 'ja-JP', - :root_url => root_url, - :url => root_url(:format => :atom), - :id => root_url -) do |feed| - feed.title MagicNumber['profile']['users']['caption'] - feed.subtitle sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br)) - feed.updated Time.now - feed.author {|author| author.name(MagicNumber['profile']['web_master'])} - - @comic.stories.each do |story| - feed.entry( - story.panel, - :url => panel_url(story.panel), - :id => panel_url(story.panel), - :published => story.panel.updated_at, - :updated => story.panel.updated_at - ) do |item| - item.title(story.panel.caption) - item.content(story.panel.scenario, :type => 'html') - item.author {|author| author.name(story.panel.author.name)} - end - end -end diff --git a/app/views/comics/show.html.erb b/app/views/comics/show.html.erb deleted file mode 100644 index 81a1bbf3..00000000 --- a/app/views/comics/show.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -<% @page_title = t('.title') + ':' + @comic.title %> -

<%= t('.title') %>

-

<%= notice %>

- -

- <%= t_m 'Comic.title' -%>: - <%= link_to h(@comic.title), :controller => 'stories', :action => :comic, :id => @comic.id %> -

- -

- <%= t_m 'Comic.description' -%>: - <%= h(@comic.description) %> -

- -

- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> -

- -

- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> -

- -

- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> -

- -

- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> -

- -<%= link_to t('link.edit'), edit_comic_path(@comic) %> diff --git a/app/views/comics/show.rss.builder b/app/views/comics/show.rss.builder deleted file mode 100644 index 553f344f..00000000 --- a/app/views/comics/show.rss.builder +++ /dev/null @@ -1,24 +0,0 @@ -xml.instruct! - -xml.rss("version" => "2.0", - "xmlns:dc" => "http://purl.org/dc/elements/1.1/", - "xmlns:atom" => "http://www.w3.org/2005/Atom") do - xml.channel do - xml.title MagicNumber['profile']['users']['caption'] - xml.link root_url - xml.pubDate Time.now.rfc822 - xml.description sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br)) - xml.atom :link, "href" => @rss_url, "rel" => "self", "type" => "application/rss+xml" - - @comic.stories.each do |story| - xml.item do - xml.title story.panel.caption - xml.link panel_url(story.panel) - xml.guid panel_url(story.panel) - xml.description story.panel.plain_scenario - xml.pubDate story.panel.updated_at.to_formatted_s(:rfc822) - xml.dc :creator, story.panel.author.name - end - end - end -end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 392ac957..1f47cb16 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,14 +1,14 @@

<%= t '.title' -%>

<%= link_to h(@author.name), main_app.author_path(@author) -%>

-

<%= t('.updated_comic') -%>

+

<%= t('.updated_scroll') -%>

- - - - - - - - diff --git a/app/views/panels/_append_scroll.html.erb b/app/views/panels/_append_scroll.html.erb new file mode 100644 index 00000000..83aef117 --- /dev/null +++ b/app/views/panels/_append_scroll.html.erb @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/app/views/panels/show.html.erb b/app/views/panels/show.html.erb index 6840f865..d947d080 100644 --- a/app/views/panels/show.html.erb +++ b/app/views/panels/show.html.erb @@ -10,16 +10,16 @@ <% if @author %> -

<%= t('panels.show.new_comics') -%>

+

<%= t('panels.show.new_scrolls') -%>

- <%= link_to t_m('Comic'), '/home/comics' %> + <%= link_to t_m('Scroll'), '/home/scrolls' %> - <%= link_to t_m('Story'), '/home/stories' %> + <%= link_to t_m('ScrollPanel'), '/home/scroll_panels' %> <%= link_to t_m('Panel'), '/home/panels' %> diff --git a/app/views/home/scroll_panels.html.erb b/app/views/home/scroll_panels.html.erb index a99f490f..3d75a57d 100644 --- a/app/views/home/scroll_panels.html.erb +++ b/app/views/home/scroll_panels.html.erb @@ -1,9 +1,9 @@

<%= t '.title' -%>

- <% @stories.each do |story| %> - <%= render 'stories/list_item', :story => story, :author => @author %> + <% @scroll_panels.each do |scroll_panel| %> + <%= render 'scroll_panels/list_item', :scroll_panel => scroll_panel, :author => @author %> <% end %>
<%= paginate(@paginate) %> -<%= link_to t('stories.new.title'), new_story_path %> +<%= link_to t('scroll_panels.new.title'), new_scroll_panel_path %> diff --git a/app/views/home/scrolls.html.erb b/app/views/home/scrolls.html.erb index 9d0287d7..bba50b74 100644 --- a/app/views/home/scrolls.html.erb +++ b/app/views/home/scrolls.html.erb @@ -2,9 +2,9 @@

<%= notice %>

- <% @comics.each do |comic| %> - <%= render 'comics/list_item', :comic => comic, :author => @author %> + <% @scrolls.each do |scroll| %> + <%= render 'scrolls/list_item', :scroll => scroll, :author => @author %> <% end %>
<%= paginate(@paginate) %> -<%= link_to t('comics.new.title'), new_comic_path %> +<%= link_to t('scrolls.new.title'), new_scroll_path %> diff --git a/app/views/layouts/system.html.erb b/app/views/layouts/system.html.erb index eb14d8fb..f5abbcf1 100644 --- a/app/views/layouts/system.html.erb +++ b/app/views/layouts/system.html.erb @@ -11,7 +11,7 @@
<% if user_signed_in? %> <%= link_to t('home.index.title'), '/home' %> - <%= link_to t('home.comics.title'), '/home/comic' %> + <%= link_to t('home.scrolls.title'), '/home/scroll' %> <%= link_to t('home.panels.title'), '/home/panel' %> <%= link_to t('home.panel_pictures.title'), '/home/panel_picture' %> <%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %> @@ -41,8 +41,8 @@
user.resources - <%= link_to 'comics', main_app.comics_path %> - <%= link_to 'stories', main_app.new_story_path %> + <%= link_to 'scrolls', main_app.scrolls_path %> + <%= link_to 'scroll_panels', main_app.new_scroll_panel_path %> <%= link_to 'panels', main_app.panels_path %> <%= link_to 'original_pictures', main_app.original_pictures_path %> <%= link_to 'resource_pictures', main_app.resource_pictures_path %> diff --git a/app/views/layouts/test.html.erb b/app/views/layouts/test.html.erb index 0f5cfcde..618f32cb 100644 --- a/app/views/layouts/test.html.erb +++ b/app/views/layouts/test.html.erb @@ -52,7 +52,7 @@
<%= link_to t('tab.reader.title'), '/' %> - <%= link_to t_m('Comic'), main_app.comics_path %> + <%= link_to t_m('Scroll'), main_app.scrolls_path %> <%= link_to t_m('Panel'), main_app.panels_path %> <%= link_to t_m('ResourcePicture'), main_app.resource_pictures_path %> <%= link_to t_m('SpeechBalloonTemplate'), main_app.speech_balloon_templates_path %> @@ -63,7 +63,7 @@ <% if @author %>
<%= link_to t('tab.creator.home'), '/home' %> - <%= link_to t('tab.creator.comic'), '/home/comics' %> + <%= link_to t('tab.creator.scroll'), '/home/scrolls' %> <%= link_to t('tab.creator.panel'), '/home/panels' %> <% if @artist %> <%= link_to t('tab.creator.original_picture'), main_app.original_pictures_path %> diff --git a/app/views/panels/_append_comic.html.erb b/app/views/panels/_append_comic.html.erb deleted file mode 100644 index 2190d65c..00000000 --- a/app/views/panels/_append_comic.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -
- <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %> - <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> - (<%= comic.stories.size -%>) - - <%= distance_of_time_in_words_to_now comic.updated_at %> - - <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %> - <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %> - - <% if comic.own? author %> - <% @story = Story.new :comic_id => comic.id, :panel_id => panel.id %> - <%= form_for(@story) do |f| %> - <%= f.hidden_field :comic_id %> - <%= f.hidden_field :t %> - <%= f.hidden_field :panel_id %> -
- <%= f.submit t('panels.show.append') %> -
- <% end %> - <% end %> -
- <%= h(truncate(comic.description, :length => 40)) %> -
+ <%= link_to scroll_icon(:object => scroll, :size => 25), scroll_path(scroll) %> + <%= link_to h(truncate(scroll.title, :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %> + (<%= scroll.scroll_panels.size -%>) + + <%= distance_of_time_in_words_to_now scroll.updated_at %> + + <%= link_to author_icon(:object => scroll.author, :size => 25), scroll_path(scroll.author) %> + <%= link_to h(truncate(scroll.author.name, :length => 12)), author_path(scroll.author) %> + + <% if scroll.own? author %> + <% @scroll_panel = ScrollPanel.new :scroll_id => scroll.id, :panel_id => panel.id %> + <%= form_for(@scroll_panel) do |f| %> + <%= f.hidden_field :scroll_id %> + <%= f.hidden_field :t %> + <%= f.hidden_field :panel_id %> +
+ <%= f.submit t('panels.show.append') %> +
+ <% end %> + <% end %> +
+ <%= h(truncate(scroll.description, :length => 40)) %> +
- <% @new_comics.each do |comic| %> - <%= render 'append_comic', :panel => @panel, :comic => comic, :author => @author %> + <% @new_scrolls.each do |scroll| %> + <%= render 'append_scroll', :panel => @panel, :scroll => scroll, :author => @author %> <% end %>
-

<%= t('panels.show.fresh_comics') -%>

+

<%= t('panels.show.fresh_scrolls') -%>

- <% @fresh_comics.each do |comic| %> - <%= render 'append_comic', :panel => @panel, :comic => comic, :author => @author %> + <% @fresh_scrolls.each do |scroll| %> + <%= render 'append_scroll', :panel => @panel, :scroll => scroll, :author => @author %> <% end %>

<%= t('panels.show.copy') -%>

diff --git a/app/views/scroll_panels/_append_panel.html.erb b/app/views/scroll_panels/_append_panel.html.erb index 241bcf84..a7d84bce 100644 --- a/app/views/scroll_panels/_append_panel.html.erb +++ b/app/views/scroll_panels/_append_panel.html.erb @@ -4,18 +4,18 @@ <%= link_to author_icon(:object => panel.author, :size => 17), author_path(panel.author) %> - <%= link_to h(truncate(h(panel.caption), :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> + <%= link_to h(truncate(h(panel.caption), :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %> <%= l panel.updated_at %> - <% @story = Story.new :comic_id => comic.id, :panel_id => panel.id -%> - <%= form_for(@story) do |f| %> - <%= f.hidden_field :comic_id %> + <% @scroll_panel = ScrollPanel.new :scroll_id => scroll.id, :panel_id => panel.id -%> + <%= form_for(@scroll_panel) do |f| %> + <%= f.hidden_field :scroll_id %> <%= f.hidden_field :t %> <%= f.hidden_field :panel_id %> - <%= f.submit t('stories.comic.append') %> + <%= f.submit t('scroll_panels.scroll.append') %> <% end %> diff --git a/app/views/scroll_panels/_footer.html.erb b/app/views/scroll_panels/_footer.html.erb index 56e93674..a72fb755 100644 --- a/app/views/scroll_panels/_footer.html.erb +++ b/app/views/scroll_panels/_footer.html.erb @@ -1,22 +1,22 @@ diff --git a/app/views/scroll_panels/_form.html.erb b/app/views/scroll_panels/_form.html.erb index 8d705f58..f2f70ad5 100644 --- a/app/views/scroll_panels/_form.html.erb +++ b/app/views/scroll_panels/_form.html.erb @@ -1,9 +1,9 @@ -<%= form_for(@story) do |f| %> - <%= render 'system/error_explanation', :obj => @story %> +<%= form_for(@scroll_panel) do |f| %> + <%= render 'system/error_explanation', :obj => @scroll_panel %>
- <%= f.label :comic_id %>
- <%= f.number_field :comic_id %> + <%= f.label :scroll_id %>
+ <%= f.number_field :scroll_id %>
<%= f.label :t %>
diff --git a/app/views/scroll_panels/_list_item.html.erb b/app/views/scroll_panels/_list_item.html.erb index 1b18f0fc..719097a7 100644 --- a/app/views/scroll_panels/_list_item.html.erb +++ b/app/views/scroll_panels/_list_item.html.erb @@ -1,28 +1,28 @@
diff --git a/app/views/scroll_panels/_order.html.erb b/app/views/scroll_panels/_order.html.erb index e0ceadfe..6d515f84 100644 --- a/app/views/scroll_panels/_order.html.erb +++ b/app/views/scroll_panels/_order.html.erb @@ -1,14 +1,14 @@ -<%= form_for(story) do |f| %> +<%= form_for(scroll_panel) do |f| %>
- <% if story.panel -%> - <%= link_to panel_icon(:object => story.panel, :size => 25), panel_path(story.panel) %> - <%= link_to author_icon(:object => story.panel.author, :size => 17), author_path(story.panel.author) %> - <%= distance_of_time_in_words_to_now story.panel.updated_at %> + <% if scroll_panel.panel -%> + <%= link_to panel_icon(:object => scroll_panel.panel, :size => 25), panel_path(scroll_panel.panel) %> + <%= link_to author_icon(:object => scroll_panel.panel.author, :size => 17), author_path(scroll_panel.panel.author) %> + <%= distance_of_time_in_words_to_now scroll_panel.panel.updated_at %> <% end %> - <%= link_to story_icon(:object => story, :size => 25), story_path(story) %> - <%= link_to author_icon(:object => story.author, :size => 17), author_path(story.author) %> - <%= l story.updated_at %> + <%= link_to scroll_panel_icon(:object => scroll_panel, :size => 25), scroll_panel_path(scroll_panel) %> + <%= link_to author_icon(:object => scroll_panel.author, :size => 17), author_path(scroll_panel.author) %> + <%= l scroll_panel.updated_at %> - <% if story.own? author %> - <%= render 'order', :story => story %> + <% if scroll_panel.own? author %> + <%= render 'order', :scroll_panel => scroll_panel %> <% else %> - No.<%= story.t %> + No.<%= scroll_panel.t %> <% end %>
- <%= link_to comic_icon(:object => story.comic, :size => 25), comic_path(story.comic) %> + <%= link_to scroll_icon(:object => scroll_panel.scroll, :size => 25), scroll_path(scroll_panel.scroll) %> - <%= link_to h(story.comic.title), :controller => 'stories', :action => :comic, :id => story.comic.id %> + <%= link_to h(scroll_panel.scroll.title), :controller => 'scroll_panels', :action => :scroll, :id => scroll_panel.scroll.id %> - <%= link_to author_icon(:object => story.comic.author, :size => 17), author_path(story.comic.author) %> + <%= link_to author_icon(:object => scroll_panel.scroll.author, :size => 17), author_path(scroll_panel.scroll.author) %> - <%= link_to story_icon(:object => story, :size => 25), story_path(story) %> + <%= link_to scroll_panel_icon(:object => scroll_panel, :size => 25), scroll_panel_path(scroll_panel) %> - <%= link_to author_icon(:object => story.author, :size => 17), author_path(story.author) %> + <%= link_to author_icon(:object => scroll_panel.author, :size => 17), author_path(scroll_panel.author) %> - No.<%= story.t %> + No.<%= scroll_panel.t %> - <%= l story.updated_at %> + <%= l scroll_panel.updated_at %> - <% if story.panel %> - <%= h story.panel.caption %> + <% if scroll_panel.panel %> + <%= h scroll_panel.panel.caption %> <% end %>
No. <%= f.number_field :t, :size => 3 %> <%= f.hidden_field :panel_id %> - <%= f.hidden_field :comic_id %> + <%= f.hidden_field :scroll_id %> - <%= f.submit t 'stories.move' %> + <%= f.submit t 'scroll_panels.move' %>
diff --git a/app/views/scroll_panels/_scroll_header.html.erb b/app/views/scroll_panels/_scroll_header.html.erb index d1eb9e77..a1766055 100644 --- a/app/views/scroll_panels/_scroll_header.html.erb +++ b/app/views/scroll_panels/_scroll_header.html.erb @@ -1,16 +1,16 @@

- <%= link_to comic_icon, comic_path(comic) %> - <%= link_to h(comic.title), :controller => 'stories', :action => :comic, :id => comic.id %> + <%= link_to scroll_icon, scroll_path(scroll) %> + <%= link_to h(scroll.title), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %>

-<% if comic.own? author -%> - <%= form_for(comic) do |f| %> +<% if scroll.own? author -%> + <%= form_for(scroll) do |f| %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.label :visible %>
- <%= f.collection_select :visible, t_select_items(MagicNumber['comic_visible_items']), :last, :first, :html => {:selected => @comic.visible} %> + <%= f.collection_select :visible, t_select_items(MagicNumber['scroll_visible_items']), :last, :first, :html => {:selected => @scroll.visible} %>
<%= f.submit %> @@ -18,23 +18,23 @@ <% end %> <% else %>

- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> + <%= t_m 'Scroll.visible' -%>: + <%= t_selected_item('scroll_visible_items', @scroll.visible) %>

<% end %>

- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> + <%= t_m 'Scroll.author_id' -%>: + <%= link_to h(@scroll.author.name), author_path(@scroll.author) %>

- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> + <%= t_m 'Scroll.created_at' -%>: + <%= l @scroll.created_at %>

- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> + <%= t_m 'Scroll.updated_at' -%>: + <%= l @scroll.updated_at %>

diff --git a/app/views/scroll_panels/browse.html.erb b/app/views/scroll_panels/browse.html.erb index 24a7a6ca..b4083f67 100644 --- a/app/views/scroll_panels/browse.html.erb +++ b/app/views/scroll_panels/browse.html.erb @@ -1,28 +1,28 @@

<%= notice %>

- comic_id: - <%= @story.comic_id %> + scroll_id: + <%= @scroll_panel.scroll_id %>

panel_id: - <%= @story.panel_id %> + <%= @scroll_panel.panel_id %>

t: - <%= @story.t %> + <%= @scroll_panel.t %>

author_id: - <%= @story.author_id %> + <%= @scroll_panel.author_id %>

updated_at: - <%= @story.updated_at %> + <%= @scroll_panel.updated_at %>

<%= link_to 'Back', :action => :list %> diff --git a/app/views/scroll_panels/edit.html.erb b/app/views/scroll_panels/edit.html.erb index cee9463d..91bdcac0 100644 --- a/app/views/scroll_panels/edit.html.erb +++ b/app/views/scroll_panels/edit.html.erb @@ -2,4 +2,4 @@

<%= notice %>

<%= render 'form' %> -<%= button_to 'Destroy', @story.panel, confirm: 'Are you sure?', method: :delete %> +<%= button_to 'Destroy', @scroll_panel.panel, confirm: 'Are you sure?', method: :delete %> diff --git a/app/views/scroll_panels/edit.js.erb b/app/views/scroll_panels/edit.js.erb index 29c687f7..65bc52a8 100644 --- a/app/views/scroll_panels/edit.js.erb +++ b/app/views/scroll_panels/edit.js.erb @@ -1 +1 @@ -$("#story-update-<%= @story.id -%>").html("<%= escape_javascript(render('editform')) -%>"); +$("#scroll_panel-update-<%= @scroll_panel.id -%>").html("<%= escape_javascript(render('editform')) -%>"); diff --git a/app/views/scroll_panels/index.html.erb b/app/views/scroll_panels/index.html.erb index 7b61ab84..74213ffd 100644 --- a/app/views/scroll_panels/index.html.erb +++ b/app/views/scroll_panels/index.html.erb @@ -1,8 +1,8 @@

<%= t '.title' -%>

- <% @stories.each do |story| %> - <%= render 'list_item', :story => story, :author => @author %> + <% @scroll_panels.each do |scroll_panel| %> + <%= render 'list_item', :scroll_panel => scroll_panel, :author => @author %> <% end %>
<%= paginate(@paginate) %> -<%= link_to t('stories.new.title'), new_story_path %> +<%= link_to t('scroll_panels.new.title'), new_scroll_panel_path %> diff --git a/app/views/scroll_panels/list.html.erb b/app/views/scroll_panels/list.html.erb index 6fae81c5..9606beff 100644 --- a/app/views/scroll_panels/list.html.erb +++ b/app/views/scroll_panels/list.html.erb @@ -1,9 +1,9 @@ -

Listing Story

+

Listing ScrollPanel

- + @@ -12,15 +12,15 @@ -<% @stories.each do |story| %> +<% @scroll_panels.each do |scroll_panel| %> - - - - - - - + + + + + + + diff --git a/app/views/scroll_panels/scroll.html.erb b/app/views/scroll_panels/scroll.html.erb index 631f6f03..b25cca22 100644 --- a/app/views/scroll_panels/scroll.html.erb +++ b/app/views/scroll_panels/scroll.html.erb @@ -1,33 +1,33 @@ -<% @page_title = @comic.title %> +<% @page_title = @scroll.title %>

<%= t '.title' -%>

<%= notice %>

-<%= render 'comic_header', :comic => @comic, :author => @author %> +<%= render 'scroll_header', :scroll => @scroll, :author => @author %> -<% if @stories.empty? -%> -

<%= t('stories.comic.empty') %>

+<% if @scroll_panels.empty? -%> +

<%= t('scroll_panels.scroll.empty') %>

<% else %> - <% @stories.each do |story| %> - <% if story.panel -%> - <%= render 'panels/body', :panel => story.panel, :author => @author, :spot => nil %> + <% @scroll_panels.each do |scroll_panel| %> + <% if scroll_panel.panel -%> + <%= render 'panels/body', :panel => scroll_panel.panel, :author => @author, :spot => nil %> <% end %> - <%= render 'footer', :story => story, :author => @author %> + <%= render 'footer', :scroll_panel => scroll_panel, :author => @author %> <% end %> - <%= render 'licensed_pictures', :licensed_pictures => Story.licensed_pictures(@stories) %> + <%= render 'licensed_pictures', :licensed_pictures => ScrollPanel.licensed_pictures(@scroll_panels) %> <% if @prev_offset -%> - <%= link_to h('< @prev_offset, :count => @panel_count}) %> + <%= link_to h('< @prev_offset, :count => @panel_count}) %> <% end %> <% if @next_offset -%> - <%= link_to h('next>>'), comic_story_path(@comic, {:offset => @next_offset, :count => @panel_count}) %> + <%= link_to h('next>>'), scroll_scroll_panel_path(@scroll, {:offset => @next_offset, :count => @panel_count}) %> <% end %> <% end %> -<% if @comic.own? @author -%> -

<%= t('stories.comic.new_panels') -%>

+<% if @scroll.own? @author -%> +

<%= t('scroll_panels.scroll.new_panels') -%>

idcomic_idscroll_id panel_id t author_id
<%= link_to story.id, :action => :browse, :id => story.id %><%= story.comic_id %><%= story.panel_id %><%= story.t %><%= link_to story.author_id, :controller => '/authors', :action => :browse, :id => story.author_id %><%= story.created_at %><%= story.updated_at %><%= link_to scroll_panel.id, :action => :browse, :id => scroll_panel.id %><%= scroll_panel.scroll_id %><%= scroll_panel.panel_id %><%= scroll_panel.t %><%= link_to scroll_panel.author_id, :controller => '/authors', :action => :browse, :id => scroll_panel.author_id %><%= scroll_panel.created_at %><%= scroll_panel.updated_at %>
<% @new_panels.each do |panel| %> - <%= render 'append_panel', :comic => @comic, :panel => panel, :author => @author %> + <%= render 'append_panel', :scroll => @scroll, :panel => panel, :author => @author %> <% end %>
<% end %> diff --git a/app/views/scroll_panels/show.html.erb b/app/views/scroll_panels/show.html.erb index fa0c3a0b..a883094e 100644 --- a/app/views/scroll_panels/show.html.erb +++ b/app/views/scroll_panels/show.html.erb @@ -2,40 +2,40 @@

<%= notice %>

- <%= t_m 'Story.comic_id' -%>: - <%= link_to comic_icon(:object => @story.comic), comic_path(@story.comic) %> - <%= link_to h(@story.comic.title), :controller => 'stories', :action => :comic, :id => @story.comic.id %> + <%= t_m 'ScrollPanel.scroll_id' -%>: + <%= link_to scroll_icon(:object => @scroll_panel.scroll), scroll_path(@scroll_panel.scroll) %> + <%= link_to h(@scroll_panel.scroll.title), :controller => 'scroll_panels', :action => :scroll, :id => @scroll_panel.scroll.id %>

- <%= t_m 'Story.panel_id' -%>: - <%= link_to panel_icon(:object => @story.panel), panel_path(@story.panel) %> + <%= t_m 'ScrollPanel.panel_id' -%>: + <%= link_to panel_icon(:object => @scroll_panel.panel), panel_path(@scroll_panel.panel) %>

- <%= t_m 'Story.t' -%>: - <%= @story.t %> + <%= t_m 'ScrollPanel.t' -%>: + <%= @scroll_panel.t %>

- <%= t_m 'Story.author_id' -%>: - <%= link_to author_icon(:object => @story.author), author_path(@story.author) %> - <%= link_to h(@story.author.name), author_path(@story.author) %> + <%= t_m 'ScrollPanel.author_id' -%>: + <%= link_to author_icon(:object => @scroll_panel.author), author_path(@scroll_panel.author) %> + <%= link_to h(@scroll_panel.author.name), author_path(@scroll_panel.author) %>

- <%= t_m 'Story.created_at' -%>: - <%= l @story.created_at %> + <%= t_m 'ScrollPanel.created_at' -%>: + <%= l @scroll_panel.created_at %>

- <%= t_m 'Story.updated_at' -%>: - <%= l @story.updated_at %> + <%= t_m 'ScrollPanel.updated_at' -%>: + <%= l @scroll_panel.updated_at %>

-<% if @story.own? @author -%> - <%= link_to t('link.edit'), edit_story_path(@story) %> - <%= link_to t('link.destroy'), story_path(@story), :method => :delete %> +<% if @scroll_panel.own? @author -%> + <%= link_to t('link.edit'), edit_scroll_panel_path(@scroll_panel) %> + <%= link_to t('link.destroy'), scroll_panel_path(@scroll_panel), :method => :delete %> <% end %>
-<%= render 'panels/standard', :panel => @story.panel, :author => @author %> +<%= render 'panels/standard', :panel => @scroll_panel.panel, :author => @author %> diff --git a/app/views/scrolls/_form.html.erb b/app/views/scrolls/_form.html.erb index 84b983cc..3ca23fb0 100644 --- a/app/views/scrolls/_form.html.erb +++ b/app/views/scrolls/_form.html.erb @@ -1,5 +1,5 @@ -<%= form_for(@comic) do |f| %> - <%= render 'system/error_explanation', :obj => @comic %> +<%= form_for(@scroll) do |f| %> + <%= render 'system/error_explanation', :obj => @scroll %>
<%= f.label :title %>
@@ -11,7 +11,7 @@
<%= f.label :visible %>
- <%= f.collection_select :visible, t_select_items(MagicNumber['comic_visible_items']), :last, :first, :html => {:selected => @comic.visible} %> + <%= f.collection_select :visible, t_select_items(MagicNumber['scroll_visible_items']), :last, :first, :html => {:selected => @scroll.visible} %>
<%= f.label :author_id %>
diff --git a/app/views/scrolls/_list_item.html.erb b/app/views/scrolls/_list_item.html.erb index 2e9d719a..1b3b40fb 100644 --- a/app/views/scrolls/_list_item.html.erb +++ b/app/views/scrolls/_list_item.html.erb @@ -1,25 +1,25 @@ - <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %> - <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> - (<%= comic.stories.size -%>) + <%= link_to scroll_icon(:object => scroll, :size => 25), scroll_path(scroll) %> + <%= link_to h(truncate(scroll.title, :length => 40)), :controller => 'scroll_panels', :action => :scroll, :id => scroll.id %> + (<%= scroll.scroll_panels.size -%>) - <%= distance_of_time_in_words_to_now comic.updated_at %> + <%= distance_of_time_in_words_to_now scroll.updated_at %> - <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %> - <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %> + <%= link_to author_icon(:object => scroll.author, :size => 25), scroll_path(scroll.author) %> + <%= link_to h(truncate(scroll.author.name, :length => 12)), author_path(scroll.author) %> - <% if comic.own? author %> - <%= link_to t('link.edit'), edit_comic_path(comic) %> - <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %> + <% if scroll.own? author %> + <%= link_to t('link.edit'), edit_scroll_path(scroll) %> + <%= link_to t('link.destroy'), scroll_path(scroll), :method => :delete %> <% end %> - <%= h(truncate(comic.description, :length => 40)) %> + <%= h(truncate(scroll.description, :length => 40)) %> diff --git a/app/views/scrolls/browse.html.erb b/app/views/scrolls/browse.html.erb index c93e6224..62e9f5e1 100644 --- a/app/views/scrolls/browse.html.erb +++ b/app/views/scrolls/browse.html.erb @@ -1,34 +1,34 @@

<%= t '.title' -%>

- <%= t_m 'Comic.id' -%>: - <%= h @comic.id %> + <%= t_m 'Scroll.id' -%>: + <%= h @scroll.id %>

- <%= t_m 'Comic.title' -%>: - <%= h @comic.title %> + <%= t_m 'Scroll.title' -%>: + <%= h @scroll.title %>

- <%= t_m 'Comic.visible' -%>: - <%= @comic.visible %> - <%= t_selected_item('comic_visible_items', @comic.visible) %> + <%= t_m 'Scroll.visible' -%>: + <%= @scroll.visible %> + <%= t_selected_item('scroll_visible_items', @scroll.visible) %>

- <%= t_m 'Comic.author_id' -%>: - <%= @comic.author_id %> - <%= link_to h(@comic.author.name), browse_author_path(@comic.author) %> + <%= t_m 'Scroll.author_id' -%>: + <%= @scroll.author_id %> + <%= link_to h(@scroll.author.name), browse_author_path(@scroll.author) %>

- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> + <%= t_m 'Scroll.created_at' -%>: + <%= l @scroll.created_at %>

- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> + <%= t_m 'Scroll.updated_at' -%>: + <%= l @scroll.updated_at %>

<%= link_to t('link.back'), :action => :list %> diff --git a/app/views/scrolls/edit.js.erb b/app/views/scrolls/edit.js.erb index ab2a7d24..830c4f59 100644 --- a/app/views/scrolls/edit.js.erb +++ b/app/views/scrolls/edit.js.erb @@ -1 +1 @@ -$("#newcomic").html("<%= escape_javascript(render('form')) -%>"); +$("#newscroll").html("<%= escape_javascript(render('form')) -%>"); diff --git a/app/views/scrolls/index.html.erb b/app/views/scrolls/index.html.erb index cef2ab93..df40c94c 100644 --- a/app/views/scrolls/index.html.erb +++ b/app/views/scrolls/index.html.erb @@ -1,9 +1,9 @@

<%= t '.title' -%>

- <% @comics.each do |comic| %> - <%= render 'list_item', :comic => comic, :author => @author %> + <% @scrolls.each do |scroll| %> + <%= render 'list_item', :scroll => scroll, :author => @author %> <% end %>
<%= paginate(@paginate) %> -<%= link_to t('comics.new.title'), new_comic_path %> +<%= link_to t('scrolls.new.title'), new_scroll_path %> diff --git a/app/views/scrolls/list.html.erb b/app/views/scrolls/list.html.erb index 43fdf7e5..557736ea 100644 --- a/app/views/scrolls/list.html.erb +++ b/app/views/scrolls/list.html.erb @@ -2,22 +2,22 @@ - - - - - - + + + + + + -<% @comics.each do |comic| %> +<% @scrolls.each do |scroll| %> - - - - - - + + + + + + <% end %>
<%= t_m 'Comic.id' -%><%= t_m 'Comic.title' -%><%= t_m 'Comic.visible' -%><%= t_m 'Comic.author_id' -%><%= t_m 'Comic.created_at' -%><%= t_m 'Comic.updated_at' -%><%= t_m 'Scroll.id' -%><%= t_m 'Scroll.title' -%><%= t_m 'Scroll.visible' -%><%= t_m 'Scroll.author_id' -%><%= t_m 'Scroll.created_at' -%><%= t_m 'Scroll.updated_at' -%>
<%= link_to comic.id, browse_comic_path(comic) %><%= h(truncate(comic.title, :length => 12)) %><%= comic.visible %><%= link_to comic.author_id, browse_author_path(comic.author) %><%= l comic.created_at %><%= l comic.updated_at %><%= link_to scroll.id, browse_scroll_path(scroll) %><%= h(truncate(scroll.title, :length => 12)) %><%= scroll.visible %><%= link_to scroll.author_id, browse_author_path(scroll.author) %><%= l scroll.created_at %><%= l scroll.updated_at %>
diff --git a/app/views/scrolls/new.html.erb b/app/views/scrolls/new.html.erb index 7142b57d..2b0b2ef6 100644 --- a/app/views/scrolls/new.html.erb +++ b/app/views/scrolls/new.html.erb @@ -2,4 +2,4 @@ <%= render 'form' %> -<%= link_to t('link.back'), comics_path %> +<%= link_to t('link.back'), scrolls_path %> diff --git a/app/views/scrolls/new.js.erb b/app/views/scrolls/new.js.erb index ab2a7d24..830c4f59 100644 --- a/app/views/scrolls/new.js.erb +++ b/app/views/scrolls/new.js.erb @@ -1 +1 @@ -$("#newcomic").html("<%= escape_javascript(render('form')) -%>"); +$("#newscroll").html("<%= escape_javascript(render('form')) -%>"); diff --git a/app/views/scrolls/show.html.erb b/app/views/scrolls/show.html.erb index 81a1bbf3..48b0d62f 100644 --- a/app/views/scrolls/show.html.erb +++ b/app/views/scrolls/show.html.erb @@ -1,35 +1,35 @@ -<% @page_title = t('.title') + ':' + @comic.title %> +<% @page_title = t('.title') + ':' + @scroll.title %>

<%= t('.title') %>

<%= notice %>

- <%= t_m 'Comic.title' -%>: - <%= link_to h(@comic.title), :controller => 'stories', :action => :comic, :id => @comic.id %> + <%= t_m 'Scroll.title' -%>: + <%= link_to h(@scroll.title), :controller => 'scroll_panels', :action => :scroll, :id => @scroll.id %>

- <%= t_m 'Comic.description' -%>: - <%= h(@comic.description) %> + <%= t_m 'Scroll.description' -%>: + <%= h(@scroll.description) %>

- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> + <%= t_m 'Scroll.visible' -%>: + <%= t_selected_item('scroll_visible_items', @scroll.visible) %>

- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> + <%= t_m 'Scroll.author_id' -%>: + <%= link_to h(@scroll.author.name), author_path(@scroll.author) %>

- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> + <%= t_m 'Scroll.created_at' -%>: + <%= l @scroll.created_at %>

- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> + <%= t_m 'Scroll.updated_at' -%>: + <%= l @scroll.updated_at %>

-<%= link_to t('link.edit'), edit_comic_path(@comic) %> +<%= link_to t('link.edit'), edit_scroll_path(@scroll) %> diff --git a/app/views/stories/_append_panel.html.erb b/app/views/stories/_append_panel.html.erb deleted file mode 100644 index 241bcf84..00000000 --- a/app/views/stories/_append_panel.html.erb +++ /dev/null @@ -1,21 +0,0 @@ - - - <%= link_to panel_icon(:object => panel, :size => 25), panel_path(panel) %> - <%= link_to author_icon(:object => panel.author, :size => 17), author_path(panel.author) %> - - - <%= link_to h(truncate(h(panel.caption), :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %> - - - <%= l panel.updated_at %> - - - <% @story = Story.new :comic_id => comic.id, :panel_id => panel.id -%> - <%= form_for(@story) do |f| %> - <%= f.hidden_field :comic_id %> - <%= f.hidden_field :t %> - <%= f.hidden_field :panel_id %> - <%= f.submit t('stories.comic.append') %> - <% end %> - - diff --git a/app/views/stories/_comic_header.html.erb b/app/views/stories/_comic_header.html.erb deleted file mode 100644 index d1eb9e77..00000000 --- a/app/views/stories/_comic_header.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -

- <%= link_to comic_icon, comic_path(comic) %> - <%= link_to h(comic.title), :controller => 'stories', :action => :comic, :id => comic.id %> -

-<% if comic.own? author -%> - <%= form_for(comic) do |f| %> -
- <%= f.label :title %>
- <%= f.text_field :title %> -
-
- <%= f.label :visible %>
- <%= f.collection_select :visible, t_select_items(MagicNumber['comic_visible_items']), :last, :first, :html => {:selected => @comic.visible} %> -
-
- <%= f.submit %> -
- <% end %> -<% else %> -

- <%= t_m 'Comic.visible' -%>: - <%= t_selected_item('comic_visible_items', @comic.visible) %> -

-<% end %> - -

- <%= t_m 'Comic.author_id' -%>: - <%= link_to h(@comic.author.name), author_path(@comic.author) %> -

- -

- <%= t_m 'Comic.created_at' -%>: - <%= l @comic.created_at %> -

- -

- <%= t_m 'Comic.updated_at' -%>: - <%= l @comic.updated_at %> -

- diff --git a/app/views/stories/_footer.html.erb b/app/views/stories/_footer.html.erb deleted file mode 100644 index 56e93674..00000000 --- a/app/views/stories/_footer.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - -
- <% if story.panel -%> - <%= link_to panel_icon(:object => story.panel, :size => 25), panel_path(story.panel) %> - <%= link_to author_icon(:object => story.panel.author, :size => 17), author_path(story.panel.author) %> - <%= distance_of_time_in_words_to_now story.panel.updated_at %> - <% end %> - - <%= link_to story_icon(:object => story, :size => 25), story_path(story) %> - <%= link_to author_icon(:object => story.author, :size => 17), author_path(story.author) %> - <%= l story.updated_at %> - - <% if story.own? author %> - <%= render 'order', :story => story %> - <% else %> - No.<%= story.t %> - <% end %> -
diff --git a/app/views/stories/_form.html.erb b/app/views/stories/_form.html.erb deleted file mode 100644 index 8d705f58..00000000 --- a/app/views/stories/_form.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -<%= form_for(@story) do |f| %> - <%= render 'system/error_explanation', :obj => @story %> - -
- <%= f.label :comic_id %>
- <%= f.number_field :comic_id %> -
-
- <%= f.label :t %>
- <%= f.number_field :t %> -
-
- <%= f.label :panel_id %>
- <%= f.number_field :panel_id %> -
- -
- <%= f.submit %> -
-<% end %> diff --git a/app/views/stories/_licensed_pictures.html.erb b/app/views/stories/_licensed_pictures.html.erb deleted file mode 100644 index 1c10cc72..00000000 --- a/app/views/stories/_licensed_pictures.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -
- <% licensed_pictures.each do |pid, picture| %> - - - - - -
- <%= link_to(tag(:img, picture.tmb_opt_img_tag), picture_path(picture.id)) -%> - - <%= render picture.credit_template, :picture => picture %> -
- <% end %> -
diff --git a/app/views/stories/_list_item.html.erb b/app/views/stories/_list_item.html.erb deleted file mode 100644 index 1b18f0fc..00000000 --- a/app/views/stories/_list_item.html.erb +++ /dev/null @@ -1,28 +0,0 @@ - - - <%= link_to comic_icon(:object => story.comic, :size => 25), comic_path(story.comic) %> - - - <%= link_to h(story.comic.title), :controller => 'stories', :action => :comic, :id => story.comic.id %> - - - <%= link_to author_icon(:object => story.comic.author, :size => 17), author_path(story.comic.author) %> - - - <%= link_to story_icon(:object => story, :size => 25), story_path(story) %> - - - <%= link_to author_icon(:object => story.author, :size => 17), author_path(story.author) %> - - - No.<%= story.t %> - - - <%= l story.updated_at %> - - - <% if story.panel %> - <%= h story.panel.caption %> - <% end %> - - diff --git a/app/views/stories/_order.html.erb b/app/views/stories/_order.html.erb deleted file mode 100644 index e0ceadfe..00000000 --- a/app/views/stories/_order.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<%= form_for(story) do |f| %> - - - - - -
- No. - <%= f.number_field :t, :size => 3 %> - <%= f.hidden_field :panel_id %> - <%= f.hidden_field :comic_id %> - - <%= f.submit t 'stories.move' %> -
-<% end %> diff --git a/app/views/stories/browse.html.erb b/app/views/stories/browse.html.erb deleted file mode 100644 index 24a7a6ca..00000000 --- a/app/views/stories/browse.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -

<%= notice %>

- -

- comic_id: - <%= @story.comic_id %> -

- -

- panel_id: - <%= @story.panel_id %> -

- -

- t: - <%= @story.t %> -

- -

- author_id: - <%= @story.author_id %> -

- -

- updated_at: - <%= @story.updated_at %> -

- -<%= link_to 'Back', :action => :list %> diff --git a/app/views/stories/comic.html.erb b/app/views/stories/comic.html.erb deleted file mode 100644 index 631f6f03..00000000 --- a/app/views/stories/comic.html.erb +++ /dev/null @@ -1,33 +0,0 @@ -<% @page_title = @comic.title %> -

<%= t '.title' -%>

-

<%= notice %>

-<%= render 'comic_header', :comic => @comic, :author => @author %> - -<% if @stories.empty? -%> -

<%= t('stories.comic.empty') %>

-<% else %> - <% @stories.each do |story| %> - <% if story.panel -%> - <%= render 'panels/body', :panel => story.panel, :author => @author, :spot => nil %> - <% end %> - <%= render 'footer', :story => story, :author => @author %> - <% end %> - <%= render 'licensed_pictures', :licensed_pictures => Story.licensed_pictures(@stories) %> - - <% if @prev_offset -%> - <%= link_to h('< @prev_offset, :count => @panel_count}) %> - <% end %> - - <% if @next_offset -%> - <%= link_to h('next>>'), comic_story_path(@comic, {:offset => @next_offset, :count => @panel_count}) %> - <% end %> - -<% end %> -<% if @comic.own? @author -%> -

<%= t('stories.comic.new_panels') -%>

- - <% @new_panels.each do |panel| %> - <%= render 'append_panel', :comic => @comic, :panel => panel, :author => @author %> - <% end %> -
-<% end %> diff --git a/app/views/stories/edit.html.erb b/app/views/stories/edit.html.erb deleted file mode 100644 index cee9463d..00000000 --- a/app/views/stories/edit.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

<%= t('.title') %>

-

<%= notice %>

- -<%= render 'form' %> -<%= button_to 'Destroy', @story.panel, confirm: 'Are you sure?', method: :delete %> diff --git a/app/views/stories/edit.js.erb b/app/views/stories/edit.js.erb deleted file mode 100644 index 29c687f7..00000000 --- a/app/views/stories/edit.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#story-update-<%= @story.id -%>").html("<%= escape_javascript(render('editform')) -%>"); diff --git a/app/views/stories/index.html.erb b/app/views/stories/index.html.erb deleted file mode 100644 index 7b61ab84..00000000 --- a/app/views/stories/index.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

<%= t '.title' -%>

- - <% @stories.each do |story| %> - <%= render 'list_item', :story => story, :author => @author %> - <% end %> -
-<%= paginate(@paginate) %> -<%= link_to t('stories.new.title'), new_story_path %> diff --git a/app/views/stories/list.html.erb b/app/views/stories/list.html.erb deleted file mode 100644 index 6fae81c5..00000000 --- a/app/views/stories/list.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -

Listing Story

- - - - - - - - - - - - - -<% @stories.each do |story| %> - - - - - - - - - - -<% end %> -
idcomic_idpanel_idtauthor_idcreated_atupdated_at
<%= link_to story.id, :action => :browse, :id => story.id %><%= story.comic_id %><%= story.panel_id %><%= story.t %><%= link_to story.author_id, :controller => '/authors', :action => :browse, :id => story.author_id %><%= story.created_at %><%= story.updated_at %> -
- diff --git a/app/views/stories/new.html.erb b/app/views/stories/new.html.erb deleted file mode 100644 index f33a2f89..00000000 --- a/app/views/stories/new.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -

<%= t('.title') %>

- -<%= render 'form' %> diff --git a/app/views/stories/show.html.erb b/app/views/stories/show.html.erb deleted file mode 100644 index fa0c3a0b..00000000 --- a/app/views/stories/show.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -

<%= t('.title') %>

-

<%= notice %>

- -

- <%= t_m 'Story.comic_id' -%>: - <%= link_to comic_icon(:object => @story.comic), comic_path(@story.comic) %> - <%= link_to h(@story.comic.title), :controller => 'stories', :action => :comic, :id => @story.comic.id %> -

- -

- <%= t_m 'Story.panel_id' -%>: - <%= link_to panel_icon(:object => @story.panel), panel_path(@story.panel) %> -

- -

- <%= t_m 'Story.t' -%>: - <%= @story.t %> -

- -

- <%= t_m 'Story.author_id' -%>: - <%= link_to author_icon(:object => @story.author), author_path(@story.author) %> - <%= link_to h(@story.author.name), author_path(@story.author) %> -

- -

- <%= t_m 'Story.created_at' -%>: - <%= l @story.created_at %> -

- -

- <%= t_m 'Story.updated_at' -%>: - <%= l @story.updated_at %> -

-<% if @story.own? @author -%> - <%= link_to t('link.edit'), edit_story_path(@story) %> - <%= link_to t('link.destroy'), story_path(@story), :method => :delete %> -<% end %> - -
-<%= render 'panels/standard', :panel => @story.panel, :author => @author %> diff --git a/app/views/system/browse.html.erb b/app/views/system/browse.html.erb index f336f5af..671614fb 100644 --- a/app/views/system/browse.html.erb +++ b/app/views/system/browse.html.erb @@ -5,7 +5,7 @@ @@ -15,7 +15,7 @@ diff --git a/app/views/top/index.html.erb b/app/views/top/index.html.erb index d6f27d6c..2d9add6b 100644 --- a/app/views/top/index.html.erb +++ b/app/views/top/index.html.erb @@ -5,10 +5,10 @@
- <%= link_to 'comics', :controller => 'comics', :action => :list %> + <%= link_to 'scrolls', :controller => 'scrolls', :action => :list %>
- <%= link_to 'stories', :controller => 'stories', :action => :list %> + <%= link_to 'scroll_panels', :controller => 'scroll_panels', :action => :list %>
- <%= link_to t_m('Comic'), main_app.comics_path %> + <%= link_to t_m('Scroll'), main_app.scrolls_path %> - <%= link_to t_m('Story'), main_app.stories_path %> + <%= link_to t_m('ScrollPanel'), main_app.scroll_panels_path %> <%= link_to t_m('Panel'), main_app.panels_path %> diff --git a/config/locales/pettanr.ja.yml b/config/locales/pettanr.ja.yml index 42eef606..ad5340d4 100644 --- a/config/locales/pettanr.ja.yml +++ b/config/locales/pettanr.ja.yml @@ -18,8 +18,8 @@ ja: user: ユーザ admin: 管理者 demand_user: 借手 - comic: コミック - story: ストーリー + scroll: コミック + scroll_panel: ストーリー panel: コマ panel_picture: コマ絵 speech_balloon: フキダシ @@ -67,15 +67,15 @@ ja: current_password: 現在のパスワード remember_me: 次回から自動でログイン authentication_token: 認証トークン - comic: + scroll: title: タイトル description: あらすじ visible: 公開 author_id: 作家 created_at: 更新 updated_at: 作成 - story: - comic_id: コミック + scroll_panel: + scroll_id: コミック panel_id: コマ author_id: 編集者 t: No. @@ -314,7 +314,7 @@ ja: picture_io: error: 画像保管庫との手続きで異常が発生しました。 select_items: - comic: + scroll: visible: private: 非公開 public: 公開 @@ -405,15 +405,15 @@ ja: home: index: title: ホーム - updated_comic: 最近更新した漫画 + updated_scroll: 最近更新した漫画 catch: つかんでいるコマ used_element: 最近使った部品 updated_picture: 最近更新した画像 artist: 絵師 not_artist: 画像を公開するには絵師登録 - comics: + scrolls: title: 最近更新したコミック - stories: + scroll_panels: title: 最近更新したストーリー panels: title: 最近更新したコマ @@ -458,7 +458,7 @@ ja: human_resources: 人物から system_resources: システムリソースから return: シンプル版に戻る - comics: + scrolls: index: title: コミック一覧 new: 新刊 @@ -478,7 +478,7 @@ ja: title: コミック 生一覧 browse: title: コミック 生単票 - stories: + scroll_panels: index: title: ストーリー一覧 show: @@ -493,7 +493,7 @@ ja: title: 並び替え destroy: title: ストーリー削除 - comic: + scroll: title: コミックを読む empty: ストーリーはありません append: このコマを追加する @@ -509,8 +509,8 @@ ja: show: title: コマ詳細 append: このコミックに追加する - new_comics: 最近作成したコミック - fresh_comics: 最近更新したコミック + new_scrolls: 最近作成したコミック + fresh_scrolls: 最近更新したコミック copy: コマをコピーしたい inspire: インスパイヤ new: @@ -755,16 +755,16 @@ ja: title: 作家一覧 show: title: 作家詳細 - to_comics: 最近更新したコミック - to_stories: 最近更新したストーリー + to_scrolls: 最近更新したコミック + to_scroll_panels: 最近更新したストーリー to_panels: 最近更新したコマ to_panel_pictures: 最近コマで使ったコマ絵 to_speech_balloons: 最近更新したフキダシ to_ground_pictures: 最近コマで使った絵地 to_ground_colors: 最近コマで使った色地 - comics: + scrolls: title: 最近更新したコミック - stories: + scroll_panels: title: 最近更新したストーリー panels: title: 最近更新したコマ @@ -992,7 +992,7 @@ ja: tab: creator: home: 作る・見せる - comic: コミック + scroll: コミック panel: コマ original_picture: 原画 resource_picture: 素材 diff --git a/config/magic_number.yml b/config/magic_number.yml index e9037f67..a0619918 100644 --- a/config/magic_number.yml +++ b/config/magic_number.yml @@ -6,9 +6,9 @@ provider_status_status_items: [['select_items.provider_status.status.waiting', 0], ['select_items.provider_status.status.receiving', 1]] demander_status_status_items: [['select_items.demander_status.status.waiting', 0], ['select_items.demander_status.status.rejected', 1], ['select_items.demander_status.status.requesting', 2], ['select_items.demander_status.status.approved', 3]] - comic_visible_items: [ - ['select_items.comic.visible.private', 0], - ['select_items.comic.visible.public', 1] + scroll_visible_items: [ + ['select_items.scroll.visible.private', 0], + ['select_items.scroll.visible.public', 1] ] panel_visible_items: [ ['select_items.panel.visible.private', 0], diff --git a/config/routes.rb b/config/routes.rb index ec569e81..6bfe6691 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,42 +55,6 @@ Pettanr::Application.routes.draw do get :resource_pictures end end - resources :comics do - new do - get :new - end - collection do - get :index - get :show - get :count - post :create - get :list - end - member do - get :edit - put :update - delete :destroy - get :browse - end - end - resources :stories do - new do - get :new - end - collection do - get :index - get :show - post :create - get :list - end - member do - get :edit - get :comic - put :update - delete :destroy - get :browse - end - end resources :scrolls do new do get :new diff --git a/db/migrate/20130911043458_copy_to_scroll.rb b/db/migrate/20130911043458_copy_to_scroll.rb new file mode 100644 index 00000000..fe977c8f --- /dev/null +++ b/db/migrate/20130911043458_copy_to_scroll.rb @@ -0,0 +1,20 @@ +require Rails.root + 'config/environment' +class CopyToScroll < ActiveRecord::Migration + def up + ::Comic.find(:all).each do |i| + attr = i.attributes + attr.delete 'id' + ::Scroll.create! attr + end + ::Story.find(:all).each do |i| + attr = i.attributes + attr.delete 'id' + attr['scroll_id'] = attr['comic_id'] + attr.delete 'comic_id' + ::ScrollPanel.create! attr + end + end + + def down + end +end diff --git a/spec/controllers/authors_controller_spec.rb b/spec/controllers/authors_controller_spec.rb index d058db12..53728ca2 100644 --- a/spec/controllers/authors_controller_spec.rb +++ b/spec/controllers/authors_controller_spec.rb @@ -249,80 +249,80 @@ if MagicNumber['run_mode'] == 1 @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id Author.stub(:show).and_return(@other_author) - Comic.stub(:himlist).and_return([@comic, @comic, @comic]) + Scroll.stub(:himlist).and_return([@scroll, @scroll, @scroll]) sign_in @user end context 'パラメータpageについて' do it '@pageに値が入る' do - get :comics, :id => @other_author.id, :page => 5 + get :scrolls, :id => @other_author.id, :page => 5 assigns(:page).should eq 5 end it '省略されると@pageに1値が入る' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id assigns(:page).should eq 1 end it '与えられたpage_sizeがセットされている' do - get :comics, :id => @other_author.id, :page_size => 15 + get :scrolls, :id => @other_author.id, :page_size => 15 assigns(:page_size).should eq 15 end it '省略されると@page_sizeにデフォルト値が入る' do - get :comics, :id => @other_author.id - assigns(:page_size).should eq Author.default_comic_page_size + get :scrolls, :id => @other_author.id + assigns(:page_size).should eq Author.default_scroll_page_size end it '最大を超えると@page_sizeにデフォルト最大値が入る' do - get :comics, :id => @other_author.id, :page_size => 1500 - assigns(:page_size).should eq Author.comic_max_page_size + get :scrolls, :id => @other_author.id, :page_size => 1500 + assigns(:page_size).should eq Author.scroll_max_page_size end it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do - get :comics, :id => @other_author.id, :page_size => 0 - assigns(:page_size).should eq Author.default_comic_page_size + get :scrolls, :id => @other_author.id, :page_size => 0 + assigns(:page_size).should eq Author.default_scroll_page_size end end context 'つつがなく終わるとき' do it 'ステータスコード200 OKを返す' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end it '作家モデルに単体取得を問い合わせている' do Author.should_receive(:show).exactly(1) - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id end it 'コミックモデルに一覧を問い合わせている' do - Comic.should_receive(:himlist).exactly(1) - get :comics, :id => @other_author.id + Scroll.should_receive(:himlist).exactly(1) + get :scrolls, :id => @other_author.id end - it '@comicsにリストを取得している' do - get :comics, :id => @other_author.id - assigns(:comics).should have_at_least(3).items + it '@scrollsにリストを取得している' do + get :scrolls, :id => @other_author.id + assigns(:scrolls).should have_at_least(3).items end context 'html形式' do it '@paginateにページ制御を取得している' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true end - it 'comicsテンプレートを描画する' do - get :comics, :id => @other_author.id - response.should render_template("comics") + it 'scrollsテンプレートを描画する' do + get :scrolls, :id => @other_author.id + response.should render_template("scrolls") end end context 'json形式' do it 'jsonデータを返す' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end it 'コミックモデルにjson一覧出力オプションを問い合わせている' do - Comic.should_receive(:list_json_opt).exactly(1) - get :comics, :id => @other_author.id, :format => :json + Scroll.should_receive(:list_json_opt).exactly(1) + get :scrolls, :id => @other_author.id, :format => :json end it 'データがリスト構造になっている' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json json = JSON.parse response.body json.should have_at_least(3).items end it 'リストの先頭くらいはコミックっぽいものであって欲しい' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json json = JSON.parse response.body json.first.has_key?("title").should be_true json.first.has_key?("visible").should be_true @@ -335,21 +335,21 @@ if MagicNumber['run_mode'] == 1 end context 'html形式' do it 'ステータスコード302 Foundを返す' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.status.should eq 302 end it 'サインインページへ遷移する' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should redirect_to '/users/sign_in' end end context 'json形式' do it 'ステータスコード401 Unauthorizedを返す' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json response.status.should eq 401 end it '応答メッセージにUnauthorizedを返す' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json response.message.should match(/Unauthorized/) end end @@ -360,7 +360,7 @@ if MagicNumber['run_mode'] == 1 sign_in @admin end it 'ステータスコード200 OKを返す' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end end @@ -369,7 +369,7 @@ if MagicNumber['run_mode'] == 1 @author.destroy end it 'ステータスコード200 OKを返す' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end end @@ -380,85 +380,85 @@ if MagicNumber['run_mode'] == 1 @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_user.author.id + @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_user.author.id Author.stub(:show).and_return(@other_author) - Story.stub(:himlist).and_return([@story, @story, @story]) + ScrollPanel.stub(:himlist).and_return([@scroll_panel, @scroll_panel, @scroll_panel]) sign_in @user end context 'パラメータpageについて' do it '@pageに値が入る' do - get :stories, :id => @other_author.id, :page => 5 + get :scroll_panels, :id => @other_author.id, :page => 5 assigns(:page).should eq 5 end it '省略されると@pageに1値が入る' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id assigns(:page).should eq 1 end it '与えられたpage_sizeがセットされている' do - get :stories, :id => @other_author.id, :page_size => 15 + get :scroll_panels, :id => @other_author.id, :page_size => 15 assigns(:page_size).should eq 15 end it '省略されると@page_sizeにデフォルト値が入る' do - get :stories, :id => @other_author.id - assigns(:page_size).should eq Author.default_story_page_size + get :scroll_panels, :id => @other_author.id + assigns(:page_size).should eq Author.default_scroll_panel_page_size end it '最大を超えると@page_sizeにデフォルト最大値が入る' do - get :stories, :id => @other_author.id, :page_size => 1500 - assigns(:page_size).should eq Author.story_max_page_size + get :scroll_panels, :id => @other_author.id, :page_size => 1500 + assigns(:page_size).should eq Author.scroll_panel_max_page_size end it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do - get :stories, :id => @other_author.id, :page_size => 0 - assigns(:page_size).should eq Author.default_story_page_size + get :scroll_panels, :id => @other_author.id, :page_size => 0 + assigns(:page_size).should eq Author.default_scroll_panel_page_size end end context 'つつがなく終わるとき' do it 'ステータスコード200 OKを返す' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end it '作家モデルに単体取得を問い合わせている' do Author.should_receive(:show).exactly(1) - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id end it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do - Story.should_receive(:himlist).exactly(1) - get :stories, :id => @other_author.id + ScrollPanel.should_receive(:himlist).exactly(1) + get :scroll_panels, :id => @other_author.id end - it '@storiesにリストを取得している' do - get :stories, :id => @other_author.id - assigns(:stories).should have_at_least(3).items + it '@scroll_panelsにリストを取得している' do + get :scroll_panels, :id => @other_author.id + assigns(:scroll_panels).should have_at_least(3).items end context 'html形式' do it '@paginateにページ制御を取得している' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true end - it 'storiesテンプレートを描画する' do - get :stories, :id => @other_author.id - response.should render_template("stories") + it 'scroll_panelsテンプレートを描画する' do + get :scroll_panels, :id => @other_author.id + response.should render_template("scroll_panels") end end context 'json形式' do it 'jsonデータを返す' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do - Story.should_receive(:list_json_opt).exactly(1) - get :stories, :id => @other_author.id, :format => :json + ScrollPanel.should_receive(:list_json_opt).exactly(1) + get :scroll_panels, :id => @other_author.id, :format => :json end it 'データがリスト構造になっている' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json json = JSON.parse response.body json.should have_at_least(3).items end it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json json = JSON.parse response.body json.first.has_key?("panel_id").should be_true - json.first.has_key?("comic_id").should be_true + json.first.has_key?("scroll_id").should be_true json.first.has_key?("t").should be_true end end @@ -469,21 +469,21 @@ if MagicNumber['run_mode'] == 1 end context 'html形式' do it 'ステータスコード302 Foundを返す' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.status.should eq 302 end it 'サインインページへ遷移する' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should redirect_to '/users/sign_in' end end context 'json形式' do it 'ステータスコード401 Unauthorizedを返す' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json response.status.should eq 401 end it '応答メッセージにUnauthorizedを返す' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json response.message.should match(/Unauthorized/) end end @@ -494,7 +494,7 @@ if MagicNumber['run_mode'] == 1 sign_in @admin end it 'ステータスコード200 OKを返す' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end end @@ -503,7 +503,7 @@ if MagicNumber['run_mode'] == 1 @author.destroy end it 'ステータスコード200 OKを返す' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end end @@ -1780,24 +1780,24 @@ else @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id - Comic.stub(:mylist).and_return([@comic, @comic, @comic]) + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id + Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll]) sign_in @user end context 'つつがなく終わるとき' do it 'ステータスコード200 OKを返す' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end context 'html形式' do - it 'comicテンプレートを描画する' do - get :comics, :id => @other_author.id - response.should render_template("comic") + it 'scrollテンプレートを描画する' do + get :scrolls, :id => @other_author.id + response.should render_template("scroll") end end context 'json形式' do it 'jsonデータを返す' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end @@ -1807,18 +1807,18 @@ else sign_out @user end it 'ステータスコード200 OKを返す' do - get :comics, :id => @other_author.id + get :scrolls, :id => @other_author.id response.should be_success end context 'html形式' do - it 'comicsテンプレートを描画する' do - get :comics, :id => @other_author.id - response.should render_template("comics") + it 'scrollsテンプレートを描画する' do + get :scrolls, :id => @other_author.id + response.should render_template("scrolls") end end context 'json形式' do it 'jsonデータを返す' do - get :comics, :id => @other_author.id, :format => :json + get :scrolls, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end @@ -1830,26 +1830,26 @@ else @other_user = FactoryGirl.create( :user_yas) @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id + @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id @panel = FactoryGirl.create :panel, :author_id => @other_author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_author.id - Story.stub(:mylist).and_return([@story, @story, @story]) + @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_author.id + ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel]) sign_in @user end context 'つつがなく終わるとき' do it 'ステータスコード200 OKを返す' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end context 'html形式' do - it 'storiesテンプレートを描画する' do - get :stories, :id => @other_author.id - response.should render_template("stories") + it 'scroll_panelsテンプレートを描画する' do + get :scroll_panels, :id => @other_author.id + response.should render_template("scroll_panels") end end context 'json形式' do it 'jsonデータを返す' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end @@ -1859,18 +1859,18 @@ else sign_out @user end it 'ステータスコード200 OKを返す' do - get :stories, :id => @other_author.id + get :scroll_panels, :id => @other_author.id response.should be_success end context 'html形式' do - it 'storiesテンプレートを描画する' do - get :stories, :id => @other_author.id - response.should render_template("stories") + it 'scroll_panelsテンプレートを描画する' do + get :scroll_panels, :id => @other_author.id + response.should render_template("scroll_panels") end end context 'json形式' do it 'jsonデータを返す' do - get :stories, :id => @other_author.id, :format => :json + get :scroll_panels, :id => @other_author.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end end diff --git a/spec/controllers/comics_controller_spec.rb b/spec/controllers/comics_controller_spec.rb deleted file mode 100644 index 449cbcbe..00000000 --- a/spec/controllers/comics_controller_spec.rb +++ /dev/null @@ -1,1301 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#コミック -describe ComicsController do - before do - @admin =FactoryGirl.create :admin - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @user = FactoryGirl.create :user_yas - @author = FactoryGirl.create :author, :user_id => @user.id - end - -if MagicNumber['run_mode'] == 1 - describe '一覧表示に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - Comic.stub(:list).and_return([@comic, @comic, @comic]) - sign_in @user - end - context '事前チェックする' do - it '与えられたpageがセットされている' do - get :index, :page => 5 - assigns(:page).should eq 5 - end - it '省略されると@pageに1値が入る' do - get :index - assigns(:page).should eq 1 - end - it '与えられたpage_sizeがセットされている' do - get :index, :page_size => 15 - assigns(:page_size).should eq 15 - end - it '省略されると@page_sizeにデフォルト値が入る' do - get :index - assigns(:page_size).should eq Comic.default_page_size - end - it '最大を超えると@page_sizeにデフォルト最大値が入る' do - get :index, :page_size => 1500 - assigns(:page_size).should eq Comic.max_page_size - end - it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do - get :index, :page_size => 0 - assigns(:page_size).should eq Comic.default_page_size - end - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - it 'コミックモデルに一覧を問い合わせている' do - Comic.should_receive(:list).exactly(1) - get :index - end - it '@comicsにリストを取得している' do - get :index - assigns(:comics).should have_at_least(3).items - end - context 'html形式' do - it '@paginateにページ制御を取得している' do - get :index - assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true - end - it 'indexテンプレートを描画する' do - get :index - response.should render_template("index") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'コミックモデルにjson一覧出力オプションを問い合わせている' do - Comic.should_receive(:list_json_opt).exactly(1) - get :index, :format => :json - end - it 'データがリスト構造になっている' do - get :index, :format => :json - json = JSON.parse response.body - json.should have_at_least(3).items - end - it 'リストの先頭くらいはコミックっぽいものであって欲しい' do - get :index, :format => :json - json = JSON.parse response.body - json.first.has_key?("title").should be_true - json.first.has_key?("visible").should be_true - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :index - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :index - response.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :index, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :index, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - end - end - end - - describe '単体表示に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id, :title => 'normal' - Comic.stub(:show).and_return(@comic) - sign_in @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @comic.id - response.should be_success - end - it 'コミックモデルに単体取得を問い合わせている' do - Comic.should_receive(:show).exactly(1) - get :show - end - it '@comicにアレを取得している' do - get :show, :id => @comic.id - assigns(:comic).id.should eq(@comic.id) - end - context 'html形式' do - it 'showテンプレートを描画する' do - get :show, :id => @comic.id - response.should render_template("show") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :show, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'コミックモデルにjson単体出力オプションを問い合わせている' do - Comic.should_receive(:show_json_opt).exactly(1) - get :show, :id => @comic.id, :format => :json - end - it 'データがアレになっている' do - get :show, :id => @comic.id, :format => :json - json = JSON.parse response.body - json["title"].should match(/normal/) - json["visible"].should_not be_nil - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :show, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :show, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :show, :id => @comic.id, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :show, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - it 'ステータスコード200 OKを返す' do - get :show, :id => @comic.id - response.should be_success - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @comic.id - response.should be_success - end - end - end -=begin - context '対象コミックがないとき' do - context 'html形式' do - it '例外404 not_foundを返す' do - lambda{ - get :show, :id => 0 - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - context 'json形式' do - it '例外404 not_foundを返す' do - lambda{ - get :show, :id => 0, :format => :json - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - context '非公開コミックを見ようとしたとき' do - context 'html形式' do - it '例外403 forbiddenを返す' do - Comic.any_instance.stub(:visible?).with(any_args()).and_return(false) - hidden = FactoryGirl.create :hidden_comic, :author_id => @author.id - lambda{ - get :show, :id => hidden - }.should raise_error(ActiveRecord::Forbidden) - end - end - context 'json形式' do - it '例外403 forbiddenを返す' do - Comic.any_instance.stub(:visible?).with(any_args()).and_return(false) - hidden = FactoryGirl.create :hidden_comic, :author_id => @author.id - lambda{ - get :show, :id => hidden, :format => :json - }.should raise_error(ActiveRecord::Forbidden) - end - end - end -=end - end - describe 'コミック数取得に於いて' do - before do - Comic.should_receive(:visible_count).and_return(3) -# sign_in @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :count, :format => :json - response.should be_success - end - context 'json形式' do - it 'jsonデータを返す' do - get :count, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'データがHash構造になっていてコミック数が1である' do - get :count, :format => :json - json = JSON.parse response.body - json["count"].should == 3 - end - end - end - end - - describe '新規作成フォーム表示に於いて' do - before do - sign_in @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :new - response.should be_success - end - it '@comicに新規データを用意している' do - get :new - assigns(:comic).should be_a_new(Comic) - end - it 'コミックモデルにデフォルト値補充を依頼している' do - Comic.any_instance.should_receive(:supply_default).exactly(1) - get :new - end - context 'html形式' do - it 'newテンプレートを描画する' do - get :new - response.should render_template("new") - end - end - context 'js形式' do - it 'new.jsテンプレートを描画する' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'コミックモデルにjson単体出力オプションを問い合わせている' do - Comic.should_receive(:show_json_opt).exactly(1) - get :new, :format => :json - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :new, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :new, :format => :js - response.message.should match(/Unauthorized/) - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :new, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new, @attr - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - get :new, @attr - response.body.should redirect_to new_author_path - end - end - end - end - - describe '新規作成に於いて' do - before do - sign_in @user - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'normal') - end - context '事前チェックしておく' do - it 'コミックモデルにデフォルト値補充を依頼している' do - Comic.any_instance.should_receive(:supply_default).exactly(1) - post :create, :comic => @attr - end - it 'コミックモデルにカラム値復元を依頼している' do - Comic.any_instance.should_receive(:attributes=).exactly(1) - post :create, :comic => @attr - end - it 'コミックモデルに上書き補充を依頼している' do - Comic.any_instance.should_receive(:overwrite).exactly(1) - post :create, :comic => @attr - end - it 'モデルに保存依頼する' do - Comic.any_instance.should_receive(:save).exactly(1) - post :create, :comic => @attr - end - end - context 'つつがなく終わるとき' do - it "@comicに作成されたコミックを保持していて、それがDBにある" do - post :create, :comic => @attr - assigns(:comic).should be_a(Comic) - assigns(:comic).should be_persisted - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.status.should eq 302 - end - it '作成されたコミックの表示ページへ遷移する' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.should redirect_to(Comic.last) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr, :format => :json - response.should be_success - end - it '作成されたコミックをjsonデータで返す' do - post :create, :comic => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'データがアレになっている' do - post :create, :comic => @attr, :format => :json - json = JSON.parse response.body - json["title"].should match(/normal/) - json["visible"].should_not be_nil - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :comic => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - post :create, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - post :create, :comic => @attr, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - post :create, :comic => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :comic => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - post :create, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :comic => @attr - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - post :create, :comic => @attr - response.body.should redirect_to new_author_path - end - end - end - context '検証、保存に失敗した' do - before do - Comic.any_instance.stub(:save).and_return(false) - end - it "未保存のコミックを保持している" do - post :create, :comic => @attr - assigns(:comic).should be_a_new(Comic) - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - post :create, :comic => @attr - response.status.should eq 200 - end - it '新規ページを描画する' do - post :create, :comic => @attr - response.should render_template("new") - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - post :create, :comic => @attr, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - post :create, :comic => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe '編集フォーム表示に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - sign_in @user - Comic.stub(:edit).and_return(@comic) - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @comic.id - response.should be_success - end - it 'コミックモデルに編集取得を問い合わせている' do - Comic.should_receive(:edit).exactly(1) - get :edit, :id => @comic.id - end - it '@comicにデータを用意している' do - get :edit, :id => @comic.id - assigns(:comic).should eq @comic - end - context 'html形式' do - it 'editテンプレートを描画する' do - get :edit, :id => @comic.id - response.should render_template("edit") - end - end - context 'js形式' do - it 'edit.jsテンプレートを描画する' do - get :edit, :id => @comic.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :edit, :id => @comic.id, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :edit, :id => @comic.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - get :edit, :id => @comic.id - response.body.should redirect_to new_author_path - end - end - end - end - - describe '更新に於いて' do - before do - @comic = FactoryGirl.create :comic, :author => @author - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'updated title', :visible => 0) - sign_in @user - end - context '事前チェックしておく' do - it 'コミックモデルに編集取得を問い合わせている' do - Comic.stub(:edit).with(any_args()).and_return @comic - Comic.should_receive(:edit).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it 'コミックモデルにカラム値復元を依頼している' do - Comic.any_instance.should_receive(:attributes=).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it 'コミックモデルに上書き補充を依頼している' do - Comic.any_instance.should_receive(:overwrite).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it 'モデルに更新を依頼する' do - Comic.any_instance.stub(:save).with(any_args).and_return true - Comic.any_instance.should_receive(:save).exactly(1) - put :update, :id => @comic.id, :comic => @attr - end - it '@comicにアレを取得している' do - put :update, :id => @comic.id, :comic => @attr - assigns(:comic).id.should eq(@comic.id) - end - end - context 'つつがなく終わるとき' do - it '更新される' do - put :update, :id => @comic.id, :comic => @attr - Comic.find(@comic.id).visible.should eq 0 - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it '更新されたコミックの表示ページへ遷移する' do - put :update, :id => @comic.id, :comic => @attr - response.should redirect_to(@comic) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.should be_success - end - it 'ページ本体は特に返さない' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.body.should match /./ - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to new_author_path - end - end - end - context '検証、保存に失敗したとき' do - before do - Comic.any_instance.stub(:save).and_return(false) - end - context 'html形式' do - it 'ステータスコード200 Okを返す' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 200 - end - it '編集ページを描画する' do - put :update, :id => @comic.id, :comic => @attr - response.should render_template("edit") - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - Comic.any_instance.stub(:save).and_return(false) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe '削除に於いて' do - before do - @comic = FactoryGirl.create :comic, :author => @author - sign_in @user - end - context '事前チェックしておく' do - before do - Comic.stub(:edit).with(any_args()).and_return @comic - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'コミックモデルに編集取得を問い合わせている' do - Comic.should_receive(:edit).exactly(1) - delete :destroy, :id => @comic.id - end - it 'モデルに削除を依頼する' do - Comic.any_instance.should_receive(:destroy_with_story).exactly(1) - delete :destroy, :id => @comic.id - end - it '@comicにアレを取得している' do - delete :destroy, :id => @comic.id - assigns(:comic).id.should eq(@comic.id) - end - end - context 'つつがなく終わるとき' do - it '削除される' do - lambda { - delete :destroy, :id => @comic.id - }.should change Comic, :count - end - context 'html形式' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'マイコミックの一覧ページへ遷移する' do - delete :destroy, :id => @comic.id - response.should redirect_to('/home/comics') - end - end - context 'json形式' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ステータスコード200 OKを返す' do - delete :destroy, :id => @comic.id, :format => :json - response.should be_success - end - it 'ページ本体は特に返さない' do - delete :destroy, :id => @comic.id, :format => :json - response.body.should match /./ - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - delete :destroy, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - delete :destroy, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - delete :destroy, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - delete :destroy, :id => @comic.id - response.body.should redirect_to new_author_path - end - end - end - context '削除に失敗したとき' do - before do - Comic.any_instance.stub(:destroy_with_story).and_return(false) - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'そのコミックの詳細ページへ遷移する' do - delete :destroy, :id => @comic.id - response.should redirect_to(comic_path(@comic)) - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - delete :destroy, :id => @comic.id, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - delete :destroy, :id => @comic.id, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - -else - describe '一覧表示に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - Comic.stub(:list).and_return([@comic, @comic, @comic]) - sign_in @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - context 'html形式' do - it 'indexテンプレートを描画する' do - get :index - response.should render_template("index") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - context 'html形式' do - it 'indexテンプレートを描画する' do - get :index - response.should render_template("index") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe '単体表示に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id, :title => 'normal' - Comic.stub(:show).and_return(@comic) - sign_in @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @comic.id - response.should be_success - end - context 'html形式' do - it 'showテンプレートを描画する' do - get :show, :id => @comic.id - response.should render_template("show") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :show, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - it 'ステータスコード200 OKを返す' do - get :show, :id => @comic.id - response.should be_success - end - context 'html形式' do - it 'showテンプレートを描画する' do - get :show, :id => @comic.id - response.should render_template("show") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :show, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - describe 'コミック数取得に於いて' do - before do - Comic.should_receive(:visible_count).and_return(3) - sign_out @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :count, :format => :json - response.should be_success - end - context 'json形式' do - it 'jsonデータを返す' do - get :count, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe '新規作成フォーム表示に於いて' do - before do - sign_in @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :new - response.should be_success - end - context 'html形式' do - it 'newテンプレートを描画する' do - get :new - response.should render_template("new") - end - end - context 'js形式' do - it 'new.jsテンプレートを描画する' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :new, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :new, :format => :js - response.message.should match(/Unauthorized/) - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :new, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '新規作成に於いて' do - before do - sign_in @user - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'normal') - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.status.should eq 302 - end - it '作成されたコミックの表示ページへ遷移する' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr - response.should redirect_to(Comic.last) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do -# Comic.any_instance.stub(:save).and_return(true) - post :create, :comic => @attr, :format => :json - response.should be_success - end - it '作成されたコミックをjsonデータで返す' do - post :create, :comic => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :comic => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - post :create, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - post :create, :comic => @attr, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - post :create, :comic => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '編集フォーム表示に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - sign_in @user - Comic.stub(:edit).and_return(@comic) - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @comic.id - response.should be_success - end - context 'html形式' do - it 'editテンプレートを描画する' do - get :edit, :id => @comic.id - response.should render_template("edit") - end - end - context 'js形式' do - it 'edit.jsテンプレートを描画する' do - get :edit, :id => @comic.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :edit, :id => @comic.id, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :edit, :id => @comic.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '更新に於いて' do - before do - @comic = FactoryGirl.create :comic, :author => @author - @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'updated title', :visible => 0) - sign_in @user - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - it '更新されたコミックの表示ページへ遷移する' do - put :update, :id => @comic.id, :comic => @attr - response.should redirect_to(@comic) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.should be_success - end - it 'ページ本体は特に返さない' do - Comic.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @comic.id, :comic => @attr, :format => :json - response.body.should match /./ - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - it 'ステータスコード302 Foundを返す' do - put :update, :id => @comic.id, :comic => @attr - response.status.should eq 302 - end - context 'html形式' do - it 'サインインページへ遷移する' do - put :update, :id => @comic.id, :comic => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - end - - describe '削除に於いて' do - before do - @comic = FactoryGirl.create :comic, :author => @author - sign_in @user - end - context 'つつがなく終わるとき' do - context 'html形式' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - it 'マイコミックの一覧ページへ遷移する' do - delete :destroy, :id => @comic.id - response.should redirect_to('/home/comic') - end - end - context 'json形式' do - before do - Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true) - end - it 'ステータスコード200 OKを返す' do - delete :destroy, :id => @comic.id, :format => :json - response.should be_success - end - it 'ページ本体は特に返さない' do - delete :destroy, :id => @comic.id, :format => :json - response.body.should match /./ - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @comic.id - response.status.should eq 302 - end - context 'html形式' do - it 'サインインページへ遷移する' do - delete :destroy, :id => @comic.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - delete :destroy, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - -end - -end diff --git a/spec/controllers/speech_balloon_templates_controller_spec.rb b/spec/controllers/speech_balloon_templates_controller_spec.rb index 08eb32f9..2fb447e0 100644 --- a/spec/controllers/speech_balloon_templates_controller_spec.rb +++ b/spec/controllers/speech_balloon_templates_controller_spec.rb @@ -17,11 +17,11 @@ if MagicNumber['run_mode'] == 1 describe '一覧表示に於いて' do before do sign_in @user - SpeechBalloonTemplate.stub(:list).and_return([@sbt, @sbt, @sbt]) + SpeechBalloonTemplate.stub(:enable_list).and_return([@sbt, @sbt, @sbt]) end context 'つつがなく終わるとき' do it 'フキダシテンプレートモデルに一覧を問い合わせている' do - SpeechBalloonTemplate.should_receive(:list).exactly(1) + SpeechBalloonTemplate.should_receive(:enable_list).exactly(1) get :index end it '@speech_balloon_templatesにリストを取得している' do diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb deleted file mode 100644 index 7e7a4d48..00000000 --- a/spec/controllers/stories_controller_spec.rb +++ /dev/null @@ -1,1456 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#ストーリー -describe StoriesController do - before do - @admin = FactoryGirl.create :admin - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @user = FactoryGirl.create :user_yas - @author = FactoryGirl.create :author, :user_id => @user.id - @comic = FactoryGirl.create :comic, :author_id => @user.author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - -if MagicNumber['run_mode'] == 1 - describe '一覧表示に於いて' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:list).and_return([@story, @story, @story]) - end - context 'パラメータpageについて' do - it '@pageに値が入る' do - get :index, :page => 5 - assigns(:page).should eq 5 - end - it '省略されると@pageに1値が入る' do - get :index - assigns(:page).should eq 1 - end - it '与えられたpage_sizeがセットされている' do - get :index, :page_size => 15 - assigns(:page_size).should eq 15 - end - it '省略されると@page_sizeにデフォルト値が入る' do - get :index - assigns(:page_size).should eq Story.default_page_size - end - it '最大を超えると@page_sizeにデフォルト最大値が入る' do - get :index, :page_size => 1500 - assigns(:page_size).should eq Story.max_page_size - end - it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do - get :index, :page_size => 0 - assigns(:page_size).should eq Story.default_page_size - end - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - it 'ストーリーモデルに一覧を問い合わせている' do - Story.should_receive(:list).exactly(1) - get :index - end - it '@storiesにリストを取得している' do - get :index - assigns(:stories).should have_at_least(3).items - end - context 'html形式' do - it '@paginateにページ制御を取得している' do - get :index - assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true - end - it 'indexテンプレートを描画する' do - get :index - response.should render_template("index") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do - Story.should_receive(:list_json_opt).exactly(1) - get :index, :format => :json - end - it 'データがリスト構造になっている' do - get :index, :format => :json - json = JSON.parse response.body - json.should have_at_least(3).items - end - it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do - get :index, :format => :json - json = JSON.parse response.body - json.first.has_key?("panel_id").should be_true - json.first.has_key?("comic_id").should be_true - json.first.has_key?("t").should be_true - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :index - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :index - response.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :index, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :index, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - end - end - - describe '単体表示に於いて' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story) - Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story) - end - context 'つつがなく終わるとき' do - it 'ストーリーモデルに単体取得を問い合わせている' do - Story.should_receive(:show).with(@story.id.to_s, [@user, nil]).exactly(1) - get :show, :id => @story.id - end - it '@storyにアレを取得している' do - get :show, :id => @story.id - assigns(:story).should eq @story - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id - response.should be_success - end - it 'showテンプレートを描画する' do - get :show, :id => @story.id - response.should render_template("show") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :show, :id => @story.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ストーリーモデルにストーリーjson出力を問い合わせている' do - Story.any_instance.should_receive(:story_as_json).exactly(1) - get :show, :id => @story.id, :format => :json - end - it 'データがアレになっている' do - get :show, :id => @story.id, :format => :json - json = JSON.parse response.body - json.has_key?("panel_id").should be_true - json.has_key?("comic_id").should be_true - json.has_key?("author_id").should be_true - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :show, :id => @story.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :show, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :show, :id => @story.id, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :show, :id => @story.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id - response.should be_success - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id - response.should be_success - end - end - end - - describe '閲覧に於いて' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:count).and_return(10) - Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) - sign_in @user - end - context 'パラメータチェックする' do - it '与えられたoffsetがセットされている' do - get :comic, :id => @comic.id, :offset => 5 - assigns(:offset).should eq 5 - end - it '省略されると@offsetに0値が入る' do - get :comic, :id => @comic.id - assigns(:offset).should eq 0 - end - it '与えられたcountがセットされている' do - get :comic, :id => @comic.id, :count => 4 - assigns(:panel_count).should eq 4 - end - it '省略されると@panel_countにデフォルト値が入る' do - get :comic, :id => @comic.id - assigns(:panel_count).should eq Story.default_panel_size - end - it '最大を超えると@panel_countにデフォルト最大値が入る' do - get :comic, :id => @comic.id, :count => 1500 - assigns(:panel_count).should eq Story.max_panel_size - end - it '不正な値が入ると@panel_countにデフォルト最大値が入る' do - get :comic, :id => @comic.id, :count => -1 - assigns(:panel_count).should eq Story.default_panel_size - end - end - context '事前チェックする' do - it 'コミックモデルに単体取得を問い合わせている' do - Comic.should_receive(:show).with(@comic.id.to_s, [@user, nil]).exactly(1) - get :comic, :id => @comic.id - end - it 'ストーリーモデルにプレイリスト取得を問い合わせている' do - Story.should_receive(:play_list).with(@comic, @author, 0, 30).exactly(1) - get :comic, :id => @comic.id - end - end - context 'つつがなく終わるとき' do - it '@storiesにリストを取得している' do - get :comic, :id => @comic.id - assigns(:stories).should have_at_least(3).items - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id - response.should be_success - end - it 'comicテンプレートを描画する' do - get :comic, :id => @comic.id - response.should render_template("comic") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :comic, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ストーリーモデルにストーリーリストのjson出力を問い合わせている' do - Story.should_receive(:list_as_json_text).exactly(1) - get :comic, :id => @comic.id, :format => :json - end - it 'データがリスト構造になっている' do - get :comic, :id => @comic.id, :format => :json - json = JSON.parse response.body - json.should have_at_least(3).items - end - it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do - get :comic, :id => @comic.id, :format => :json - json = JSON.parse response.body - json.first.has_key?("panel_id").should be_true - json.first.has_key?("comic_id").should be_true - json.first.has_key?("author_id").should be_true - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :comic, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :comic, :id => @comic.id - response.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :comic, :id => @comic.id, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :comic, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id - response.should be_success - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id - response.should be_success - end - end - end - - describe '新規作成フォーム表示に於いて' do - before do - sign_in @user - end - context 'つつがなく終わるとき' do - it '@storyに新規データを用意している' do - get :new - assigns(:story).should be_a_new(Story) - end - it 'モデルにデフォルト値補充を依頼している' do - Story.any_instance.should_receive(:supply_default).exactly(1) - get :new - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :new - response.should be_success - end - it 'newテンプレートを描画する' do - get :new - response.should render_template("new") - end - end - context 'js形式' do - it 'ステータスコード200 OKを返す' do - get :new, :format => :js - response.should be_success - end - it 'new.jsテンプレートを描画する' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :new, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ストーリーモデルのストーリーのjson出力を問い合わせている' do - Story.any_instance.should_receive(:story_as_json).exactly(1) - get :new, :format => :json - end - it 'データがアレになっている' do - get :new, :format => :json - json = JSON.parse response.body - json.has_key?("panel_id").should be_true - json.has_key?("comic_id").should be_true - json.has_key?("author_id").should be_true - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :new, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - get :new - response.body.should redirect_to new_author_path - end - end - end - end - - describe '新規作成に於いて' do - before do - @attr = FactoryGirl.attributes_for(:story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id) - sign_in @user - end - context 'つつがなく終わるとき' do - it 'デフォルト値補充を依頼する' do - Story.any_instance.should_receive(:supply_default).exactly(1) - post :create, :story => @attr - end - it 'POSTデータから、カラム値を復元している' do - Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - assigns(:story).comic_id.should eq @comic.id - assigns(:story).panel_id.should eq @panel.id - end - it '上書き補充を依頼する' do - Story.any_instance.should_receive(:overwrite).exactly(1) - post :create, :story => @attr - end - it 'コミックモデルに編集取得を依頼している' do - Comic.should_receive(:edit).with(@comic.id, @author).exactly(1) - post :create, :story => @attr - end - it 'コマモデルに単体取得を依頼している' do - Panel.should_receive(:show).with(@panel.id, @author).exactly(1) - post :create, :story => @attr - end - it 'モデルに保存依頼する' do - Story.any_instance.should_receive(:store).exactly(1) - post :create, :story => @attr - end - it "@storyに作成されたコマを保持していて、それがDBにある" do - post :create, :story => @attr - assigns(:story).should be_a(Story) - assigns(:story).should be_persisted - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.status.should eq 302 - end - it 'コミックのストーリー表示へ遷移する' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr, :format => :json - response.should be_success - end - it '作成されたコマをjsonデータで返す' do - post :create, :story => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'ストーリーモデルのストーリーのjson出力を問い合わせている' do - Story.any_instance.should_receive(:story_as_json).exactly(1) - post :create, :story => @attr, :format => :json - end - it 'データがアレになっている' do - post :create, :story => @attr, :format => :json - json = JSON.parse response.body - json["t"].should eq 0 - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :story => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - post :create, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - post :create, :story => @attr, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - post :create, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :story => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - post :create, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :story => @attr - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - post :create, :story => @attr - response.body.should redirect_to new_author_path - end - end - end - context '検証、保存に失敗した' do - before do - Story.any_instance.stub(:store).and_return(false) - end - it "未保存のコマを保持している" do - post :create, :story => @attr - assigns(:story).should be_a_new(Story) - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - post :create, :story => @attr - response.status.should eq 200 - end - it '新規ページを描画する' do - post :create, :story => @attr - response.should render_template("new") - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - post :create, :story => @attr, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - post :create, :story => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe '編集フォーム表示に於いて' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:show).and_return(@story) - end - context 'つつがなく終わるとき' do - it 'ストーリーモデルに編集取得を問い合わせている' do - Story.should_receive(:edit).exactly(1) - get :edit, :id => @story.id - end - it '@storyにデータを用意している' do - get :edit, :id => @story.id - assigns(:story).should eq @story - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @story.id - response.should be_success - end - it 'editテンプレートを描画する' do - get :edit, :id => @story.id - response.should render_template("edit") - end - end - context 'js形式' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @story.id, :format => :js - response.should be_success - end - it 'edit.jsテンプレートを描画する' do - get :edit, :id => @story.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :edit, :id => @story.id, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :edit, :id => @story.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - get :edit, :id => @story.id - response.body.should redirect_to new_author_path - end - end - end - end - - describe '更新に於いて' do - before do - @story = FactoryGirl.create :story, :author_id => @user.author.id - @attr = FactoryGirl.attributes_for(:story, :author_id => @author.id) - sign_in @user - end - context 'つつがなく終わるとき' do - it 'モデルに編集取得依頼する' do - Story.stub(:edit).with(any_args).and_return(@story) - Story.should_receive(:edit).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it 'POSTデータから、カラム値を復元している' do - Story.any_instance.stub(:store).and_return(true) - Story.any_instance.should_receive(:attributes=).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it '上書き補充を依頼する' do - Story.any_instance.should_receive(:overwrite).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it 'モデルに保存依頼する' do - Story.any_instance.should_receive(:store).exactly(1) - put :update, :id => @story.id, :story => @attr - end - it "@storyに作成されたストーリーを保持していて、それがDBにある" do - put :update, :id => @story.id, :story => @attr - assigns(:story).should be_a(Story) - assigns(:story).should be_persisted - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ストーリー表示へ遷移する' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr, :format => :json - response.should be_success - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to new_author_path - end - end - end - context '検証、保存に失敗した' do - before do - Story.any_instance.stub(:store).and_return(false) - end - it "指定のコマを保持している" do - put :update, :id => @story.id, :story => @attr - assigns(:story).should eq @story - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 200 - end - it '編集ページを描画する' do - put :update, :id => @story.id, :story => @attr - response.should render_template("edit") - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe '削除に於いて' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:edit).and_return(@story) - end - context '事前チェックしておく' do - before do - Story.stub(:edit).with(any_args()).and_return @story - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true) - end - it 'ストーリーモデルに編集取得を問い合わせている' do - Story.should_receive(:edit).exactly(1) - delete :destroy, :id => @story.id - end - it 'モデルに削除を依頼する' do - Story.any_instance.should_receive(:destroy_and_shorten).exactly(1) - delete :destroy, :id => @story.id - end - it '@storyにアレを取得している' do - delete :destroy, :id => @story.id - assigns(:story).id.should eq(@story.id) - end - end - context 'つつがなく終わるとき' do - before do - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true) - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it '閲覧ページへ遷移する' do - delete :destroy, :id => @story.id - response.should redirect_to(:controller => 'stories', :action => :comic, :id => @story.comic_id) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - delete :destroy, :id => @story.id, :format => :json - response.should be_success - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - delete :destroy, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - delete :destroy, :id => @story.id, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - delete :destroy, :id => @story.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context 'ユーザ権限はないが管理者権限があるとき' do - before do - sign_out @user - sign_in @admin - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - delete :destroy, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - end - context 'ユーザだが作家登録していないとき' do - before do - @author.destroy - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it '作家登録ページへ遷移する' do - delete :destroy, :id => @story.id - response.body.should redirect_to new_author_path - end - end - end - context '削除に失敗したとき' do - before do - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(false) - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'そのコミックの詳細ページへ遷移する' do - delete :destroy, :id => @story.id - response.should redirect_to(story_path(@story)) - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - delete :destroy, :id => @story.id, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - delete :destroy, :id => @story.id, :format => :json - response.message.should match(/Unprocessable/) - end - end - end -=begin - context '対象ストーリーがないとき' do - end - context '他人のストーリーだったとき' do - end -=end - end - -else - describe '一覧表示に於いて' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:list).and_return([@story, @story, @story]) - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - context 'html形式' do - it 'indexテンプレートを描画する' do - get :index - response.should render_template("index") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - it 'ステータスコード200 OKを返す' do - get :index - response.should be_success - end - context 'html形式' do - it 'indexテンプレートを描画する' do - get :index - response.should render_template("index") - end - end - context 'json形式' do - it 'jsonデータを返す' do - get :index, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe '単体表示に於いて' do - before do - sign_in @user - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:show).with(@story.id.to_s, [nil, nil]).and_return(@story) - Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story) - Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story) - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id - response.should be_success - end - it 'showテンプレートを描画する' do - get :show, :id => @story.id - response.should render_template("show") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :show, :id => @story.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id - response.should be_success - end - it 'showテンプレートを描画する' do - get :show, :id => @story.id - response.should render_template("show") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :show, :id => @story.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :show, :id => @story.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe '閲覧に於いて' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:count).and_return(10) - Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) - sign_in @user - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id - response.should be_success - end - it 'comicテンプレートを描画する' do - get :comic, :id => @comic.id - response.should render_template("comic") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :comic, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id - response.should be_success - end - it 'comicテンプレートを描画する' do - get :comic, :id => @comic.id - response.should render_template("comic") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :comic, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - end - - describe '新規作成フォーム表示に於いて' do - before do - sign_in @user - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :new - response.should be_success - end - it 'newテンプレートを描画する' do - get :new - response.should render_template("new") - end - end - context 'js形式' do - it 'ステータスコード200 OKを返す' do - get :new, :format => :js - response.should be_success - end - it 'new.jsテンプレートを描画する' do - get :new, :format => :js - response.should render_template("new") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :new, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :new, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :new, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '新規作成に於いて' do - before do - @attr = FactoryGirl.attributes_for(:story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id) - sign_in @user - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.status.should eq 302 - end - it 'コミックのストーリー表示へ遷移する' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do -# Story.any_instance.stub(:store).and_return(true) - post :create, :story => @attr, :format => :json - response.should be_success - end - it '作成されたコマをjsonデータで返す' do - post :create, :story => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :story => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - post :create, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - post :create, :story => @attr, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - post :create, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '編集フォーム表示に於いて' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:show).and_return(@story) - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @story.id - response.should be_success - end - it 'editテンプレートを描画する' do - get :edit, :id => @story.id - response.should render_template("edit") - end - end - context 'js形式' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @story.id, :format => :js - response.should be_success - end - it 'edit.jsテンプレートを描画する' do - get :edit, :id => @story.id, :format => :js - response.should render_template("edit") - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @story.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :edit, :id => @story.id, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :edit, :id => @story.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '更新に於いて' do - before do - @story = FactoryGirl.create :story, :author_id => @user.author.id - @attr = FactoryGirl.attributes_for(:story, :author_id => @author.id) - sign_in @user - end - context 'つつがなく終わるとき' do - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'ストーリー表示へ遷移する' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr - response.should redirect_to(:action => :comic, :id => @attr[:comic_id]) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do -# Story.any_instance.stub(:store).and_return(true) - put :update, :id => @story.id, :story => @attr, :format => :json - response.should be_success - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - put :update, :id => @story.id, :story => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - put :update, :id => @story.id, :story => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - put :update, :id => @story.id, :story => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '削除に於いて' do - before do - @story = FactoryGirl.create :story, :author_id => @author.id - sign_in @user - Story.stub(:edit).and_return(@story) - end - context 'つつがなく終わるとき' do - before do - Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true) - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it '閲覧ページへ遷移する' do - delete :destroy, :id => @story.id - response.should redirect_to(:controller => 'stories', :action => :comic, :id => @story.comic_id) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - delete :destroy, :id => @story.id, :format => :json - response.should be_success - end - end - end - context 'ユーザ権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - delete :destroy, :id => @story.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - delete :destroy, :id => @story.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - delete :destroy, :id => @story.id, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - delete :destroy, :id => @story.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - end - -end -end diff --git a/spec/factories.rb b/spec/factories.rb index d0e9aa67..0f29ff86 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -69,15 +69,9 @@ FactoryGirl.define do writing_format.settings '{}' end - factory :comic, :class => Comic do |comic| - comic.title "comic" - comic.description 'comic description' - comic.visible 1 - end - factory :scroll, :class => Scroll do |scroll| - scroll.title "comic" - scroll.description 'comic description' + scroll.title "scroll" + scroll.description 'scroll description' scroll.visible 1 end @@ -216,16 +210,6 @@ FactoryGirl.define do panel.author_id 1 end - factory :story, :class => Story do |story| - story.comic_id 1 - story.panel_id 1 - story.author_id 1 - story.t 0 - story.x nil - story.y nil - story.z nil - end - factory :provider, :class => Provider do |provider| provider.name 'admin@penguinkingdom.com' provider.caption 'ペンギン王国' diff --git a/spec/helpers/comics_helper_spec.rb b/spec/helpers/comics_helper_spec.rb deleted file mode 100644 index 3ffabda5..00000000 --- a/spec/helpers/comics_helper_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# -*- encoding: utf-8 -*- -#  -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the ComicsHelper. For example: -# -# describe ComicsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe ComicsHelper do -end diff --git a/spec/models/comic_spec.rb b/spec/models/comic_spec.rb deleted file mode 100644 index 63fe8a1c..00000000 --- a/spec/models/comic_spec.rb +++ /dev/null @@ -1,840 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#コミック - -describe Comic do - before do - @admin = FactoryGirl.create :admin - @demand_user = FactoryGirl.create :demand_user - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @user = FactoryGirl.create( :user_yas) - @author = FactoryGirl.create :author, :user_id => @user.id - @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @other_user = FactoryGirl.create( :user_yas) - @other_author = FactoryGirl.create :author, :user_id => @other_user.id - @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - end - - describe '検証に於いて' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - - context 'オーソドックスなデータのとき' do - it '下限データが通る' do - @comic.title = 'a' - @comic.visible = 0 - @comic.should be_valid - end - it '上限データが通る' do - @comic.title = 'a'*100 - @comic.visible = 1 - @comic.should be_valid - end - end - - context 'titleを検証するとき' do - it 'nullなら失敗する' do - @comic.title = nil - @comic.should_not be_valid - end - it '100文字以上なら失敗する' do - @comic.title = 'a'*101 - @comic.should_not be_valid - end - end - context 'visibleを検証するとき' do - it 'nullなら失敗する' do - @comic.visible = nil - @comic.should_not be_valid - end - it '負なら失敗する' do - @comic.visible = -1 - @comic.should_not be_valid - end - it '2以上なら失敗する' do - @comic.visible = 2 - @comic.should_not be_valid - end - end - end - - describe '文字コード検証に於いて' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - - context 'titleを検証するとき' do - it 'Shift JISなら失敗する' do - @comic.title = "\x83G\x83r\x83]\x83D" - lambda{ - @comic.valid_encode - }.should raise_error(Pettanr::BadRequest) - end - end - - context 'descriptionを検証するとき' do - it 'Shift JISなら失敗する' do - @comic.description = "\x83G\x83r\x83]\x83D" - lambda{ - @comic.valid_encode - }.should raise_error(Pettanr::BadRequest) - end - end - end - - describe 'デフォルト値補充に於いて' do - it 'visibleが0になっている' do - @comic = FactoryGirl.build :comic, :visible => nil - @comic.supply_default - @comic.visible.should eq 0 - end - end - - describe '上書き補充に於いて' do - it '作家idが設定されている' do - @comic = FactoryGirl.build :comic, :author_id => nil - @comic.overwrite @author - @comic.author_id.should eq @author.id - end - end - - describe 'ロールリストからの作家取得に於いて' do - context 'ロールがユーザのとき' do - it 'ユーザから作家を取得して、それを返す' do - r = Comic.get_author_from_roles([@user]) - r.should eq @author - end - end - context 'ロールが作家のとき' do - it '作家を返す' do - r = Comic.get_author_from_roles([@author]) - r.should eq @author - end - end - context 'ロールが絵師のとき' do - it '絵師から作家を取得できれば、それをを返す' do - r = Comic.get_author_from_roles([@artist]) - r.should eq @author - end - it '絵師から作家を取得できないときnilを返す' do - @artist.author_id = nil - @artist.save! - r = Comic.get_author_from_roles([@artist]) - r.should be_nil - end - end - context 'ロールが管理者のとき' do - it 'nilを返す' do - r = Comic.get_author_from_roles([@admin]) - r.should be_nil - end - end - end - - describe 'ロールリストからの絵師取得に於いて' do - context 'ロールがユーザのとき' do - it 'ユーザから作家を取得して、そこから絵師を取得できれば、それを返す' do - r = Comic.get_artist_from_roles([@user]) - r.should eq @artist - end - it '作家から絵師を取得できないときnilを返す' do - @artist.author_id = nil - @artist.save! - r = Comic.get_artist_from_roles([@user]) - r.should be_nil - end - end - context 'ロールが作家のとき' do - it 'そこから絵師を取得できれば、それを返す' do - r = Comic.get_artist_from_roles([@author]) - r.should eq @artist - end - it '作家から絵師を取得できないときnilを返す' do - @artist.author_id = nil - @artist.save! - r = Comic.get_artist_from_roles([@author]) - r.should be_nil - end - end - context 'ロールが絵師のとき' do - it 'それを返す' do - r = Comic.get_artist_from_roles([@artist]) - r.should eq @artist - end - end - context 'ロールが管理者のとき' do - it 'nilを返す' do - r = Comic.get_artist_from_roles([@admin]) - r.should be_nil - end - end - end - - describe '所持判定に於いて' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context '事前チェックする' do - it '自身にロールリストからの作家取得を依頼している' do - Comic.should_receive(:get_author_from_roles).with(any_args).exactly(1) - r = @comic.own?([@author]) - end - end - context 'ロール内作家が取得できるとき' do - before do - end - it 'ロール内作家のidが自身の作家idと一致するなら許可する' do - Comic.stub(:get_author_from_roles).with(any_args).and_return(@author) - r = @comic.own?([@author]) - r.should be_true - end - it 'ロール内作家のidが自身の作家idと一致しないならno' do - Comic.stub(:get_author_from_roles).with(any_args).and_return(@other_author) - @comic.own?(@other_author).should be_false - end - end - context 'ロール内作家が取得できないとき' do - before do - Comic.stub(:get_author_from_roles).with(any_args).and_return(nil) - end - it 'Falseを返す' do - r = @comic.own?([@author]) - r.should be_false - end - end - end - - describe '読者用ロールチェックに於いて' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context 'ロールリストに作家が含まれるとき' do - it 'ロールリストがリストではないとき、リストにする trueを返す' do - r = @comic.reader_role_check(@author) - r.should be_true - end - it 'trueを返す' do - r = @comic.reader_role_check([@author]) - r.should be_true - end - end - context 'ロールリストに絵師が含まれるとき' do - it 'trueを返す' do - r = @comic.reader_role_check([@artist]) - r.should be_true - end - end - context 'ロールリストにユーザが含まれるとき' do - it 'trueを返す' do - r = @comic.reader_role_check([@user]) - r.should be_true - end - end - context 'ロールリストに管理者が含まれるとき' do - it 'trueを返す' do - r = @comic.reader_role_check([@admin]) - r.should be_true - end - end - context 'ロールリストにユーザ、管理者、作家、絵師が含まれないとき' do - it 'falseを返す' do - r = @comic.reader_role_check([nil]) - r.should be_false - end - end - end - - describe '素材読者用ロールチェックに於いて' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context 'ロールリストに作家が含まれるとき' do - it 'ロールリストがリストではないとき、リストにする trueを返す' do - r = @comic.resource_reader_role_check(@author) - r.should be_true - end - it 'trueを返す' do - r = @comic.resource_reader_role_check([@author]) - r.should be_true - end - end - context 'ロールリストに絵師が含まれるとき' do - it 'trueを返す' do - r = @comic.resource_reader_role_check([@artist]) - r.should be_true - end - end - context 'ロールリストにユーザが含まれるとき' do - it 'trueを返す' do - r = @comic.resource_reader_role_check([@user]) - r.should be_true - end - end - context 'ロールリストに管理者が含まれるとき' do - it 'trueを返す' do - r = @comic.resource_reader_role_check([@admin]) - r.should be_true - end - end - context 'ロールリストに借手が含まれるとき' do - it 'trueを返す' do - r = @comic.resource_reader_role_check([@demand_user]) - r.should be_true - end - end - context 'ロールリストにユーザ、管理者、作家、絵師、借手が含まれないとき' do - it 'falseを返す' do - r = @comic.resource_reader_role_check([nil]) - r.should be_false - end - end - end - - describe '閲覧許可に於いて' do - before do - @comic = FactoryGirl.build :comic, :author_id => @author.id - end - context 'オープンモードのとき' do - before do - MagicNumber['run_mode'] = 0 - end - it '自身にゲスト用ロールチェックを問い合わせしている' do - Comic.any_instance.stub(:guest_role_check).and_return(true) - Comic.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1) - r = @comic.visible?([@author]) - end - it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do - Comic.any_instance.stub(:guest_role_check).and_return(false) - r = @comic.visible?([@author]) - r.should be_false - end - end - context 'クローズドモードのとき' do - before do - MagicNumber['run_mode'] = 1 - end - it '自身に読者用ロールチェックを問い合わせしている' do - Comic.any_instance.stub(:reader_role_check).and_return(true) - Comic.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1) - r = @comic.visible?([@author]) - end - it '読者用ロールチェックが失敗したとき、falseを返す' do - Comic.any_instance.stub(:reader_role_check).and_return(false) - r = @comic.visible?([@author]) - r.should be_false - end - end - context '事前チェックする' do - before do - MagicNumber['run_mode'] = 1 - Comic.any_instance.stub(:reader_role_check).and_return(true) - Comic.any_instance.stub(:own?).and_return(true) - end - it '自身に所持判定を問い合わせしている' do - Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = @comic.visible?([@author]) - end - end - context 'つつがなく終わるとき' do - before do - MagicNumber['run_mode'] = 1 - Comic.any_instance.stub(:reader_role_check).and_return(true) - end - it '自分のコミックなら許可する' do - Comic.any_instance.stub(:own?).and_return(true) - Comic.any_instance.stub(:visible).and_return(0) - r = @comic.visible?([@author]) - r.should be_true - end - it '他人の非公開コミックなら許可しない' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(0) - r = @comic.visible?([@author]) - r.should be_false - end - it '他人のコミックでも公開なら許可する' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(1) - r = @comic.visible?([@author]) - r.should be_true - end - end - end - - describe '一覧取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'page補正について' do - it '文字列から数値に変換される' do - Comic.page('8').should eq 8 - end - it 'nilの場合は1になる' do - Comic.page().should eq 1 - end - it '0以下の場合は1になる' do - Comic.page('0').should eq 1 - end - end - context 'page_size補正について' do - it '文字列から数値に変換される' do - Comic.page_size('7').should eq 7 - end - it 'nilの場合はComic.default_page_sizeになる' do - Comic.page_size().should eq Comic.default_page_size - end - it '0以下の場合はComic.default_page_sizeになる' do - Comic.page_size('0').should eq Comic.default_page_size - end - it 'Comic.max_page_sizeを超えた場合はComic.max_page_sizeになる' do - Comic.page_size('1000').should eq Comic.max_page_size - end - end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) - r = Comic.list - end - end - it 'リストを返す' do - c = Comic.list - c.should eq [@comic] - end - it '非公開コミックは(自分のコミックであっても)含んでいない' do - FactoryGirl.create :comic, :author_id => @author.id, :visible => 0 - c = Comic.list - c.should eq [@comic] - end - it '時系列で並んでいる' do - #公開コミックは(他人のコミックであっても)含んでいる - v = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100 - c = Comic.list - c.should eq [v, @comic] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 100 - @comic3 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 200 - @comic4 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 300 - @comic5 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 400 - Comic.stub(:default_page_size).and_return(2) - end - it '通常は2件を返す' do - c = Comic.list - c.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - c = Comic.list(1) - c.should eq [@comic5, @comic4] - end - it 'page=2なら中間2件を返す' do - c = Comic.list(2) - c.should eq [@comic3, @comic2] - end - it 'page=3なら先頭1件を返す' do - c = Comic.list(3) - c.should eq [@comic] - end - end - end - - describe '自分のコミック一覧取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) - r = Comic.mylist @author - end - end - it 'リストを返す' do - c = Comic.mylist @author - c.should eq [@comic] - end - it '時系列で並んでいる' do - nc = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 100 - cl = Comic.mylist @author - cl.should eq [nc, @comic] - end - it '他人のコミックは公開でも含まない' do - nc = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - cl = Comic.mylist @author - cl.should eq [@comic] - end - it '自分のコミックは非公開でも含んでいる' do - nc = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100 - cl = Comic.mylist @author - cl.should eq [nc, @comic] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 100 - @comic3 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 200 - @comic4 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 300 - @comic5 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 400 - end - it '通常は2件を返す' do - c = Comic.mylist @author, 1, 2 - c.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - c = Comic.mylist(@author, 1, 2) - c.should eq [@comic5, @comic4] - end - it 'page=2なら中間2件を返す' do - c = Comic.mylist(@author, 2, 2) - c.should eq [@comic3, @comic2] - end - it 'page=3なら先頭1件を返す' do - c = Comic.mylist(@author, 3, 2) - c.should eq [@comic] - end - end - end - - describe '他作家のコミック一覧取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) - r = Comic.himlist @other_author - end - end - it '指定した作家のリストを返す' do - r = Comic.himlist @other_author - r.should eq [@other_comic] - end - it '時系列で並んでいる' do - nc = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100 - r = Comic.himlist @other_author - r.should eq [nc, @other_comic] - end - it '公開コミックに限る ' do - hidden = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 0 - r = Comic.himlist @other_author - r.should eq [@other_comic] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @other_comic2 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 100 - @other_comic3 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 200 - @other_comic4 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 300 - @other_comic5 = FactoryGirl.create :comic, :author_id => @other_author.id, :updated_at => Time.now + 400 - end - it '通常は2件を返す' do - c = Comic.himlist @other_author, 1, 2 - c.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - c = Comic.himlist(@other_author, 1, 2) - c.should eq [@other_comic5, @other_comic4] - end - it 'page=2なら中間2件を返す' do - c = Comic.himlist(@other_author, 2, 2) - c.should eq [@other_comic3, @other_comic2] - end - it 'page=3なら先頭1件を返す' do - c = Comic.himlist(@other_author, 3, 2) - c.should eq [@other_comic] - end - end - end - - describe 'コミック一覧ページ制御に於いて' do - before do - Comic.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Comic.list_paginate - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'コミック一覧の取得条件を利用している' do - Comic.stub(:list_where).with(any_args).and_return('') - Comic.should_receive(:list_where).with(any_args).exactly(1) - r = Comic.list_paginate - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Comic.list_paginate 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '自分のコミック一覧ページ制御に於いて' do - before do - Comic.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Comic.mylist_paginate @author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it '自分のコミック一覧の取得条件を利用している' do - Comic.stub(:mylist_where).with(any_args).and_return('') - Comic.should_receive(:mylist_where).with(any_args).exactly(1) - r = Comic.mylist_paginate @author - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Comic.mylist_paginate @author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '他作家のコミック一覧ページ制御に於いて' do - before do - Comic.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Comic.himlist_paginate @other_author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it '他作家のコミック一覧の取得条件を利用している' do - Comic.stub(:himlist_where).with(any_args).and_return('') - Comic.should_receive(:himlist_where).with(any_args).exactly(1) - r = Comic.himlist_paginate @other_author - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Comic.himlist_paginate @other_author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '一覧取得オプションに於いて' do - it '2つの項目を含んでいる' do - r = Comic.list_opt - r.should have(2).items - end - it 'ストーリーを含んでいる' do - r = Comic.list_opt - r.has_key?(:stories).should be_true - end - it 'ストーリーはコマを含んでいる' do - r = Comic.list_opt - r[:stories].has_key?(:panel).should be_true - end - it '作家を含んでいる' do - r = Comic.list_opt - r.has_key?(:author).should be_true - end - end - describe 'json一覧出力オプションに於いて' do - before do - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - it 'ストーリーを含んでいる' do - r = Comic.list.to_json Comic.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('stories').should be_true - end - it 'ストーリーはコマを含んでいる' do - r = Comic.list.to_json Comic.list_json_opt - j = JSON.parse r - i = j.first - s = i['stories'].first - s.has_key?('panel').should be_true - end - it '作家を含んでいる' do - r = Comic.list.to_json Comic.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('author').should be_true - end - end - - describe '単体取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Comic.stub(:show_opt).with(any_args).and_return({}) - Comic.should_receive(:show_opt).with(any_args).exactly(1) - r = Comic.show @comic.id, @author - end - it '閲覧許可を問い合わせている' do - Comic.any_instance.stub(:visible?).with(any_args).and_return(true) - Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1) - r = Comic.show @comic.id, @author - end - end - it '指定のコミックを返す' do - c = Comic.show @comic.id, @author - c.should eq @comic - end - context '閲覧許可が出なかったとき' do - it '403Forbidden例外を返す' do - Comic.any_instance.stub(:visible?).and_return(false) - lambda{ - Comic.show @comic.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しないコミックを開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Comic.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe '編集取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Comic.stub(:show_opt).with(any_args).and_return({}) - Comic.should_receive(:show_opt).with(any_args).exactly(1) - r = Comic.edit @comic.id, @author - end - it '所持判定を問い合わせている' do - Comic.any_instance.stub(:own?).with(any_args).and_return(true) - Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = Comic.edit @comic.id, @author - end - end - it '指定のコミックを返す' do - Comic.any_instance.stub(:own?).and_return(true) - c = Comic.edit @comic.id, @author.id - c.should eq @comic - end - context '他人のコミックを開こうとしたとき' do - it '403Forbidden例外を返す' do - Comic.any_instance.stub(:own?).and_return(false) - lambda{ - Comic.edit @comic.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しないコミックを開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Comic.edit 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - describe '単体取得オプションに於いて' do - it 'includeキーを含んでいる' do - r = Comic.show_opt - r.has_key?(:include).should be_true - end - it '2つの項目を含んでいる' do - r = Comic.show_opt[:include] - r.should have(2).items - end - it '作家を含んでいる' do - r = Comic.show_opt[:include] - r.has_key?(:author).should be_true - end - it 'ストーリーを含んでいる' do - r = Comic.show_opt[:include] - r.has_key?(:stories).should be_true - end - it 'ストーリーはコマを含んでいる' do - r = Comic.show_opt[:include] - r[:stories].has_key?(:panel).should be_true - end - end - describe 'json単体出力オプションに於いて' do - before do - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - it 'ストーリーを含んでいる' do - r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt - j = JSON.parse r - i = j - i.has_key?('stories').should be_true - end - it 'ストーリーはコマを含んでいる' do - r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt - j = JSON.parse r - i = j - s = i['stories'].first - s.has_key?('panel').should be_true - end - it '作家を含んでいる' do - r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt - j = JSON.parse r - i = j - i.has_key?('author').should be_true - end - end - - describe '削除に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @author.id - @other_story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @other_comic.id, :panel_id => @panel.id - end - context 'つつがなく終わるとき' do - it '自身を削除する' do - lambda { - r = @comic.destroy_with_story - }.should change(Comic, :count).by(-1) - lambda { - r = Comic.find @comic.id - }.should raise_error - end - it '自身にリンクしているストーリーをすべて削除する' do - lambda { - r = @comic.destroy_with_story - }.should change(Story, :count).by(-1) - lambda { - r = Story.find @story.id - }.should raise_error - end - it 'Trueを返す' do - r = @comic.destroy_with_story - r.should be_true - end - end - context '削除に失敗したとき' do - before do - Story.any_instance.stub(:destroy).with(any_args).and_return(false) - end - it 'Falseを返す' do - r = @comic.destroy_with_story - r.should be_false - end - it 'ロールバックしている' do - lambda { - r = @comic.destroy_with_story - }.should_not change(Comic, :count) - lambda { - r = @comic.destroy_with_story - }.should_not change(Story, :count) - end - end - end -end diff --git a/spec/models/ground_color_spec.rb b/spec/models/ground_color_spec.rb index edf88a30..8debd825 100644 --- a/spec/models/ground_color_spec.rb +++ b/spec/models/ground_color_spec.rb @@ -479,9 +479,9 @@ describe GroundColor do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id end it 'コマを含んでいる' do diff --git a/spec/models/ground_picture_spec.rb b/spec/models/ground_picture_spec.rb index 8230ce01..680b5034 100644 --- a/spec/models/ground_picture_spec.rb +++ b/spec/models/ground_picture_spec.rb @@ -536,9 +536,9 @@ describe GroundPicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id end it 'コマを含んでいる' do diff --git a/spec/models/license_group_spec.rb b/spec/models/license_group_spec.rb index a1c4f70f..685c69a5 100644 --- a/spec/models/license_group_spec.rb +++ b/spec/models/license_group_spec.rb @@ -190,9 +190,9 @@ describe LicenseGroup do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ライセンスを含んでいる' do r = LicenseGroup.list.to_json LicenseGroup.list_json_opt @@ -251,9 +251,9 @@ describe LicenseGroup do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ライセンスを含んでいる' do r = LicenseGroup.show(@lg.id).to_json LicenseGroup.show_json_opt diff --git a/spec/models/original_picture_spec.rb b/spec/models/original_picture_spec.rb index 54c6d2c3..cc587fc3 100644 --- a/spec/models/original_picture_spec.rb +++ b/spec/models/original_picture_spec.rb @@ -542,9 +542,9 @@ describe OriginalPicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it '素材を含んでいる' do r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt @@ -681,9 +681,9 @@ describe OriginalPicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it '素材を含んでいる' do r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt diff --git a/spec/models/panel_spec.rb b/spec/models/panel_spec.rb index f9aa5722..a1582eed 100644 --- a/spec/models/panel_spec.rb +++ b/spec/models/panel_spec.rb @@ -253,9 +253,9 @@ describe Panel do describe '閲覧許可に於いて' do before do - @comic = FactoryGirl.create :comic, :author_id => @author.id + @scroll = FactoryGirl.create :scroll, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end context 'オープンモードのとき' do before do @@ -1418,7 +1418,7 @@ describe Panel do describe '削除に於いて' do before do - @comic = FactoryGirl.create :comic, :author_id => @author.id + @scroll = FactoryGirl.create :scroll, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height @sb = @panel.speech_balloons.build( diff --git a/spec/models/resource_picture_spec.rb b/spec/models/resource_picture_spec.rb index 8fd9a97f..fd3433bc 100644 --- a/spec/models/resource_picture_spec.rb +++ b/spec/models/resource_picture_spec.rb @@ -670,9 +670,9 @@ describe ResourcePicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ライセンスを含んでいる' do r = ResourcePicture.list.to_json ResourcePicture.list_json_opt @@ -760,9 +760,9 @@ describe ResourcePicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id @sbt = FactoryGirl.create :speech_balloon_template - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id + @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id end it 'ライセンスを含んでいる' do r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt diff --git a/spec/models/speech_balloon_spec.rb b/spec/models/speech_balloon_spec.rb index 701f1c64..4d63acae 100644 --- a/spec/models/speech_balloon_spec.rb +++ b/spec/models/speech_balloon_spec.rb @@ -532,7 +532,7 @@ describe SpeechBalloon do end context 'DBに5件あって1ページの件数を2件に変えたとして' do before do - @other_sb2 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb2 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100 @other_sb2.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) @@ -541,7 +541,7 @@ describe SpeechBalloon do ) @other_sb2.boost @other_sb2.save! - @other_sb3 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb3 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 200 @other_sb3.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) @@ -550,7 +550,7 @@ describe SpeechBalloon do ) @other_sb3.boost @other_sb3.save! - @other_sb4 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb4 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 300 @other_sb4.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) @@ -559,7 +559,7 @@ describe SpeechBalloon do ) @other_sb4.boost @other_sb4.save! - @other_sb5 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id + @other_sb5 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 400 @other_sb5.build_speech( FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) ) diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb deleted file mode 100644 index 878c2049..00000000 --- a/spec/models/story_spec.rb +++ /dev/null @@ -1,1940 +0,0 @@ -# -*- encoding: utf-8 -*- -require 'spec_helper' -#ストーリー -describe Story do - before do - @admin = FactoryGirl.create :admin - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}' - @writing_format = FactoryGirl.create :writing_format - @user = FactoryGirl.create( :user_yas) - @author = FactoryGirl.create :author, :user_id => @user.id - @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @other_user = FactoryGirl.create( :user_yas) - @other_author = FactoryGirl.create :author, :user_id => @other_user.id - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - end - - describe '検証に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - - context 'オーソドックスなデータのとき' do - it '下限データが通る' do - @story.t = 0 - @story.should be_valid - end - it '上限データが通る' do - @story.t = 99999 - @story.should be_valid - end - end - - context 'comic_idを検証するとき' do - it 'nullなら失敗する' do - @story.comic_id = nil - @story.should_not be_valid - end - it '数値でなければ失敗する' do - @story.comic_id = 'a' - @story.should_not be_valid - end - it '存在するコミックでなければ失敗する' do - @story.comic_id = 0 - @story.should_not be_valid - end - end - - context 'panel_idを検証するとき' do - it 'nullなら失敗する' do - @story.panel_id = nil - @story.should_not be_valid - end - it '数値でなければ失敗する' do - @story.panel_id = 'a' - @story.should_not be_valid - end - it '存在するコマでなければ失敗する' do - @story.panel_id = 0 - @story.should_not be_valid - end - end - - context 'tを検証するとき' do - it 'nullなら失敗する' do - @story.t = nil - @story.should_not be_valid - end - it '数値でなければ失敗する' do - @story.t = 'a' - @story.should_not be_valid - end - it '負なら失敗する' do - @story.t = -1 - @story.should_not be_valid - end - end - - context 'author_idを検証するとき' do - it 'nullなら失敗する' do - @story.author_id = nil - @story.should_not be_valid - end - it '数値でなければ失敗する' do - @story.author_id = 'a' - @story.should_not be_valid - end - it '存在する作家でなければ失敗する' do - @story.author_id = 0 - @story.should_not be_valid - end - end - context '全体を検証するとき' do - end - end - - describe 'デフォルト値補充に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - - #dbのデフォルト値が0だから明示的にnilにしないと追加ができない - it 'tをnilにする' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id - @story.supply_default - @story.t.should be_nil - end - - end - - describe '上書き補充に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - - context 'author_idを補充' do - it '問答無用でauthor_idを補充する' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id - @story.author_id = nil - @story.overwrite @author - @story.author_id.should eq @author.id - end - end - - end - - describe '所持判定に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @comico = FactoryGirl.create :comic, :author_id => @other_author.id - @panelo = FactoryGirl.create :panel, :author_id => @other_author.id - @storyo = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @comico.id, :panel_id => @panelo.id - end - context '事前チェックする' do - it '自身にロールリストからの作家取得を依頼している' do - Story.should_receive(:get_author_from_roles).with(any_args).exactly(1) - r = @story.own?([@author]) - end - end - context 'ロール内作家が取得できるとき' do - before do - end - it 'ロール内作家のidが自身の作家idと一致するなら許可する' do - Story.stub(:get_author_from_roles).with(any_args).and_return(@author) - r = @story.own?([@author]) - r.should be_true - end - it 'ロール内作家のidが自身の作家idと一致しないならno' do - Story.stub(:get_author_from_roles).with(any_args).and_return(@other_author) - @story.own?(@other_author).should be_false - end - end - context 'ロール内作家が取得できないとき' do - before do - Story.stub(:get_author_from_roles).with(any_args).and_return(nil) - end - it 'Falseを返す' do - r = @story.own?([@author]) - r.should be_false - end - end - end - - describe '閲覧許可に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context 'オープンモードのとき' do - before do - MagicNumber['run_mode'] = 0 - end - it '自身にゲスト用ロールチェックを問い合わせしている' do - Story.any_instance.stub(:guest_role_check).and_return(true) - Story.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do - Story.any_instance.stub(:guest_role_check).and_return(false) - r = @story.visible?([@author]) - r.should be_false - end - end - context 'クローズドモードのとき' do - before do - MagicNumber['run_mode'] = 1 - end - it '自身に読者用ロールチェックを問い合わせしている' do - Story.any_instance.stub(:reader_role_check).and_return(true) - Story.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - it '読者用ロールチェックが失敗したとき、falseを返す' do - Story.any_instance.stub(:reader_role_check).and_return(false) - r = @story.visible?([@author]) - r.should be_false - end - end - context '事前チェックする' do - before do - MagicNumber['run_mode'] = 1 - Story.any_instance.stub(:reader_role_check).and_return(true) - end - it '自身のコミックに所持判定を問い合わせしている' do - Comic.any_instance.stub(:own?).and_return(true) - Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - it '自身のコミックに閲覧許可を問い合わせしている' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible?).and_return(true) - Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1) - r = @story.visible?([@author]) - end - end - context 'つつがなく終わるとき' do - before do - MagicNumber['run_mode'] = 1 - Story.any_instance.stub(:reader_role_check).and_return(true) - end - it '自分のコミックのストーリーなら許可する' do - Comic.any_instance.stub(:own?).and_return(true) - Comic.any_instance.stub(:visible).and_return(0) - r = @story.visible?([@author]) - r.should be_true - end - it '他人の非公開コミックのストーリーなら許可しない' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(0) - r = @story.visible?([@author]) - r.should be_false - end - it '他人のコミックのストーリーでも公開なら許可する' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(1) - r = @story.visible?([@author]) - r.should be_true - end - end - end - - describe 'プレイリスト取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @panel2 = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0 - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - end - context 'offset補正について' do - it '文字列から数値に変換される' do - Story.offset(100, '8').should eq 8 - end - it 'nilの場合は0になる' do - Story.offset(100).should eq 0 - end - #投稿されたコマ数以上の値が指定されたときは、最後のコマだけになる - #最後のコマとは、コマ数‐1. - it '1件のときオフセット1なら0になる' do - Story.offset(1, '1').should eq 0 - end - it '5件のときオフセット5なら4になる' do - Story.offset(5, '5').should eq 4 - end - # 負の値が指定されたときは、最後のコマから数えてコマを飛ばして表示する。 - #-4のときは、最後から4つのコマを表示する。 - it '2件のときオフセット-1なら1になる' do - Story.offset(2, '-1').should eq 1 - end - it '5件のときオフセット-2なら3になる' do - Story.offset(5, '-2').should eq 3 - end - # 最終的なが負になるなど、不正な値が入ったときは0となる。 - it '2件のときオフセット-5なら0になる' do - Story.offset(2, '-5').should eq 0 - end - end - context 'panel_count補正について' do - it '文字列から数値に変換される' do - Story.panel_count(100, '7').should eq 7 - end - it 'nilの場合はStory.default_panel_sizeになる' do - Story.panel_count(100).should eq Story.default_panel_size - end - it '0以下の場合はStory.default_panel_sizeになる' do - Story.panel_count(100, '0').should eq Story.default_panel_size - end - it 'Story.max_panel_sizeを超えた場合はStory.max_panel_sizeになる' do - Story.panel_count(100, '1000').should eq Story.max_panel_size - end - end - it 'リストを返す' do - c = Story.play_list @comic, @author - c.should eq [@story] - end - it 't順で並んでいる' do - #公開コミックの公開コマは(他人のコミックであっても)含んでいる - v = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1 - c = Story.play_list @comic, @author - c.should eq [ @story, v] - end - it '非公開のコマは含んでいる' do - h = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel2.id, :t => 1 - c = Story.play_list @comic, @author - c.should eq [ @story, h] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1 - @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2 - @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3 - @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4 - end - it 'offset=0なら末尾2件を返す' do - #時系列で並んでいる - c = Story.play_list( @comic, @author, 0, 2) - c.should eq [@story, @story2] - end - it 'offset=2なら中間2件を返す' do - c = Story.play_list(@comic, @author, 2, 2) - c.should eq [@story3, @story4] - end - it 'offset=4なら先頭1件を返す' do - c = Story.play_list(@comic, @author, 4, 2) - c.should eq [@story5] - end - end - end - - describe '一覧取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - @hidden_comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0 - end - context 'page補正について' do - it '文字列から数値に変換される' do - Story.page('8').should eq 8 - end - it 'nilの場合は1になる' do - Story.page().should eq 1 - end - it '0以下の場合は1になる' do - Story.page('0').should eq 1 - end - end - context 'page_size補正について' do - it '文字列から数値に変換される' do - Story.page_size('7').should eq 7 - end - it 'nilの場合はStory.default_page_sizeになる' do - Story.page_size().should eq Story.default_page_size - end - it '0以下の場合はStory.default_page_sizeになる' do - Story.page_size('0').should eq Story.default_page_size - end - it 'Story.max_page_sizeを超えた場合はStory.max_page_sizeになる' do - Story.page_size('1000').should eq Story.max_page_size - end - end - it 'リストを返す' do - c = Story.list - c.should eq [@story] - end - it '時系列で並んでいる' do - #公開コミックのStoryは(他人のStoryであっても)含んでいる - v = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 0, :updated_at => Time.now + 100 - c = Story.list - c.should eq [ v, @story] - end - it '非公開のストーリーは(自分のストーリーであっても)含まない' do - h = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @hidden_comic.id, :panel_id => @panel.id, :t => 0 - c = Story.list - c.should eq [ @story] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100 - @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200 - @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300 - @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400 - end - it '通常は2件を返す' do - l = Story.list 1, 2 - l.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - l = Story.list 1, 2 - l.should eq [@story5, @story4] - end - it 'page=2なら中間2件を返す' do - l = Story.list 2, 2 - l.should eq [@story3, @story2] - end - it 'page=3なら先頭1件を返す' do - l = Story.list 3, 2 - l.should eq [@story] - end - end - end - - describe '自分のストーリー一覧取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - @hcomic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0 - @hpanel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0 - end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Story.stub(:list_opt).with(any_args).and_return({}) - Story.should_receive(:list_opt).with(any_args).exactly(1) - r = Story.mylist @author - end - end - it 'リストを返す' do - s = Story.mylist @author - s.should eq [@story] - end - it '時系列で並んでいる' do - ns = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100 - sl = Story.mylist @author - sl.should eq [ns, @story] - end - it '他人のストーリーはコマコミックともに公開でも含まない' do - so = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id - sl = Story.mylist @author - sl.should eq [@story] - end - it '自分のストーリーはコマコミックともに非公開でも含んでいる' do - hs = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @hcomic.id, :panel_id => @hpanel.id, :updated_at => Time.now + 100 - sl = Story.mylist @author - sl.should eq [hs, @story] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100 - @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200 - @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300 - @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400 - Story.stub(:default_page_size).and_return(2) - end - it '通常は2件を返す' do - l = Story.mylist @author, 1, 2 - l.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - l = Story.mylist @author, 1, 2 - l.should eq [@story5, @story4] - end - it 'page=2なら中間2件を返す' do - l = Story.mylist @author, 2, 2 - l.should eq [@story3, @story2] - end - it 'page=3なら先頭1件を返す' do - l = Story.mylist @author, 3, 2 - l.should eq [@story] - end - end - end - - describe '他作家のストーリー一覧取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1 - @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 - @other_story = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id - end - it 'リストを返す' do - r = Story.himlist @other_author - r.should eq [@other_story] - end - it '時系列で並んでいる' do - ns = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100 - r = Story.himlist @other_author - r.should eq [ns, @other_story] - end - it '公開コミックのストーリー' do - @hcomic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 0 - ns = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @hcomic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100 - r = Story.himlist @other_author - r.should eq [@other_story] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @other_story2 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100 - @other_story3 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 2, :updated_at => Time.now + 200 - @other_story4 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 3, :updated_at => Time.now + 300 - @other_story5 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 4, :updated_at => Time.now + 400 - Story.stub(:default_page_size).and_return(2) - end - it '通常は2件を返す' do - l = Story.himlist @other_author, 1, 2 - l.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - l = Story.himlist @other_author, 1, 2 - l.should eq [@other_story5, @other_story4] - end - it 'page=2なら中間2件を返す' do - l = Story.himlist @other_author, 2, 2 - l.should eq [@other_story3, @other_story2] - end - it 'page=3なら先頭1件を返す' do - l = Story.himlist @other_author, 3, 2 - l.should eq [@other_story] - end - end - end - - describe 'ストーリー一覧ページ制御に於いて' do - before do - Story.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Story.list_paginate - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'ストーリー一覧の取得条件を利用している' do - Story.stub(:list_where).with(any_args).and_return('') - Story.should_receive(:list_where).with(any_args).exactly(1) - r = Story.list_paginate - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Story.list_paginate 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '自分のストーリー一覧ページ制御に於いて' do - before do - Story.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Story.mylist_paginate @author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it '自分のストーリー一覧の取得条件を利用している' do - Story.stub(:mylist_where).with(any_args).and_return('') - Story.should_receive(:mylist_where).with(any_args).exactly(1) - r = Story.mylist_paginate @author - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Story.mylist_paginate @author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '他作家のストーリー一覧ページ制御に於いて' do - before do - Story.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Story.himlist_paginate @other_author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it '他作家のストーリー一覧の取得条件を利用している' do - Story.stub(:himlist_where).with(any_args).and_return('') - Story.should_receive(:himlist_where).with(any_args).exactly(1) - r = Story.himlist_paginate @other_author - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Story.himlist_paginate @other_author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe 'list関連テーブルプションに於いて' do - it '3つの項目を含んでいる' do - r = Story.list_opt - r.should have(3).items - end - it 'コミックを含んでいる' do - r = Story.list_opt - r.has_key?(:comic).should be_true - end - it 'コミックは作家を含んでいる' do - r = Story.list_opt - r[:comic].has_key?(:author).should be_true - end - it '作家を含んでいる' do - r = Story.list_opt - r.has_key?(:author).should be_true - end - it 'コマを含んでいる' do - r = Story.list_opt - r.has_key?(:panel).should be_true - end - it 'コマは作家を含んでいる' do - r = Story.list_opt - r[:panel].has_key?(:author).should be_true - end - it 'コマはコマ絵を含んでいる' do - r = Story.list_opt - r[:panel].has_key?(:panel_pictures).should be_true - end - it 'コマ絵は実素材を含んでいる' do - r = Story.list_opt - r[:panel][:panel_pictures].has_key?(:picture).should be_true - end - it '実素材は絵師を含んでいる' do - r = Story.list_opt - r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true - end - it '実素材はライセンスを含んでいる' do - r = Story.list_opt - r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true - end - it 'コマはフキダシを含んでいる' do - r = Story.list_opt - r[:panel].has_key?(:speech_balloons).should be_true - end - it 'フキダシはフキダシ枠を含んでいる' do - r = Story.list_opt - r[:panel][:speech_balloons].has_key?(:balloon).should be_true - end - it 'フキダシはセリフを含んでいる' do - r = Story.list_opt - r[:panel][:speech_balloons].has_key?(:speech).should be_true - end - end - describe 'json一覧出力オプションに於いて' do - end - - describe '単体取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Story.stub(:show_opt).with(any_args).and_return({}) - Story.should_receive(:show_opt).with(any_args).exactly(1) - r = Story.show @story.id, @author - end - it '閲覧許可を問い合わせている' do - Story.any_instance.stub(:visible?).with(@author).and_return(true) - Story.any_instance.should_receive(:visible?).with(@author).exactly(1) - r = Story.show @story.id, @author - end - end - it '指定のストーリーを返す' do - l = Story.show @story.id, @author - l.should eq @story - end - context '他人のストーリーを開こうとしたとき' do - it '403Forbidden例外を返す' do - Story.any_instance.stub(:visible?).with(@other_author).and_return(false) - lambda{ - Story.show @story.id, @other_author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しないストーリーを開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Story.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe '編集取得に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Story.stub(:show_opt).with(any_args).and_return({}) - Story.should_receive(:show_opt).with(any_args).exactly(1) - r = Story.edit @story.id, @author - end - it '所持判定を問い合わせている' do - Story.any_instance.stub(:own?).with(any_args).and_return(true) - Story.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = Story.edit @story.id, @author - end - end - it '指定のストーリーを返す' do - l = Story.edit @story.id, @author - l.should eq @story - end - context '他人のストーリーを開こうとしたとき' do - it '403Forbidden例外を返す' do - Story.any_instance.stub(:own?).and_return(false) - lambda{ - Story.edit @story.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しないストーリーを開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Story.edit 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end - - describe '単体取得オプションに於いて' do - it 'includeキーを含んでいる' do - r = Story.show_opt - r.has_key?(:include).should be_true - end - it '3つの項目を含んでいる' do - r = Story.show_opt[:include] - r.should have(3).items - end - it 'コミックを含んでいる' do - r = Story.show_opt[:include] - r.has_key?(:comic).should be_true - end - it 'コミックは作家を含んでいる' do - r = Story.show_opt[:include] - r[:comic].has_key?(:author).should be_true - end - it '作家を含んでいる' do - r = Story.show_opt[:include] - r.has_key?(:author).should be_true - end - it 'コマを含んでいる' do - r = Story.show_opt[:include] - r.has_key?(:panel).should be_true - end - it 'コマは作家を含んでいる' do - r = Story.show_opt[:include] - r[:panel].has_key?(:author).should be_true - end - it 'コマはコマ絵を含んでいる' do - r = Story.show_opt[:include] - r[:panel].has_key?(:panel_pictures).should be_true - end - it 'コマ絵は実素材を含んでいる' do - r = Story.show_opt[:include] - r[:panel][:panel_pictures].has_key?(:picture).should be_true - end - it '実素材は絵師を含んでいる' do - r = Story.show_opt[:include] - r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true - end - it '実素材はライセンスを含んでいる' do - r = Story.show_opt[:include] - r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true - end - it 'コマはフキダシを含んでいる' do - r = Story.show_opt[:include] - r[:panel].has_key?(:speech_balloons).should be_true - end - it 'フキダシはフキダシ枠を含んでいる' do - r = Story.show_opt[:include] - r[:panel][:speech_balloons].has_key?(:balloon).should be_true - end - it 'フキダシはセリフを含んでいる' do - r = Story.show_opt[:include] - r[:panel][:speech_balloons].has_key?(:speech).should be_true - end - end - describe 'json単体取得オプションに於いて' do - end - - describe 'ストーリーのjson出力に於いて' do - before do - #コマを作成しておく。 - @panel = FactoryGirl.create :panel, :author_id => @author.id - @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height - @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id - @speech = @sb.build_speech( - FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id) - ) - @balloon = @sb.build_balloon( - FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id) - ) - @sb.boost - @sb.save! - @gc = @panel.ground_colors.create( - FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id) - ) - @gp = @panel.ground_pictures.create( - FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id) - ) - @panel.reload - @comic = FactoryGirl.create :comic, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - end - context '事前チェックする' do - before do - Panel.any_instance.stub(:elements).and_return('{}') - end - it 'コマ要素のjson出力を依頼している' do - Panel.any_instance.stub(:visible?).with(any_args).and_return(true) - Panel.any_instance.should_receive(:elements).with(any_args).exactly(1) - r = @story.story_as_json @author - end - end - it 'json textを返している' do - r = JSON.parse @story.story_as_json(@author) - r.is_a?(Hash).should be_true - end - it 'comic,author,panel,コマ要素を含んでいる' do - r = JSON.parse @story.story_as_json(@author) - r.has_key?('comic').should be_true - r['comic'].has_key?('author').should be_true - r.has_key?('author').should be_true - r.has_key?('panel').should be_true - r['panel'].has_key?('author').should be_true - end - context 'コマ閲覧許可のとき' do - before do - Panel.any_instance.stub(:visible?).with(any_args).and_return(true) - end - it 'コマ要素にコマ要素を追加している' do - r = JSON.parse @story.story_as_json(@author) - r['panel'].has_key?('elements').should be_true - r['panel']['elements'].should_not be_empty - end - end - context 'コマ閲覧不許可のとき' do - before do - Panel.any_instance.stub(:visible?).with(any_args).and_return(false) - end - it 'コマ要素にデータを含ませない' do - r = JSON.parse @story.story_as_json(@author) - r['panel'].has_key?('elements').should be_false - end - end - end - - describe 'ストーリーリストのjson出力に於いて' do - before do - @panel = FactoryGirl.create :panel, :author_id => @author.id - @comic = FactoryGirl.create :comic, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - Story.any_instance.stub(:story_as_json).with(@author).and_return('{"s": 5}') - end - context 'つつがなく終わるとき' do - it 'ストーリーのjson出力を依頼している' do - Story.any_instance.should_receive(:story_as_json).with(@author).exactly(1) - r = Story.list_as_json_text [@story], @author - end - end - it 'json textを返している' do - r = Story.list_as_json_text [@story], @author - j = JSON.parse r - j.is_a?(Array).should be_true - end - it 'ストーリーを含んでいる' do - r = Story.list_as_json_text [@story], @author - j = JSON.parse r - j.first.has_key?('s').should be_true - end - end - - describe 'ライセンス素材に於いて' do - before do - #コマを作成しておく。 - @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p2 = FactoryGirl.create :picture, :original_picture_id => @op2.id, :license_id => @license.id, :artist_id => @artist.id - @rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p2.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 0, :width => @p.width, :height => @p.height, :picture_id => @p.id - @panel.reload - @panel2 = FactoryGirl.create :panel, :author_id => @author.id - @pp2= FactoryGirl.create :panel_picture, :panel_id => @panel2.id, :t => 0, :width => @p2.width, :height => @p2.height, :picture_id => @p2.id - @panel2.reload - - @comic = FactoryGirl.create :comic, :author_id => @author.id - @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel2.id - end - context '事前チェック' do - end - context 'つつがなく終わるとき' do - end - it '連想配列(値は実素材、キーは実素材id)を返している' do - r = Story.licensed_pictures [@story, @story2] - r.is_a?(Hash).should be_true - r.should have(2).items - r[@pp.picture_id].should eq @p - r[@pp2.picture_id].should eq @p2 - end - context 'コマが削除されているときき' do - before do - @panel2.destroy - end - it '削除されているコマは無視する' do - r = Story.licensed_pictures [@story, @story2] - r.is_a?(Hash).should be_true - r.should have(1).items - r[@pp.picture_id].should eq @p - r[@pp2.picture_id].should be_nil - end - end - end - - describe 't補充値に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - - context 'コミック初のコマなら' do - it '0を補充値とする' do - @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story.t = nil - r = Story.new_t @story.comic_id - r.should eq 0 - end - end - context 'コミックに一個コマがあるとき' do - it '1を補充値とする' do - FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0 - @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story.t = nil - r = Story.new_t @story.comic_id - r.should eq 1 - end - end - context 'コミックに2個コマがあるとき' do - it '2を補充値とする' do - FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0 - FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1 - @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id - @story.t = nil - r = Story.new_t @story.comic_id - r.should eq 2 - end - end - end - describe 'シリアライズチェックに於いて' do - context 'つつがなく終わるとき' do - it '0からシリアライズされているならTrueを返す' do - r = Story.serial? [0, 1, 2] - r.should be_true - end - it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do - r = Story.serial? [0, 2, 1] - r.should be_true - end - it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do - r = Story.serial? [ 2, 1, 4, 3, 0] - r.should be_true - end - end - context '異常なとき' do - it '0から始まらないならFalseを返す' do - r = Story.serial? [1, 2, 3] - r.should be_false - end - it '連続していないならFalseを返す' do - r = Story.serial? [0, 1, 2, 4] - r.should be_false - end - it '連続していないならFalseを返す' do - r = Story.serial? [0, 1, 2, 4, 5] - r.should be_false - end - end - end - describe 't収集に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @c2story = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it 'ストーリーから同一コミックのtだけを収集している' do - r = Story.collect_t @story - r.should eq [0] - end - end - context '複数コマのとき' do - it 'ストーリーから同一コミックのtだけを収集している' do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - r = Story.collect_t @story - r.sort.should eq [0, 1] - end - end - context '複数コマでヨソのコミックも混じっているとき' do - it 'ストーリーから同一コミックのtだけを収集している' do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - r = Story.collect_t @story - r.sort.should eq [0, 1] - end - end - end - describe 'tチェックに於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it 't収集を依頼している' do - Story.should_receive(:collect_t).with(any_args).exactly(1) - Story.stub(:collect_t).with(any_args).and_return([]) - Story.stub(:serial?).with(any_args).and_return(true) - r = Story.validate_t @story - end - it '収集したtをシリアライズチェック依頼している' do - Story.stub(:collect_t).with(any_args).and_return([]) - Story.should_receive(:serial?).with(any_args).exactly(1) - Story.stub(:serial?).with(any_args).and_return(true) - r = Story.validate_t @story - end - end - #実データでチェック - #依頼チェックだけでは不安なので最低限のチェックを - context '新規のとき' do - it '一件だけで正常通過している' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0 - r = Story.validate_t @story - r.should be_true - end - end - context '既存のとき' do - it '2件目を作っても正常通過している' do - @story = FactoryGirl.create :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0 - @story2 = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1 - r = Story.validate_t @story2 - r.should be_true - end - end - end - describe '挿入シフトに於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context '依頼チェック' do - #テーブルが空で0に挿入 - it 'Updateを依頼している' do - Story.stub(:update_all).with(any_args) - Story.should_receive(:update_all).with(any_args).exactly(1) - @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story.insert_shift - end - end - context 'テーブルに1件(t:0)で0に挿入したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '既存の行を1にシフトしている' do - @story2.insert_shift - l = Story.find :all - l.first.t.should eq 1 - end - it 'これから挿入するt(0)が欠番になっている' do - @story2.insert_shift - l = Story.find(:all).map {|s| s.t } - l.include?(0).should_not be_true - end - end - context 'テーブルに2件(t:0,1)で1に挿入したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do - @story3.insert_shift - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 2] - end - end - context 'テーブルに5件(t:0,1,2,3,4)で2に挿入したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do - @story6.insert_shift - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 1, 3, 4, 5] - end - end - context '先ほどのケース+他のコミック1件で挿入したとき' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do - @story6.insert_shift - l = Story.find(:all, :conditions => ['comic_id = ?', @comic.id]).map {|s| s.t } - l.sort.should eq [0, 1, 3, 4, 5] - end - it '他のコミックに影響がない' do - ot = @storyc2.t - @story6.insert_shift - @storyc2.reload - @storyc2.t.should eq ot - end - end - end - describe '少ない方に移動に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context '依頼チェック' do - it 'Updateを依頼している' do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:update_all).with(any_args) - Story.should_receive(:update_all).with(any_args).exactly(1) - ot = @story2.t - @story2.t = 0 - @story2.lesser_shift ot - end - end - context 'テーブルに2件(t:0,1)で1を0に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 0 - end - it '既存のt0を1にシフトしてこれから挿入するt(0)が欠番になっている' do - #移動させたい行はそのまま残る - @story2.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [1, 1] - end - it '既存のt0を1にシフトしている' do - @story2.lesser_shift @ot - @story.reload - @story.t.should eq 1 - end - end - context 'テーブルに3件(t:0,1,2)で2を1に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story3.t - @story3.t = 1 - end - it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do - #移動させたい行はそのまま残る - @story3.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 2, 2] - end - it '既存のt1を2にシフトしている' do - @story3.lesser_shift @ot - @story2.reload - @story2.t.should eq 2 - end - end - context 'テーブルに5件(t:0,1,2,3,4)で3を1に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it 'これから挿入するt(1)が欠番になっている' do - #移動させたい行はそのまま残る - @story4.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 2, 3, 3, 4] - end - it '既存のt0には変化がない' do - @story4.lesser_shift @ot - @story.reload - @story.t.should eq 0 - end - it '既存のt4には変化がない' do - @story4.lesser_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it '既存のt1を2にシフトしている' do - @story4.lesser_shift @ot - @story2.reload - @story2.t.should eq 2 - end - it '既存のt2を3にシフトしている' do - @story4.lesser_shift @ot - @story3.reload - @story3.t.should eq 3 - end - end - context '先ほどのケース+他のコミック1件で挿入したとき' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it 'これから挿入するt(1)が欠番になっている' do - @story4.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0, 2, 3, 3, 4] - end - it '既存のt0には変化がない' do - @story4.lesser_shift @ot - @story.reload - @story.t.should eq 0 - end - it '既存のt4には変化がない' do - @story4.lesser_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it '既存のt1を2にシフトしている' do - @story4.lesser_shift @ot - @story2.reload - @story2.t.should eq 2 - end - it '既存のt2を3にシフトしている' do - @story4.lesser_shift @ot - @story3.reload - @story3.t.should eq 3 - end - it '他のコミックに影響がない' do - @story4.lesser_shift @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - #例外ケース。 - #負のときは0として正常扱い - context 'テーブルに2件(t:0,1)で1を-1に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = -1 - end - it '既存のt0を1にシフトしてこれから挿入するt(0)が欠番になっている' do - #移動させたい行はそのまま残る - @story2.lesser_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [1, 1] - end - it '既存のt0を1にシフトしている' do - @story2.lesser_shift @ot - @story.reload - @story.t.should eq 1 - end - it '既存のt1は0に補正されている' do - @story2.lesser_shift @ot - @story2.t.should eq 0 - end - end - end - describe '大きい方に移動に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context '依頼チェック' do - it 'Updateを依頼している' do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:update_all).with(any_args) - Story.should_receive(:update_all).with(any_args).exactly(1) - ot = @story.t - @story.t = 1 - @story.higher_shift ot - end - end - context 'テーブルに2件(t:0,1)で0を1に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story.t - @story.t = 1 - end - it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do - #移動させたい行はそのまま残る - @story.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0] - end - it '既存のt1を0にシフトしている' do - @story.higher_shift @ot - @story2.reload - @story2.t.should eq 0 - end - end - context 'テーブルに3件(t:0,1,2)で0を1に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story.t - @story.t = 1 - end - it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do - #移動させたい行はそのまま残る - @story.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0, 2] - end - it '既存のt1を0にシフトしている' do - @story.higher_shift @ot - @story2.reload - @story2.t.should eq 0 - end - end - context 'テーブルに5件(t:0,1,2,3,4)で1を3に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 3 - end - it 'これから挿入するt(3)が欠番になっている' do - #移動させたい行はそのまま残る - @story2.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 1, 1, 2, 4] - end - it '既存のt0には変化がない' do - @story2.higher_shift @ot - @story.reload - @story.t.should eq 0 - end - it '既存のt4には変化がない' do - @story2.higher_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it '既存のt2を1にシフトしている' do - @story2.higher_shift @ot - @story3.reload - @story3.t.should eq 1 - end - it '既存のt3を2にシフトしている' do - @story2.higher_shift @ot - @story4.reload - @story4.t.should eq 2 - end - end - context '先ほどのケース+他のコミック1件で挿入したとき' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 3 - end - it 'これから挿入するt(3)が欠番になっている' do - #移動させたい行はそのまま残る - @story2.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0, 1, 1, 2, 4] - end - it '既存のt0には変化がない' do - @story2.higher_shift @ot - @story.reload - @story.t.should eq 0 - end - it '既存のt4には変化がない' do - @story2.higher_shift @ot - @story5.reload - @story5.t.should eq 4 - end - it '既存のt2を1にシフトしている' do - @story2.higher_shift @ot - @story3.reload - @story3.t.should eq 1 - end - it '既存のt3を2にシフトしている' do - @story2.higher_shift @ot - @story4.reload - @story4.t.should eq 2 - end - it '他のコミックに影響がない' do - @story2.higher_shift @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - #例外ケース。 - #max超えたときはmaxとして正常扱い - context 'テーブルに2件(t:0,1)で0を2に移動したとき' do - before do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story.t - @story.t = 2 - end - it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do - #移動させたい行はそのまま残る - @story.higher_shift @ot - l = Story.find(:all).map {|s| s.t } - l.sort.should eq [0, 0] - end - it '既存のt1を0にシフトしている' do - @story.higher_shift @ot - @story2.reload - @story2.t.should eq 0 - end - it '既存のt0は1に補正されている' do - @story.higher_shift @ot - @story.t.should eq 1 - end - end - end - describe '入れ替えに於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context '新tが旧tより小さいとき' do - it '少ない方に移動を依頼している' do - Story.any_instance.stub(:lesser_shift).with(any_args) - Story.any_instance.should_receive(:lesser_shift).with(any_args).exactly(1) - ot = @story2.t - @story2.t = 0 - @story2.update_shift ot - end - end - context '新tが旧tより大きいとき' do - it '大きい方に移動を依頼している' do - Story.any_instance.stub(:higher_shift).with(any_args) - Story.any_instance.should_receive(:higher_shift).with(any_args).exactly(1) - ot = @story.t - @story.t = 1 - @story.update_shift ot - end - end - end - describe '順序入れ替えに於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - end - context 'オブジェクトが新規でtが空のとき' do - it '末尾追加としてtを補充依頼している' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.stub(:new_t).with(any_args).and_return(0) - Story.should_receive(:new_t).with(any_args).exactly(1) - @story.t = nil - r = @story.rotate - end - end - context 'オブジェクトが新規でtが設定されているとき' do - it '挿入追加として挿入シフトを依頼している' do - @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.any_instance.stub(:insert_shift).with(any_args) - Story.any_instance.should_receive(:insert_shift).with(any_args).exactly(1) - @story.t = 0 - r = @story.rotate - end - end - context 'オブジェクトが新規でなくtが設定されているとき' do - it 'コマ移動として入れ替えを依頼している' do - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.any_instance.stub(:update_shift).with(any_args) - Story.any_instance.should_receive(:update_shift).with(1).exactly(1) - @story2.t = 0 - r = @story.rotate 1 - end - end - context 'オブジェクトが新規でなくtが空のとき' do - it '入れ替えもシフトもせず、tを空のままにしている' do - #結果、tに欠番が生じてシリアライズチェックでひっかかる - end - end - end - describe '編集許可に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it 'trueを返す' do - r = @story.allow? - r.should be_true - end - end - context 'コミックで引っかかるとき' do - it 'falseを返す' do - Panel.any_instance.stub(:usable?).with(any_args).and_return(true) - Comic.any_instance.stub(:own?).with(any_args).and_return(false) - r = @story.allow? - r.should be_false - end - end - context 'コマで引っかかるとき' do - it 'falseを返す' do - Comic.any_instance.stub(:own?).with(any_args).and_return(true) - Panel.any_instance.stub(:usable?).with(any_args).and_return(false) - r = @story.allow? - r.should be_false - end - end - context 'コミックまたはコマが指定されていなかったとき' do - it 'nilを返す' do - Comic.any_instance.stub(:own?).with(any_args).and_return(true) - @story.panel_id = nil - r = @story.allow? - r.should eq nil - end - it 'nilを返す' do - Panel.any_instance.stub(:usable?).with(any_args).and_return(true) - @story.comic_id = nil - r = @story.allow? - r.should eq nil - end - end - end - describe '保存に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it '編集許可チェックを依頼している' do - Story.any_instance.stub(:allow?).with(any_args).and_return(true) - Story.any_instance.should_receive(:allow?).with(any_args).exactly(1) - r = @story.store - end - it '順序入れ替えを依頼している' do - Story.any_instance.stub(:rotate).with(any_args).and_return(0) - Story.any_instance.should_receive(:rotate).with(any_args).exactly(1) - Story.any_instance.stub(:save).with(any_args).and_return(true) - Story.stub(:validate_t).with(any_args).and_return(true) - r = @story.store - end - it '保存を依頼している' do - Story.stub(:new_t).with(any_args).and_return(0) - Story.any_instance.stub(:save).with(any_args).and_return(true) - Story.any_instance.should_receive(:save).with(any_args).exactly(1) - Story.stub(:validate_t).with(any_args).and_return(true) - r = @story.store - end - it 'tのシリアライズチェックを依頼している' do - Story.stub(:new_t).with(any_args).and_return(0) - Story.any_instance.stub(:save).with(any_args).and_return(true) - Story.stub(:validate_t).with(any_args).and_return(true) - Story.should_receive(:validate_t).with(any_args).exactly(1) - r = @story.store - end - end - #入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている - context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で2に挿入したとき' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '既存のt0には変化がない' do - @story6.store - @story.reload - @story.t.should eq 0 - end - it '既存のt1には変化がない' do - @story6.store - @story2.reload - @story2.t.should eq 1 - end - it '既存のt2を3にシフトしている' do - @story6.store - @story3.reload - @story3.t.should eq 3 - end - it '既存のt3を4にシフトしている' do - @story6.store - @story4.reload - @story4.t.should eq 4 - end - it '既存のt5を5にシフトしている' do - @story6.store - @story5.reload - @story5.t.should eq 5 - end - it '新規のt2が作成されている' do - @story6.store - @story6.reload - @story6.t.should eq 2 - end - it '他のコミックに影響がない' do - @ot = @storyc2.t - @story6.store - @storyc2.reload - @storyc2.t.should eq @ot - end - end - context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で3を1に移動したとき' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it '既存のt0には変化がない' do - @story4.store @ot - @story.reload - @story.t.should eq 0 - end - it '既存のt4には変化がない' do - @story4.store @ot - @story5.reload - @story5.t.should eq 4 - end - it '既存のt1を2にシフトしている' do - @story4.store @ot - @story2.reload - @story2.t.should eq 2 - end - it '既存のt2を3にシフトしている' do - @story4.store @ot - @story3.reload - @story3.t.should eq 3 - end - it '既存のt3を1にシフトしている' do - @story4.store @ot - @story4.reload - @story4.t.should eq 1 - end - it '他のコミックに影響がない' do - @story4.store @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で1を3に移動したとき' do - before do - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story2.t - @story2.t = 3 - end - it '既存のt0には変化がない' do - @story2.store @ot - @story.reload - @story.t.should eq 0 - end - it '既存のt4には変化がない' do - @story2.store @ot - @story5.reload - @story5.t.should eq 4 - end - it '既存のt1を3にシフトしている' do - @story2.store @ot - @story2.reload - @story2.t.should eq 3 - end - it '既存のt2を1にシフトしている' do - @story2.store @ot - @story3.reload - @story3.t.should eq 1 - end - it '既存のt3を2にシフトしている' do - @story2.store @ot - @story4.reload - @story4.t.should eq 2 - end - it '他のコミックに影響がない' do - @story2.store @ot - @storyc2.reload - @storyc2.t.should eq 0 - end - end - #ロールバックテスト。入れ替えが直接DBをいじるので、すべてのケースで確実にロールバックを確認する - context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で2に挿入したが保存に失敗したとき' do - before do - Story.any_instance.stub(:save).with(any_args).and_return(false) - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '既存のtに変化がない' do - @story6.store - @story.reload - @story.t.should eq 0 - @story2.reload - @story2.t.should eq 1 - @story3.reload - @story3.t.should eq 2 - @story4.reload - @story4.t.should eq 3 - @story5.reload - @story5.t.should eq 4 - @storyc2.reload - @storyc2.t.should eq 0 - end - it 'falseを返す' do - r = @story6.store - r.should be_false - end - end - context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で3を1に移動したがシリアルチェックに失敗したとき' do - before do - Story.stub(:validate_t).with(any_args).and_return(false) - @comic2 = FactoryGirl.create :comic, :author_id => @author.id - @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @ot = @story4.t - @story4.t = 1 - end - it '既存のtに変化がない' do - @story4.store @ot - @story.reload - @story.t.should eq 0 - @story2.reload - @story2.t.should eq 1 - @story3.reload - @story3.t.should eq 2 - @story4.reload - @story4.t.should eq 3 - @story5.reload - @story5.t.should eq 4 - @storyc2.reload - @storyc2.t.should eq 0 - end - it 'falseを返す' do - r = @story4.store @ot - r.should be_false - end - it 'tにエラーメッセージが入っている' do - @story4.store @ot - @story4.errors[:t].should_not be_empty - @story4.valid?.should be_true - end - end - context '編集不可だったとき' do - before do - @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Story.any_instance.stub(:allow?).and_return(false) - end - it '403Forbidden例外を返す' do - lambda{ - @story.store - }.should raise_error(ActiveRecord::Forbidden) - end - end - end - describe '切り詰め処理つき削除に於いて' do - before do - @comic = FactoryGirl.create :comic, :author_id => @author.id - @panel = FactoryGirl.create :panel, :author_id => @author.id - @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it '削除される' do - lambda{ - @story.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it 'Trueを返す' do - r = @story.destroy_and_shorten - r.should be_true - end - end - context '削除に失敗したとき' do - before do - Story.any_instance.stub(:destroy).and_return(false) - end - it 'ロールバックされる' do - lambda{ - @story.destroy_and_shorten - }.should_not change(Story, :count ) - end - it 'Falseを返す' do - r = @story.destroy_and_shorten - r.should be_false - end - end - #連携テスト。切り詰めが直接DBをいじる - context '2件で先頭を削除したとき' do - before do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '行が削除される' do - lambda{ - @story.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it '先頭は削除される' do - @story.destroy_and_shorten - lambda{ - Story.find @story.id - }.should raise_error(ActiveRecord::RecordNotFound) - end - it '2件目は前に詰められる' do - @story.destroy_and_shorten - @story2.reload - @story2.t.should eq 0 - end - end - context '3件で先頭を削除したとき' do - before do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '行が削除される' do - lambda{ - @story.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it '先頭は削除される' do - @story.destroy_and_shorten - lambda{ - Story.find @story.id - }.should raise_error(ActiveRecord::RecordNotFound) - end - it '2件目は前に詰められる' do - @story.destroy_and_shorten - @story2.reload - @story2.t.should eq 0 - end - it '3件目は前に詰められる' do - @story.destroy_and_shorten - @story3.reload - @story3.t.should eq 1 - end - end - context '5件で3件目を削除したとき' do - before do - @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - end - it '行が削除される' do - lambda{ - @story3.destroy_and_shorten - }.should change(Story, :count ).by(-1) - end - it '1件目は変化がない' do - @story3.destroy_and_shorten - @story.reload - @story.t.should eq 0 - end - it '2件目は変化がない' do - @story3.destroy_and_shorten - @story2.reload - @story2.t.should eq 1 - end - it '3件目は削除される' do - @story3.destroy_and_shorten - lambda{ - Story.find @story3.id - }.should raise_error(ActiveRecord::RecordNotFound) - end - it '4件目は前に詰められる' do - @story3.destroy_and_shorten - @story4.reload - @story4.t.should eq 2 - end - it '5件目は前に詰められる' do - @story3.destroy_and_shorten - @story5.reload - @story5.t.should eq 3 - end - end - #ロールバックテスト。切り詰めが直接DBをいじるので、すべてのケースで確実にロールバックを確認する - end -end -- 2.11.0