end
before_filter :authenticate_admin!, :only => [:list, :browse]
- # GET /artists
- # GET /artists.json
def index
@page = Artist.page params[:page]
@page_size = Artist.page_size params[:page_size]
@artists = Artist.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Artist.list_paginate(@page, @page_size)
+ }
format.json { render :json => @artists.to_json(Artist.list_json_opt) }
end
end
- # GET /artists/1
- # GET /artists/1.json
def show
@ar = Artist.show(params[:id], [@user, @admin, @demand_user])
def resource_pictures
@ar = Artist.show(params[:id], [@user, @admin, @demand_user])
-
@page = Author.page params[:page]
@page_size = Author.resource_picture_page_size params[:page_size]
- @resource_pictures = ResourcePicture.mylist(@ar, @page, @page_size)
-
+ @resource_pictures = ResourcePicture.himlist(@ar, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = ResourcePicture.himlist_paginate(@ar, @page, @page_size)
+ }
format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
end
end
@authors = Author.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Author.list_paginate(@page, @page_size)
+ }
format.json { render :json => @authors.to_json(Author.list_json_opt) }
end
end
@comics = Comic.himlist(@au, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Comic.himlist_paginate(@au, @page, @page_size)
+ }
format.json { render json: @comics.to_json(Comic.list_json_opt) }
end
end
@stories = Story.himlist(@au, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Story.himlist_paginate(@au, @page, @page_size)
+ }
format.json { render json: @stories.to_json(Story.list_json_opt) }
end
end
@panels = Panel.himlist(@au, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Panel.himlist_paginate(@au, @page, @page_size)
+ }
format.json { render text: Panel.list_as_json_text(@panels) }
end
end
@panel_pictures = PanelPicture.himlist(@au, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = PanelPicture.himlist_paginate(@au, @page, @page_size)
+ }
format.json { render json: @panel_pictures.to_json(PanelPicture.list_json_opt) }
end
end
@ground_pictures = GroundPicture.himlist(@au, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundPicture.himlist_paginate(@au, @page, @page_size)
+ }
format.json { render json: @ground_pictures.to_json(GroundPicture.list_json_opt) }
end
end
@ground_colors = GroundColor.himlist(@au, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundColor.himlist_paginate(@au, @page, @page_size)
+ }
format.json { render json: @ground_colors.to_json(GroundColor.list_json_opt) }
end
end
- def panel_colors
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.panel_color_page_size params[:page_size]
- @panel_colors = PanelColor.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @panel_colors.to_json(PanelColor.list_json_opt) }
- end
- end
-
def count
@au = {:count => Author.visible_count}
respond_to do |format|
@page_size = Comic.page_size params[:page_size]
@comics = Comic.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Comic.list_paginate(@page, @page_size)
+ }
format.json { render json: @comics.to_json(Comic.list_json_opt) }
format.atom
format.rss
@ground_colors = GroundColor.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundColor.list_paginate(@page, @page_size)
+ }
format.json { render :json => @ground_colors.to_json(GroundColor.list_json_opt) }
end
end
@ground_pictures = GroundPicture.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundPicture.list_paginate(@page, @page_size)
+ }
format.json { render :json => @ground_pictures.to_json(GroundPicture.list_json_opt) }
end
end
@comics = Comic.mylist(@author, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Comic.mylist_paginate(@author, @page, @page_size)
+ }
format.json { render json: @comics.to_json(Comic.list_json_opt) }
end
end
@stories = Story.mylist(@author, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Story.mylist_paginate(@author, @page, @page_size)
+ }
format.json { render text: Story.list_as_json_text(@stories) }
end
end
@panels = Panel.mylist(@author, @page, @page_size)
respond_to do |format|
- format.html
+ format.html {
+ @paginate = Panel.mylist_paginate(@author, @page, @page_size)
+ }
format.json { render text: Panel.list_as_json_text(@panels) }
end
end
@panel_pictures = PanelPicture.mylist(@author, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = PanelPicture.mylist_paginate(@author, @page, @page_size)
+ }
format.json { render json: @panel_pictures.to_json(PanelPicture.list_json_opt) }
end
end
@ground_pictures = GroundPicture.mylist(@author, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundPicture.mylist_paginate(@author, @page, @page_size)
+ }
format.json { render json: @ground_pictures.to_json(GroundPicture.list_json_opt) }
end
end
@ground_colors = GroundColor.mylist(@author, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = GroundColor.mylist_paginate(@author, @page, @page_size)
+ }
format.json { render json: @ground_colors.to_json(GroundColor.list_json_opt) }
end
end
@resource_pictures = ResourcePicture.mylist(@artist, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = ResourcePicture.mylist_paginate(@author, @page, @page_size)
+ }
format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
end
end
before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy]
before_filter :authenticate_admin!, :only => [:list, :browse]
- # GET /original_pictures
- # GET /original_pictures.json
def index
@page = OriginalPicture.page params[:page]
@page_size = OriginalPicture.page_size params[:page_size]
- @original_pictures = OriginalPicture.mylist(@artist.id, @page, @page_size)
+ @original_pictures = OriginalPicture.mylist(@artist, @page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = OriginalPicture.mylist_paginate(@artist, @page, @page_size)
+ }
format.json { render json: @original_pictures.to_json(OriginalPicture.list_json_opt) }
end
end
- # GET /original_pictures/1
- # GET /original_pictures/1.json
def show
@original_picture = OriginalPicture.show(params[:id], [@artist, @admin])
@panel_pictures = PanelPicture.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = PanelPicture.list_paginate(@page, @page_size)
+ }
format.json { render :json => @panel_pictures.to_json(PanelPicture.list_json_opt) }
end
end
@panels = Panel.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Panel.list_paginate(@page, @page_size)
+ }
format.json { render text: Panel.list_as_json_text(@panels) }
format.atom
format.rss { render :layout => false }
end
before_filter :authenticate_admin!, :only => [:list, :browse]
- # GET /resource_pictures
- # GET /resource_pictures.json
def index
@page = ResourcePicture.page params[:page]
@page_size = ResourcePicture.page_size params[:page_size]
@resource_pictures = ResourcePicture.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = ResourcePicture.list_paginate(@page, @page_size)
+ }
format.json { render :json => @resource_pictures.to_json(ResourcePicture.list_json_opt) }
end
end
- # GET /resource_pictures/1
- # GET /resource_pictures/1.json
def show
@resource_picture = ResourcePicture.show(params[:id], [@user, @admin, @demand_user])
@stories = Story.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = Story.list_paginate(@page, @page_size)
+ }
format.json { render :json => @stories.to_json(Story.list_json_opt) }
end
end
@stories = Story.play_list(@comic, @author, @offset, @panel_count)
respond_to do |format|
format.html {
+ @paginate = Story.play_list_paginate(@comic, @offset, @panel_count)
if @author
@new_panels = Panel.mylist(@author, 0, 5)
end
offset
end
+ def self.list_where
+ 'artists.author_id is not null'
+ end
+
def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(Artist.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['artists.author_id is not null'], :order => 'artists.created_at desc'})
- Artist.find(:all, opt)
+ Artist.where(self.list_where()).includes(Artist.list_opt).order('artists.created_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(Artist.where(self.list_where()).count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {:author => {}} }
+ {:author => {} }
end
def self.list_json_opt
end
def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(Author.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:order => 'created_at desc'})
- Author.find(:all, opt)
+ Author.includes(Author.list_opt).order('authors.created_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(Author.count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {:artist => {}} }
+ {:artist => {} }
end
def self.list_json_opt
end
def self.default_resource_picture_page_size
- 100
+ 25
end
def self.resource_picture_max_page_size
page_size
end
- def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(Comic.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['visible > 0'], :order => 'updated_at desc'})
- Comic.find(:all, opt)
+ def self.list_where
+ 'comics.visible > 0'
end
- def self.list_opt
- {:include => {:stories => {:panel => {}}, :author => {}}}
+ def self.mylist_where au
+ ['comics.author_id = ?', au.id]
end
- def self.list_json_opt
- {:include => {:stories => {:include => {:panel => {}}}, :author => {}}}
+ 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
- opt = {}
- opt.merge!(Comic.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['comics.author_id = ?', au.id], :order => 'comics.updated_at desc'})
- Comic.find(:all, opt)
+ 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
- opt = {}
- opt.merge!(Comic.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['comics.author_id = ? and visible > 0', au.id], :order => 'comics.updated_at desc'})
- Comic.find(:all, opt)
+ 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
page_size
end
+ def self.list_where
+ 'panels.publish > 0'
+ end
+
+ def self.mylist_where au
+ ['panels.author_id = ?', au.id]
+ end
+
+ def self.himlist_where au
+ ['panels.author_id = ? and panels.publish > 0', au.id]
+ end
+
def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(GroundColor.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => 'panels.publish > 0', :order => 'ground_colors.updated_at desc'})
- GroundColor.find(:all, opt)
+ GroundColor.where(self.list_where()).includes(GroundColor.list_opt).order('ground_colors.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.mylist au, page = 1, page_size = Author.default_ground_color_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ?', au.id], :order => 'ground_colors.updated_at desc'})
- GroundColor.find(:all, opt)
+ GroundColor.where(self.mylist_where(au)).includes(GroundColor.list_opt).order('ground_colors.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.himlist au, page = 1, page_size = Author.default_ground_color_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'ground_colors.updated_at desc'})
- GroundColor.find(:all, opt)
+ GroundColor.where(self.himlist_where(au)).includes(GroundColor.list_opt).order('ground_colors.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(GroundColor.where(self.list_where()).includes(GroundColor.list_opt).count, nil)).page(page).per(page_size)
+ end
+
+ def self.mylist_paginate au, page = 1, page_size = Author.default_ground_color_page_size
+ Kaminari.paginate_array(Array.new(GroundColor.where(self.mylist_where(au)).includes(GroundColor.list_opt).count, nil)).page(page).per(page_size)
+ end
+
+ def self.himlist_paginate au, page = 1, page_size = Author.default_ground_color_page_size
+ Kaminari.paginate_array(Array.new(GroundColor.where(self.himlist_where(au)).includes(GroundColor.list_opt).count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {:panel => {:author => {}} }}
+ {:panel => {:author => {}} }
end
def self.list_json_opt
page_size
end
+ def self.list_where
+ 'panels.publish > 0'
+ end
+
+ def self.mylist_where au
+ ['panels.author_id = ?', au.id]
+ end
+
+ def self.himlist_where au
+ ['panels.author_id = ? and panels.publish > 0', au.id]
+ end
+
def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(GroundPicture.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => 'panels.publish > 0', :order => 'ground_pictures.updated_at desc'})
- GroundPicture.find(:all, opt)
+ GroundPicture.where(self.list_where()).includes(GroundPicture.list_opt).order('ground_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.mylist au, page = 1, page_size = Author.default_ground_picture_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ?', au.id], :order => 'ground_pictures.updated_at desc'})
- GroundPicture.find(:all, opt)
+ GroundPicture.where(self.mylist_where(au)).includes(GroundPicture.list_opt).order('ground_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.himlist au, page = 1, page_size = Author.default_ground_picture_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'ground_pictures.updated_at desc'})
- GroundPicture.find(:all, opt)
+ GroundPicture.where(self.himlist_where(au)).includes(GroundPicture.list_opt).order('ground_pictures.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(GroundPicture.where(self.list_where()).includes(GroundPicture.list_opt).count, nil)).page(page).per(page_size)
+ end
+
+ def self.mylist_paginate au, page = 1, page_size = Author.default_ground_picture_page_size
+ Kaminari.paginate_array(Array.new(GroundPicture.where(self.mylist_where(au)).includes(GroundPicture.list_opt).count, nil)).page(page).per(page_size)
+ end
+
+ def self.himlist_paginate au, page = 1, page_size = Author.default_ground_picture_page_size
+ Kaminari.paginate_array(Array.new(GroundPicture.where(self.himlist_where(au)).includes(GroundPicture.list_opt).count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
+ {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}} }
end
def self.list_json_opt
page_size
end
- def self.mylist artist_id, page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['original_pictures.artist_id = ?', artist_id], :order => 'original_pictures.updated_at desc'})
- OriginalPicture.find(:all, opt)
+ def self.mylist_where ar
+ ['original_pictures.artist_id = ?', ar.id]
end
- def history
- Picture.find(:all, {:conditions => ['pictures.original_picture_id = ?', self.id], :order => 'pictures.revision desc'} )
+ def self.mylist ar, page = 1, page_size = self.default_page_size
+ OriginalPicture.where(self.mylist_where(ar)).includes(OriginalPicture.list_opt).order('original_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
+ end
+
+ def self.mylist_paginate ar, page = 1, page_size = self.default_page_size
+ Kaminari.paginate_array(Array.new(OriginalPicture.where(self.mylist_where(ar)).count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {:resource_picture => {}, :pictures => {}}}
+ {:resource_picture => {}, :pictures => {} }
end
def self.list_json_opt
{:include => {:resource_picture => {}, :pictures => {}}}
end
+ def history
+ Picture.find(:all, {:conditions => ['pictures.original_picture_id = ?', self.id], :order => 'pictures.revision desc'} )
+ end
+
def self.show cid, roles
opt = {}
opt.merge!(self.show_opt)
page_size
end
+ def self.list_where
+ 'panels.publish > 0'
+ end
+
+ def self.mylist_where au
+ ['panels.author_id = ?', au.id]
+ end
+
+ def self.himlist_where au
+ ['panels.author_id = ? and panels.publish > 0', au.id]
+ end
+
def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => 'panels.publish > 0', :order => 'panels.updated_at desc'})
- Panel.find(:all, opt)
+ Panel.where(self.list_where()).includes(Panel.list_opt).order('panels.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.mylist au, page = 1, page_size = Author.default_panel_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ?', au.id], :order => 'panels.updated_at desc'})
- Panel.find(:all, opt)
+ Panel.where(self.mylist_where(au)).includes(Panel.list_opt).order('panels.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.himlist au, page = 1, page_size = Author.default_panel_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'panels.updated_at desc'})
- Panel.find(:all, opt)
+ Panel.where(self.himlist_where(au)).includes(Panel.list_opt).order('panels.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(Panel.where(self.list_where()).count, nil)).page(page).per(page_size)
+ end
+
+ def self.mylist_paginate au, page = 1, page_size = Author.default_panel_page_size
+ Kaminari.paginate_array(Array.new(Panel.where(self.mylist_where(au)).count, nil)).page(page).per(page_size)
+ end
+
+ def self.himlist_paginate au, page = 1, page_size = Author.default_panel_page_size
+ Kaminari.paginate_array(Array.new(Panel.where(self.himlist_where(au)).count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {
+ {
:panel_pictures => {
:picture => {:artist => {}, :license => {}}
},
:ground_colors => {
},
:author => {}
- }}
+ }
end
def self.show rid, roles
page_size
end
+ def self.list_where
+ 'panels.publish > 0'
+ end
+
+ def self.mylist_where au
+ ['panels.author_id = ?', au.id]
+ end
+
+ def self.himlist_where au
+ ['panels.author_id = ? and panels.publish > 0', au.id]
+ end
+
def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(PanelPicture.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => 'panels.publish > 0', :order => 'panel_pictures.updated_at desc'})
- PanelPicture.find(:all, opt)
+ PanelPicture.where(self.list_where()).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.mylist au, page = 1, page_size = Author.default_panel_picture_page_size
- opt = {}
- opt.merge!(PanelPicture.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ?', au.id], :order => 'panel_pictures.updated_at desc'})
- PanelPicture.find(:all, opt)
+ PanelPicture.where(self.mylist_where(au)).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
def self.himlist au, page = 1, page_size = Author.default_panel_picture_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'panel_pictures.updated_at desc'})
- PanelPicture.find(:all, opt)
+ PanelPicture.where(self.himlist_where(au)).includes(PanelPicture.list_opt).order('panel_pictures.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(PanelPicture.where(self.list_where()).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size)
+ end
+
+ def self.mylist_paginate au, page = 1, page_size = Author.default_panel_picture_page_size
+ Kaminari.paginate_array(Array.new(PanelPicture.where(self.mylist_where(au)).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size)
+ end
+
+ def self.himlist_paginate au, page = 1, page_size = Author.default_panel_picture_page_size
+ Kaminari.paginate_array(Array.new(PanelPicture.where(self.himlist_where(au)).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
+ {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}} }
end
def self.list_json_opt
end
def self.default_page_size
- 100 #25
+ 25
end
def self.max_page_size
page_size
end
+ def self.mylist_where ar
+ ['resource_pictures.artist_id = ?', ar.id]
+ end
+
+ def self.himlist_where ar
+ ['resource_pictures.artist_id = ?', ar.id]
+ end
+
def self.list page = 1, page_size = self.default_page_size
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:order => 'updated_at desc'})
- ResourcePicture.find(:all, opt)
+ ResourcePicture.includes(ResourcePicture.list_opt).order('resource_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
+ end
+
+ def self.mylist ar, page = 1, page_size = Author.default_resource_picture_page_size
+ ResourcePicture.where(self.mylist_where(ar)).includes(ResourcePicture.list_opt).order('resource_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size)
+ end
+
+ def self.himlist ar, page = 1, page_size = Author.default_resource_picture_page_size
+ ResourcePicture.where(self.himlist_where(ar)).includes(ResourcePicture.list_opt).order('resource_pictures.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(ResourcePicture.count, nil)).page(page).per(page_size)
+ end
+
+ def self.mylist_paginate ar, page = 1, page_size = Author.default_resource_picture_page_size
+ Kaminari.paginate_array(Array.new(ResourcePicture.where(self.mylist_where(ar)).count, nil)).page(page).per(page_size)
+ end
+
+ def self.himlist_paginate ar, page = 1, page_size = Author.default_resource_picture_page_size
+ Kaminari.paginate_array(Array.new(ResourcePicture.where(self.himlist_where(ar)).count, nil)).page(page).per(page_size)
end
def self.list_opt
- {:include => {:license => {}, :artist => {}, :picture => {}} }
+ {:license => {}, :artist => {}, :picture => {} }
end
def self.list_json_opt
{:include => {:license => {}, :artist => {}, :picture => {}} }
end
- def self.mylist ar, page = 1, page_size = Author.default_resource_picture_page_size
- opt = {}
- opt.merge!(ResourcePicture.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['resource_pictures.artist_id = ?', ar.id], :order => 'resource_pictures.updated_at desc'})
- ResourcePicture.find(:all, opt)
- end
-
def self.show rid, roles
opt = {}
opt.merge!(self.show_opt)
count
end
- def self.play_list comic, author, offset = 0, limit = Story.default_panel_size
- opt = {}
- opt.merge!(Story.list_opt)
- opt.merge!({:offset => offset, :limit => limit}) if limit > 0
- opt.merge!({:conditions => ['stories.comic_id = ?', comic.id], :order => 'stories.t'})
- Story.find(:all, opt)
- end
-
- def self.list_opt
- {:include => {
- :author => {},
- :comic => {
- :author => {}
- },
- :panel => {
- :author => {},
- :panel_pictures => {:picture => {:artist => {}, :license => {}}},
- :speech_balloons =>{:balloons => {}, :speeches => {}}
- }
- }}
- end
-
- def self.list_json_opt
- {:include => {
- :author => {},
- :comic => {
- :author => {}
- },
- :panel => {
- :author => {},
- :panel_pictures => {:picture => {:artist => {}, :license => {}}},
- :speech_balloons =>{:balloons => {}, :speeches => {}}
- }
- }}
- end
-
def self.default_page_size
25
end
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
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['comics.visible > 0'], :order => 'stories.updated_at desc'})
- Story.find(:all, opt)
+ 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
- opt = {}
- opt.merge!(Story.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['stories.author_id = ?', au.id], :order => 'stories.updated_at desc'})
- Story.find(:all, opt)
+ 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
- opt = {}
- opt.merge!(Story.list_opt)
- opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:conditions => ['stories.author_id = ? and comics.visible > 0', au.id], :order => 'stories.updated_at desc'})
- Story.find(:all, opt)
+ 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.play_list_paginate comic, author, offset = 0, limit = Story.default_panel_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 =>{:balloons => {}, :speeches => {}}
+ }
+ }
+ end
+
+ def self.list_json_opt
+ {:include => {
+ :author => {},
+ :comic => {
+ :author => {}
+ },
+ :panel => {
+ :author => {},
+ :panel_pictures => {:picture => {:artist => {}, :license => {}}},
+ :speech_balloons =>{:balloons => {}, :speeches => {}}
+ }
+ }}
end
def self.show sid, roles
</tr>
<% end %>
</table>
+<%= paginate(@paginate) %>
</tr>
<% end %>
</table>
+<%= paginate(@paginate) %>
</tr>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('comics.new.title'), new_comic_path %>
<%= render 'ground_colors/list_item', :ground_color => ground_color, :author => @author %>
<% end -%>
</table>
+<%= paginate(@paginate) %>
<%= render 'ground_pictures/list_item', :ground_picture => gp %>
<% end %>
</table>
+<%= paginate(@paginate) %>
</tr>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= render 'panel_pictures/list_item', :panel_picture => panel_picture %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<% @panels.each do |panel| %>
<%= render 'panels/standard', :panel => panel, :author => @author %>
<% end %>
+<%= paginate(@paginate) %>
<%= link_to t('panels.new.title'), new_panel_path %>
<%= render 'stories/list_item', :story => story, :author => @author %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('stories.new.title'), new_story_path %>
<%= render 'list_item', :comic => comic, :author => @author %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('comics.new.title'), new_comic_path %>
<%= render 'list_item', :ground_color => gc %>
<% end -%>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('ground_colors.new.title'), new_ground_color_path %>
<%= render 'list_item', :ground_picture => gp %>
<% end -%>
</table>
+<%= paginate(@paginate) %>
<%= render 'comics/list_item', :comic => comic, :author => @author %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('comics.new.title'), new_comic_path %>
<%= render 'ground_colors/list_item', :ground_color => gc, :author => @author %>
<% end -%>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('ground_colors.new.title'), new_ground_color_path %>
<%= render 'ground_pictures/list_item', :ground_picture => gp %>
<% end -%>
</table>
+<%= paginate(@paginate) %>
<%= render 'panel_pictures/list_item', :panel_picture => panel_picture %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= render 'panels/standard', :panel => panel, :author => @author %>
</div>
<% end %>
+<%= paginate(@paginate) %>
<%= link_to t('panels.new.title'), new_panel_path %>
</tr>
<% end %>
</table>
+<%= paginate(@resource_pictures) %>
<%= render 'stories/list_item', :story => story, :author => @author %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('stories.new.title'), new_story_path %>
</tr>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= render 'list_item', :panel_picture => panel_picture %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<% @panels.each do |panel| %>
<%= render 'standard', :panel => panel, :author => @author %>
<% end %>
+<%= paginate(@paginate) %>
<%= link_to t('panels.new.title'), new_panel_path %>
<%= render 'list_item', :resource_picture => resource_picture %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= render 'list_item', :story => story, :author => @author %>
<% end %>
</table>
+<%= paginate(@paginate) %>
<%= link_to t('stories.new.title'), new_story_path %>
assigns(:artists).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")
@op = FactoryGirl.create :original_picture, :artist_id => @other_artist.id
@p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @other_artist.id
@rp = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
- ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
+ Artist.stub(:show).and_return(@artist)
+ ResourcePicture.stub(:himlist).and_return([@rp, @rp, @rp], [nil, nil, nil])
sign_in @user
end
context 'パラメータpageについて' do
get :resource_pictures, :id => @other_artist.id
end
it '素材モデルに一覧を問い合わせている' do
- ResourcePicture.should_receive(:mylist).exactly(1)
+ ResourcePicture.should_receive(:himlist).exactly(1)
get :resource_pictures, :id => @other_artist.id
end
it '@resource_picturesにリストを取得している' do
assigns(:resource_pictures).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :resource_pictures, :id => @other_artist.id
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'resource_pictureテンプレートを描画する' do
get :resource_pictures, :id => @other_artist.id
response.should render_template("resource_pictures")
assigns(:authors).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")
@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
+ Author.stub(:show).and_return(@other_author)
Comic.stub(:himlist).and_return([@comic, @comic, @comic])
sign_in @user
end
assigns(:comics).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :comics, :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")
@comic = FactoryGirl.create :comic, :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
+ Author.stub(:show).and_return(@other_author)
Story.stub(:himlist).and_return([@story, @story, @story])
sign_in @user
end
assigns(:stories).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :stories, :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")
@other_author = FactoryGirl.create :author, :user_id => @other_user.id
@other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
@panel = FactoryGirl.create :panel, :author_id => @other_author.id
+ Author.stub(:show).and_return(@other_author)
Panel.stub(:himlist).and_return([@panel, @panel, @panel])
sign_in @user
end
assigns(:panels).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :panels, :id => @other_author.id
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'panelsテンプレートを描画する' do
get :panels, :id => @other_author.id
response.should render_template("panels")
@rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
@panel = FactoryGirl.create :panel, :author_id => @author.id
@panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
+ Author.stub(:show).and_return(@other_author)
PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
sign_in @user
end
assigns(:panel_pictures).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :panel_pictures, :id => @other_author.id
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'panel_picturesテンプレートを描画する' do
get :panel_pictures, :id => @other_author.id
response.should render_template("panel_pictures")
@rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
@panel = FactoryGirl.create :panel, :author_id => @author.id
@ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ Author.stub(:show).and_return(@other_author)
GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
sign_in @user
end
assigns(:ground_pictures).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :ground_pictures, :id => @other_author.id
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'ground_picturesテンプレートを描画する' do
get :ground_pictures, :id => @other_author.id
response.should render_template("ground_pictures")
@other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
@gc = FactoryGirl.create :ground_color
@panel = FactoryGirl.create :panel, :author_id => @author.id
+ Author.stub(:show).and_return(@other_author)
GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
sign_in @user
end
assigns(:ground_colors).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :ground_colors, :id => @other_author.id
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'ground_colorsテンプレートを描画する' do
get :ground_colors, :id => @other_author.id
response.should render_template("ground_colors")
assigns(:comics).should have_at_least(3).items\r
end\r
context 'html形式' do\r
+ it '@paginateにページ制御を取得している' do\r
+ get :index\r
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
it 'indexテンプレートを描画する' do\r
get :index\r
response.should render_template("index")\r
assigns(:ground_colors).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")
assigns(:ground_pictures).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")
assigns(:comics).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :comics
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'comicsテンプレートを描画する' do
get :comics
response.should render_template("comics")
assigns(:panels).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :panels
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'ステータスコード200 OKを返す' do
get :panels
response.should be_success
end
context 'つつがなく終わるとき' do
it 'ステータスコード200 OKを返す' do
- get :panel_pictures
response.should be_success
end
it 'コマ絵モデルに一覧を問い合わせている' do
assigns(:panel_pictures).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :panel_pictures
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'panel_picturesテンプレートを描画する' do
get :panel_pictures
response.should render_template("panel_pictures")
assigns(:ground_pictures).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :ground_pictures
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'ground_picturesテンプレートを描画する' do
get :ground_pictures
response.should render_template("ground_pictures")
assigns(:ground_colors).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :ground_colors
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'ground_colorsテンプレートを描画する' do
get :ground_colors
response.should render_template("ground_colors")
assigns(:resource_pictures).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :resource_pictures
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'resource_picturesテンプレートを描画する' do
get :resource_pictures
response.should render_template("resource_pictures")
assigns(:original_pictures).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")
assigns(:panel_pictures).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")
assigns(:panels).should have_at_least(3).items\r
end\r
context 'html形式' do\r
+ it '@paginateにページ制御を取得している' do\r
+ get :index\r
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
it 'ステータスコード200 OKを返す' do\r
get :index\r
response.should be_success \r
assigns(:resource_pictures).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 'ステータスコード200 OKを返す' do
get :index
response.should be_success
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")
assigns(:stories).should have_at_least(3).items
end
context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :comic, :id => @comic.id
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
it 'ステータスコード200 OKを返す' do
get :comic, :id => @comic.id
response.should be_success
r.should eq [@artist]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @artist2 = FactoryGirl.create :artist, :author_id => @author.id, :name => 'artist2', :created_at => Time.now + 100
- @artist3 = FactoryGirl.create :artist, :author_id => @author.id, :name => 'artist3', :created_at => Time.now + 200
- @artist4 = FactoryGirl.create :artist, :author_id => @author.id, :name => 'artist4', :created_at => Time.now + 300
- @artist5 = FactoryGirl.create :artist, :author_id => @author.id, :name => 'artist5', :created_at => Time.now + 400
- Artist.stub(:default_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = Artist.list 5, 0
- r.should have(5).items
- end
+ end
+
+ describe '一覧ページ制御に於いて' do
+ before do
+ Artist.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = Artist.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '一覧の取得条件を利用している' do
+ Artist.stub(:list_where).with(any_args).and_return('')
+ Artist.should_receive(:list_where).with(any_args).exactly(1)
+ r = Artist.list_paginate
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = Artist.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
end
end
+
describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = Artist.list_opt
- r.has_key?(:include).should be_true
- end
it '1つの項目を含んでいる' do
- r = Artist.list_opt[:include]
+ r = Artist.list_opt
r.should have(1).items
end
it '作家を含んでいる' do
- r = Artist.list_opt[:include]
+ r = Artist.list_opt
r.has_key?(:author).should be_true
end
end
r.should eq [@author]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @other_user2 = FactoryGirl.create :user_yas
- @author2 = FactoryGirl.create :author, :user_id => @other_user2.id
- @author2.created_at = Time.now + 100
- @author2.save
- @other_user3 = FactoryGirl.create :user_yas
- @author3 = FactoryGirl.create :author, :user_id => @other_user3.id
- @author3.created_at = Time.now + 200
- @author3.save
- @other_user4 = FactoryGirl.create :user_yas
- @author4 = FactoryGirl.create :author, :user_id => @other_user4.id
- @author4.created_at = Time.now + 300
- @author4.save
- @other_user5 = FactoryGirl.create :user_yas
- @author5 = FactoryGirl.create :author, :user_id => @other_user5.id
- @author5.created_at = Time.now + 400
- @author5.save
- Author.stub(:default_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = Author.list 5, 0
- r.should have(5).items
- end
+ end
+
+ describe '一覧ページ制御に於いて' do
+ before do
+ Author.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = Author.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = Author.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
end
end
+
describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = Author.list_opt
- r.has_key?(:include).should be_true
- end
it '1つの項目を含んでいる' do
- r = Author.list_opt[:include]
+ r = Author.list_opt
r.should have(1).items
end
it '絵師を含んでいる' do
- r = Author.list_opt[:include]
+ r = Author.list_opt
r.has_key?(:artist).should be_true
end
end
c.should eq [@comic]
end
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 '件数0は全件(5件)を返す' do
- r = Comic.list 5, 0
- r.should have(5).items
- end
- end
- end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = Comic.list_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = Comic.list_opt[:include]
- r.should have(2).items
- end
- it 'ストーリーを含んでいる' do
- r = Comic.list_opt[:include]
- r.has_key?(:stories).should be_true
- end
- it 'ストーリーはコマを含んでいる' do
- r = Comic.list_opt[:include]
- r[:stories].has_key?(:panel).should be_true
- end
- it '作家を含んでいる' do
- r = Comic.list_opt[:include]
- 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
c.should eq [@comic]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' 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
- Author.stub(:default_comic_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = Comic.mylist @author, 5, 0
- r.should have(5).items
- end
- end
end
describe '他作家のコミック一覧取得に於いて' do
c.should eq [@other_comic]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' 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
- Author.stub(:default_comic_page_size).and_return(2)
+ 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 '通常は全件(5件)を返す' do
- r = Comic.himlist @other_author, 5, 0
- r.should have(5).items
+ 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
pl.should eq [@gc]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @gc2 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 1, :updated_at => Time.now + 100
- @gc3 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 2, :updated_at => Time.now + 200
- @gc4 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 3, :updated_at => Time.now + 300
- @gc5 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 4, :updated_at => Time.now + 400
- GroundColor.stub(:default_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = GroundColor.list 5, 0
- r.should have(5).items
- end
- end
end
describe '自分のコマで使った色地一覧取得に於いて' do
c.should eq [@gc]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @gc2 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 1, :updated_at => Time.now + 100
- @gc3 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 2, :updated_at => Time.now + 200
- @gc4 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 3, :updated_at => Time.now + 300
- @gc5 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 4, :updated_at => Time.now + 400
- Author.stub(:default_ground_color_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = GroundColor.mylist @author, 5, 0
- r.should have(5).items
- end
- end
end
describe '他作家の色地一覧取得に於いて' do
pl.should eq [@other_gc]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @other_gc2 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :updated_at => Time.now + 100
- @other_gc3 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :updated_at => Time.now + 200
- @other_gc4 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :updated_at => Time.now + 300
- @other_gc5 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :updated_at => Time.now + 400
- Author.stub(:default_ground_color_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = GroundColor.himlist @other_author, 5, 0
- r.should have(5).items
- end
+ end
+
+ describe '色地一覧ページ制御に於いて' do
+ before do
+ GroundColor.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundColor.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '色地一覧の取得条件を利用している' do
+ GroundColor.stub(:list_where).with(any_args).and_return('')
+ GroundColor.should_receive(:list_where).with(any_args).exactly(1)
+ r = GroundColor.list_paginate
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundColor.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = GroundColor.list_opt
- r.has_key?(:include).should be_true
+ describe '自分の色地一覧ページ制御に於いて' do
+ before do
+ GroundColor.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundColor.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '自分の色地一覧の取得条件を利用している' do
+ GroundColor.stub(:mylist_where).with(any_args).and_return('')
+ GroundColor.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = GroundColor.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundColor.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
end
+ end
+
+ describe '他作家の色地一覧ページ制御に於いて' do
+ before do
+ GroundColor.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundColor.himlist_paginate @other_author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '他作家の色地一覧の取得条件を利用している' do
+ GroundColor.stub(:himlist_where).with(any_args).and_return('')
+ GroundColor.should_receive(:himlist_where).with(any_args).exactly(1)
+ r = GroundColor.himlist_paginate @other_author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundColor.himlist_paginate @other_author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
it '1つの項目を含んでいる' do
- r = GroundColor.list_opt[:include]
+ r = GroundColor.list_opt
r.should have(1).items
end
it 'コマを含んでいる' do
- r = GroundColor.list_opt[:include]
+ r = GroundColor.list_opt
r.has_key?(:panel).should be_true
end
it 'コマは作家を含んでいる' do
- r = GroundColor.list_opt[:include]
+ r = GroundColor.list_opt
r[:panel].has_key?(:author).should be_true
end
end
pl.should eq [@gp]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @gp2 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 1, :picture_id => @p.id, :updated_at => Time.now + 100
- @gp3 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 2, :picture_id => @p.id, :updated_at => Time.now + 200
- @gp4 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 3, :picture_id => @p.id, :updated_at => Time.now + 300
- @gp5 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 4, :picture_id => @p.id, :updated_at => Time.now + 400
- GroundPicture.stub(:default_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = GroundPicture.list 5, 0
- r.should have(5).items
- end
- end
end
describe '自分のコマで使った絵地一覧取得に於いて' do
c.should eq [@gp]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @gp2 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 1, :picture_id => @p.id, :updated_at => Time.now + 100
- @gp3 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 2, :picture_id => @p.id, :updated_at => Time.now + 200
- @gp4 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 3, :picture_id => @p.id, :updated_at => Time.now + 300
- @gp5 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 4, :picture_id => @p.id, :updated_at => Time.now + 400
- Author.stub(:default_ground_picture_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = GroundPicture.mylist @author, 5, 0
- r.should have(5).items
- end
- end
end
describe '他作家の絵地一覧取得に於いて' do
pl.should eq [@other_gp]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @other_gp2 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 100
- @other_gp3 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 200
- @other_gp4 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 300
- @other_gp5 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 400
- Author.stub(:default_ground_picture_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = GroundPicture.himlist @other_author, 5, 0
- r.should have(5).items
- end
+ end
+
+ describe '絵地一覧ページ制御に於いて' do
+ before do
+ GroundPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundPicture.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '絵地一覧の取得条件を利用している' do
+ GroundPicture.stub(:list_where).with(any_args).and_return('')
+ GroundPicture.should_receive(:list_where).with(any_args).exactly(1)
+ r = GroundPicture.list_paginate
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundPicture.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = GroundPicture.list_opt
- r.has_key?(:include).should be_true
+ describe '自分の絵地一覧ページ制御に於いて' do
+ before do
+ GroundPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundPicture.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
end
+ it '自分の絵地一覧の取得条件を利用している' do
+ GroundPicture.stub(:mylist_where).with(any_args).and_return('')
+ GroundPicture.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = GroundPicture.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundPicture.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '他作家の絵地一覧ページ制御に於いて' do
+ before do
+ GroundPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = GroundPicture.himlist_paginate @other_author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '他作家の絵地一覧の取得条件を利用している' do
+ GroundPicture.stub(:himlist_where).with(any_args).and_return('')
+ GroundPicture.should_receive(:himlist_where).with(any_args).exactly(1)
+ r = GroundPicture.himlist_paginate @other_author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = GroundPicture.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 = GroundPicture.list_opt[:include]
+ r = GroundPicture.list_opt
r.should have(2).items
end
it 'コマを含んでいる' do
- r = GroundPicture.list_opt[:include]
+ r = GroundPicture.list_opt
r.has_key?(:panel).should be_true
end
it 'コマは作家を含んでいる' do
- r = GroundPicture.list_opt[:include]
+ r = GroundPicture.list_opt
r[:panel].has_key?(:author).should be_true
end
it '実素材を含んでいる' do
- r = GroundPicture.list_opt[:include]
+ r = GroundPicture.list_opt
r.has_key?(:picture).should be_true
end
it '実素材は絵師を含んでいる' do
- r = GroundPicture.list_opt[:include]
+ r = GroundPicture.list_opt
r[:picture].has_key?(:artist).should be_true
end
it '実素材はライセンスを含んでいる' do
- r = GroundPicture.list_opt[:include]
+ r = GroundPicture.list_opt
r[:picture].has_key?(:license).should be_true
end
end
end
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = OriginalPicture.list_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = OriginalPicture.list_opt[:include]
- r.should have(2).items
- end
- it '素材を含んでいる' do
- r = OriginalPicture.list_opt[:include]
- r.has_key?(:resource_picture).should be_true
- end
- it '実素材を含んでいる' do
- r = OriginalPicture.list_opt[:include]
- r.has_key?(:pictures).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 = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('resource_picture').should be_true
- end
- it '実素材を含んでいる' do
- r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('pictures').should be_true
- end
- end
describe '自分の原画一覧取得に於いて' do
before do
r.should eq [@op]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
- @op3 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 200
- @op4 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 300
- @op5 = FactoryGirl.create :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 400
- OriginalPicture.stub(:default_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = OriginalPicture.mylist @artist, 5, 0
- r.should have(5).items
- end
+ end
+
+ describe '自分の原画一覧ページ制御に於いて' do
+ before do
+ OriginalPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = OriginalPicture.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '自分の原画一覧の取得条件を利用している' do
+ OriginalPicture.stub(:mylist_where).with(any_args).and_return('')
+ OriginalPicture.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = OriginalPicture.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = OriginalPicture.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
+ it '2つの項目を含んでいる' do
+ r = OriginalPicture.list_opt
+ r.should have(2).items
+ end
+ it '素材を含んでいる' do
+ r = OriginalPicture.list_opt
+ r.has_key?(:resource_picture).should be_true
+ end
+ it '実素材を含んでいる' do
+ r = OriginalPicture.list_opt
+ r.has_key?(:pictures).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 = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('resource_picture').should be_true
+ end
+ it '実素材を含んでいる' do
+ r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('pictures').should be_true
end
end
end
end
-
describe '一覧取得に於いて' do
before do
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
pl.should eq [@pp]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @npl2 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
- @npl3 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 2, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 200
- @npl4 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 3, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 300
- @npl5 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 4, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 400
- PanelPicture.stub(:default_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = PanelPicture.list 5, 0
- r.should have(5).items
- end
- end
end
describe '自分のコマ絵一覧取得に於いて' do
r.should eq [@pp]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @npl2 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
- @npl3 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 2, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 200
- @npl4 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 3, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 300
- @npl5 = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 4, :picture_id => @p.id,
- :width => @p.width, :height => @p.height, :updated_at => Time.now + 400
- Author.stub(:default_panel_picture_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = PanelPicture.mylist @author, 5, 0
- r.should have(5).items
- end
- end
end
describe '他作家のコマ絵一覧取得に於いて' do
pl.should eq [@other_pp]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @other_pp2 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 1, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
- @other_pp3 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 2, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 200
- @other_pp4 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 3, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 300
- @other_pp5 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 4, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 400
- Author.stub(:default_panel_picture_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = PanelPicture.himlist @other_author, 5, 0
- r.should have(5).items
- end
+ end
+
+ describe 'コマ絵一覧ページ制御に於いて' do
+ before do
+ PanelPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = PanelPicture.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it 'コマ絵一覧の取得条件を利用している' do
+ PanelPicture.stub(:list_where).with(any_args).and_return('')
+ PanelPicture.should_receive(:list_where).with(any_args).exactly(1)
+ r = PanelPicture.list_paginate
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = PanelPicture.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = PanelPicture.list_opt
- r.has_key?(:include).should be_true
+ describe '自分のコマ絵一覧ページ制御に於いて' do
+ before do
+ PanelPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = PanelPicture.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
end
+ it '自分のコマ絵一覧の取得条件を利用している' do
+ PanelPicture.stub(:mylist_where).with(any_args).and_return('')
+ PanelPicture.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = PanelPicture.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = PanelPicture.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '他作家のコマ絵一覧ページ制御に於いて' do
+ before do
+ PanelPicture.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = PanelPicture.himlist_paginate @other_author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '他作家のコマ絵一覧の取得条件を利用している' do
+ PanelPicture.stub(:himlist_where).with(any_args).and_return('')
+ PanelPicture.should_receive(:himlist_where).with(any_args).exactly(1)
+ r = PanelPicture.himlist_paginate @other_author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = PanelPicture.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 = PanelPicture.list_opt[:include]
+ r = PanelPicture.list_opt
r.should have(2).items
end
it 'コマを含んでいる' do
- r = PanelPicture.list_opt[:include]
+ r = PanelPicture.list_opt
r.has_key?(:panel).should be_true
end
it 'コマは作家を含んでいる' do
- r = PanelPicture.list_opt[:include]
+ r = PanelPicture.list_opt
r[:panel].has_key?(:author).should be_true
end
it '実素材を含んでいる' do
- r = PanelPicture.list_opt[:include]
+ r = PanelPicture.list_opt
r.has_key?(:picture).should be_true
end
it '実素材は絵師を含んでいる' do
- r = PanelPicture.list_opt[:include]
+ r = PanelPicture.list_opt
r[:picture].has_key?(:artist).should be_true
end
it '実素材はライセンスを含んでいる' do
- r = PanelPicture.list_opt[:include]
+ r = PanelPicture.list_opt
r[:picture].has_key?(:license).should be_true
end
end
pl.should eq [@panel]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
- before do\r
- @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
- @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
- @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
- @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
- Panel.stub(:default_page_size).and_return(2)\r
- end\r
- it '件数0は全件(5件)を返す' do\r
- r = Panel.list 5, 0\r
- r.should have(5).items \r
- end\r
- end\r
end\r
\r
describe '自分のコマ一覧取得に於いて' do\r
pl.should eq [@panel]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
- before do\r
- @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
- @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
- @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
- @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
- Author.stub(:default_panel_page_size).and_return(2)\r
- end\r
- it '通常は全件(5件)を返す' do\r
- r = Panel.mylist @author, 5, 0\r
- r.should have(5).items \r
- end\r
- end\r
end\r
\r
describe '他作家のコマ一覧取得に於いて' do\r
pl.should eq [@other_panel]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
- before do\r
- @other_panel2 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100\r
- @other_panel3 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 200\r
- @other_panel4 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 300\r
- @other_panel5 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 400\r
- Author.stub(:default_panel_page_size).and_return(2)\r
- end\r
- it '通常は全件(5件)を返す' do\r
- r = Panel.himlist @other_author, 5, 0\r
- r.should have(5).items \r
- end\r
+ end\r
+ \r
+ describe 'コマ一覧ページ制御に於いて' do\r
+ before do\r
+ Panel.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = Panel.list_paginate \r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it 'コマ一覧の取得条件を利用している' do\r
+ Panel.stub(:list_where).with(any_args).and_return('')\r
+ Panel.should_receive(:list_where).with(any_args).exactly(1)\r
+ r = Panel.list_paginate \r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = Panel.list_paginate 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
end\r
end\r
\r
- describe '一覧取得オプションに於いて' do\r
- it 'includeキーを含んでいる' do\r
- r = Panel.list_opt\r
- r.has_key?(:include).should be_true\r
+ describe '自分のコマ一覧ページ制御に於いて' do\r
+ before do\r
+ Panel.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = Panel.mylist_paginate @author\r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it '自分のコマ一覧の取得条件を利用している' do\r
+ Panel.stub(:mylist_where).with(any_args).and_return('')\r
+ Panel.should_receive(:mylist_where).with(any_args).exactly(1)\r
+ r = Panel.mylist_paginate @author\r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = Panel.mylist_paginate @author, 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
end\r
+ end\r
+ \r
+ describe '他作家のコマ一覧ページ制御に於いて' do\r
+ before do\r
+ Panel.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = Panel.himlist_paginate @other_author\r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it '他作家のコマ一覧の取得条件を利用している' do\r
+ Panel.stub(:himlist_where).with(any_args).and_return('')\r
+ Panel.should_receive(:himlist_where).with(any_args).exactly(1)\r
+ r = Panel.himlist_paginate @other_author\r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = Panel.himlist_paginate @other_author, 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
+ end\r
+ end\r
+ \r
+ describe '一覧取得オプションに於いて' do\r
it '5つの項目を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.should have(5).items\r
end\r
it 'コマ絵を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:panel_pictures).should be_true\r
end\r
it 'コマ絵は実素材を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:panel_pictures].has_key?(:picture).should be_true\r
end\r
it '実素材は絵師を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:panel_pictures][:picture].has_key?(:artist).should be_true\r
end\r
it '実素材はライセンスを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:panel_pictures][:picture].has_key?(:license).should be_true\r
end\r
it 'フキダシを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:speech_balloons).should be_true\r
end\r
it 'フキダシはフキダシ枠を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:speech_balloons].has_key?(:balloons).should be_true\r
end\r
it 'フキダシはセリフを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:speech_balloons].has_key?(:speeches).should be_true\r
end\r
it '絵地を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:ground_pictures).should be_true\r
end\r
it '絵地は実素材を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:ground_pictures].has_key?(:picture).should be_true\r
end\r
it '実素材は絵師を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:ground_pictures][:picture].has_key?(:artist).should be_true\r
end\r
it '実素材はライセンスを含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r[:ground_pictures][:picture].has_key?(:license).should be_true\r
end\r
it '色地を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:ground_colors).should be_true\r
end\r
it '作家を含んでいる' do\r
- r = Panel.list_opt[:include]\r
+ r = Panel.list_opt\r
r.has_key?(:author).should be_true\r
end\r
end\r
r.should eq [@rp]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
- before do\r
- nop2 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @nrp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop2.id, :picture_id => @p.id, :updated_at => Time.now + 100\r
- nop3 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @nrp3 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop3.id, :picture_id => @p.id, :updated_at => Time.now + 200\r
- nop4 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @nrp4 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop4.id, :picture_id => @p.id, :updated_at => Time.now + 300\r
- nop5 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @nrp5 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop5.id, :picture_id => @p.id, :updated_at => Time.now + 400\r
- ResourcePicture.stub(:default_page_size).and_return(2)\r
- end\r
- it '件数0は全件(5件)を返す' do\r
- r = ResourcePicture.list 5, 0\r
- r.should have(5).items \r
- end\r
- end\r
- end\r
- describe '一覧取得オプションに於いて' do\r
- it 'includeキーを含んでいる' do\r
- r = ResourcePicture.list_opt\r
- r.has_key?(:include).should be_true\r
- end\r
- it '3つの項目を含んでいる' do\r
- r = ResourcePicture.list_opt[:include]\r
- r.should have(3).items\r
- end\r
- it 'ライセンスを含んでいる' do\r
- r = ResourcePicture.list_opt[:include]\r
- r.has_key?(:license).should be_true\r
- end\r
- it '絵師を含んでいる' do\r
- r = ResourcePicture.list_opt[:include]\r
- r.has_key?(:artist).should be_true\r
- end\r
- it '実素材を含んでいる' do\r
- r = ResourcePicture.list_opt[:include]\r
- r.has_key?(:picture).should be_true\r
- end\r
- end\r
- describe 'json一覧出力オプションに於いて' do\r
- before do\r
- @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
- @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
- @sbt = FactoryGirl.create :speech_balloon_template\r
- @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1\r
- @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1\r
- @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id\r
- end\r
- it 'ライセンスを含んでいる' do\r
- r = ResourcePicture.list.to_json ResourcePicture.list_json_opt\r
- j = JSON.parse r\r
- i = j.first\r
- i.has_key?('license').should be_true\r
- end\r
- it '絵師を含んでいる' do\r
- r = ResourcePicture.list.to_json ResourcePicture.list_json_opt\r
- j = JSON.parse r\r
- i = j.first\r
- i.has_key?('artist').should be_true\r
- end\r
- it '実素材を含んでいる' do\r
- r = ResourcePicture.list.to_json ResourcePicture.list_json_opt\r
- j = JSON.parse r\r
- i = j.first\r
- i.has_key?('picture').should be_true\r
- end\r
end\r
\r
describe '自分の素材一覧取得に於いて' do\r
c.should eq [@rp]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
+ end\r
+ \r
+ describe '他作家の素材一覧取得に於いて' do\r
+ before do\r
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
+ @other_op = FactoryGirl.create :original_picture, :artist_id => @other_artist.id\r
+ @other_p = FactoryGirl.create :picture, :original_picture_id => @other_op.id, :license_id => @license.id, :artist_id => @other_artist.id\r
+ @other_rp = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @other_op.id, :picture_id => @other_p.id\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it '一覧取得オプションを利用している' do\r
+ ResourcePicture.stub(:list_opt).with(any_args).and_return({})\r
+ ResourcePicture.should_receive(:list_opt).with(any_args).exactly(1)\r
+ r = ResourcePicture.himlist @other_artist\r
+ end\r
+ end\r
+ it '指定した作家のリストを返す' do\r
+ r = ResourcePicture.himlist @other_artist\r
+ r.should eq [@other_rp]\r
+ end\r
+ it '時系列で並んでいる' do\r
+ nop = FactoryGirl.create :original_picture, :artist_id => @other_artist.id\r
+ nrp = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => nop.id, :picture_id => @other_p.id, :updated_at => Time.now + 100\r
+ r = ResourcePicture.himlist @other_artist\r
+ r.should eq [nrp, @other_rp]\r
+ end\r
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
before do\r
- @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p.id, :updated_at => Time.now + 100\r
- @op3 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @rp3 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op3.id, :picture_id => @p.id, :updated_at => Time.now + 200\r
- @op4 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @rp4 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op4.id, :picture_id => @p.id, :updated_at => Time.now + 300\r
- @op5 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @rp5 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op5.id, :picture_id => @p.id, :updated_at => Time.now + 400\r
- Author.stub(:default_resource_picture_page_size).and_return(2)\r
+ @op2 = FactoryGirl.create :original_picture, :artist_id => @other_artist.id\r
+ @rp2 = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p.id, :updated_at => Time.now + 100\r
+ @op3 = FactoryGirl.create :original_picture, :artist_id => @other_artist.id\r
+ @rp3 = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @op3.id, :picture_id => @p.id, :updated_at => Time.now + 200\r
+ @op4 = FactoryGirl.create :original_picture, :artist_id => @other_artist.id\r
+ @rp4 = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @op4.id, :picture_id => @p.id, :updated_at => Time.now + 300\r
+ @op5 = FactoryGirl.create :original_picture, :artist_id => @other_artist.id\r
+ @rp5 = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @op5.id, :picture_id => @p.id, :updated_at => Time.now + 400\r
end\r
- it '通常は全件(5件)を返す' do\r
- r = ResourcePicture.mylist @artist, 5, 0\r
- r.should have(5).items \r
+ it '通常は2件を返す' do\r
+ r = ResourcePicture.himlist @other_artist, 1, 2\r
+ r.should have(2).items \r
end\r
+ it 'page=1なら末尾2件を返す' do\r
+ #時系列で並んでいる\r
+ r = ResourcePicture.himlist(@other_artist, 1, 2)\r
+ r.should eq [@rp5, @rp4]\r
+ end\r
+ it 'page=2なら中間2件を返す' do\r
+ r = ResourcePicture.himlist(@other_artist, 2, 2)\r
+ r.should eq [@rp3, @rp2]\r
+ end\r
+ it 'page=3なら先頭1件を返す' do\r
+ r = ResourcePicture.himlist(@other_artist, 3, 2)\r
+ r.should eq [@other_rp]\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '一覧ページ制御に於いて' do\r
+ before do\r
+ ResourcePicture.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = ResourcePicture.list_paginate\r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = ResourcePicture.list_paginate 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
+ end\r
+ end\r
+ \r
+ describe '自分の素材一覧ページ制御に於いて' do\r
+ before do\r
+ ResourcePicture.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = ResourcePicture.mylist_paginate @artist\r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it '自分の素材一覧の取得条件を利用している' do\r
+ ResourcePicture.stub(:mylist_where).with(any_args).and_return('')\r
+ ResourcePicture.should_receive(:mylist_where).with(any_args).exactly(1)\r
+ r = ResourcePicture.mylist_paginate @artist\r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = ResourcePicture.mylist_paginate @artist, 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
+ end\r
+ end\r
+ \r
+ describe '他作家の素材一覧ページ制御に於いて' do\r
+ before do\r
+ ResourcePicture.stub(:count).with(any_args).and_return(100)\r
+ end\r
+ it 'ページ制御を返す' do\r
+ r = ResourcePicture.himlist_paginate @other_artist\r
+ r.is_a?(Kaminari::PaginatableArray).should be_true\r
+ end\r
+ it '他作家の素材一覧の取得条件を利用している' do\r
+ ResourcePicture.stub(:himlist_where).with(any_args).and_return('')\r
+ ResourcePicture.should_receive(:himlist_where).with(any_args).exactly(1)\r
+ r = ResourcePicture.himlist_paginate @other_artist\r
+ end\r
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+ r = ResourcePicture.himlist_paginate @other_artist, 3, 10\r
+ r.limit_value.should eq 10\r
+ r.offset_value.should eq 20\r
+ end\r
+ end\r
+ \r
+ describe '一覧取得オプションに於いて' do\r
+ it '3つの項目を含んでいる' do\r
+ r = ResourcePicture.list_opt\r
+ r.should have(3).items\r
+ end\r
+ it 'ライセンスを含んでいる' do\r
+ r = ResourcePicture.list_opt\r
+ r.has_key?(:license).should be_true\r
+ end\r
+ it '絵師を含んでいる' do\r
+ r = ResourcePicture.list_opt\r
+ r.has_key?(:artist).should be_true\r
+ end\r
+ it '実素材を含んでいる' do\r
+ r = ResourcePicture.list_opt\r
+ r.has_key?(:picture).should be_true\r
+ end\r
+ end\r
+ describe 'json一覧出力オプションに於いて' do\r
+ before do\r
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
+ @sbt = FactoryGirl.create :speech_balloon_template\r
+ @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1\r
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1\r
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id\r
+ end\r
+ it 'ライセンスを含んでいる' do\r
+ r = ResourcePicture.list.to_json ResourcePicture.list_json_opt\r
+ j = JSON.parse r\r
+ i = j.first\r
+ i.has_key?('license').should be_true\r
+ end\r
+ it '絵師を含んでいる' do\r
+ r = ResourcePicture.list.to_json ResourcePicture.list_json_opt\r
+ j = JSON.parse r\r
+ i = j.first\r
+ i.has_key?('artist').should be_true\r
+ end\r
+ it '実素材を含んでいる' do\r
+ r = ResourcePicture.list.to_json ResourcePicture.list_json_opt\r
+ j = JSON.parse r\r
+ i = j.first\r
+ i.has_key?('picture').should be_true\r
end\r
end\r
\r
end
end
end
- describe 'list関連テーブルプションに於いて' do
- it 'includeキーを含んでいる' do
- r = Story.list_opt
- r.has_key?(:include).should be_true
- end
- it '3つの項目を含んでいる' do
- r = Story.list_opt[:include]
- r.should have(3).items
- end
- it 'コミックを含んでいる' do
- r = Story.list_opt[:include]
- r.has_key?(:comic).should be_true
- end
- it 'コミックは作家を含んでいる' do
- r = Story.list_opt[:include]
- r[:comic].has_key?(:author).should be_true
- end
- it '作家を含んでいる' do
- r = Story.list_opt[:include]
- r.has_key?(:author).should be_true
- end
- it 'コマを含んでいる' do
- r = Story.list_opt[:include]
- r.has_key?(:panel).should be_true
- end
- it 'コマは作家を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel].has_key?(:author).should be_true
- end
- it 'コマはコマ絵を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel].has_key?(:panel_pictures).should be_true
- end
- it 'コマ絵は実素材を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:panel_pictures].has_key?(:picture).should be_true
- end
- it '実素材は絵師を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
- end
- it '実素材はライセンスを含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
- end
- it 'コマはフキダシを含んでいる' do
- r = Story.list_opt[:include]
- r[:panel].has_key?(:speech_balloons).should be_true
- end
- it 'フキダシはフキダシ枠を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:speech_balloons].has_key?(:balloons).should be_true
- end
- it 'フキダシはセリフを含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:speech_balloons].has_key?(:speeches).should be_true
- end
- end
- describe 'json一覧出力オプションに於いて' do
- end
describe '一覧取得に於いて' do
before do
l.should eq [@story]
end
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 '件数0は全件(5件)を返す' do
- r = Story.list 5, 0
- r.should have(5).items
- end
- end
end
describe '自分のストーリー一覧取得に於いて' do
l.should eq [@story]
end
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
- Author.stub(:default_story_page_size).and_return(2)
- end
- it '件数0は全件(5件)を返す' do
- r = Story.mylist @author, 5, 0
- r.should have(5).items
- end
- end
end
describe '他作家のストーリー一覧取得に於いて' do
l.should eq [@other_story]
end
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
- Author.stub(:default_story_page_size).and_return(2)
- end
- it '件数0は全件(5件)を返す' do
- r = Story.himlist @other_author, 5, 0
- r.should have(5).items
+ 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?(:balloons).should be_true
+ end
+ it 'フキダシはセリフを含んでいる' do
+ r = Story.list_opt
+ r[:panel][:speech_balloons].has_key?(:speeches).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
end
describe '単体取得に於いて' do