if MagicNumber['run_mode'] == 0
before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
else
- before_filter :authenticate_reader, :only => [:index, :show]
+ before_filter :authenticate_resource_reader, :only => [:index, :show]
before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
end
before_filter :authenticate_admin!, :only => [:list, :browse]
end
def show
- @au = Author.show(params[:id], @author)
+ @au = Author.show(params[:id], [@author, @admin])
respond_to do |format|
format.html
end
def show
- @balloon = Balloon.show(params[:id], @author)
+ @balloon = Balloon.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @balloon.to_json(Balloon.show_json_opt) }
end
def show
- @comic = Comic.show(params[:id], @author)
+ @comic = Comic.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
end
def show
- @ground_color = GroundColor.show(params[:id], @author)
+ @ground_color = GroundColor.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @ground_color.to_json(GroundColor.show_json_opt) }
end
def show
- @ground_picture = GroundPicture.show(params[:id], @author)
+ @ground_picture = GroundPicture.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @ground_picture.to_json(GroundPicture.show_json_opt) }
# GET /original_pictures/1
# GET /original_pictures/1.json
def show
- @original_picture = OriginalPicture.show(params[:id], @admin || @artist)
+ @original_picture = OriginalPicture.show(params[:id], [@artist, @admin])
respond_to do |format|
opt = {:type => @original_picture.mime_type, :disposition=>"inline"}
end
def history
- @original_picture = OriginalPicture.show(params[:id], @artist)
+ @original_picture = OriginalPicture.show(params[:id], [@artist, @admin])
@history = @original_picture.history
respond_to do |format|
end
def show
- @panel_color = PanelColor.show(params[:id], @author)
+ @panel_color = PanelColor.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @panel_color.to_json(PanelColor.show_json_opt) }
end
def show
- @panel_picture = PanelPicture.show(params[:id], @author)
+ @panel_picture = PanelPicture.show(params[:id], [@author, @admin])
respond_to do |format|
format.html
end
def show
- @panel = Panel.show(params[:id], @author)
+ @panel = Panel.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
before_filter :authenticate_admin!, :only => [:list, :browse]
def show
- @picture = Picture.show(params[:id], @author)
+ @picture = Picture.show(params[:id], [@author, @admin, @demand_user])
respond_to do |format|
opt = {:type => @picture.mime_type, :disposition=>"inline"}
end
def credit
- @picture = Picture.show(params[:id], @author)
+ @picture = Picture.show(params[:id], [@author, @admin, @demand_user])
respond_to do |format|
format.html { render :layout => false } # show.html.erb
class ResourcePicturesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
if MagicNumber['run_mode'] == 0
- before_filter :authenticate_resource_user, :only => [:new, :create, :update, :destroy]
+ before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
before_filter :authenticate_artist, :only => [:new, :create, :destroy]
else
before_filter :authenticate_resource_reader, :only => [:index, :show, :credit]
# GET /resource_pictures/1
# GET /resource_pictures/1.json
def show
- @resource_picture = ResourcePicture.show(params[:id], @author)
+ @resource_picture = ResourcePicture.show(params[:id], [@author, @admin, @demand_user])
respond_to do |format|
opt = {:type => @resource_picture.mime_type, :disposition=>"inline"}
# GET /speech_balloon_templates/1
# GET /speech_balloon_templates/1.json
def show
- @speech_balloon_template = SpeechBalloonTemplate.show(params[:id], @author)
+ @speech_balloon_template = SpeechBalloonTemplate.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
end
def show
- @speech_balloon = SpeechBalloon.show(params[:id], @author)
+ @speech_balloon = SpeechBalloon.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
end
def show
- @speech = Speech.show(params[:id], @author)
+ @speech = Speech.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @speech.to_json(Speech.show_json_opt) }
end
def show
- @story = Story.show(params[:id], @author)
+ @story = Story.show(params[:id], [@author, @admin])
respond_to do |format|
format.html # show.html.erb
end
def comic
- @comic = Comic.show(params[:id], @author)
+ @comic = Comic.show(params[:id], [@author, @admin])
cnt = Story.count(:conditions => ['comic_id = ?', @comic.id]).to_i
@offset = Story.offset cnt, params[:offset]
@panel_count = Story.panel_count cnt, params[:count]
self.author_id = au.id
end
- def own? au
- if au.is_a?(Author)
- self.author_id == au.id
- elsif au.is_a?(Artist)
- self.id == au.id
- else
- false
- end
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ au = Artist.get_author_from_roles roles
+ return false unless au
+ self.author_id == au.id
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless resource_reader_role_check(roles)
end
true
end
self.user_id = uid
end
- def own? au
- return false unless au.is_a?(Author)
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ au = Author.get_author_from_roles roles
+ return false unless au
self.id == au.id
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- true
+ return true
end
def artist?
{:include => {:artist => {}} }
end
- def self.show aid, au
+ def self.show aid, roles
opt = {}
opt.merge!(Author.show_opt)
res = Author.find(aid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(au)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end
'/system_pictures/' + self.system_picture.filename
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- elsif au.is_a?(Admin)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.speech_balloon.visible? au
+ return true if self.speech_balloon.panel.own?(roles)
+ self.speech_balloon.panel.visible? roles
end
def self.default_page_size
self.author_id = au.id
end
- def own? au
- return false unless au.is_a?(Author)
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ au = Comic.get_author_from_roles roles
+ return false unless au
self.author_id == au.id
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- return true if self.own?(au)
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
+ return true if self.own?(roles)
self.visible > 0
end
Comic.find(:all, opt)
end
- def self.show cid, au
+ def self.show cid, roles
opt = {}
opt.merge!(Comic.show_opt)
res = Comic.find(cid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(au)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end
def overwrite
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- elsif au.is_a?(Admin)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.panel.publish?
+ return true if self.panel.own?(roles)
+ self.panel.visible? roles
end
def self.default_page_size
GroundColor.find(:all, opt)
end
- def self.show cid, au
+ def self.show cid, roles
opt = {}
opt.merge!(GroundColor.show_opt)
res = GroundColor.find(cid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(au)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end
def overwrite
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- elsif au.is_a?(Admin)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.panel.publish?
+ return true if self.panel.own?(roles)
+ self.panel.visible? roles
end
def self.default_page_size
self.artist_id = ar.id
end
- def own? ar
- if ar.is_a?(Author)
- self.artist_id == ar.artist.id
- elsif ar.is_a?(Artist)
- self.artist_id == ar.id
- else
- false
- end
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ ar = OriginalPicture.get_artist_from_roles roles
+ return false unless ar
+ self.artist_id == ar.id
end
- def visible? ar
- return true if ar.is_a?(Admin)
- self.own?(ar)
+ def visible? roles
+ return true if self.admin_role_check roles
+ self.own?(roles)
end
def filename
{:include => {:resource_picture => {}, :pictures => {}}}
end
- def self.show cid, ar
+ def self.show cid, roles
opt = {}
opt.merge!(self.show_opt)
res = OriginalPicture.find(cid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(ar)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end
self.author_id = au.id
end
- def own? au
- return false unless au.is_a?(Author)
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ au = Panel.get_author_from_roles roles
+ return false unless au
self.author_id == au.id
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- return true if self.own?(au)
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
+ return true if self.own?(roles)
self.publish?
end
Panel.find(:all, opt)
end
- def self.show rid, au
+ def self.show rid, roles
opt = {}
opt.merge!(Panel.show_opt)
res = Panel.find(rid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(au)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end
def overwrite
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- elsif au.is_a?(Admin)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.panel.publish?
+ return true if self.panel.own?(roles)
+ self.panel.visible? roles
end
def self.default_page_size
PanelColor.find(:all, opt)
end
- def self.show cid, au
+ def self.show cid, roles
opt = {}
opt.merge!(PanelColor.show_opt)
res = PanelColor.find(cid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(au)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end
validates :z, :presence => true, :numericality => {:greater_than => 0}
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- elsif au.is_a?(Admin)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.panel.publish?
+ return true if self.panel.own?(roles)
+ self.panel.visible? roles
end
def flip
self.revision = self.new_revision #Do not move to attr. new_revision reffernces self.original_picture_id
end
- def own? ar
- if ar.is_a?(Author)
- self.artist_id == ar.artist.id
- elsif ar.is_a?(Artist)
- self.artist_id == ar.id
- else
- false
- end
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ ar = Picture.get_artist_from_roles roles
+ return false unless ar
+ self.artist_id == ar.id
end
def visible? ar
Picture.list_by_md5(md5, opid).empty? ? false : true
end
- def self.show rid, au
+ def self.show rid, roles
opt = {}
r = Picture.find(rid, opt)
- raise ActiveRecord::Forbidden unless r.visible?(au)
+ raise ActiveRecord::Forbidden unless r.visible?(roles)
r
end
self.attributes = attr
end
- def own? ar
- return false unless ar.is_a?(Artist)
- ar.id == self.artist_id
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ ar = ResourcePicture.get_artist_from_roles roles
+ return false unless ar
+ self.artist_id == ar.id
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless resource_reader_role_check(roles)
end
true
end
ResourcePicture.find(:all, opt)
end
- def self.show rid, au
+ def self.show rid, roles
opt = {}
opt.merge!(self.show_opt)
r = ResourcePicture.find(rid, opt)
- raise ActiveRecord::Forbidden unless r.visible?(au)
+ raise ActiveRecord::Forbidden unless r.visible?(roles)
r
end
validates :height, :presence => true, :numericality => true, :natural_number => true
# validates :settings, :presence => true
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- elsif au.is_a?(Admin)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.speech_balloon.visible? au
+ return true if self.speech_balloon.panel.own?(roles)
+ self.speech_balloon.panel.visible? roles
end
def self.default_page_size
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
# validates :settings, :presence => true
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- elsif au.is_a?(Admin)
- return true
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.panel.publish?
+ return true if self.panel.own?(roles)
+ self.panel.visible? roles
end
def self.default_page_size
self.author_id = au.id
end
- def own? au
- return false unless au.is_a?(Author)
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ au = Story.get_author_from_roles roles
+ return false unless au
self.author_id == au.id
end
- def visible? au
- if au == nil
- return false if MagicNumber['run_mode'] == 1
- elsif au.is_a?(Author)
- return true if self.comic.own?(au)
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
- self.comic.visible? au
+ return true if self.comic.own?(roles)
+ self.comic.visible? roles
end
def self.default_panel_size
Story.find(:all, opt)
end
- def self.show sid, au
+ def self.show sid, roles
opt = {}
opt.merge!(Story.show_opt)
res = Story.find sid, opt
- raise ActiveRecord::Forbidden unless res.visible?(au)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end
def overwrite
end
- def own? ad
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ ad = SystemPicture.get_admin_from_roles roles
+ return false unless ad
true
end
Pettanr::Application.initialize!
require 'picture_io'
require 'pettan_imager'
+require 'ar_helper'
--- /dev/null
+
+module ActiveRecord
+ class Base
+ module ActiveRecordHelper
+ def self.included(base)
+ base.extend(ClassMethods)
+ base.__send__ :include, InstanceMethods
+ end
+
+ module ClassMethods
+ def get_author_from_roles roles
+ roles.each do |role|
+ return role if role.is_a?(Author)
+ return role.author if role.is_a?(User)
+ return role.author if role.is_a?(Artist) and role.author
+ end
+ nil
+ end
+
+ def get_artist_from_roles roles
+ roles.each do |role|
+ return role.artist if role.is_a?(Author) and role.artist
+ return role.author.artist if role.is_a?(User) and role.author and role.author.artist
+ return role if role.is_a?(Artist)
+ end
+ nil
+ end
+
+ def get_admin_from_roles roles
+ roles.each do |role|
+ return role if role.is_a?(Admin)
+ end
+ nil
+ end
+
+ end
+
+ module InstanceMethods
+ private
+
+ public
+
+ def guest_role_check roles
+ true
+ end
+
+ def reader_role_check roles
+ roles = [roles] unless roles.respond_to?(:each)
+ roles.each do |role|
+ return true if role.is_a?(Author) or role.is_a?(Artist) or role.is_a?(Admin) or role.is_a?(User)
+ end
+ false
+ end
+
+ def resource_reader_role_check roles
+ roles = [roles] unless roles.respond_to?(:each)
+ roles.each do |role|
+ return true if role.is_a?(Author) or role.is_a?(Artist) or role.is_a?(Admin) or role.is_a?(User) or role.is_a?(DemandUser)
+ end
+ false
+ end
+
+ def admin_role_check roles
+ roles = [roles] unless roles.respond_to?(:each)
+ roles.each do |role|
+ return true if role.is_a?(Admin)
+ end
+ false
+ end
+
+ end
+
+ end
+ include ActiveRecordHelper
+ end
+end
+
describe ArtistsController do
before do
@admin = FactoryGirl.create :admin
+ @demand_user = FactoryGirl.create :demand_user
@sp = FactoryGirl.create :system_picture
@lg = FactoryGirl.create :license_group
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
response.should be_success
end
end
+ context '作家権限はないが借手権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @demand_user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ end
end
describe '閲覧に於いて' do
response.should be_success
end
end
+ context '作家権限はないが借手権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @demand_user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @artist.id
+ response.should be_success
+ end
+ end
=begin
context '対象作家がないとき' do
context 'html形式' do
describe '単体表示に於いて' do\r
before do\r
@panel = FactoryGirl.create :panel, :author_id => @user.author.id\r
- Panel.stub(:show).with(@panel.id.to_s, @author).and_return(@panel)\r
- Panel.stub(:show).with(@panel.id.to_s, nil).and_return(@panel)\r
+ Panel.stub(:show).with(@panel.id.to_s, [@author, nil]).and_return(@panel)\r
+ Panel.stub(:show).with(@panel.id.to_s, [nil, @admin]).and_return(@panel)\r
sign_in @user\r
end\r
context 'つつがなく終わるとき' do\r
before do
@p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
sign_in @user
- Picture.stub(:show).with(@p.id.to_s, @author).and_return(@p)
- Picture.stub(:show).with(@p.id.to_s, nil).and_return(@p)
+ Picture.stub(:show).with(@p.id.to_s, [@author, nil, nil]).and_return(@p)
+ Picture.stub(:show).with(@p.id.to_s, [nil, @admin, nil]).and_return(@p)
+ Picture.stub(:show).with(@p.id.to_s, [nil, nil, @demand_user]).and_return(@p)
end
context 'つつがなく終わるとき as json' do
it 'ステータスコード200 OKを返す' do
before do
@p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
sign_in @user
- Picture.stub(:show).with(@p.id.to_s, @author).and_return(@p)
- Picture.stub(:show).with(@p.id.to_s, nil).and_return(@p)
+ Picture.stub(:show).with(@p.id.to_s, [@author, nil, nil]).and_return(@p)
+ Picture.stub(:show).with(@p.id.to_s, [nil, @admin, nil]).and_return(@p)
+ Picture.stub(:show).with(@p.id.to_s, [nil, nil, @demand_user]).and_return(@p)
end
context 'つつがなく終わるとき' do
it 'ステータスコード200 OKを返す' do
@p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
@rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
sign_in @user
- ResourcePicture.stub(:show).with(@rp.id.to_s, @author).and_return(@rp)
- ResourcePicture.stub(:show).with(@rp.id.to_s, nil).and_return(@rp)
+ ResourcePicture.stub(:show).with(@rp.id.to_s, [@author, nil, nil]).and_return(@rp)
+ ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, @admin, nil]).and_return(@rp)
+ ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, nil, @demand_user]).and_return(@rp)
end
context 'つつがなく終わるとき' do
it '素材モデルに単体取得を問い合わせている' do
describe '単体表示に於いて' do
before do
sign_in @user
- SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, @author).and_return(@sbt)
- SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, nil).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, [@author, nil]).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, [nil, @admin]).and_return(@sbt)
end
context 'つつがなく終わるとき' do
it 'フキダシテンプレートモデルに単体取得を問い合わせている' do
before do
sign_in @user
@story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
- Comic.stub(:show).with(@comic.id.to_s, @author).and_return(@comic)
- Comic.stub(:show).with(@comic.id.to_s, nil).and_return(@comic)
- Story.stub(:show).with(@story.id.to_s, @author).and_return(@story)
- Story.stub(:show).with(@story.id.to_s, nil).and_return(@story)
+ Comic.stub(:show).with(@comic.id.to_s, [@author, nil]).and_return(@comic)
+ Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic)
+ Story.stub(:show).with(@story.id.to_s, [@author, nil]).and_return(@story)
+ Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story)
end
context 'つつがなく終わるとき' do
it 'ストーリーモデルに単体取得を問い合わせている' do
- Story.should_receive(:show).with(@story.id.to_s, @author).exactly(1)
+ Story.should_receive(:show).with(@story.id.to_s, [@author, nil]).exactly(1)
get :show, :id => @story.id
end
it '@storyにアレを取得している' do
describe '閲覧に於いて' do
before do
@story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
- Comic.stub(:show).with(@comic.id.to_s, @author).and_return(@comic)
- Comic.stub(:show).with(@comic.id.to_s, nil).and_return(@comic)
+ Comic.stub(:show).with(@comic.id.to_s, [@author, nil]).and_return(@comic)
+ Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic)
Story.stub(:count).and_return(10)
Story.stub(:play_list).with(any_args).and_return([@story, @story, @story])
sign_in @user
end
context '事前チェックする' do
it 'コミックモデルに単体取得を問い合わせている' do
- Comic.should_receive(:show).with(@comic.id.to_s, @author).exactly(1)
+ Comic.should_receive(:show).with(@comic.id.to_s, [@author, nil]).exactly(1)
get :comic, :id => @comic.id
end
it 'ストーリーモデルにプレイリスト取得を問い合わせている' do
@artist = FactoryGirl.create :artist, :author_id => @author.id
@other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
end
- it '自分の絵師ならyes' do
- @artist.own?(@author).should == true
+ context '事前チェックする' do
+ it '自身にロールリストからの作家取得を依頼している' do
+ Artist.should_receive(:get_author_from_roles).with(any_args).exactly(1)
+ r = @artist.own?([@author])
+ end
end
- it '他人の絵師ならno' do
- @artist.own?(@other_author).should == false
+ context 'ロール内作家が取得できるとき' do
+ before do
+ end
+ it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
+ Artist.stub(:get_author_from_roles).with(any_args).and_return(@author)
+ r = @artist.own?([@author])
+ r.should be_true
+ end
+ it 'ロール内作家のidが自身の作家idと一致しないならno' do
+ Artist.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
+ @artist.own?(@other_author).should be_false
+ end
end
- it 'パラメータが作家でないならならno' do
- @artist.own?(nil).should == false
+ context 'ロール内作家が取得できないとき' do
+ before do
+ Artist.stub(:get_author_from_roles).with(any_args).and_return(nil)
+ end
+ it 'Falseを返す' do
+ r = @artist.own?([@author])
+ r.should be_false
+ end
end
end
before do
@artist = FactoryGirl.create :artist, :author_id => @author.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @artist.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '許可する' do
- r = @artist.visible?(nil)
- r.should be_true
- end
- end
- end
- context '検査対象が作家のとき' do
- it '許可する' do
- r = @artist.visible?(@author)
- r.should == true
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ Artist.any_instance.stub(:guest_role_check).and_return(true)
+ Artist.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @artist.visible?([@author])
+ end
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
+ Artist.any_instance.stub(:guest_role_check).and_return(false)
+ r = @artist.visible?([@author])
+ r.should be_false
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @artist.visible?(@admin)
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に素材読者用ロールチェックを問い合わせしている' do
+ Artist.any_instance.stub(:resource_reader_role_check).and_return(true)
+ Artist.any_instance.should_receive(:resource_reader_role_check).with(any_args).exactly(1)
+ r = @artist.visible?([@author])
+ end
+ it '素材読者用ロールチェックが失敗したとき、falseを返す' do
+ Artist.any_instance.stub(:resource_reader_role_check).and_return(false)
+ r = @artist.visible?([@author])
r.should be_false
end
end
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Artist.any_instance.stub(:resource_reader_role_check).and_return(true)
+ end
+ it '許可する' do
+ r = @artist.visible?([@author])
+ r.should be_true
+ end
+ end
end
describe '一覧取得に於いて' do
describe '所持判定に於いて' do
before do
@other_user = FactoryGirl.create :user_yas
-#アカウントを作ると連動して作家ができる @other_author = FactoryGirl.create :author_yas, :user_id => @other_user.id
+ @other_author = @other_user.author
end
- it '作家自身ならyes' do
- @author.own?(@author).should == true
+ context '事前チェックする' do
+ it '自身にロールリストからの作家取得を依頼している' do
+ Author.should_receive(:get_author_from_roles).with(any_args).exactly(1)
+ r = @author.own?([@author])
+ end
end
- it '作家自身でなければno' do
- @author.own?(@other_author).should == false
+ context 'ロール内作家が取得できるとき' do
+ before do
+ end
+ it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
+ Author.stub(:get_author_from_roles).with(any_args).and_return(@author)
+ r = @author.own?([@author])
+ r.should be_true
+ end
+ it 'ロール内作家のidが自身の作家idと一致しないならno' do
+ Author.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
+ @author.own?(@other_author).should be_false
+ end
end
- it 'パラメータが作家でないならno' do
- @author.own?(nil).should == false
+ context 'ロール内作家が取得できないとき' do
+ before do
+ Author.stub(:get_author_from_roles).with(any_args).and_return(nil)
+ end
+ it 'Falseを返す' do
+ r = @author.own?([@author])
+ r.should be_false
+ end
end
end
describe '閲覧許可に於いて' do
before do
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @author.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '許可する' do
- r = @author.visible?(nil)
- r.should be_true
- end
- end
- end
- context '検査対象が作家のとき' do
- it '許可する' do
- r = @author.visible?(@author)
- r.should == true
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ Author.any_instance.stub(:guest_role_check).and_return(true)
+ Author.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @author.visible?([@author])
+ end
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
+ Author.any_instance.stub(:guest_role_check).and_return(false)
+ r = @author.visible?([@author])
+ r.should be_false
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @author.visible?(@admin)
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ Author.any_instance.stub(:reader_role_check).and_return(true)
+ Author.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @author.visible?([@author])
+ end
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ Author.any_instance.stub(:reader_role_check).and_return(false)
+ r = @author.visible?([@author])
r.should be_false
end
end
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Author.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Author.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '許可する' do
+ r = @author.visible?([@author])
+ r.should be_true
+ end
+ end
end
describe '絵師作家判定に於いて' do
@balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
@speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
end\r
- context '検査対象がnil(ゲスト)のとき' do\r
- context 'クローズドモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 1\r
- end\r
- it '不許可を返す。' do\r
- r = @balloon.visible?(nil)\r
- r.should be_false\r
- end\r
+ context 'オープンモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 0\r
end\r
- context 'オープンモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 0\r
- end\r
- it '公開されたコマのフキダシ枠なら許可する' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(true)\r
- r = @balloon.visible?(nil)\r
- r.should be_true\r
- end\r
- it 'れ以外なら不許可を返す' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(false)\r
- r = @balloon.visible?(nil)\r
- r.should be_false\r
- end\r
+ it '自身にゲスト用ロールチェックを問い合わせしている' do\r
+ Balloon.any_instance.stub(:guest_role_check).and_return(true)\r
+ Balloon.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)\r
+ r = @balloon.visible?([@author])\r
+ end\r
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do\r
+ Balloon.any_instance.stub(:guest_role_check).and_return(false)\r
+ r = @balloon.visible?([@author])\r
+ r.should be_false\r
end\r
end\r
- context '検査対象が作家のとき' do\r
- it '公開されたコマのフキダシ枠なら許可する' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(true)\r
- r = @balloon.visible?(@author)\r
- r.should be_true\r
+ context 'クローズドモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ end\r
+ it '自身に読者用ロールチェックを問い合わせしている' do\r
+ Balloon.any_instance.stub(:reader_role_check).and_return(true)\r
+ Balloon.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)\r
+ r = @balloon.visible?([@author])\r
end\r
- it 'れ以外なら不許可を返す' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(false)\r
- r = @balloon.visible?(@author)\r
+ it '読者用ロールチェックが失敗したとき、falseを返す' do\r
+ Balloon.any_instance.stub(:reader_role_check).and_return(false)\r
+ r = @balloon.visible?([@author])\r
r.should be_false\r
end\r
end\r
- context '検査対象が管理者のとき' do\r
- it '許可を返す。' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(false)\r
- r = @balloon.visible?(@admin)\r
- r.should be_true\r
+ context '事前チェックする' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ Balloon.any_instance.stub(:reader_role_check).and_return(true)\r
+ end\r
+ it '自身のコマに所持判定を問い合わせしている' do\r
+ Panel.any_instance.stub(:own?).and_return(true)\r
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
+ r = @balloon.visible?([@author])\r
+ end\r
+ it '自身のコマに閲覧許可を問い合わせしている' do\r
+ Panel.any_instance.stub(:own?).and_return(false)\r
+ Panel.any_instance.stub(:visible?).and_return(true)\r
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)\r
+ r = @balloon.visible?([@author])\r
end\r
end\r
- context '検査対象がそれ以外のとき' do\r
- it '不許可を返す。' do\r
- r = @balloon.visible?(1)\r
+ context 'つつがなく終わるとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ Panel.any_instance.stub(:reader_role_check).and_return(true)\r
+ end\r
+ it '自分のコマのコマ絵なら許可する' do\r
+ Panel.any_instance.stub(:own?).and_return(true)\r
+ Panel.any_instance.stub(:visible?).and_return(false)\r
+ r = @balloon.visible?([@author])\r
+ r.should be_true\r
+ end\r
+ it '他人の非公開コマのコマ絵なら許可しない' do\r
+ Panel.any_instance.stub(:own?).and_return(false)\r
+ Panel.any_instance.stub(:visible?).and_return(false)\r
+ r = @balloon.visible?([@author])\r
r.should be_false\r
end\r
+ it '他人のコマのコマ絵でも公開なら許可する' do\r
+ Panel.any_instance.stub(:own?).and_return(false)\r
+ Panel.any_instance.stub(:visible?).and_return(true)\r
+ r = @balloon.visible?([@author])\r
+ r.should be_true\r
+ end\r
end\r
end\r
+ \r
describe '一覧取得に於いて' do\r
before do\r
@sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
describe Comic do
before do
@admin = FactoryGirl.create :admin
+ @demand_user = FactoryGirl.create :demand_user
@sp = FactoryGirl.create :system_picture
@lg = FactoryGirl.create :license_group
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
end
+ describe 'ロールリストからの作家取得に於いて' do
+ context 'ロールがユーザのとき' do
+ it 'ユーザから作家を取得して、それを返す' do
+ r = Comic.get_author_from_roles([@user])
+ r.should eq @author
+ end
+ end
+ context 'ロールが作家のとき' do
+ it '作家を返す' do
+ r = Comic.get_author_from_roles([@author])
+ r.should eq @author
+ end
+ end
+ context 'ロールが絵師のとき' do
+ it '絵師から作家を取得できれば、それをを返す' do
+ r = Comic.get_author_from_roles([@artist])
+ r.should eq @author
+ end
+ it '絵師から作家を取得できないときnilを返す' do
+ @artist.author_id = nil
+ @artist.save!
+ r = Comic.get_author_from_roles([@artist])
+ r.should be_nil
+ end
+ end
+ context 'ロールが管理者のとき' do
+ it 'nilを返す' do
+ r = Comic.get_author_from_roles([@admin])
+ r.should be_nil
+ end
+ end
+ end
+
+ describe 'ロールリストからの絵師取得に於いて' do
+ context 'ロールがユーザのとき' do
+ it 'ユーザから作家を取得して、そこから絵師を取得できれば、それを返す' do
+ r = Comic.get_artist_from_roles([@user])
+ r.should eq @artist
+ end
+ it '作家から絵師を取得できないときnilを返す' do
+ @artist.author_id = nil
+ @artist.save!
+ r = Comic.get_artist_from_roles([@user])
+ r.should be_nil
+ end
+ end
+ context 'ロールが作家のとき' do
+ it 'そこから絵師を取得できれば、それを返す' do
+ r = Comic.get_artist_from_roles([@author])
+ r.should eq @artist
+ end
+ it '作家から絵師を取得できないときnilを返す' do
+ @artist.author_id = nil
+ @artist.save!
+ r = Comic.get_artist_from_roles([@author])
+ r.should be_nil
+ end
+ end
+ context 'ロールが絵師のとき' do
+ it 'それを返す' do
+ r = Comic.get_artist_from_roles([@artist])
+ r.should eq @artist
+ end
+ end
+ context 'ロールが管理者のとき' do
+ it 'nilを返す' do
+ r = Comic.get_artist_from_roles([@admin])
+ r.should be_nil
+ end
+ end
+ end
+
describe '所持判定に於いて' do
before do
@comic = FactoryGirl.build :comic, :author_id => @author.id
end
- it '自分のコミックならyes' do
- @comic.own?(@author).should == true
+ context '事前チェックする' do
+ it '自身にロールリストからの作家取得を依頼している' do
+ Comic.should_receive(:get_author_from_roles).with(any_args).exactly(1)
+ r = @comic.own?([@author])
+ end
+ end
+ context 'ロール内作家が取得できるとき' do
+ before do
+ end
+ it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
+ Comic.stub(:get_author_from_roles).with(any_args).and_return(@author)
+ r = @comic.own?([@author])
+ r.should be_true
+ end
+ it 'ロール内作家のidが自身の作家idと一致しないならno' do
+ Comic.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
+ @comic.own?(@other_author).should be_false
+ end
+ end
+ context 'ロール内作家が取得できないとき' do
+ before do
+ Comic.stub(:get_author_from_roles).with(any_args).and_return(nil)
+ end
+ it 'Falseを返す' do
+ r = @comic.own?([@author])
+ r.should be_false
+ end
+ end
+ end
+
+ describe '読者用ロールチェックに於いて' do
+ before do
+ @comic = FactoryGirl.build :comic, :author_id => @author.id
+ end
+ context 'ロールリストに作家が含まれるとき' do
+ it 'ロールリストがリストではないとき、リストにする trueを返す' do
+ r = @comic.reader_role_check(@author)
+ r.should be_true
+ end
+ it 'trueを返す' do
+ r = @comic.reader_role_check([@author])
+ r.should be_true
+ end
+ end
+ context 'ロールリストに絵師が含まれるとき' do
+ it 'trueを返す' do
+ r = @comic.reader_role_check([@artist])
+ r.should be_true
+ end
+ end
+ context 'ロールリストにユーザが含まれるとき' do
+ it 'trueを返す' do
+ r = @comic.reader_role_check([@user])
+ r.should be_true
+ end
+ end
+ context 'ロールリストに管理者が含まれるとき' do
+ it 'trueを返す' do
+ r = @comic.reader_role_check([@admin])
+ r.should be_true
+ end
+ end
+ context 'ロールリストにユーザ、管理者、作家、絵師が含まれないとき' do
+ it 'falseを返す' do
+ r = @comic.reader_role_check([nil])
+ r.should be_false
+ end
+ end
+ end
+
+ describe '素材読者用ロールチェックに於いて' do
+ before do
+ @comic = FactoryGirl.build :comic, :author_id => @author.id
+ end
+ context 'ロールリストに作家が含まれるとき' do
+ it 'ロールリストがリストではないとき、リストにする trueを返す' do
+ r = @comic.resource_reader_role_check(@author)
+ r.should be_true
+ end
+ it 'trueを返す' do
+ r = @comic.resource_reader_role_check([@author])
+ r.should be_true
+ end
end
- it '他人のコミックならno' do
- @comic.own?(@other_author).should == false
+ context 'ロールリストに絵師が含まれるとき' do
+ it 'trueを返す' do
+ r = @comic.resource_reader_role_check([@artist])
+ r.should be_true
+ end
end
- it 'パラメータが作家でないならno' do
- @comic.own?(nil).should == false
+ context 'ロールリストにユーザが含まれるとき' do
+ it 'trueを返す' do
+ r = @comic.resource_reader_role_check([@user])
+ r.should be_true
+ end
+ end
+ context 'ロールリストに管理者が含まれるとき' do
+ it 'trueを返す' do
+ r = @comic.resource_reader_role_check([@admin])
+ r.should be_true
+ end
+ end
+ context 'ロールリストに借手が含まれるとき' do
+ it 'trueを返す' do
+ r = @comic.resource_reader_role_check([@demand_user])
+ r.should be_true
+ end
+ end
+ context 'ロールリストにユーザ、管理者、作家、絵師、借手が含まれないとき' do
+ it 'falseを返す' do
+ r = @comic.resource_reader_role_check([nil])
+ r.should be_false
+ end
end
end
before do
@comic = FactoryGirl.build :comic, :author_id => @author.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @comic.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開コミックなら許可する' do
- Comic.any_instance.stub(:visible).and_return(1)
- r = @comic.visible?(nil)
- r.should be_true
- end
- it '非公開コミックなら許可しない' do
- Comic.any_instance.stub(:visible).and_return(0)
- r = @comic.visible?(nil)
- r.should be_false
- end
- end
- end
- context '検査対象が作家のとき' do
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ Comic.any_instance.stub(:guest_role_check).and_return(true)
+ Comic.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @comic.visible?([@author])
+ end
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
+ Comic.any_instance.stub(:guest_role_check).and_return(false)
+ r = @comic.visible?([@author])
+ r.should be_false
+ end
+ end
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ Comic.any_instance.stub(:reader_role_check).and_return(true)
+ Comic.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @comic.visible?([@author])
+ end
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ Comic.any_instance.stub(:reader_role_check).and_return(false)
+ r = @comic.visible?([@author])
+ r.should be_false
+ end
+ end
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Comic.any_instance.stub(:reader_role_check).and_return(true)
+ Comic.any_instance.stub(:own?).and_return(true)
+ end
+ it '自身に所持判定を問い合わせしている' do
+ Comic.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @comic.visible?([@author])
+ end
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Comic.any_instance.stub(:reader_role_check).and_return(true)
+ end
it '自分のコミックなら許可する' do
Comic.any_instance.stub(:own?).and_return(true)
Comic.any_instance.stub(:visible).and_return(0)
- r = @comic.visible?(@author)
- r.should == true
+ r = @comic.visible?([@author])
+ r.should be_true
end
it '他人の非公開コミックなら許可しない' do
Comic.any_instance.stub(:own?).and_return(false)
Comic.any_instance.stub(:visible).and_return(0)
- r = @comic.visible?(@author)
- r.should == false
+ r = @comic.visible?([@author])
+ r.should be_false
end
it '他人のコミックでも公開なら許可する' do
Comic.any_instance.stub(:own?).and_return(false)
Comic.any_instance.stub(:visible).and_return(1)
- r = @comic.visible?(@author)
- r.should == true
- end
- end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @comic.visible?(@admin)
- r.should be_false
+ r = @comic.visible?([@author])
+ r.should be_true
end
end
end
before do
@gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @gc.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開されたコマの選択色地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @gc.visible?(nil)
- r.should be_true
- end
- it 'れ以外なら不許可を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @gc.visible?(nil)
- r.should be_false
- end
- end
- end
- context '検査対象が作家のとき' do
- it '公開されたコマの選択色地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @gc.visible?(@author)
- r.should be_true
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ GroundColor.any_instance.stub(:guest_role_check).and_return(true)
+ GroundColor.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @gc.visible?([@author])
end
- it 'ã\82\8c以å¤\96ã\81ªã\82\89ä¸\8d許å\8f¯を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @gc.visible?(@author)
+ it 'ã\82²ã\82¹ã\83\88ç\94¨ã\83ã\83¼ã\83«ã\83\81ã\82§ã\83\83ã\82¯ã\81\8c失æ\95\97ã\81\97ã\81\9fã\81¨ã\81\8dã\80\81falseを返す' do
+ GroundColor.any_instance.stub(:guest_role_check).and_return(false)
+ r = @gc.visible?([@author])
r.should be_false
end
end
- context '検査対象が管理者のとき' do
- it '許可を返す。' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @gc.visible?(@admin)
- r.should be_true
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ GroundColor.any_instance.stub(:reader_role_check).and_return(true)
+ GroundColor.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @gc.visible?([@author])
+ end
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ GroundColor.any_instance.stub(:reader_role_check).and_return(false)
+ r = @gc.visible?([@author])
+ r.should be_false
+ end
+ end
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ GroundColor.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自身のコマに所持判定を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @gc.visible?([@author])
+ end
+ it '自身のコマに閲覧許可を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
+ r = @gc.visible?([@author])
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @gc.visible?(1)
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Panel.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自分のコマの選択色地なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @gc.visible?([@author])
+ r.should be_true
+ end
+ it '他人の非公開コマの選択色地なら許可しない' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @gc.visible?([@author])
r.should be_false
end
+ it '他人のコマの選択色地でも公開なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ r = @gc.visible?([@author])
+ r.should be_true
+ end
end
end
before do
@gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @gp.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開されたコマの絵地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @gp.visible?(nil)
- r.should be_true
- end
- it 'れ以外なら不許可を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @gp.visible?(nil)
- r.should be_false
- end
- end
- end
- context '検査対象が作家のとき' do
- it '公開されたコマの絵地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @gp.visible?(@author)
- r.should be_true
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ GroundPicture.any_instance.stub(:guest_role_check).and_return(true)
+ GroundPicture.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @gp.visible?([@author])
end
- it 'ã\82\8c以å¤\96ã\81ªã\82\89ä¸\8d許å\8f¯を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @gp.visible?(@author)
+ it 'ã\82²ã\82¹ã\83\88ç\94¨ã\83ã\83¼ã\83«ã\83\81ã\82§ã\83\83ã\82¯ã\81\8c失æ\95\97ã\81\97ã\81\9fã\81¨ã\81\8dã\80\81falseを返す' do
+ GroundPicture.any_instance.stub(:guest_role_check).and_return(false)
+ r = @gp.visible?([@author])
r.should be_false
end
end
- context '検査対象が管理者のとき' do
- it '許可を返す。' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @gp.visible?(@admin)
- r.should be_true
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ GroundPicture.any_instance.stub(:reader_role_check).and_return(true)
+ GroundPicture.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @gp.visible?([@author])
+ end
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ GroundPicture.any_instance.stub(:reader_role_check).and_return(false)
+ r = @gp.visible?([@author])
+ r.should be_false
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @gp.visible?(1)
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ GroundPicture.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自身のコマに所持判定を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @gp.visible?([@author])
+ end
+ it '自身のコマに閲覧許可を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
+ r = @gp.visible?([@author])
+ end
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Panel.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自分のコマの絵地なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @gp.visible?([@author])
+ r.should be_true
+ end
+ it '他人の非公開コマの絵地なら許可しない' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @gp.visible?([@author])
r.should be_false
end
+ it '他人のコマの絵地でも公開なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ r = @gp.visible?([@author])
+ r.should be_true
+ end
end
end
+
describe '一覧取得に於いて' do
before do
@gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
end
end
- describe '作者判定に於いて' do
+ describe '所持判定に於いて' do
before do
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
- context 'パラメータが作家のとき' do
- it '自作の原画ならyes' do
- @op.own?(@author).should == true
- end
- it '他人のならno' do
- @op.own?(@other_author).should == false
+ context '事前チェックする' do
+ it '自身にロールリストからの絵師取得を依頼している' do
+ OriginalPicture.should_receive(:get_artist_from_roles).with(any_args).exactly(1)
+ r = @op.own?([@artist])
end
end
- context 'パラメータが絵師のとき' do
- it '自作の原画ならyes' do
- @op.own?(@artist).should == true
+ context 'ロール内絵師が取得できるとき' do
+ before do
+ end
+ it 'ロール内絵師のidが自身の絵師idと一致するなら許可する' do
+ OriginalPicture.stub(:get_artist_from_roles).with(any_args).and_return(@artist)
+ r = @op.own?([@artist])
+ r.should be_true
end
- it '他人のならno' do
- @op.own?(@other_artist).should == false
+ it 'ロール内絵師のidが自身の絵師idと一致しないならno' do
+ OriginalPicture.stub(:get_artist_from_roles).with(any_args).and_return(@other_artist)
+ @op.own?(@other_artist).should be_false
end
end
- context 'それ以外のとき' do
- it 'no' do
- @op.own?(nil).should == false
+ context 'ロール内絵師が取得できないとき' do
+ before do
+ OriginalPicture.stub(:get_artist_from_roles).with(any_args).and_return(nil)
+ end
+ it 'Falseを返す' do
+ r = @op.own?([@artist])
+ r.should be_false
end
end
end
before do
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
- it '検査対象が管理者のとき、許可を返す' do
- OriginalPicture.any_instance.stub(:own?).and_return(false)
- r = @op.visible?(@admin)
- r.should == true
- end
- it '所持判定を問い合わせ、自分の原画なら許可する' do
- OriginalPicture.any_instance.stub(:own?).and_return(true)
- r = @op.visible?(@artist)
- r.should == true
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身の原画に所持判定を問い合わせしている' do
+ OriginalPicture.any_instance.stub(:own?).and_return(true)
+ OriginalPicture.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @op.visible?([@artist])
+ end
end
- it '他人の原画なら許可しない' do
- OriginalPicture.any_instance.stub(:own?).and_return(false)
- r = @op.visible?(@artist)
- r.should == false
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自分の原画なら許可する' do
+ OriginalPicture.any_instance.stub(:own?).and_return(true)
+ r = @op.visible?([@artist])
+ r.should be_true
+ end
+ it '他人の原画なら許可しない' do
+ OriginalPicture.any_instance.stub(:own?).and_return(false)
+ r = @op.visible?([@artist])
+ r.should be_false
+ end
end
end
before do
@pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @pc.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開されたコマの指定色地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @pc.visible?(nil)
- r.should be_true
- end
- it 'れ以外なら不許可を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pc.visible?(nil)
- r.should be_false
- end
- end
- end
- context '検査対象が作家のとき' do
- it '公開されたコマの指定色地なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @pc.visible?(@author)
- r.should be_true
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ PanelColor.any_instance.stub(:guest_role_check).and_return(true)
+ PanelColor.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
end
- it 'ã\82\8c以å¤\96ã\81ªã\82\89ä¸\8d許å\8f¯を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pc.visible?(@author)
+ it 'ã\82²ã\82¹ã\83\88ç\94¨ã\83ã\83¼ã\83«ã\83\81ã\82§ã\83\83ã\82¯ã\81\8c失æ\95\97ã\81\97ã\81\9fã\81¨ã\81\8dã\80\81falseを返す' do
+ PanelColor.any_instance.stub(:guest_role_check).and_return(false)
+ r = @pc.visible?([@author])
r.should be_false
end
end
- context '検査対象が管理者のとき' do
- it '許可を返す。' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pc.visible?(@admin)
- r.should be_true
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ PanelColor.any_instance.stub(:reader_role_check).and_return(true)
+ PanelColor.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
+ end
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ PanelColor.any_instance.stub(:reader_role_check).and_return(false)
+ r = @pc.visible?([@author])
+ r.should be_false
+ end
+ end
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ PanelColor.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自身のコマに所持判定を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
+ end
+ it '自身のコマに閲覧許可を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
+ r = @pc.visible?([@author])
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @pc.visible?(1)
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Panel.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自分のコマの指定色地なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @pc.visible?([@author])
+ r.should be_true
+ end
+ it '他人の非公開コマの指定色地なら許可しない' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @pc.visible?([@author])
r.should be_false
end
+ it '他人のコマの指定色地でも公開なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ r = @pc.visible?([@author])
+ r.should be_true
+ end
end
end
end
end
end
+
describe '閲覧許可に於いて' do
before do
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
:width => @p.width, :height => @p.height
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @pp.visible?(nil)
- r.should be_false
- end
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開されたコマのコマ絵なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @pp.visible?(nil)
- r.should be_true
- end
- it 'れ以外なら不許可を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pp.visible?(nil)
- r.should be_false
- end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ PanelPicture.any_instance.stub(:guest_role_check).and_return(true)
+ PanelPicture.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @pp.visible?([@author])
+ end
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
+ PanelPicture.any_instance.stub(:guest_role_check).and_return(false)
+ r = @pp.visible?([@author])
+ r.should be_false
end
end
- context '検査対象が作家のとき' do
- it '公開されたコマのコマ絵なら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @pp.visible?(@author)
- r.should be_true
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ PanelPicture.any_instance.stub(:reader_role_check).and_return(true)
+ PanelPicture.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @pp.visible?([@author])
end
- it 'れ以外なら不許可を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pp.visible?(@author)
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ PanelPicture.any_instance.stub(:reader_role_check).and_return(false)
+ r = @pp.visible?([@author])
r.should be_false
end
end
- context '検査対象が管理者のとき' do
- it '許可を返す。' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @pp.visible?(@admin)
- r.should be_true
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ PanelPicture.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自身のコマに所持判定を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @pp.visible?([@author])
+ end
+ it '自身のコマに閲覧許可を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
+ r = @pp.visible?([@author])
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @pp.visible?(1)
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Panel.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自分のコマのコマ絵なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @pp.visible?([@author])
+ r.should be_true
+ end
+ it '他人の非公開コマのコマ絵なら許可しない' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @pp.visible?([@author])
r.should be_false
end
+ it '他人のコマのコマ絵でも公開なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ r = @pp.visible?([@author])
+ r.should be_true
+ end
end
end
+
+
describe '一覧取得に於いて' do
before do
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
\r
end\r
\r
- describe '作者判定に於いて' do\r
+ describe '所持判定に於いて' do\r
before do\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
end\r
- it '自作のコマならyes' do\r
- @panel.own?(@author).should == true\r
+ context '事前チェックする' do\r
+ it '自身にロールリストからの作家取得を依頼している' do\r
+ Panel.should_receive(:get_author_from_roles).with(any_args).exactly(1)\r
+ r = @panel.own?([@author])\r
+ end\r
end\r
- it '他人のコマならno' do\r
- @panel.own?(@other_author).should == false\r
+ context 'ロール内作家が取得できるとき' do\r
+ before do\r
+ end\r
+ it 'ロール内作家のidが自身の作家idと一致するなら許可する' do\r
+ Panel.stub(:get_author_from_roles).with(any_args).and_return(@author)\r
+ r = @panel.own?([@author])\r
+ r.should be_true\r
+ end\r
+ it 'ロール内作家のidが自身の作家idと一致しないならno' do\r
+ Panel.stub(:get_author_from_roles).with(any_args).and_return(@other_author)\r
+ @panel.own?(@other_author).should be_false\r
+ end\r
end\r
- it 'パラメータが作家でないならno' do\r
- @panel.own?(nil).should == false\r
+ context 'ロール内作家が取得できないとき' do\r
+ before do\r
+ Panel.stub(:get_author_from_roles).with(any_args).and_return(nil)\r
+ end\r
+ it 'Falseを返す' do\r
+ r = @panel.own?([@author])\r
+ r.should be_false\r
+ end\r
end\r
end\r
\r
describe '閲覧許可に於いて' do\r
before do\r
+ @comic = FactoryGirl.create :comic, :author_id => @author.id\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id\r
end\r
- context '検査対象がnil(ゲスト)のとき' do\r
- context 'クローズドモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 1\r
- end\r
- it '不許可を返す。' do\r
- r = @panel.visible?(nil)\r
- r.should be_false\r
- end\r
+ context 'オープンモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 0\r
end\r
- context 'オープンモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 0\r
- end\r
- it '公開コマなら許可する' do\r
- Panel.any_instance.stub(:publish?).and_return(true)\r
- r = @panel.visible?(nil)\r
- r.should be_true\r
- end\r
- it '非公開コマなら許可しない' do\r
- Panel.any_instance.stub(:publish?).and_return(false)\r
- r = @panel.visible?(nil)\r
- r.should be_false\r
- end\r
+ it '自身にゲスト用ロールチェックを問い合わせしている' do\r
+ Panel.any_instance.stub(:guest_role_check).and_return(true)\r
+ Panel.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)\r
+ r = @panel.visible?([@author])\r
+ end\r
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do\r
+ Panel.any_instance.stub(:guest_role_check).and_return(false)\r
+ r = @panel.visible?([@author])\r
+ r.should be_false\r
end\r
end\r
- context '検査対象が作家のとき' do\r
- it '自分のコマなら許可する' do\r
+ context 'クローズドモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ end\r
+ it '自身に読者用ロールチェックを問い合わせしている' do\r
+ Panel.any_instance.stub(:reader_role_check).and_return(true)\r
+ Panel.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)\r
+ r = @panel.visible?([@author])\r
+ end\r
+ it '読者用ロールチェックが失敗したとき、falseを返す' do\r
+ Panel.any_instance.stub(:reader_role_check).and_return(false)\r
+ r = @panel.visible?([@author])\r
+ r.should be_false\r
+ end\r
+ end\r
+ context '事前チェックする' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ Panel.any_instance.stub(:reader_role_check).and_return(true)\r
+ end\r
+ it '自身に所持判定を問い合わせしている' do\r
Panel.any_instance.stub(:own?).and_return(true)\r
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
+ r = @panel.visible?([@author])\r
+ end\r
+ it '自身に閲覧許可を問い合わせしている' do\r
+ Panel.any_instance.stub(:own?).and_return(false)\r
Panel.any_instance.stub(:publish?).and_return(true)\r
- r = @panel.visible?(@author)\r
- r.should == true\r
+ Panel.any_instance.should_receive(:publish?).with(any_args).exactly(1)\r
+ r = @panel.visible?([@author])\r
+ end\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ Panel.any_instance.stub(:reader_role_check).and_return(true)\r
+ end\r
+ it '自分のコマなら許可する' do\r
+ Panel.any_instance.stub(:own?).and_return(true)\r
+ Panel.any_instance.stub(:publish?).and_return(false)\r
+ r = @panel.visible?([@author])\r
+ r.should be_true\r
end\r
it '他人の非公開コマなら許可しない' do\r
Panel.any_instance.stub(:own?).and_return(false)\r
Panel.any_instance.stub(:publish?).and_return(false)\r
- r = @panel.visible?(@author)\r
- r.should == false\r
+ r = @panel.visible?([@author])\r
+ r.should be_false\r
end\r
it '他人のコマでも公開なら許可する' do\r
Panel.any_instance.stub(:own?).and_return(false)\r
Panel.any_instance.stub(:publish?).and_return(true)\r
- r = @panel.visible?(@author)\r
- r.should == true\r
- end\r
- end\r
- context '検査対象がそれ以外のとき' do\r
- it '不許可を返す。' do\r
- r = @panel.visible?(@admin)\r
- r.should be_false\r
+ r = @panel.visible?([@author])\r
+ r.should be_true\r
end\r
end\r
end\r
before do
@p = FactoryGirl.build :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
end
- context 'パラメータが作家のとき' do
- it '自作の実素材ならyes' do
- @p.own?(@author).should == true
- end
- it '他人のならno' do
- @p.own?(@other_author).should == false
+ context '事前チェックする' do
+ it '自身にロールリストからの絵師取得を依頼している' do
+ Picture.should_receive(:get_artist_from_roles).with(any_args).exactly(1)
+ r = @p.own?([@artist])
end
end
- context 'パラメータが絵師のとき' do
- it '自作の実素材ならyes' do
- @p.own?(@artist).should == true
+ context 'ロール内絵師が取得できるとき' do
+ before do
end
- it '他人のならno' do
- @p.own?(@other_artist).should == false
+ it 'ロール内絵師のidが自身の絵師idと一致するなら許可する' do
+ Picture.stub(:get_artist_from_roles).with(any_args).and_return(@artist)
+ r = @p.own?([@artist])
+ r.should be_true
+ end
+ it 'ロール内絵師のidが自身の絵師idと一致しないならno' do
+ Picture.stub(:get_artist_from_roles).with(any_args).and_return(@other_artist)
+ @p.own?(@other_artist).should be_false
end
end
- context 'それ以外のとき' do
- it 'no' do
- @p.own?(nil).should == false
+ context 'ロール内絵師が取得できないとき' do
+ before do
+ Picture.stub(:get_artist_from_roles).with(any_args).and_return(nil)
+ end
+ it 'Falseを返す' do
+ r = @p.own?([@artist])
+ r.should be_false
end
end
end
+
describe '閲覧許可に於いて' do
before do
@p = FactoryGirl.build :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
@p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id\r
@rp = FactoryGirl.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id\r
end\r
- it '素材を更新することはないので、Falseを返す' do\r
- @rp.own?(@author).should == false\r
+ context '事前チェックする' do\r
+ it '自身にロールリストからの絵師取得を依頼している' do\r
+ ResourcePicture.should_receive(:get_artist_from_roles).with(any_args).exactly(1)\r
+ r = @rp.own?([@author])\r
+ end\r
+ end\r
+ context 'ロール内絵師が取得できるとき' do\r
+ before do\r
+ end\r
+ it 'ロール内絵師のidが自身の絵師idと一致するなら許可する' do\r
+ ResourcePicture.stub(:get_artist_from_roles).with(any_args).and_return(@artist)\r
+ r = @rp.own?([@author])\r
+ r.should be_true\r
+ end\r
+ it 'ロール内絵師のidが自身の絵師idと一致しないならno' do\r
+ ResourcePicture.stub(:get_artist_from_roles).with(any_args).and_return(@other_artist)\r
+ @rp.own?(@other_artist).should be_false\r
+ end\r
+ end\r
+ context 'ロール内絵師が取得できないとき' do\r
+ before do\r
+ ResourcePicture.stub(:get_artist_from_roles).with(any_args).and_return(nil)\r
+ end\r
+ it 'Falseを返す' do\r
+ r = @rp.own?([@author])\r
+ r.should be_false\r
+ end\r
end\r
end\r
\r
@p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id\r
@rp = FactoryGirl.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id\r
end\r
- context '検査対象がnil(ゲスト)のとき' do\r
- context 'クローズドモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 1\r
- end\r
- it '不許可を返す。' do\r
- r = @rp.visible?(nil)\r
- r.should be_false\r
- end\r
- end\r
- context 'オープンモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 0\r
- end\r
- it '許可する' do\r
- r = @rp.visible?(nil)\r
- r.should be_true\r
- end\r
- end\r
- end\r
- context '検査対象が作家のとき' do\r
- it '許可する' do\r
- r = @rp.visible?(@author)\r
- r.should == true\r
+ context 'オープンモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 0\r
+ end\r
+ it '自身にゲスト用ロールチェックを問い合わせしている' do\r
+ ResourcePicture.any_instance.stub(:guest_role_check).and_return(true)\r
+ ResourcePicture.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)\r
+ r = @rp.visible?([@author])\r
+ end\r
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do\r
+ ResourcePicture.any_instance.stub(:guest_role_check).and_return(false)\r
+ r = @rp.visible?([@author])\r
+ r.should be_false\r
end\r
end\r
- context '検査対象がそれ以外のとき' do\r
- it '不許可を返す。' do\r
- r = @rp.visible?(@admin)\r
+ context 'クローズドモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ end\r
+ it '自身に素材読者用ロールチェックを問い合わせしている' do\r
+ ResourcePicture.any_instance.stub(:resource_reader_role_check).and_return(true)\r
+ ResourcePicture.any_instance.should_receive(:resource_reader_role_check).with(any_args).exactly(1)\r
+ r = @rp.visible?([@author])\r
+ end\r
+ it '素材読者用ロールチェックが失敗したとき、falseを返す' do\r
+ ResourcePicture.any_instance.stub(:resource_reader_role_check).and_return(false)\r
+ r = @rp.visible?([@author])\r
r.should be_false\r
end\r
end\r
+ context 'つつがなく終わるとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ ResourcePicture.any_instance.stub(:resource_reader_role_check).and_return(true)\r
+ end\r
+ it '許可する' do\r
+ r = @rp.visible?([@author])\r
+ r.should be_true\r
+ end\r
+ end\r
end\r
\r
describe 'ファイル名に於いて' do\r
describe '閲覧許可に於いて' do
before do
@sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
- @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id
- @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @sb.visible?(nil)
- r.should be_false
- end
- end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開されたコマのフキダシなら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @sb.visible?(nil)
- r.should be_true
- end
- it 'れ以外なら不許可を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @sb.visible?(nil)
- r.should be_false
- end
- end
- end
- context '検査対象が作家のとき' do
- it '公開されたコマのフキダシなら許可する' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(true)
- r = @sb.visible?(@author)
- r.should be_true
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
+ end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ SpeechBalloon.any_instance.stub(:guest_role_check).and_return(true)
+ SpeechBalloon.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @sb.visible?([@author])
end
- it 'ã\82\8c以å¤\96ã\81ªã\82\89ä¸\8d許å\8f¯を返す' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @sb.visible?(@author)
+ it 'ã\82²ã\82¹ã\83\88ç\94¨ã\83ã\83¼ã\83«ã\83\81ã\82§ã\83\83ã\82¯ã\81\8c失æ\95\97ã\81\97ã\81\9fã\81¨ã\81\8dã\80\81falseを返す' do
+ SpeechBalloon.any_instance.stub(:guest_role_check).and_return(false)
+ r = @sb.visible?([@author])
r.should be_false
end
end
- context '検査対象が管理者のとき' do
- it '許可を返す。' do
- Panel.any_instance.stub(:publish?).with(any_args).and_return(false)
- r = @sb.visible?(@admin)
- r.should be_true
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ end
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ SpeechBalloon.any_instance.stub(:reader_role_check).and_return(true)
+ SpeechBalloon.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @sb.visible?([@author])
+ end
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ SpeechBalloon.any_instance.stub(:reader_role_check).and_return(false)
+ r = @sb.visible?([@author])
+ r.should be_false
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @sb.visible?(1)
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ SpeechBalloon.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自身のコマに所持判定を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @sb.visible?([@author])
+ end
+ it '自身のコマに閲覧許可を問い合わせしている' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)
+ r = @sb.visible?([@author])
+ end
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Panel.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自分のコマのフキダシなら許可する' do
+ Panel.any_instance.stub(:own?).and_return(true)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @sb.visible?([@author])
+ r.should be_true
+ end
+ it '他人の非公開コマのフキダシなら許可しない' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(false)
+ r = @sb.visible?([@author])
r.should be_false
end
+ it '他人のコマのフキダシでも公開なら許可する' do
+ Panel.any_instance.stub(:own?).and_return(false)
+ Panel.any_instance.stub(:visible?).and_return(true)
+ r = @sb.visible?([@author])
+ r.should be_true
+ end
end
end
+
describe '一覧取得に於いて' do
before do
@sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
@balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
@speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
end\r
- context '検査対象がnil(ゲスト)のとき' do\r
- context 'クローズドモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 1\r
- end\r
- it '不許可を返す。' do\r
- r = @speech.visible?(nil)\r
- r.should be_false\r
- end\r
+ context 'オープンモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 0\r
end\r
- context 'オープンモードのとき' do\r
- before do\r
- MagicNumber['run_mode'] = 0\r
- end\r
- it '公開されたコマのセリフなら許可する' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(true)\r
- r = @speech.visible?(nil)\r
- r.should be_true\r
- end\r
- it 'れ以外なら不許可を返す' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(false)\r
- r = @speech.visible?(nil)\r
- r.should be_false\r
- end\r
+ it '自身にゲスト用ロールチェックを問い合わせしている' do\r
+ Speech.any_instance.stub(:guest_role_check).and_return(true)\r
+ Speech.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)\r
+ r = @speech.visible?([@author])\r
+ end\r
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do\r
+ Speech.any_instance.stub(:guest_role_check).and_return(false)\r
+ r = @speech.visible?([@author])\r
+ r.should be_false\r
end\r
end\r
- context '検査対象が作家のとき' do\r
- it '公開されたコマのセリフなら許可する' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(true)\r
- r = @speech.visible?(@author)\r
- r.should be_true\r
+ context 'クローズドモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ end\r
+ it '自身に読者用ロールチェックを問い合わせしている' do\r
+ Speech.any_instance.stub(:reader_role_check).and_return(true)\r
+ Speech.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)\r
+ r = @speech.visible?([@author])\r
end\r
- it 'れ以外なら不許可を返す' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(false)\r
- r = @speech.visible?(@author)\r
+ it '読者用ロールチェックが失敗したとき、falseを返す' do\r
+ Speech.any_instance.stub(:reader_role_check).and_return(false)\r
+ r = @speech.visible?([@author])\r
r.should be_false\r
end\r
end\r
- context '検査対象が管理者のとき' do\r
- it '許可を返す。' do\r
- SpeechBalloon.any_instance.stub(:visible?).with(any_args).and_return(false)\r
- r = @speech.visible?(@admin)\r
- r.should be_true\r
+ context '事前チェックする' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ Speech.any_instance.stub(:reader_role_check).and_return(true)\r
+ end\r
+ it '自身のコマに所持判定を問い合わせしている' do\r
+ Panel.any_instance.stub(:own?).and_return(true)\r
+ Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
+ r = @speech.visible?([@author])\r
+ end\r
+ it '自身のコマに閲覧許可を問い合わせしている' do\r
+ Panel.any_instance.stub(:own?).and_return(false)\r
+ Panel.any_instance.stub(:visible?).and_return(true)\r
+ Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)\r
+ r = @speech.visible?([@author])\r
end\r
end\r
- context '検査対象がそれ以外のとき' do\r
- it '不許可を返す。' do\r
- r = @speech.visible?(1)\r
+ context 'つつがなく終わるとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ Panel.any_instance.stub(:reader_role_check).and_return(true)\r
+ end\r
+ it '自分のコマのセリフなら許可する' do\r
+ Panel.any_instance.stub(:own?).and_return(true)\r
+ Panel.any_instance.stub(:visible?).and_return(false)\r
+ r = @speech.visible?([@author])\r
+ r.should be_true\r
+ end\r
+ it '他人の非公開コマのセリフなら許可しない' do\r
+ Panel.any_instance.stub(:own?).and_return(false)\r
+ Panel.any_instance.stub(:visible?).and_return(false)\r
+ r = @speech.visible?([@author])\r
r.should be_false\r
end\r
+ it '他人のコマのセリフでも公開なら許可する' do\r
+ Panel.any_instance.stub(:own?).and_return(false)\r
+ Panel.any_instance.stub(:visible?).and_return(true)\r
+ r = @speech.visible?([@author])\r
+ r.should be_true\r
+ end\r
end\r
end\r
+ \r
describe '一覧取得に於いて' do\r
before do\r
@sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@panelo = FactoryGirl.create :panel, :author_id => @other_author.id
@storyo = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @comico.id, :panel_id => @panelo.id
end
- it '自分のストーリーならyes' do
- @story.own?(@author).should == true
+ context '事前チェックする' do
+ it '自身にロールリストからの作家取得を依頼している' do
+ Story.should_receive(:get_author_from_roles).with(any_args).exactly(1)
+ r = @story.own?([@author])
+ end
end
- it '他人のストーリーならno' do
- @storyo.own?(@author).should == false
+ context 'ロール内作家が取得できるとき' do
+ before do
+ end
+ it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
+ Story.stub(:get_author_from_roles).with(any_args).and_return(@author)
+ r = @story.own?([@author])
+ r.should be_true
+ end
+ it 'ロール内作家のidが自身の作家idと一致しないならno' do
+ Story.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
+ @story.own?(@other_author).should be_false
+ end
end
- it 'パラメータが作家でないならno' do
- @story.own?(nil).should == false
+ context 'ロール内作家が取得できないとき' do
+ before do
+ Story.stub(:get_author_from_roles).with(any_args).and_return(nil)
+ end
+ it 'Falseを返す' do
+ r = @story.own?([@author])
+ r.should be_false
+ end
end
end
@panel = FactoryGirl.create :panel, :author_id => @author.id
@story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
end
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
- it '不許可を返す。' do
- r = @story.visible?(nil)
- r.should be_false
- end
+ context 'オープンモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 0
end
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
- it '公開コミックのストーリーなら許可する' do
- Comic.any_instance.stub(:visible?).with(nil).and_return(true)
- r = @story.visible?(nil)
- r.should be_true
- end
- it '非公開コミックのストーリーなら許可しない' do
- Comic.any_instance.stub(:visible?).with(nil).and_return(false)
- r = @story.visible?(nil)
- r.should be_false
- end
+ it '自身にゲスト用ロールチェックを問い合わせしている' do
+ Story.any_instance.stub(:guest_role_check).and_return(true)
+ Story.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
+ r = @story.visible?([@author])
+ end
+ it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
+ Story.any_instance.stub(:guest_role_check).and_return(false)
+ r = @story.visible?([@author])
+ r.should be_false
end
end
- context '検査対象が作家のとき' do
- it '自分のコミックのストーリーなら許可する' do
- Comic.any_instance.stub(:own?).with(@author).and_return(true)
- Comic.any_instance.stub(:visible?).with(@author).and_return(true)
- r = @story.visible?(@author)
- r.should == true
+ context 'クローズドモードのとき' do
+ before do
+ MagicNumber['run_mode'] = 1
end
- it '他人の非公開コミックのストーリーなら許可しない' do
- Comic.any_instance.stub(:own?).with(@other_author).and_return(false)
- Comic.any_instance.stub(:visible?).with(@other_author).and_return(false)
- r = @story.visible?(@other_author)
- r.should == false
+ it '自身に読者用ロールチェックを問い合わせしている' do
+ Story.any_instance.stub(:reader_role_check).and_return(true)
+ Story.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
+ r = @story.visible?([@author])
end
- it '他人のコミックのストーリーでも公開なら許可する' do
- Comic.any_instance.stub(:own?).with(@other_author).and_return(false)
- Comic.any_instance.stub(:visible?).with(@other_author).and_return(true)
- r = @story.visible?(@other_author)
- r.should == true
+ it '読者用ロールチェックが失敗したとき、falseを返す' do
+ Story.any_instance.stub(:reader_role_check).and_return(false)
+ r = @story.visible?([@author])
+ r.should be_false
+ end
+ end
+ context '事前チェックする' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Story.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自身のコミックに所持判定を問い合わせしている' do
+ Comic.any_instance.stub(:own?).and_return(true)
+ Comic.any_instance.should_receive(:own?).with(any_args).exactly(1)
+ r = @story.visible?([@author])
+ end
+ it '自身のコミックに閲覧許可を問い合わせしている' do
+ Comic.any_instance.stub(:own?).and_return(false)
+ Comic.any_instance.stub(:visible?).and_return(true)
+ Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1)
+ r = @story.visible?([@author])
end
end
- context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do
- r = @story.visible?(@admin)
+ context 'つつがなく終わるとき' do
+ before do
+ MagicNumber['run_mode'] = 1
+ Story.any_instance.stub(:reader_role_check).and_return(true)
+ end
+ it '自分のコミックのストーリーなら許可する' do
+ Comic.any_instance.stub(:own?).and_return(true)
+ Comic.any_instance.stub(:visible).and_return(0)
+ r = @story.visible?([@author])
+ r.should be_true
+ end
+ it '他人の非公開コミックのストーリーなら許可しない' do
+ Comic.any_instance.stub(:own?).and_return(false)
+ Comic.any_instance.stub(:visible).and_return(0)
+ r = @story.visible?([@author])
r.should be_false
end
+ it '他人のコミックのストーリーでも公開なら許可する' do
+ Comic.any_instance.stub(:own?).and_return(false)
+ Comic.any_instance.stub(:visible).and_return(1)
+ r = @story.visible?([@author])
+ r.should be_true
+ end
end
end