layout 'test' if MagicNumber['test_layout']
before_filter :authenticate_user, :only => [
:index, :show, :profile, :configure, :create_token, :delete_token,
- :comics, :stories, :panels, :resource_pictures, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors
+ :scrolls, :scroll_panels, :panels, :resource_pictures, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors
]
- before_filter :authenticate_author, :only => [:comics, :stories, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors]
+ before_filter :authenticate_author, :only => [:scrolls, :scroll_panels, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors]
before_filter :authenticate_artist, :only => [:resource_pictures]
def index
end
end
- def comics
+ def scrolls
@page = Author.page params[:page]
- @page_size = Author.comic_page_size params[:page_size]
- @comics = Comic.mylist(@author, @page, @page_size)
+ @page_size = Author.scroll_page_size params[:page_size]
+ @scrolls = Scroll.mylist(@author, @page, @page_size)
respond_to do |format|
format.html {
- @paginate = Comic.mylist_paginate(@author, @page, @page_size)
+ @paginate = Scroll.mylist_paginate(@author, @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
@page = Author.page params[:page]
- @page_size = Author.story_page_size params[:page_size]
- @stories = Story.mylist(@author, @page, @page_size)
+ @page_size = Author.scroll_panel_page_size params[:page_size]
+ @scroll_panels = ScrollPanel.mylist(@author, @page, @page_size)
respond_to do |format|
format.html {
- @paginate = Story.mylist_paginate(@author, @page, @page_size)
+ @paginate = ScrollPanel.mylist_paginate(@author, @page, @page_size)
}
- format.json { render text: Story.list_as_json_text(@stories) }
+ format.json { render text: ScrollPanel.list_as_json_text(@scroll_panels) }
end
end
class Author < ActiveRecord::Base
has_one :artist
belongs_to :user
- has_many :comics
+ has_many :scrolls
has_many :panels
belongs_to :working_panel, :class_name => "Panel"
res
end
- def self.default_comic_page_size
+ def self.default_scroll_page_size
25
end
- def self.comic_max_page_size
+ def self.scroll_max_page_size
100
end
- def self.comic_page_size prm = self.default_comic_page_size
+ def self.scroll_page_size prm = self.default_scroll_page_size
page_size = prm.to_i
- page_size = self.comic_max_page_size if page_size > self.comic_max_page_size
- page_size = self.default_comic_page_size if page_size < 1
+ page_size = self.scroll_max_page_size if page_size > self.scroll_max_page_size
+ page_size = self.default_scroll_page_size if page_size < 1
page_size
end
- def self.default_story_page_size
+ def self.default_scroll_panel_page_size
25
end
- def self.story_max_page_size
+ def self.scroll_panel_max_page_size
100
end
- def self.story_page_size prm = self.default_story_page_size
+ def self.scroll_panel_page_size prm = self.default_scroll_panel_page_size
page_size = prm.to_i
- page_size = self.story_max_page_size if page_size > self.story_max_page_size
- page_size = self.default_story_page_size if page_size < 1
+ page_size = self.scroll_panel_max_page_size if page_size > self.scroll_panel_max_page_size
+ page_size = self.default_scroll_panel_page_size if page_size < 1
page_size
end
class Panel < ActiveRecord::Base
belongs_to :author
belongs_to :resource_picture
- has_many :stories
+ has_many :scroll_panels
has_many :panel_pictures, :dependent => :destroy
has_many :speech_balloons, :dependent => :destroy
has_many :ground_pictures, :dependent => :destroy
+++ /dev/null
-<h1><%= t '.title' -%></h1>
-<p id="notice"><%= notice %></p>
-
-<table>
- <% @comics.each do |comic| %>
- <%= render 'comics/list_item', :comic => comic, :author => @author %>
- <% end %>
-</table>
-<%= paginate(@paginate) %>
-<%= link_to t('comics.new.title'), new_comic_path %>
+++ /dev/null
-<h1><%= t '.title' -%></h1>
-
-<table>
- <% @stories.each do |story| %>
- <%= render 'stories/list_item', :story => story, :author => @author %>
- <% end %>
-</table>
-<%= paginate(@paginate) %>
-<%= link_to t('stories.new.title'), new_story_path %>
get :browse
end
end
+ resources :scrolls 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 :scroll_panels do
+ new do
+ get :new
+ end
+ collection do
+ get :index
+ get :show
+ post :create
+ get :list
+ end
+ member do
+ get :edit
+ get :scroll
+ put :update
+ delete :destroy
+ get :browse
+ end
+ end
resources :panels do
new do
get :new
# Keep in mind you can assign values other than :controller and :action
match 'resource_pictures/:subdir/:id(.:format)/' => 'resource_pictures#show'
match 'pictures/:subdir/:id(.:format)/' => 'pictures#show'
- #match 'stories/comic/:id(.:format)' => 'stories#comic'
+ #match 'scroll_panels/scroll/:id(.:format)' => 'scroll_panels#scroll'
match 'top/(:action)', :controller => 'top'
match 'home/(:action)', :controller => 'home'
match 'system/(:action)', :controller => 'system'
if MagicNumber['run_mode'] == 1
describe '自分のコミック一覧表示に於いて' do
before do
- @comic = FactoryGirl.create :comic, :author_id => @author.id
+ @scroll = FactoryGirl.create :scroll, :author_id => @author.id
sign_in @user
- Comic.stub(:mylist).and_return([@comic, @comic, @comic])
+ Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
end
context 'パラメータpageについて' do
it '@pageに値が入る' do
- get :comics, :page => 5
+ get :scrolls, :page => 5
assigns(:page).should eq 5
end
it '省略されると@pageに1値が入る' do
- get :comics
+ get :scrolls
assigns(:page).should eq 1
end
it '与えられたpage_sizeがセットされている' do
- get :comics, :page_size => 15
+ get :scrolls, :page_size => 15
assigns(:page_size).should eq 15
end
it '省略されると@page_sizeにデフォルト値が入る' do
- get :comics
- assigns(:page_size).should eq Author.default_comic_page_size
+ get :scrolls
+ assigns(:page_size).should eq Author.default_scroll_page_size
end
it '最大を超えると@page_sizeにデフォルト最大値が入る' do
- get :comics, :page_size => 1500
- assigns(:page_size).should eq Author.comic_max_page_size
+ get :scrolls, :page_size => 1500
+ assigns(:page_size).should eq Author.scroll_max_page_size
end
it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
- get :comics, :page_size => 0
- assigns(:page_size).should eq Author.default_comic_page_size
+ get :scrolls, :page_size => 0
+ assigns(:page_size).should eq Author.default_scroll_page_size
end
end
context 'つつがなく終わるとき' do
it 'ステータスコード200 OKを返す' do
- get :comics
+ get :scrolls
response.should be_success
end
it 'コミックモデルに一覧を問い合わせている' do
- Comic.should_receive(:mylist).exactly(1)
- get :comics
+ Scroll.should_receive(:mylist).exactly(1)
+ get :scrolls
end
- it '@comicsにリストを取得している' do
- get :comics
- assigns(:comics).should have_at_least(3).items
+ it '@scrollsにリストを取得している' do
+ get :scrolls
+ assigns(:scrolls).should have_at_least(3).items
end
context 'html形式' do
it '@paginateにページ制御を取得している' do
- get :comics
+ get :scrolls
assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
end
- it 'comicsテンプレートを描画する' do
- get :comics
- response.should render_template("comics")
+ it 'scrollsテンプレートを描画する' do
+ get :scrolls
+ response.should render_template("scrolls")
end
end
context 'json形式' do
it 'jsonデータを返す' do
- get :comics, :format => :json
+ get :scrolls, :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, :format => :json
+ Scroll.should_receive(:list_json_opt).exactly(1)
+ get :scrolls, :format => :json
end
it 'データがリスト構造になっている' do
- get :comics, :format => :json
+ get :scrolls, :format => :json
json = JSON.parse response.body
json.should have_at_least(3).items
end
it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
- get :comics, :format => :json
+ get :scrolls, :format => :json
json = JSON.parse response.body
json.first.has_key?("title").should be_true
json.first.has_key?("visible").should be_true
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
- get :comics
+ get :scrolls
response.status.should eq 302
end
it 'サインインページへ遷移する' do
- get :comics
+ get :scrolls
response.should redirect_to '/users/sign_in'
end
end
context 'json形式' do
it 'ステータスコード401 Unauthorizedを返す' do
- get :comics, :format => :json
+ get :scrolls, :format => :json
response.status.should eq 401
end
it '応答メッセージにUnauthorizedを返す' do
- get :comics, :format => :json
+ get :scrolls, :format => :json
response.message.should match(/Unauthorized/)
end
end
else
describe '自分のコミック一覧表示に於いて' do
before do
- @comic = FactoryGirl.create :comic, :author_id => @author.id
+ @scroll = FactoryGirl.create :scroll, :author_id => @author.id
sign_in @user
- Comic.stub(:mylist).and_return([@comic, @comic, @comic])
+ Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
end
context 'つつがなく終わるとき' do
it 'ステータスコード200 OKを返す' do
- get :comics
+ get :scrolls
response.should be_success
end
context 'html形式' do
- it 'comicsテンプレートを描画する' do
- get :comics
- response.should render_template("comics")
+ it 'scrollsテンプレートを描画する' do
+ get :scrolls
+ response.should render_template("scrolls")
end
end
context 'json形式' do
it 'jsonデータを返す' do
- get :comics, :format => :json
+ get :scrolls, :format => :json
lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
end
end
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
- get :comics
+ get :scrolls
response.status.should eq 302
end
it 'サインインページへ遷移する' do
- get :comics
+ get :scrolls
response.should redirect_to '/users/sign_in'
end
end
context 'json形式' do
it 'ステータスコード401 Unauthorizedを返す' do
- get :comics, :format => :json
+ get :scrolls, :format => :json
response.status.should eq 401
end
it '応答メッセージにUnauthorizedを返す' do
- get :comics, :format => :json
+ get :scrolls, :format => :json
response.message.should match(/Unauthorized/)
end
end
comic.visible 1
end
+ factory :scroll, :class => Scroll do |scroll|
+ scroll.title "comic"
+ scroll.description 'comic description'
+ scroll.visible 1
+ end
+
+ factory :scroll_panel, :class => ScrollPanel do |scroll_panel|
+ scroll_panel.scroll_id 1
+ scroll_panel.panel_id 1
+ scroll_panel.author_id 1
+ scroll_panel.t 0
+ end
+
factory :original_picture, :class => OriginalPicture do |op|
op.ext 'png'
op.width 222
end
context 'コミックpage_size補正について' do
it '文字列から数値に変換される' do
- Author.comic_page_size('7').should eq 7
+ Author.scroll_page_size('7').should eq 7
end
- it 'nilの場合はAuthor.default_comic_page_sizeになる' do
- Author.comic_page_size().should eq Author.default_comic_page_size
+ it 'nilの場合はAuthor.default_scroll_page_sizeになる' do
+ Author.scroll_page_size().should eq Author.default_scroll_page_size
end
- it '0以下の場合はAuthor.default_comic_page_sizeになる' do
- Author.comic_page_size('0').should eq Author.default_comic_page_size
+ it '0以下の場合はAuthor.default_scroll_page_sizeになる' do
+ Author.scroll_page_size('0').should eq Author.default_scroll_page_size
end
- it 'Author.comic_max_page_sizeを超えた場合はAuthor.comic_max_page_sizeになる' do
- Author.comic_page_size('1000').should eq Author.comic_max_page_size
+ it 'Author.scroll_max_page_sizeを超えた場合はAuthor.scroll_max_page_sizeになる' do
+ Author.scroll_page_size('1000').should eq Author.scroll_max_page_size
end
end
context 'ストーリーpage_size補正について' do
it '文字列から数値に変換される' do
- Author.story_page_size('7').should eq 7
+ Author.scroll_panel_page_size('7').should eq 7
end
- it 'nilの場合はAuthor.default_story_page_sizeになる' do
- Author.story_page_size().should eq Author.default_story_page_size
+ it 'nilの場合はAuthor.default_scroll_panel_page_sizeになる' do
+ Author.scroll_panel_page_size().should eq Author.default_scroll_panel_page_size
end
- it '0以下の場合はAuthor.default_story_page_sizeになる' do
- Author.story_page_size('0').should eq Author.default_story_page_size
+ it '0以下の場合はAuthor.default_scroll_panel_page_sizeになる' do
+ Author.scroll_panel_page_size('0').should eq Author.default_scroll_panel_page_size
end
- it 'Author.story_max_page_sizeを超えた場合はAuthor.story_max_page_sizeになる' do
- Author.story_page_size('1000').should eq Author.story_max_page_size
+ it 'Author.scroll_panel_max_page_sizeを超えた場合はAuthor.scroll_panel_max_page_sizeになる' do
+ Author.scroll_panel_page_size('1000').should eq Author.scroll_panel_max_page_size
end
end
context 'コマpage_size補正について' do