From 2bd8e046bbbdd6d620af0637c3291cc7d787b0c5 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Sat, 1 Dec 2012 11:56:21 +0900 Subject: [PATCH] t#30200:update i18n devise --- app/controllers/application_controller.rb | 31 +- app/controllers/artists_controller.rb | 53 +- app/controllers/authors_controller.rb | 34 +- app/controllers/comics_controller.rb | 4 +- app/controllers/ground_colors_controller.rb | 1 + app/controllers/ground_pictures_controller.rb | 1 + app/controllers/home_controller.rb | 4 + .../original_picture_license_groups_controller.rb | 1 + app/controllers/original_pictures_controller.rb | 1 + app/controllers/panel_colors_controller.rb | 1 + app/controllers/panel_pictures_controller.rb | 1 + app/controllers/panels_controller.rb | 1 + app/controllers/pictures_controller.rb | 1 + app/controllers/resource_pictures_controller.rb | 1 + .../speech_balloon_templates_controller.rb | 1 + app/controllers/speeches_controller.rb | 1 + app/controllers/stories_controller.rb | 2 + app/controllers/system_pictures_controller.rb | 1 + app/models/author.rb | 3 +- app/models/user.rb | 4 - app/views/admins/passwords/edit.html.erb | 2 +- app/views/artists/_form.html.erb | 4 +- app/views/artists/browse.html.erb | 8 +- app/views/artists/edit.html.erb | 4 +- app/views/artists/new.html.erb | 2 +- app/views/artists/show.html.erb | 6 +- app/views/authors/_form.html.erb | 4 +- app/views/authors/browse.html.erb | 8 +- app/views/authors/edit.html.erb | 2 +- app/views/authors/new.html.erb | 5 + app/views/home/configure.html.erb | 68 ++- app/views/layouts/test.html.erb | 4 +- .../original_pictures/_artist_register.html.erb | 27 - app/views/user_registrations/new.html.erb | 18 - app/views/users/browse.html.erb | 38 -- app/views/users/index.html.erb | 13 - app/views/users/list.html.erb | 31 - app/views/users/passwords/edit.html.erb | 2 +- app/views/users/passwords/new.html.erb | 8 +- app/views/users/registrations/_form.html.erb | 17 + app/views/users/registrations/edit.html.erb | 26 +- app/views/users/registrations/new.html.erb | 8 +- app/views/users/sessions/new.html.erb | 36 +- app/views/users/shared/_links.erb | 8 +- app/views/users/show.html.erb | 8 - config/locales/devise.ja.yml | 64 ++ config/locales/pettanr.ja.yml | 43 ++ config/routes.rb | 8 +- spec/controllers/app_controller_spec.rb | 8 +- spec/controllers/artists_controller_spec.rb | 680 ++++++++++----------- spec/controllers/authors_controller_spec.rb | 535 +++++++++++----- spec/controllers/colors_controller_spec.rb | 1 + spec/controllers/comics_controller_spec.rb | 42 +- spec/controllers/ground_colors_controller_spec.rb | 2 +- .../controllers/ground_pictures_controller_spec.rb | 2 +- spec/controllers/home_controller_spec.rb | 4 +- spec/controllers/license_groups_controller_spec.rb | 5 +- spec/controllers/licenses_controller_spec.rb | 6 +- ...ginal_picture_license_groups_controller_spec.rb | 12 +- .../original_pictures_controller_spec.rb | 4 +- spec/controllers/panel_colors_controller_spec.rb | 2 +- spec/controllers/panel_pictures_controller_spec.rb | 4 +- spec/controllers/panels_controller_spec.rb | 46 +- spec/controllers/pictures_controller_spec.rb | 4 +- .../resource_pictures_controller_spec.rb | 222 +++---- .../speech_balloon_templates_controller_spec.rb | 2 +- spec/controllers/stories_controller_spec.rb | 210 +++---- .../controllers/system_pictures_controller_spec.rb | 2 +- spec/factories.rb | 2 +- spec/models/artist_spec.rb | 116 ++-- spec/models/author_spec.rb | 130 ++-- spec/models/balloon_spec.rb | 40 +- spec/models/color_spec.rb | 72 +-- spec/models/comic_spec.rb | 170 +++--- spec/models/ground_color_spec.rb | 40 +- spec/models/ground_picture_spec.rb | 6 +- spec/models/license_group_spec.rb | 58 +- spec/models/original_picture_license_group_spec.rb | 6 +- spec/models/original_picture_spec.rb | 4 +- spec/models/panel_color_spec.rb | 28 +- spec/models/panel_picture_spec.rb | 44 +- spec/models/panel_spec.rb | 6 +- spec/models/picture_spec.rb | 6 +- spec/models/resource_picture_spec.rb | 470 +++++++------- spec/models/speech_balloon_spec.rb | 4 +- spec/models/speech_balloon_template_spec.rb | 56 +- spec/models/speech_spec.rb | 46 +- spec/models/story_spec.rb | 4 +- spec/models/user_spec.rb | 16 +- 89 files changed, 1999 insertions(+), 1737 deletions(-) create mode 100644 app/views/authors/new.html.erb delete mode 100644 app/views/original_pictures/_artist_register.html.erb delete mode 100644 app/views/user_registrations/new.html.erb delete mode 100644 app/views/users/browse.html.erb delete mode 100644 app/views/users/index.html.erb delete mode 100644 app/views/users/list.html.erb create mode 100644 app/views/users/registrations/_form.html.erb delete mode 100644 app/views/users/show.html.erb create mode 100644 config/locales/devise.ja.yml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fc35d3f1..bb3551c0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,21 @@ class ApplicationController < ActionController::Base protect_from_forgery + layout :devise_layout if MagicNumber['test_layout'] before_filter :bf + def devise_layout + if devise_controller? + case resource_name + when :admin + 'test' + when :user + 'test' + end + else + 'application' + end + end + def bf @server_result = { :location => {:controller => params[:controller], :action => params[:action]} @@ -30,6 +44,21 @@ class ApplicationController < ActionController::Base end end + def authenticate_author + if @author + true + else + respond_to do |format| + format.html { redirect_to main_app.new_author_path, :status => :found } + format.js { render "authors/new" } + format.json { + raise ActiveRecord::Forbidden + } + end + false + end + end + def authenticate_artist if @author.artist? true @@ -49,7 +78,7 @@ class ApplicationController < ActionController::Base if file.respond_to?(:read) file.read else - Base64.decode64(file.to_s.gsub(' ', '+')) #rubyのバグ?+でデコードされるべきキャラがスペースになる + Base64.decode64(file.to_s.gsub(' ', '+')) end end diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index aab67cb5..036131b5 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,6 +1,7 @@ class ArtistsController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:index, :show, :new, :create, :edit, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] # GET /artists @@ -19,18 +20,18 @@ class ArtistsController < ApplicationController # GET /artists/1 # GET /artists/1.json def show - @artist = Artist.show(params[:id], @author) + @ar = Artist.show(params[:id], @author) respond_to do |format| format.html # show.html.erb - format.json { render :json => @artist.to_json(Artist.show_json_opt) } + format.json { render :json => @ar.to_json(Artist.show_json_opt) } end end def count - @artist = {:count => Artist.visible_count} + @ar = {:count => Artist.visible_count} respond_to do |format| - format.json { render json: @artist.to_json } + format.json { render json: @ar.to_json } end end @@ -44,30 +45,30 @@ class ArtistsController < ApplicationController end def browse - @artist = Artist.find(params[:id]) + @ar = Artist.find(params[:id]) respond_to do |format| format.html { render layout: 'system' } - format.json { render json: @artist } + format.json { render json: @ar } end end # GET /artists/new # GET /artists/new.json def new - @artist = Artist.new - @artist.supply_default + @ar = Artist.new + @ar.supply_default respond_to do |format| format.html # new.html.erb format.js - format.json { render json: @artist.to_json(Artist.show_json_opt) } + format.json { render json: @ar.to_json(Artist.show_json_opt) } end end # GET /artists/1/edit def edit - @artist = Artist.edit(params[:id], @author) + @ar = Artist.edit(params[:id], @author) respond_to do |format| format.html format.js @@ -77,17 +78,17 @@ class ArtistsController < ApplicationController # POST /artists # POST /artists.json def create - @artist = Artist.new() - @artist.supply_default - @artist.attributes = params[:artist] - @artist.overwrite @author + @ar = Artist.new() + @ar.supply_default + @ar.attributes = params[:artist] + @ar.overwrite @author respond_to do |format| - if @artist.save - format.html { redirect_to @artist, notice: 'Artist was successfully created.' } - format.json { render json: @artist.to_json(Artist.show_json_opt), status: :created, location: @artist } + if @ar.save + format.html { redirect_to @ar, notice: 'Artist was successfully created.' } + format.json { render json: @ar.to_json(Artist.show_json_opt), status: :created, location: @artist } else format.html { render action: "new" } - format.json { render json: @artist.errors, status: :unprocessable_entity } + format.json { render json: @ar.errors, status: :unprocessable_entity } end end end @@ -95,17 +96,17 @@ class ArtistsController < ApplicationController # PUT /artists/1 # PUT /artists/1.json def update - @artist = Artist.edit(params[:id], @author) - @artist.attributes = params[:artist] - @artist.overwrite @author + @ar = Artist.edit(params[:id], @author) + @ar.attributes = params[:artist] + @ar.overwrite @author respond_to do |format| - if @artist.save - format.html { redirect_to @artist, notice: 'Artist was successfully updated.' } + if @ar.save + format.html { redirect_to @ar, notice: 'Artist was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } - format.json { render json: @artist.errors, status: :unprocessable_entity } + format.json { render json: @ar.errors, status: :unprocessable_entity } end end end @@ -113,8 +114,8 @@ class ArtistsController < ApplicationController # DELETE /artists/1 # DELETE /artists/1.json def destroy - @artist = Artist.edit(params[:id], @author) - @artist.destroy + @ar = Artist.edit(params[:id], @author) + @ar.destroy respond_to do |format| format.html { redirect_to artists_url } diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 7e2055ba..f454c91b 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -1,6 +1,7 @@ class AuthorsController < ApplicationController layout 'test' if MagicNumber['test_layout'] - before_filter :authenticate_user!, :only => [:index, :show, :edit, :update] + before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update] + before_filter :authenticate_author, :only => [:index, :show, :edit, :update] before_filter :authenticate_admin!, :only => [:list, :browse] def index @@ -39,21 +40,48 @@ class AuthorsController < ApplicationController end def browse - @author = Author.find(params[:id]) + @au = Author.find(params[:id]) respond_to do |format| format.html { render layout: 'system' } end end + def new + @au = Author.new + @au.supply_default + + respond_to do |format| + format.html # new.html.erb + format.js + format.json { render json: @au.to_json(Author.show_json_opt) } + end + end + def edit @au = Author.edit(params[:id], @author) end + def create + @au = Author.new() + @au.supply_default + @au.attributes = params[:author] + @au.overwrite @user.id + respond_to do |format| + if @au.save + format.html { redirect_to @au, notice: 'Author was successfully created.' } + format.json { render json: @au.to_json(Author.show_json_opt), status: :created, location: @artist } + else + format.html { render action: "new" } + format.json { render json: @au.errors, status: :unprocessable_entity } + end + end + end + def update @au = Author.edit(params[:id], @author) @au.attributes = params[:author] - @au.overwrite + @au.overwrite @user.id respond_to do |format| if @au.save diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index bac6ee00..df4e9fdf 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -2,8 +2,10 @@ class ComicsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_user!, :only => [:top, :index, :show, :play, :new, :create, :edit, :update, :destroy] + before_filter :authenticate_user!, :only => [:top, :index, :show, :new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:top, :index, :show, :new, :create, :edit, :update, :destroy] end before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/ground_colors_controller.rb b/app/controllers/ground_colors_controller.rb index 48797907..123bef76 100644 --- a/app/controllers/ground_colors_controller.rb +++ b/app/controllers/ground_colors_controller.rb @@ -1,6 +1,7 @@ class GroundColorsController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index] + before_filter :authenticate_author, :only => [:index] # GET /ground_colors # GET /ground_colors.json diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index 64152649..18304657 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -1,6 +1,7 @@ class GroundPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index] + before_filter :authenticate_author, :only => [:index] # GET /ground_pictures # GET /ground_pictures.json diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 83142c51..264ebfbc 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,6 +4,10 @@ class HomeController < ApplicationController :index, :show, :profile, :configure, :create_token, :delete_token, :step2, :save_step2, :step3, :save_step3, :comic, :panel, :picture, :panel_picture, :panel_color, :ground_picture, :ground_color ] + before_filter :authenticate_author, :only => [ + :index, :show, :profile, :configure, :create_token, :delete_token, :step2, :save_step2, :step3, :save_step3, + :comic, :panel, :picture, :panel_picture, :panel_color, :ground_picture, :ground_color + ] before_filter :authenticate_artist, :only => [:picture] def index diff --git a/app/controllers/original_picture_license_groups_controller.rb b/app/controllers/original_picture_license_groups_controller.rb index fd85ceab..829d06f3 100644 --- a/app/controllers/original_picture_license_groups_controller.rb +++ b/app/controllers/original_picture_license_groups_controller.rb @@ -1,6 +1,7 @@ class OriginalPictureLicenseGroupsController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:new, :create] + before_filter :authenticate_author, :only => [:new, :create] before_filter :authenticate_artist, :only => [:new, :create] # GET /original_picture_license_groups/new diff --git a/app/controllers/original_pictures_controller.rb b/app/controllers/original_pictures_controller.rb index 5f053a95..d3910c81 100644 --- a/app/controllers/original_pictures_controller.rb +++ b/app/controllers/original_pictures_controller.rb @@ -2,6 +2,7 @@ class OriginalPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :history, :new, :edit, :create, :update, :destroy] + before_filter :authenticate_author, :only => [:index, :show, :history, :new, :edit, :create, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] before_filter :authenticate_artist, :only => [:index, :show, :history, :new, :edit, :create, :update, :destroy] diff --git a/app/controllers/panel_colors_controller.rb b/app/controllers/panel_colors_controller.rb index 11343791..e5f25998 100644 --- a/app/controllers/panel_colors_controller.rb +++ b/app/controllers/panel_colors_controller.rb @@ -1,6 +1,7 @@ class PanelColorsController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index] + before_filter :authenticate_author, :only => [:index] # GET /ground_pictures # GET /ground_pictures.json diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index 5420c722..952676bd 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -1,6 +1,7 @@ class PanelPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] + before_filter :authenticate_author, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse] # GET /panel_pictures diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index 544ecc08..c0cd0cfc 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -1,6 +1,7 @@ class PanelsController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :new, :edit, :create, :update, :destroy] + before_filter :authenticate_author, :only => [:index, :show, :new, :edit, :create, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] public diff --git a/app/controllers/pictures_controller.rb b/app/controllers/pictures_controller.rb index 96f44b4c..7cfaf3cd 100644 --- a/app/controllers/pictures_controller.rb +++ b/app/controllers/pictures_controller.rb @@ -1,6 +1,7 @@ class PicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:show, :credit, :md5] + before_filter :authenticate_author, :only => [:show, :credit, :md5] before_filter :authenticate_artist, :only => [:md5] before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/resource_pictures_controller.rb b/app/controllers/resource_pictures_controller.rb index 102b936e..87ce3c72 100644 --- a/app/controllers/resource_pictures_controller.rb +++ b/app/controllers/resource_pictures_controller.rb @@ -1,6 +1,7 @@ class ResourcePicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :credit, :new, :create, :update, :destroy] + before_filter :authenticate_author, :only => [:index, :show, :credit, :new, :create, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] before_filter :authenticate_artist, :only => [:new, :create, :destroy] diff --git a/app/controllers/speech_balloon_templates_controller.rb b/app/controllers/speech_balloon_templates_controller.rb index 77a808da..e28a7f70 100644 --- a/app/controllers/speech_balloon_templates_controller.rb +++ b/app/controllers/speech_balloon_templates_controller.rb @@ -1,6 +1,7 @@ class SpeechBalloonTemplatesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] + before_filter :authenticate_author, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse, :destroy] # GET /speech_balloon_templates diff --git a/app/controllers/speeches_controller.rb b/app/controllers/speeches_controller.rb index 0cb0e2d1..552abdf7 100644 --- a/app/controllers/speeches_controller.rb +++ b/app/controllers/speeches_controller.rb @@ -1,6 +1,7 @@ class SpeechesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] + before_filter :authenticate_author, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse] def list diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 9e30edab..37c196aa 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -2,8 +2,10 @@ class StoriesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else before_filter :authenticate_user!, :only => [:index, :show, :comic, :new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:index, :show, :comic, :new, :create, :edit, :update, :destroy] end before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/system_pictures_controller.rb b/app/controllers/system_pictures_controller.rb index 0a9447d9..203b5d81 100644 --- a/app/controllers/system_pictures_controller.rb +++ b/app/controllers/system_pictures_controller.rb @@ -1,6 +1,7 @@ class SystemPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] + before_filter :authenticate_author, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse, :new, :create] # GET /system_pictures diff --git a/app/models/author.rb b/app/models/author.rb index 3ceaa748..fae7bb2a 100644 --- a/app/models/author.rb +++ b/app/models/author.rb @@ -9,7 +9,8 @@ class Author < ActiveRecord::Base self.name = 'no name' if self.name.blank? end - def overwrite + def overwrite uid + self.user_id = uid end def own? au diff --git a/app/models/user.rb b/app/models/user.rb index ff5f34ed..90958af6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,10 +9,6 @@ class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email - before_create do |r| - r.build_author :name => 'no name' - end - def create_token self.ensure_authentication_token self.save diff --git a/app/views/admins/passwords/edit.html.erb b/app/views/admins/passwords/edit.html.erb index e75c9371..ff76588c 100644 --- a/app/views/admins/passwords/edit.html.erb +++ b/app/views/admins/passwords/edit.html.erb @@ -13,4 +13,4 @@
<%= f.submit "Change my password" %>
<% end %> -<%= render :partial => "devise/shared/links" %> \ No newline at end of file +<%= render :partial => "devise/shared/links" %> diff --git a/app/views/artists/_form.html.erb b/app/views/artists/_form.html.erb index ae35d64d..fba105cf 100644 --- a/app/views/artists/_form.html.erb +++ b/app/views/artists/_form.html.erb @@ -1,5 +1,5 @@ -<%= form_for(@artist) do |f| %> - <%= render 'system/error_explanation', :obj => @artist %> +<%= form_for(ar) do |f| %> + <%= render 'system/error_explanation', :obj => ar %>
<%= f.label :name %>
diff --git a/app/views/artists/browse.html.erb b/app/views/artists/browse.html.erb index 7cf62b3c..2602e3aa 100644 --- a/app/views/artists/browse.html.erb +++ b/app/views/artists/browse.html.erb @@ -3,22 +3,22 @@

<%= t_m 'Artist.id' -%>: - <%= h @artist.id %> + <%= h @ar.id %>

<%= t_m 'Artist.name' -%>: - <%= h @artist.name %> + <%= h @ar.name %>

<%= t_m 'Artist.created_at' -%>: - <%= l @artist.created_at %> + <%= l @ar.created_at %>

<%= t_m 'Artist.updated_at' -%>: - <%= l @artist.updated_at %> + <%= l @ar.updated_at %>

<%= link_to t('link.back'), :action => :list %> diff --git a/app/views/artists/edit.html.erb b/app/views/artists/edit.html.erb index 21e86b7e..6e8a5d2e 100644 --- a/app/views/artists/edit.html.erb +++ b/app/views/artists/edit.html.erb @@ -1,7 +1,7 @@

<%= t '.title' -%>

<%= notice %>

-<%= render 'form' %> +<%= render 'form', :ar => @ar %> configure -<%= link_to 'Show', @artist %> | +<%= link_to 'Show', @ar %> | <%= link_to 'Back', artists_path %> diff --git a/app/views/artists/new.html.erb b/app/views/artists/new.html.erb index 8c748272..f6db1ed3 100644 --- a/app/views/artists/new.html.erb +++ b/app/views/artists/new.html.erb @@ -2,6 +2,6 @@

素材の投稿には絵師登録が必要です。

下記フォームで登録してください。

-<%= render 'form' %> +<%= render 'form', :ar => @ar %> <%= link_to t('link.back'), artists_path %> diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index c2f21e4b..0a09a711 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -3,17 +3,17 @@

<%= t_m 'Artist.name' -%>: - <%= h @artist.name %> + <%= h @ar.name %>

<%= t_m 'Artist.created_at' -%>: - <%= l @artist.created_at %> + <%= l @ar.created_at %>

<%= t_m 'Artist.updated_at' -%>: - <%= l @artist.updated_at %> + <%= l @ar.updated_at %>

<%= link_to t('link.back'), artists_path %> diff --git a/app/views/authors/_form.html.erb b/app/views/authors/_form.html.erb index f4a8a3fe..560efe18 100644 --- a/app/views/authors/_form.html.erb +++ b/app/views/authors/_form.html.erb @@ -1,5 +1,5 @@ -<%= form_for(@au) do |f| %> - <%= render 'system/error_explanation', :obj => @au %> +<%= form_for(au) do |f| %> + <%= render 'system/error_explanation', :obj => au %>
<%= f.label :name %>
diff --git a/app/views/authors/browse.html.erb b/app/views/authors/browse.html.erb index a5f1813c..a197a079 100644 --- a/app/views/authors/browse.html.erb +++ b/app/views/authors/browse.html.erb @@ -3,22 +3,22 @@

<%= t_m 'Author.id' -%>: - <%= h @author.id %> + <%= h @au.id %>

<%= t_m 'Author.name' -%>: - <%= h @author.name %> + <%= h @au.name %>

<%= t_m 'Author.created_at' -%>: - <%= l @author.created_at %> + <%= l @au.created_at %>

<%= t_m 'Author.updated_at' -%>: - <%= l @author.updated_at %> + <%= l @au.updated_at %>

<%= link_to t('link.back'), :action => :list %> diff --git a/app/views/authors/edit.html.erb b/app/views/authors/edit.html.erb index 8e679a13..dd7fb8f8 100644 --- a/app/views/authors/edit.html.erb +++ b/app/views/authors/edit.html.erb @@ -1,6 +1,6 @@

<%= t '.title' -%>

-<%= render 'form' %> +<%= render 'form', :au => @au %> <%= link_to 'Show', @au %> | <%= link_to 'Back', authors_path %> diff --git a/app/views/authors/new.html.erb b/app/views/authors/new.html.erb new file mode 100644 index 00000000..149cd95c --- /dev/null +++ b/app/views/authors/new.html.erb @@ -0,0 +1,5 @@ +

<%= t '.title' -%>

+

<%= t '.announce' -%>

+ +<%= render 'form', :au => @au %> + diff --git a/app/views/home/configure.html.erb b/app/views/home/configure.html.erb index 71e2fe9e..e6c6cfe3 100644 --- a/app/views/home/configure.html.erb +++ b/app/views/home/configure.html.erb @@ -1,27 +1,41 @@ -

認証トークン

-
-あなたの認証トークンは<%= @user.authentication_token %>です -
-
- <% if @user.authentication_token %> - <%= link_to 'delete token', :action => :delete_token %> - <% else %> - <%= link_to 'generate token', :action => :create_token %> - <% end %> -
-
-

作家

- <%= link_to 'edit author profile', edit_author_path(@author) %> -
-
-

絵師

- <% if @artist %> - <%= link_to 'edit artist profile', edit_artist_path(@artist) %> - <% else %> - <%= link_to 'regist artist', new_artist_path %> - <% end %> -
-

退会

-
- <%= link_to('退会する', {:controller => 'user_registrations', :action => :destroy, :id => @user.id}, {:method => :delete}) %> -
+

<%= t '.title' -%>

+ +<%= t('home.configure.caption', :email => @user.email) %> + + + + + +
+

<%= t 'home.configure.password_caption' -%>

+ <%= render '/users/registrations/form', :resource => @user %> +

<%= t 'home.configure.token_caption' -%>

+ <% if @user.authentication_token %> +
<%= t 'home.configure.your_token', :token => @user.authentication_token -%>
+ <%= link_to t('home.configure.delete_token'), :action => :delete_token %> + <% else %> +
<%= t 'home.configure.about_token' -%>
+ <%= link_to t('home.configure.generate_token'), :action => :create_token %> + <% end %> +

<%= t 'home.configure.cancel_caption' -%>

+ <%= link_to t('home.configure.cancel_account'), registration_path('user'), :confirm => "Are you sure?", :method => :delete %> +
+

<%= t_m 'Author' -%>

+ <% if @author %> + <%= render '/authors/form', :au => @author %> + <% else %> +
<%= t 'home.configure.no_author' -%>
+
<%= t 'home.configure.about_author' -%>
+ <% @au = Author.new ; @au.supply_default %> + <%= render '/authors/form', :au => @au %> + <% end %> +

<%= t_m 'Artist' -%>

+ <% if @artist %> + <%= render '/artists/form', :ar => @artist %> + <% else %> +
<%= t 'home.configure.no_artist' -%>
+
<%= t 'home.configure.about_artist' -%>
+ <% @ar = Artist.new ; @ar.supply_default %> + <%= render '/artists/form', :ar => @ar %> + <% end %> +
diff --git a/app/views/layouts/test.html.erb b/app/views/layouts/test.html.erb index 6f902e33..58587ac4 100644 --- a/app/views/layouts/test.html.erb +++ b/app/views/layouts/test.html.erb @@ -16,7 +16,9 @@
- <%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %> + <% if @author %> + <%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %> + <% end %>
<% if @artist %> diff --git a/app/views/original_pictures/_artist_register.html.erb b/app/views/original_pictures/_artist_register.html.erb deleted file mode 100644 index 4fc44453..00000000 --- a/app/views/original_pictures/_artist_register.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -

素材の投稿には絵師登録が必要です。

-

下記フォームで登録してください。

- -<%= form_for(@artist) do |f| %> - <% if @artist.errors.any? %> -
-

<%= pluralize(@artist.errors.count, "error") %> prohibited this artist from being saved:

- -
    - <% @artist.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :name %>
- <%= f.text_field :name %>
- - <%= f.hidden_field :author_id, :value => @artist.author_id %> -
-
- <%= f.submit %> -
-<% end %> - diff --git a/app/views/user_registrations/new.html.erb b/app/views/user_registrations/new.html.erb deleted file mode 100644 index d15e275a..00000000 --- a/app/views/user_registrations/new.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -

Sign up

- -<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> - -
<%= f.label :email %>
- <%= f.email_field :email %>
- -
<%= f.label :password %>
- <%= f.password_field :password %>
- -
<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation %>
- -
<%= f.submit "Sign up" %>
-<% end %> - -<%= render :partial => "devise/shared/links" %> diff --git a/app/views/users/browse.html.erb b/app/views/users/browse.html.erb deleted file mode 100644 index 86d0e794..00000000 --- a/app/views/users/browse.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -

<%= notice %>

- -

- name: - <%= h(@author.name) %> -

- -

- email: - <%= h(@author.email) %> -

- -

- sign_in_count: - <%= @author.sign_in_count %> -

- -

- current_sign_in_at: - <%= @author.current_sign_in_at %> -

- -

- last_sign_in_at: - <%= @author.last_sign_in_at %> -

- -

- current_sign_in_ip: - <%= @author.current_sign_in_ip %> -

- -

- last_sign_in_ip: - <%= @author.last_sign_in_ip %> -

- -<%= link_to 'Back', :action => :list %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb deleted file mode 100644 index 5691bbbf..00000000 --- a/app/views/users/index.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -

Listing system_pictures

- - - - - - -<% @authors.each do |author| %> - - - -<% end %> -
Ext
<%= link_to h(author.name), :action => :show, :id => author.id %>
diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb deleted file mode 100644 index a5599796..00000000 --- a/app/views/users/list.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -

Listing authors

- - - - - - - - - - - - - - - -<% @authors.each do |author| %> - - - - - - - - - - - - -<% end %> -
idnameemailsign_in_countcurrent_sign_in_atlast_sign_in_atcurrent_sign_in_iplast_sign_in_ipcreated_atupdated_at
<%= link_to author.id, :action => :show, :id => author.id %><%= h(author.name) %><%= h(author.email) %><%= author.sign_in_count %><%= author.current_sign_in_at %><%= author.last_sign_in_at %><%= author.current_sign_in_ip %><%= author.last_sign_in_ip %><%= author.created_at %><%= author.updated_at %>
diff --git a/app/views/users/passwords/edit.html.erb b/app/views/users/passwords/edit.html.erb index e75c9371..ff76588c 100644 --- a/app/views/users/passwords/edit.html.erb +++ b/app/views/users/passwords/edit.html.erb @@ -13,4 +13,4 @@
<%= f.submit "Change my password" %>
<% end %> -<%= render :partial => "devise/shared/links" %> \ No newline at end of file +<%= render :partial => "devise/shared/links" %> diff --git a/app/views/users/passwords/new.html.erb b/app/views/users/passwords/new.html.erb index 6c21e9fd..3357b8c1 100644 --- a/app/views/users/passwords/new.html.erb +++ b/app/views/users/passwords/new.html.erb @@ -1,12 +1,12 @@ -

Forgot your password?

+

<%= t 'users.forgot.title' -%>

<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %> - <%= devise_error_messages! %> + <%= render 'system/error_explanation', :obj => resource %>
<%= f.label :email %>
<%= f.email_field :email %>
-
<%= f.submit "Send me reset password instructions" %>
+
<%= f.submit t('users.forgot.reset') %>
<% end %> -<%= render :partial => "devise/shared/links" %> \ No newline at end of file +<%= render :partial => "/users/shared/links" %> diff --git a/app/views/users/registrations/_form.html.erb b/app/views/users/registrations/_form.html.erb new file mode 100644 index 00000000..61e988ab --- /dev/null +++ b/app/views/users/registrations/_form.html.erb @@ -0,0 +1,17 @@ +<%= form_for(resource, :as => :user, :url => registration_path(:user), :html => { :method => :put }) do |f| %> + <%= render 'system/error_explanation', :obj => resource %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %> <%= t 'home.configure.new_password_notice' -%>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.label :current_password %> <%= t 'home.configure.current_password_notice' -%>
+ <%= f.password_field :current_password %>
+ +
<%= f.submit t('home.configure.change_password') %>
+<% end %> diff --git a/app/views/users/registrations/edit.html.erb b/app/views/users/registrations/edit.html.erb index ff380509..9bd93762 100644 --- a/app/views/users/registrations/edit.html.erb +++ b/app/views/users/registrations/edit.html.erb @@ -1,25 +1,5 @@ -

Edit <%= resource_name.to_s.humanize %>

+

<%= t 'home.configure.password_caption' -%>

-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> - <%= devise_error_messages! %> +<%= render '/users/registrations/form', :resource => resource %> -
<%= f.label :email %>
- <%= f.email_field :email %>
- -
<%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password %>
- -
<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation %>
- -
<%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password %>
- -
<%= f.submit "Update" %>
-<% end %> - -

Cancel my account

- -

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

- -<%= link_to "Back", :back %> +<%= link_to t('link.back'), :back %> diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index d15e275a..ce0af4ee 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -1,7 +1,7 @@ -

Sign up

+

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

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> + <%= render 'system/error_explanation', :obj => resource %>
<%= f.label :email %>
<%= f.email_field :email %>
@@ -12,7 +12,7 @@
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
-
<%= f.submit "Sign up" %>
+
<%= f.submit t('users.signup.signup') %>
<% end %> -<%= render :partial => "devise/shared/links" %> +<%= render :partial => "/users/shared/links" %> diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index ff59f7cc..4323c6c2 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -1,17 +1,25 @@ -

Sign in

+

Hello PettanR World

+ + + + + +
+

Site profile

+
+ <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> +
<%= f.label :email %>
+ <%= f.email_field :email %>
-<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> -
<%= f.label :email %>
- <%= f.email_field :email %>
+
<%= f.label :password %>
+ <%= f.password_field :password %>
-
<%= f.label :password %>
- <%= f.password_field :password %>
+ <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> - <% if devise_mapping.rememberable? -%> -
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
- <% end -%> - -
<%= f.submit "Sign in" %>
-<% end %> - -<%= render :partial => "devise/shared/links" %> \ No newline at end of file +
<%= f.submit t('users.signin.signin') %>
+ <% end %> +

+ <%= render :partial => "/users/shared/links" %> +
diff --git a/app/views/users/shared/_links.erb b/app/views/users/shared/_links.erb index eab783a4..8ae8c61c 100644 --- a/app/views/users/shared/_links.erb +++ b/app/views/users/shared/_links.erb @@ -1,13 +1,13 @@ <%- if controller_name != 'sessions' %> - <%= link_to "Sign in", new_session_path(resource_name) %>
+ <%= link_to t('users.shared.signin'), new_session_path(resource_name) %>
<% end -%> <%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Sign up", new_registration_path(resource_name) %>
+ <%= link_to t('users.shared.signup'), new_registration_path(resource_name) %>
<% end -%> <%- if devise_mapping.recoverable? && controller_name != 'passwords' %> - <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+ <%= link_to t('users.shared.forgot'), new_password_path(resource_name) %>
<% end -%> <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> @@ -22,4 +22,4 @@ <%- resource_class.omniauth_providers.each do |provider| %> <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
<% end -%> -<% end -%> \ No newline at end of file +<% end -%> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb deleted file mode 100644 index 464be429..00000000 --- a/app/views/users/show.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

<%= notice %>

- -

- name: - <%= h(@author.name) %> -

- -<%= link_to 'Back', :controller => 'authors' %> diff --git a/config/locales/devise.ja.yml b/config/locales/devise.ja.yml new file mode 100644 index 00000000..15605bdb --- /dev/null +++ b/config/locales/devise.ja.yml @@ -0,0 +1,64 @@ +ja: + errors: + messages: + not_found: "は見つかりませんでした" +# not_found: "not found" + already_confirmed: "は既に登録済みです" +# already_confirmed: "was already confirmed" + not_locked: "は凍結されていません" +# not_locked: "was not locked" + + devise: + failure: + unauthenticated: 'ログインしてください。' +# unauthenticated: 'You need to sign in or sign up before continuing.' + unconfirmed: '本登録を行ってください。' +# unconfirmed: 'You have to confirm your account before continuing.' + locked: 'あなたのアカウントは凍結されています。' +# locked: 'Your account is locked.' + invalid: 'メールアドレスかパスワードが違います。' +# invalid: 'Invalid email or password.' + invalid_token: '認証キーが不正です。' +# invalid_token: 'Invalid authentication token.' + timeout: 'セッションがタイムアウトしました。もう一度ログインしてください。' +# timeout: 'Your session expired, please sign in again to continue.' + inactive: 'アカウントがアクティベートされていません。' +# inactive: 'Your account was not activated yet.' + sessions: + signed_in: 'ログインしました。' +# signed_in: 'Signed in successfully.' + signed_out: 'ログアウトしました。' +# signed_out: 'Signed out successfully.' + passwords: + send_instructions: 'パスワードのリセット方法を数分以内にメールでご連絡します。' +# send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' + updated: 'パスワードを変更しました。' +# updated: 'Your password was changed successfully. You are now signed in.' + confirmations: + send_instructions: '登録方法を数分以内にメールでご連絡します。' +# send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' + confirmed: 'アカウントを登録しました。' +# confirmed: 'Your account was successfully confirmed. You are now signed in.' + registrations: + signed_up: 'アカウント登録を受け付けました。確認のメールをお送りします。' +# signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.' + updated: 'アカウントを更新しました。' +# updated: 'You updated your account successfully.' + destroyed: 'アカウントを削除しました。またのご利用をお待ちしております。' +# destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' + unlocks: + send_instructions: 'アカウントの凍結解除方法を数分以内にメールでご連絡します。' +# send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' + unlocked: 'アカウントを凍結解除しました。' +# unlocked: 'Your account was successfully unlocked. You are now signed in.' + mailer: + confirmation_instructions: + subject: 'アカウントの登録方法' +# subject: 'Confirmation instructions' + reset_password_instructions: + subject: 'パスワードの再設定' +# subject: 'Reset password instructions' + unlock_instructions: + subject: 'アカウントの凍結解除' +# subject: 'Unlock Instructions' + diff --git a/config/locales/pettanr.ja.yml b/config/locales/pettanr.ja.yml index fbe5e532..37dd2ec2 100644 --- a/config/locales/pettanr.ja.yml +++ b/config/locales/pettanr.ja.yml @@ -1,6 +1,7 @@ ja: activerecord: models: + user: ユーザ comic: コミック story: ストーリー panel: コマ @@ -22,6 +23,13 @@ ja: system_picture: システム画像 color: 色 attributes: + user: + name: ペンネーム + email: メールアドレス + password: パスワード + password_confirmation: 確認パスワード + current_password: 現在のパスワード + remember_me: 次回から自動でログイン comic: title: タイトル visible: 公開 @@ -213,6 +221,22 @@ ja: x: 横方向 y: 縦方向 no: なし + users: + shared: + signin: ログイン + signup: 新規入会 + forgot: パスワードを忘れた + signup: + title: ユーザ登録 + signup: 登録する + signin: + title: ログイン + signin: ログイン + edit: + title: アカウントの設定変更 + forgot: + title: パスワードを忘れてしまった + reset: 新しいパスワードを発行する home: index: title: ホーム @@ -235,6 +259,22 @@ ja: title: 最近指定した色地 configure: title: 設定 + caption: アカウント%{email}の設定 + password_caption: メールアドレスおよびパスワードの変更 + new_password_notice: パスワードを変更しない場合は空欄にしてください + current_password_notice: 確認のために現在のパスワードが必要です + change_password: 変更する + token_caption: 認証トークン + your_token: あなたの認証トークンは%{token}です + delete_token: 認証トークンを削除する + about_token: 認証トークンはWebAPIを利用する場合に使います + generate_token: 認証トークンを発行する + cancel_caption: 退会 + cancel_account: 退会する + no_author: 作家登録されていません + about_author: 作家になると漫画を公開できます + no_artist: 絵師登録されていません + about_artist: 絵師になると素材を公開できます sign_out: title: ログアウト comics: @@ -417,6 +457,9 @@ ja: title: 作家一覧 show: title: 作家詳細 + new: + title: 作家登録 + announce: 作家登録してください edit: title: 作家プロフィール編集 list: diff --git a/config/routes.rb b/config/routes.rb index 400f71b7..4792387a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Pettanr::Application.routes.draw do - devise_for :users , :controllers => { :registrations => "user_registrations" } + devise_for :users devise_for :admins Pettanr::Application.licenses.each do |name, klass| @@ -8,6 +8,9 @@ Pettanr::Application.routes.draw do end resources :authors do + new do + get :new + end collection do get :index get :show @@ -22,6 +25,9 @@ Pettanr::Application.routes.draw do end end resources :artists do + new do + get :new + end collection do get :index get :show diff --git a/spec/controllers/app_controller_spec.rb b/spec/controllers/app_controller_spec.rb index ea9b5410..200287ba 100644 --- a/spec/controllers/app_controller_spec.rb +++ b/spec/controllers/app_controller_spec.rb @@ -10,7 +10,7 @@ describe SystemController do context '要請の必要がないとき' do before do #要請の必要がない=管理者登録済み かつ ライセンス登録済み - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @@ -22,7 +22,7 @@ describe SystemController do context 'userがサインインしているなら' do before do @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id sign_in @user end it 'userにサインイン中のアカウントをセットしている' do @@ -46,7 +46,7 @@ describe SystemController do context 'userがサインインしていないなら' do before do @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id end it 'userが空になっている' do @@ -97,7 +97,7 @@ describe SystemController do end context 'ライセンスがないとき' do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin end context '本機能を開こうとしているなら' do it '初期化要請ページに遷移する' do diff --git a/spec/controllers/artists_controller_spec.rb b/spec/controllers/artists_controller_spec.rb index a2e1a328..c6ae2776 100644 --- a/spec/controllers/artists_controller_spec.rb +++ b/spec/controllers/artists_controller_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe ArtistsController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id end @@ -220,35 +220,35 @@ describe ArtistsController do end end - describe '新規作成フォーム表示に於いて' do - before do - sign_in @user - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :new - response.should be_success - end - it '@artistに新規データを用意している' do - get :new - assigns(:artist).should be_a_new(Artist) - end - it '絵師モデルにデフォルト値補充を依頼している' do - Artist.any_instance.should_receive(:supply_default).exactly(1) - get :new - end - context 'html形式' do - it 'newテンプレートを描画する' do - get :new - response.should render_template("new") - end - end - context 'js形式' do - it 'new.jsテンプレートを描画する' do - get :new, :format => :js - response.should render_template("new") - end - end + describe '新規作成フォーム表示に於いて' do + before do + sign_in @user + end + context 'つつがなく終わるとき' do + it 'ステータスコード200 OKを返す' do + get :new + response.should be_success + end + it '@artistに新規データを用意している' do + get :new + assigns(:ar).should be_a_new(Artist) + end + it '絵師モデルにデフォルト値補充を依頼している' do + Artist.any_instance.should_receive(:supply_default).exactly(1) + get :new + end + context 'html形式' do + it 'newテンプレートを描画する' do + get :new + response.should render_template("new") + end + end + context 'js形式' do + it 'new.jsテンプレートを描画する' do + get :new, :format => :js + response.should render_template("new") + end + end context 'json形式' do it 'jsonデータを返す' do get :new, :format => :json @@ -259,31 +259,31 @@ describe ArtistsController do get :new, :format => :json end end - end - context '作家権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :new - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :new - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :new, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :new, :format => :js - response.message.should match(/Unauthorized/) - end - end + end + context '作家権限がないとき' do + before do + sign_out @user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :new + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + get :new + response.body.should redirect_to '/users/sign_in' + end + end + context 'js形式' do + it 'ステータスコード401 Unauthorizedを返す' do + get :new, :format => :js + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + get :new, :format => :js + response.message.should match(/Unauthorized/) + end + end context 'json形式' do it 'ステータスコード401 Unauthorizedを返す' do get :new, :format => :json @@ -294,290 +294,290 @@ describe ArtistsController do response.message.should match(/Unauthorized/) end end - end - end - - describe '新規作成に於いて' do - before do - sign_in @user - @attr = FactoryGirl.attributes_for(:artist, :author_id => @author.id, :name => 'ken') - end - context '事前チェックしておく' do - it '絵師モデルにデフォルト値補充を依頼している' do - Artist.any_instance.should_receive(:supply_default).exactly(1) - post :create, :artist => @attr - end - it '絵師モデルにカラム値復元を依頼している' do - Artist.any_instance.should_receive(:attributes=).exactly(1) - post :create, :artist => @attr - end - it '絵師モデルに上書き補充を依頼している' do - Artist.any_instance.should_receive(:overwrite).exactly(1) - post :create, :artist => @attr - end - it 'モデルに保存依頼する' do - Artist.any_instance.should_receive(:save).exactly(1) - post :create, :artist => @attr - end - end - context 'つつがなく終わるとき' do - it "@artistに作成された絵師を保持していて、それがDBにある" do - post :create, :artist => @attr - assigns(:artist).should be_a(Artist) - assigns(:artist).should be_persisted - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Artist.any_instance.stub(:save).and_return(true) - post :create, :artist => @attr - response.status.should eq 302 - end - it '作成された絵師の表示ページへ遷移する' do -# Artist.any_instance.stub(:save).and_return(true) - post :create, :artist => @attr - response.should redirect_to(Artist.last) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do -# Artist.any_instance.stub(:save).and_return(true) - post :create, :artist => @attr, :format => :json - response.should be_success - end - it '作成された絵師をjsonデータで返す' do - post :create, :artist => @attr, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end + end + end + + describe '新規作成に於いて' do + before do + sign_in @user + @attr = FactoryGirl.attributes_for(:artist, :author_id => @author.id, :name => 'ken') + end + context '事前チェックしておく' do + it '絵師モデルにデフォルト値補充を依頼している' do + Artist.any_instance.should_receive(:supply_default).exactly(1) + post :create, :artist => @attr + end + it '絵師モデルにカラム値復元を依頼している' do + Artist.any_instance.should_receive(:attributes=).exactly(1) + post :create, :artist => @attr + end + it '絵師モデルに上書き補充を依頼している' do + Artist.any_instance.should_receive(:overwrite).exactly(1) + post :create, :artist => @attr + end + it 'モデルに保存依頼する' do + Artist.any_instance.should_receive(:save).exactly(1) + post :create, :artist => @attr + end + end + context 'つつがなく終わるとき' do + it "@artistに作成された絵師を保持していて、それがDBにある" do + post :create, :artist => @attr + assigns(:artist).should be_a(Artist) + assigns(:artist).should be_persisted + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + Artist.any_instance.stub(:save).and_return(true) + post :create, :artist => @attr + response.status.should eq 302 + end + it '作成された絵師の表示ページへ遷移する' do +# Artist.any_instance.stub(:save).and_return(true) + post :create, :artist => @attr + response.should redirect_to(Artist.last) + end + end + context 'json形式' do + it 'ステータスコード200 OKを返す' do +# Artist.any_instance.stub(:save).and_return(true) + post :create, :artist => @attr, :format => :json + response.should be_success + end + it '作成された絵師をjsonデータで返す' do + post :create, :artist => @attr, :format => :json + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end it '絵師モデルにjson単体出力オプションを問い合わせている' do Artist.should_receive(:show_json_opt).exactly(1) - post :create, :artist => @attr, :format => :json - end - it 'データがアレになっている' do - post :create, :artist => @attr, :format => :json - json = JSON.parse response.body - json["name"].should match(/ken/) - end - end - end - context '作家権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - post :create, :artist => @attr - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - post :create, :artist => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - post :create, :artist => @attr, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - post :create, :artist => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context '検証、保存に失敗した' do - before do - Artist.any_instance.stub(:save).and_return(false) - end - it "未保存の絵師を保持している" do - post :create, :artist => @attr - assigns(:artist).should be_a_new(Artist) - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - post :create, :artist => @attr - response.status.should eq 200 - end - it '新規ページを描画する' do - post :create, :artist => @attr - response.should render_template("new") - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - post :create, :artist => @attr, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - post :create, :artist => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - - describe '編集フォーム表示に於いて' do - before do - sign_in @user - Artist.stub(:edit).and_return(@artist) - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @artist.id - response.should be_success - end - it '絵師モデルに編集取得を問い合わせている' do - Artist.should_receive(:edit).exactly(1) - get :edit, :id => @artist.id - end - it '@artistにデータを用意している' do - get :edit, :id => @artist.id - assigns(:artist).should eq @artist - end - context 'html形式' do - it 'editテンプレートを描画する' do - get :edit, :id => @artist.id - response.should render_template("edit") - end - end - context 'js形式' do - it 'edit.jsテンプレートを描画する' do - get :edit, :id => @artist.id, :format => :js - response.should render_template("edit") - end - end - end - context '作家権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @artist.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @artist.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :edit, :id => @artist.id, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :edit, :id => @artist.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '更新に於いて' do - before do - @attr = FactoryGirl.attributes_for(:artist, :author_id => @author.id, :name => 'ryu') - sign_in @user - end - context '事前チェックしておく' do - it '絵師モデルに編集取得を問い合わせている' do - Artist.stub(:edit).with(any_args()).and_return @artist - Artist.should_receive(:edit).exactly(1) - put :update, :id => @artist.id, :artist => @attr - end - it '絵師モデルにカラム値復元を依頼している' do - Artist.any_instance.should_receive(:attributes=).exactly(1) - put :update, :id => @artist.id, :artist => @attr - end - it '絵師モデルに上書き補充を依頼している' do - Artist.any_instance.should_receive(:overwrite).exactly(1) - put :update, :id => @artist.id, :artist => @attr - end - it 'モデルに更新を依頼する' do - Artist.any_instance.stub(:save).with(any_args).and_return true - Artist.any_instance.should_receive(:save).exactly(1) - put :update, :id => @artist.id, :artist => @attr - end - it '@artistにアレを取得している' do - put :update, :id => @artist.id, :artist => @attr - assigns(:artist).should eq @artist - end - end - context 'つつがなく終わるとき' do - it '更新される' do - put :update, :id => @artist.id, :artist => @attr - Artist.find(@artist.id).name.should eq 'ryu' - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Artist.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @artist.id, :artist => @attr - response.status.should eq 302 - end - it '更新された絵師の表示ページへ遷移する' do - put :update, :id => @artist.id, :artist => @attr - response.should redirect_to(@artist) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - Artist.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @artist.id, :artist => @attr, :format => :json - response.should be_success - end - it 'ページ本体は特に返さない' do - Artist.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @artist.id, :artist => @attr, :format => :json - response.body.should match /./ - end - end - end - context '作家権限がないとき' do - before do - sign_out @user - end - it 'ステータスコード302 Foundを返す' do - put :update, :id => @artist.id, :artist => @attr - response.status.should eq 302 - end - context 'html形式' do - it 'サインインページへ遷移する' do - put :update, :id => @artist.id, :artist => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - put :update, :id => @artist.id, :artist => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context '検証、保存に失敗したとき' do - before do - Artist.any_instance.stub(:save).and_return(false) - end - context 'html形式' do - it 'ステータスコード200 Okを返す' do - put :update, :id => @artist.id, :artist => @attr - response.status.should eq 200 - end - it '編集ページを描画する' do - put :update, :id => @artist.id, :artist => @attr - response.should render_template("edit") - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - Artist.any_instance.stub(:save).and_return(false) - put :update, :id => @artist.id, :artist => @attr, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - put :update, :id => @artist.id, :artist => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end - + post :create, :artist => @attr, :format => :json + end + it 'データがアレになっている' do + post :create, :artist => @attr, :format => :json + json = JSON.parse response.body + json["name"].should match(/ken/) + end + end + end + context '作家権限がないとき' do + before do + sign_out @user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + post :create, :artist => @attr + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + post :create, :artist => @attr + response.body.should redirect_to '/users/sign_in' + end + end + context 'json形式' do + it 'ステータスコード401 Unauthorizedを返す' do + post :create, :artist => @attr, :format => :json + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + post :create, :artist => @attr, :format => :json + response.message.should match(/Unauthorized/) + end + end + end + context '検証、保存に失敗した' do + before do + Artist.any_instance.stub(:save).and_return(false) + end + it "未保存の絵師を保持している" do + post :create, :artist => @attr + assigns(:ar).should be_a_new(Artist) + end + context 'html形式' do + it 'ステータスコード200 OKを返す' do + post :create, :artist => @attr + response.status.should eq 200 + end + it '新規ページを描画する' do + post :create, :artist => @attr + response.should render_template("new") + end + end + context 'json形式' do + it 'ステータスコード422 unprocessable_entity を返す' do + post :create, :artist => @attr, :format => :json + response.status.should eq 422 + end + it '応答メッセージUnprocessable Entityを返す' do + post :create, :artist => @attr, :format => :json + response.message.should match(/Unprocessable/) + end + end + end + end + + describe '編集フォーム表示に於いて' do + before do + sign_in @user + Artist.stub(:edit).and_return(@artist) + end + context 'つつがなく終わるとき' do + it 'ステータスコード200 OKを返す' do + get :edit, :id => @artist.id + response.should be_success + end + it '絵師モデルに編集取得を問い合わせている' do + Artist.should_receive(:edit).exactly(1) + get :edit, :id => @artist.id + end + it '@artistにデータを用意している' do + get :edit, :id => @artist.id + assigns(:artist).should eq @artist + end + context 'html形式' do + it 'editテンプレートを描画する' do + get :edit, :id => @artist.id + response.should render_template("edit") + end + end + context 'js形式' do + it 'edit.jsテンプレートを描画する' do + get :edit, :id => @artist.id, :format => :js + response.should render_template("edit") + end + end + end + context '作家権限がないとき' do + before do + sign_out @user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :edit, :id => @artist.id + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + get :edit, :id => @artist.id + response.body.should redirect_to '/users/sign_in' + end + end + context 'js形式' do + it 'ステータスコード401 Unauthorizedを返す' do + get :edit, :id => @artist.id, :format => :js + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + get :edit, :id => @artist.id, :format => :js + response.message.should match(/Unauthorized/) + end + end + end + end + + describe '更新に於いて' do + before do + @attr = FactoryGirl.attributes_for(:artist, :author_id => @author.id, :name => 'ryu') + sign_in @user + end + context '事前チェックしておく' do + it '絵師モデルに編集取得を問い合わせている' do + Artist.stub(:edit).with(any_args()).and_return @artist + Artist.should_receive(:edit).exactly(1) + put :update, :id => @artist.id, :artist => @attr + end + it '絵師モデルにカラム値復元を依頼している' do + Artist.any_instance.should_receive(:attributes=).exactly(1) + put :update, :id => @artist.id, :artist => @attr + end + it '絵師モデルに上書き補充を依頼している' do + Artist.any_instance.should_receive(:overwrite).exactly(1) + put :update, :id => @artist.id, :artist => @attr + end + it 'モデルに更新を依頼する' do + Artist.any_instance.stub(:save).with(any_args).and_return true + Artist.any_instance.should_receive(:save).exactly(1) + put :update, :id => @artist.id, :artist => @attr + end + it '@artistにアレを取得している' do + put :update, :id => @artist.id, :artist => @attr + assigns(:artist).should eq @artist + end + end + context 'つつがなく終わるとき' do + it '更新される' do + put :update, :id => @artist.id, :artist => @attr + Artist.find(@artist.id).name.should eq 'ryu' + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + Artist.any_instance.stub(:save).with(any_args()).and_return(true) + put :update, :id => @artist.id, :artist => @attr + response.status.should eq 302 + end + it '更新された絵師の表示ページへ遷移する' do + put :update, :id => @artist.id, :artist => @attr + response.should redirect_to(@artist) + end + end + context 'json形式' do + it 'ステータスコード200 OKを返す' do + Artist.any_instance.stub(:save).with(any_args()).and_return(true) + put :update, :id => @artist.id, :artist => @attr, :format => :json + response.should be_success + end + it 'ページ本体は特に返さない' do + Artist.any_instance.stub(:save).with(any_args()).and_return(true) + put :update, :id => @artist.id, :artist => @attr, :format => :json + response.body.should match /./ + end + end + end + context '作家権限がないとき' do + before do + sign_out @user + end + it 'ステータスコード302 Foundを返す' do + put :update, :id => @artist.id, :artist => @attr + response.status.should eq 302 + end + context 'html形式' do + it 'サインインページへ遷移する' do + put :update, :id => @artist.id, :artist => @attr + response.body.should redirect_to '/users/sign_in' + end + end + context 'json形式' do + it '応答メッセージにUnauthorizedを返す' do + put :update, :id => @artist.id, :artist => @attr, :format => :json + response.message.should match(/Unauthorized/) + end + end + end + context '検証、保存に失敗したとき' do + before do + Artist.any_instance.stub(:save).and_return(false) + end + context 'html形式' do + it 'ステータスコード200 Okを返す' do + put :update, :id => @artist.id, :artist => @attr + response.status.should eq 200 + end + it '編集ページを描画する' do + put :update, :id => @artist.id, :artist => @attr + response.should render_template("edit") + end + end + context 'json形式' do + it 'ステータスコード422 unprocessable_entity を返す' do + Artist.any_instance.stub(:save).and_return(false) + put :update, :id => @artist.id, :artist => @attr, :format => :json + response.status.should eq 422 + end + it '応答メッセージUnprocessable Entityを返す' do + put :update, :id => @artist.id, :artist => @attr, :format => :json + response.message.should match(/Unprocessable/) + end + end + end + end + end diff --git a/spec/controllers/authors_controller_spec.rb b/spec/controllers/authors_controller_spec.rb index d13828e2..da6819d3 100644 --- a/spec/controllers/authors_controller_spec.rb +++ b/spec/controllers/authors_controller_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe AuthorsController do before do - FactoryGirl.create :admin + @admin =FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id end @@ -149,7 +149,7 @@ describe AuthorsController do it 'データがアレになっている' do get :show, :id => @author.id, :format => :json json = JSON.parse response.body - json["name"].should match(/name/) + json["name"].should match(/test/) json["user_id"].should eq @author.user_id end end @@ -223,173 +223,370 @@ describe AuthorsController do end end - describe '編集フォーム表示に於いて' do - before do - sign_in @user - Author.stub(:edit).and_return(@author) - end - context 'つつがなく終わるとき' do - it 'ステータスコード200 OKを返す' do - get :edit, :id => @author.id - response.should be_success - end - it '作家モデルに編集取得を問い合わせている' do - Author.should_receive(:edit).exactly(1) - get :edit, :id => @author.id - end + describe '新規作成フォーム表示に於いて' do + before do + @new_user = FactoryGirl.create( :user_yas) + sign_in @new_user + end + context 'つつがなく終わるとき' do + it 'ステータスコード200 OKを返す' do + get :new + response.should be_success + end + it '@auに新規データを用意している' do + get :new + assigns(:au).should be_a_new(Author) + end + it '作家モデルにデフォルト値補充を依頼している' do + Author.any_instance.should_receive(:supply_default).exactly(1) + get :new + end + context 'html形式' do + it 'newテンプレートを描画する' do + get :new + response.should render_template("new") + end + end + context 'js形式' do + it 'new.jsテンプレートを描画する' do + get :new, :format => :js + response.should render_template("new") + end + end + context 'json形式' do + it 'jsonデータを返す' do + get :new, :format => :json + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end + it '作家モデルにjson単体出力オプションを問い合わせている' do + Author.should_receive(:show_json_opt).exactly(1) + get :new, :format => :json + end + end + end + context '作家権限がないとき' do + before do + sign_out @new_user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :new + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + get :new + response.body.should redirect_to '/users/sign_in' + end + end + context 'js形式' do + it 'ステータスコード401 Unauthorizedを返す' do + get :new, :format => :js + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + get :new, :format => :js + response.message.should match(/Unauthorized/) + end + end + context 'json形式' do + it 'ステータスコード401 Unauthorizedを返す' do + get :new, :format => :json + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + get :new, :format => :json + response.message.should match(/Unauthorized/) + end + end + end + end + + describe '新規作成に於いて' do + before do + @new_user = FactoryGirl.create( :user_yas) + sign_in @new_user + @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken') + end + context '事前チェックしておく' do + it '作家モデルにデフォルト値補充を依頼している' do + Author.any_instance.should_receive(:supply_default).exactly(1) + post :create, :author => @attr + end + it '作家モデルにカラム値復元を依頼している' do + Author.any_instance.should_receive(:attributes=).exactly(1) + post :create, :author => @attr + end + it '作家モデルに上書き補充を依頼している' do + Author.any_instance.should_receive(:overwrite).exactly(1) + post :create, :author => @attr + end + it 'モデルに保存依頼する' do + Author.any_instance.should_receive(:save).exactly(1) + post :create, :author => @attr + end + end + context 'つつがなく終わるとき' do + it "@auに作成された作家を保持していて、それがDBにある" do + post :create, :author => @attr + assigns(:au).should be_a(Author) + assigns(:au).should be_persisted + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + Author.any_instance.stub(:save).and_return(true) + post :create, :author => @attr + response.status.should eq 302 + end + it '作成された作家の表示ページへ遷移する' do +# Author.any_instance.stub(:save).and_return(true) + post :create, :author => @attr + response.should redirect_to(Author.last) + end + end + context 'json形式' do + it 'ステータスコード200 OKを返す' do +# Author.any_instance.stub(:save).and_return(true) + post :create, :author => @attr, :format => :json + response.should be_success + end + it '作成された作家をjsonデータで返す' do + post :create, :author => @attr, :format => :json + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end + it '作家モデルにjson単体出力オプションを問い合わせている' do + Author.should_receive(:show_json_opt).exactly(1) + post :create, :author => @attr, :format => :json + end + it 'データがアレになっている' do + post :create, :author => @attr, :format => :json + json = JSON.parse response.body + json["name"].should match(/ken/) + end + end + end + context '作家権限がないとき' do + before do + sign_out @new_user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + post :create, :author => @attr + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + post :create, :author => @attr + response.body.should redirect_to '/users/sign_in' + end + end + context 'json形式' do + it 'ステータスコード401 Unauthorizedを返す' do + post :create, :author => @attr, :format => :json + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + post :create, :author => @attr, :format => :json + response.message.should match(/Unauthorized/) + end + end + end + context '検証、保存に失敗した' do + before do + Author.any_instance.stub(:save).and_return(false) + end + it "未保存の作家を保持している" do + post :create, :author => @attr + assigns(:au).should be_a_new(Author) + end + context 'html形式' do + it 'ステータスコード200 OKを返す' do + post :create, :author => @attr + response.status.should eq 200 + end + it '新規ページを描画する' do + post :create, :author => @attr + response.should render_template("new") + end + end + context 'json形式' do + it 'ステータスコード422 unprocessable_entity を返す' do + post :create, :author => @attr, :format => :json + response.status.should eq 422 + end + it '応答メッセージUnprocessable Entityを返す' do + post :create, :author => @attr, :format => :json + response.message.should match(/Unprocessable/) + end + end + end + end + + describe '編集フォーム表示に於いて' do + before do + sign_in @user + Author.stub(:edit).and_return(@author) + end + context 'つつがなく終わるとき' do + it 'ステータスコード200 OKを返す' do + get :edit, :id => @author.id + response.should be_success + end + it '作家モデルに編集取得を問い合わせている' do + Author.should_receive(:edit).exactly(1) + get :edit, :id => @author.id + end #@authorだとログイン中のアカウントと干渉してしまう。 - it '@auにデータを用意している' do - get :edit, :id => @author.id - assigns(:au).should eq @author - end - context 'html形式' do - it 'editテンプレートを描画する' do - get :edit, :id => @author.id - response.should render_template("edit") - end - end - context 'js形式' do - it 'edit.jsテンプレートを描画する' do - get :edit, :id => @author.id, :format => :js - response.should render_template("edit") - end - end - end - context '作家権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :edit, :id => @author.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :edit, :id => @author.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'js形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :edit, :id => @author.id, :format => :js - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :edit, :id => @author.id, :format => :js - response.message.should match(/Unauthorized/) - end - end - end - end - - describe '更新に於いて' do - before do + it '@auにデータを用意している' do + get :edit, :id => @author.id + assigns(:au).should eq @author + end + context 'html形式' do + it 'editテンプレートを描画する' do + get :edit, :id => @author.id + response.should render_template("edit") + end + end + context 'js形式' do + it 'edit.jsテンプレートを描画する' do + get :edit, :id => @author.id, :format => :js + response.should render_template("edit") + end + end + end + context '作家権限がないとき' do + before do + sign_out @user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :edit, :id => @author.id + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + get :edit, :id => @author.id + response.body.should redirect_to '/users/sign_in' + end + end + context 'js形式' do + it 'ステータスコード401 Unauthorizedを返す' do + get :edit, :id => @author.id, :format => :js + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + get :edit, :id => @author.id, :format => :js + response.message.should match(/Unauthorized/) + end + end + end + end + + describe '更新に於いて' do + before do @attr = @author.attributes - @attr['name'] = 'ryu' - sign_in @user - end - context '事前チェックしておく' do - it '作家モデルに編集取得を問い合わせている' do - Author.stub(:edit).with(any_args()).and_return @author - Author.should_receive(:edit).exactly(1) - put :update, :id => @author.id, :author => @attr - end - it 'モデルにpostデータ転送を依頼する' do - Author.any_instance.stub(:attributes=).with(any_args) - Author.any_instance.should_receive(:attributes=).exactly(1) - put :update, :id => @author.id, :author => @attr - end - it 'モデルに上書き補充を依頼する' do - Author.any_instance.stub(:overwrite).with(any_args) - Author.any_instance.should_receive(:overwrite).exactly(1) - put :update, :id => @author.id, :author => @attr - end - it 'モデルに更新を依頼する' do - Author.any_instance.stub(:save).with(any_args).and_return true - Author.any_instance.should_receive(:save).exactly(1) - put :update, :id => @author.id, :author => @attr - end - it '@auにアレを取得している' do - put :update, :id => @author.id, :author => @attr - assigns(:au).should eq @author - end - end - context 'つつがなく終わるとき' do - it '更新される' do - put :update, :id => @author.id, :author => @attr - Author.find(@author.id).name.should eq 'ryu' - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - Author.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @author.id, :author => @attr - response.status.should eq 302 - end - it '更新された作家の表示ページへ遷移する' do - put :update, :id => @author.id, :author => @attr - response.should redirect_to(@author) - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - Author.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @author.id, :author => @attr, :format => :json - response.should be_success - end - it 'ページ本体は特に返さない' do - Author.any_instance.stub(:save).with(any_args()).and_return(true) - put :update, :id => @author.id, :author => @attr, :format => :json - response.body.should match /./ - end - end - end - context '作家権限がないとき' do - before do - sign_out @user - end - it 'ステータスコード302 Foundを返す' do - put :update, :id => @author.id, :author => @attr - response.status.should eq 302 - end - context 'html形式' do - it 'サインインページへ遷移する' do - put :update, :id => @author.id, :author => @attr - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - put :update, :id => @author.id, :author => @attr, :format => :json - response.message.should match(/Unauthorized/) - end - end - end - context '検証、保存に失敗したとき' do - before do - Author.any_instance.stub(:save).and_return(false) - end - context 'html形式' do - it 'ステータスコード200 Okを返す' do - put :update, :id => @author.id, :author => @attr - response.status.should eq 200 - end - it '編集ページを描画する' do - put :update, :id => @author.id, :author => @attr - response.should render_template("edit") - end - end - context 'json形式' do - it 'ステータスコード422 unprocessable_entity を返す' do - Author.any_instance.stub(:save).and_return(false) - put :update, :id => @author.id, :author => @attr, :format => :json - response.status.should eq 422 - end - it '応答メッセージUnprocessable Entityを返す' do - put :update, :id => @author.id, :author => @attr, :format => :json - response.message.should match(/Unprocessable/) - end - end - end - end + @attr['name'] = 'ryu' + sign_in @user + end + context '事前チェックしておく' do + it '作家モデルに編集取得を問い合わせている' do + Author.stub(:edit).with(any_args()).and_return @author + Author.should_receive(:edit).exactly(1) + put :update, :id => @author.id, :author => @attr + end + it 'モデルにpostデータ転送を依頼する' do + Author.any_instance.stub(:attributes=).with(any_args) + Author.any_instance.should_receive(:attributes=).exactly(1) + put :update, :id => @author.id, :author => @attr + end + it 'モデルに上書き補充を依頼する' do + Author.any_instance.stub(:overwrite).with(any_args) + Author.any_instance.should_receive(:overwrite).exactly(1) + put :update, :id => @author.id, :author => @attr + end + it 'モデルに更新を依頼する' do + Author.any_instance.stub(:save).with(any_args).and_return true + Author.any_instance.should_receive(:save).exactly(1) + put :update, :id => @author.id, :author => @attr + end + it '@auにアレを取得している' do + put :update, :id => @author.id, :author => @attr + assigns(:au).should eq @author + end + end + context 'つつがなく終わるとき' do + it '更新される' do + put :update, :id => @author.id, :author => @attr + Author.find(@author.id).name.should eq 'ryu' + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + Author.any_instance.stub(:save).with(any_args()).and_return(true) + put :update, :id => @author.id, :author => @attr + response.status.should eq 302 + end + it '更新された作家の表示ページへ遷移する' do + put :update, :id => @author.id, :author => @attr + response.should redirect_to(@author) + end + end + context 'json形式' do + it 'ステータスコード200 OKを返す' do + Author.any_instance.stub(:save).with(any_args()).and_return(true) + put :update, :id => @author.id, :author => @attr, :format => :json + response.should be_success + end + it 'ページ本体は特に返さない' do + Author.any_instance.stub(:save).with(any_args()).and_return(true) + put :update, :id => @author.id, :author => @attr, :format => :json + response.body.should match /./ + end + end + end + context '作家権限がないとき' do + before do + sign_out @user + end + it 'ステータスコード302 Foundを返す' do + put :update, :id => @author.id, :author => @attr + response.status.should eq 302 + end + context 'html形式' do + it 'サインインページへ遷移する' do + put :update, :id => @author.id, :author => @attr + response.body.should redirect_to '/users/sign_in' + end + end + context 'json形式' do + it '応答メッセージにUnauthorizedを返す' do + put :update, :id => @author.id, :author => @attr, :format => :json + response.message.should match(/Unauthorized/) + end + end + end + context '検証、保存に失敗したとき' do + before do + Author.any_instance.stub(:save).and_return(false) + end + context 'html形式' do + it 'ステータスコード200 Okを返す' do + put :update, :id => @author.id, :author => @attr + response.status.should eq 200 + end + it '編集ページを描画する' do + put :update, :id => @author.id, :author => @attr + response.should render_template("edit") + end + end + context 'json形式' do + it 'ステータスコード422 unprocessable_entity を返す' do + Author.any_instance.stub(:save).and_return(false) + put :update, :id => @author.id, :author => @attr, :format => :json + response.status.should eq 422 + end + it '応答メッセージUnprocessable Entityを返す' do + put :update, :id => @author.id, :author => @attr, :format => :json + response.message.should match(/Unprocessable/) + end + end + end + end end diff --git a/spec/controllers/colors_controller_spec.rb b/spec/controllers/colors_controller_spec.rb index 40ad6410..92375fd9 100644 --- a/spec/controllers/colors_controller_spec.rb +++ b/spec/controllers/colors_controller_spec.rb @@ -6,6 +6,7 @@ describe ColorsController do before do @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) + @author = FactoryGirl.create :author, :user_id => @user.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group, :name => 'peta' @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id diff --git a/spec/controllers/comics_controller_spec.rb b/spec/controllers/comics_controller_spec.rb index 37b885e0..6bcc5955 100644 --- a/spec/controllers/comics_controller_spec.rb +++ b/spec/controllers/comics_controller_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe ComicsController do before do - FactoryGirl.create :admin + @admin =FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create :user_yas - @author = @user.author #ユーザ作成時に連動して作成される + @author = FactoryGirl.create :author, :user_id => @user.id end describe '一覧表示に於いて' do @@ -68,10 +68,10 @@ describe ComicsController do get :index, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end - it 'コミックモデルにjson一覧出力オプションを問い合わせている' do - Comic.should_receive(:list_json_opt).exactly(1) - get :index, :format => :json - end + it 'コミックモデルにjson一覧出力オプションを問い合わせている' do + Comic.should_receive(:list_json_opt).exactly(1) + get :index, :format => :json + end it 'データがリスト構造になっている' do get :index, :format => :json json = JSON.parse response.body @@ -142,10 +142,10 @@ describe ComicsController do get :show, :id => @comic.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end - it 'コミックモデルにjson単体出力オプションを問い合わせている' do - Comic.should_receive(:show_json_opt).exactly(1) - get :show, :id => @comic.id, :format => :json - end + it 'コミックモデルにjson単体出力オプションを問い合わせている' do + Comic.should_receive(:show_json_opt).exactly(1) + get :show, :id => @comic.id, :format => :json + end it 'データがアレになっている' do get :show, :id => @comic.id, :format => :json json = JSON.parse response.body @@ -271,16 +271,16 @@ describe ComicsController do response.should render_template("new") end end - context 'json形式' do - it 'jsonデータを返す' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'コミックモデルにjson単体出力オプションを問い合わせている' do - Comic.should_receive(:show_json_opt).exactly(1) - get :new, :format => :json - end - end + context 'json形式' do + it 'jsonデータを返す' do + get :new, :format => :json + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end + it 'コミックモデルにjson単体出力オプションを問い合わせている' do + Comic.should_receive(:show_json_opt).exactly(1) + get :new, :format => :json + end + end end context '作家権限がないとき' do before do @@ -318,7 +318,7 @@ describe ComicsController do it 'コミックモデルにデフォルト値補充を依頼している' do Comic.any_instance.should_receive(:supply_default).exactly(1) post :create, :artist => @attr - end + end it 'コミックモデルにカラム値復元を依頼している' do Comic.any_instance.should_receive(:attributes=).exactly(1) post :create, :artist => @attr diff --git a/spec/controllers/ground_colors_controller_spec.rb b/spec/controllers/ground_colors_controller_spec.rb index ecbc9bcc..d9dbd7cc 100644 --- a/spec/controllers/ground_colors_controller_spec.rb +++ b/spec/controllers/ground_colors_controller_spec.rb @@ -9,7 +9,7 @@ describe GroundColorsController do @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group, :name => 'peta' @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id @color = FactoryGirl.create :color diff --git a/spec/controllers/ground_pictures_controller_spec.rb b/spec/controllers/ground_pictures_controller_spec.rb index 9f1c7982..eabcf278 100644 --- a/spec/controllers/ground_pictures_controller_spec.rb +++ b/spec/controllers/ground_pictures_controller_spec.rb @@ -9,7 +9,7 @@ describe GroundPicturesController do @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group, :name => 'peta' @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @op = FactoryGirl.create :original_picture, :artist_id => @artist.id @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index e53cb006..0f7f3e7d 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe HomeController do before do - FactoryGirl.create :admin + @admin =FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @color = FactoryGirl.create :color @op = FactoryGirl.create :original_picture, :artist_id => @artist.id diff --git a/spec/controllers/license_groups_controller_spec.rb b/spec/controllers/license_groups_controller_spec.rb index 05da3ade..994829cb 100644 --- a/spec/controllers/license_groups_controller_spec.rb +++ b/spec/controllers/license_groups_controller_spec.rb @@ -6,6 +6,7 @@ describe LicenseGroupsController do before do @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) + @author = FactoryGirl.create :author, :user_id => @user.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group, :name => 'peta' @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @@ -108,8 +109,8 @@ describe LicenseGroupsController do json = JSON.parse response.body json["name"].should match(/peta/) json["classname"].should_not be_nil - json["caption"].should_not be_nil - json["url"].should_not be_nil + json["caption"].should_not be_nil + json["url"].should_not be_nil end end end diff --git a/spec/controllers/licenses_controller_spec.rb b/spec/controllers/licenses_controller_spec.rb index 0627afb7..4888255d 100644 --- a/spec/controllers/licenses_controller_spec.rb +++ b/spec/controllers/licenses_controller_spec.rb @@ -8,7 +8,7 @@ describe LicensesController do @lg = FactoryGirl.create :license_group @sp = FactoryGirl.create :system_picture @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id end @@ -109,8 +109,8 @@ describe LicensesController do get :show, :id => @l.id, :format => :json json = JSON.parse response.body json["name"].should match(/peta/) - json["caption"].should_not be_nil - json["url"].should_not be_nil + json["caption"].should_not be_nil + json["url"].should_not be_nil end end end diff --git a/spec/controllers/original_picture_license_groups_controller_spec.rb b/spec/controllers/original_picture_license_groups_controller_spec.rb index 0501be4f..06273952 100644 --- a/spec/controllers/original_picture_license_groups_controller_spec.rb +++ b/spec/controllers/original_picture_license_groups_controller_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' describe OriginalPictureLicenseGroupsController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group, :classname => 'PettanrUnknownV01License' @@ -29,7 +29,7 @@ describe OriginalPictureLicenseGroupsController do end it '原画モデルに単体取得を問い合わせている' do OriginalPicture.stub(:show).with(any_args()).and_return(@op) - OriginalPicture.should_receive(:show).with(any_args()).exactly(1) + OriginalPicture.should_receive(:show).with(any_args()).exactly(1) get :new, @attr end it '@original_pictureにデータを用意している' do @@ -41,7 +41,7 @@ describe OriginalPictureLicenseGroupsController do assigns(:original_picture_license_group).should be_a_new(OriginalPictureLicenseGroup) end it '原画ライセンスグループモデルにデフォルト値補充を依頼している' do - OriginalPictureLicenseGroup.any_instance.should_receive(:supply_default).exactly(1) + OriginalPictureLicenseGroup.any_instance.should_receive(:supply_default).exactly(1) get :new, @attr end context 'html形式' do @@ -125,7 +125,7 @@ describe OriginalPictureLicenseGroupsController do end it '原画モデルに単体取得を問い合わせている' do OriginalPicture.stub(:show).with(any_args()).and_return(@op) - OriginalPicture.should_receive(:show).exactly(1) + OriginalPicture.should_receive(:show).exactly(1) post :create, @attr end it '@original_pictureにデータを用意している' do @@ -134,7 +134,7 @@ describe OriginalPictureLicenseGroupsController do end it 'ライセンスグループモデルに単体取得を問い合わせている' do LicenseGroup.stub(:show).with(any_args()).and_return(@lg) - LicenseGroup.should_receive(:show).exactly(1) + LicenseGroup.should_receive(:show).exactly(1) post :create, @attr end it '@license_groupにデータを用意している' do diff --git a/spec/controllers/original_pictures_controller_spec.rb b/spec/controllers/original_pictures_controller_spec.rb index 86ef5489..4a325ef8 100644 --- a/spec/controllers/original_pictures_controller_spec.rb +++ b/spec/controllers/original_pictures_controller_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' describe OriginalPicturesController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group diff --git a/spec/controllers/panel_colors_controller_spec.rb b/spec/controllers/panel_colors_controller_spec.rb index 285d2f48..4fcd5603 100644 --- a/spec/controllers/panel_colors_controller_spec.rb +++ b/spec/controllers/panel_colors_controller_spec.rb @@ -9,7 +9,7 @@ describe PanelColorsController do @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group, :name => 'peta' @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id end diff --git a/spec/controllers/panel_pictures_controller_spec.rb b/spec/controllers/panel_pictures_controller_spec.rb index 69860659..7fac516d 100644 --- a/spec/controllers/panel_pictures_controller_spec.rb +++ b/spec/controllers/panel_pictures_controller_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe PanelPicturesController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @op = FactoryGirl.create :original_picture, :artist_id => @artist.id @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id diff --git a/spec/controllers/panels_controller_spec.rb b/spec/controllers/panels_controller_spec.rb index 8e6c8e1c..f9bfacdd 100644 --- a/spec/controllers/panels_controller_spec.rb +++ b/spec/controllers/panels_controller_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' #コマ describe PanelsController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create :user_yas - @author = @user.author #ユーザ作成時に連動して作成される + @author = FactoryGirl.create :author, :user_id => @user.id end describe '一覧表示に於いて' do @@ -71,10 +71,10 @@ describe PanelsController do get :index, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end - it 'コマモデルにコマリストのjson出力を問い合わせている' do - Panel.should_receive(:list_as_json_text).exactly(1) - get :index, :format => :json - end + it 'コマモデルにコマリストのjson出力を問い合わせている' do + Panel.should_receive(:list_as_json_text).exactly(1) + get :index, :format => :json + end it 'データがリスト構造になっている' do get :index, :format => :json json = JSON.parse response.body @@ -148,10 +148,10 @@ describe PanelsController do get :show, :id => @panel.id, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end - it 'コマモデルにコマのjson出力を問い合わせている' do - Panel.any_instance.should_receive(:panel_elements_as_json).exactly(1) - get :show, :id => @panel.id, :format => :json - end + it 'コマモデルにコマのjson出力を問い合わせている' do + Panel.any_instance.should_receive(:panel_elements_as_json).exactly(1) + get :show, :id => @panel.id, :format => :json + end it 'データがアレになっている' do get :show, :id => @panel.id, :format => :json json = JSON.parse response.body @@ -277,16 +277,16 @@ describe PanelsController do response.should render_template("new") end end - context 'json形式' do - it 'jsonデータを返す' do - get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end - it 'コマモデルにコマのjson出力を問い合わせている' do - Panel.any_instance.should_receive(:panel_elements_as_json).exactly(1) - get :new, :format => :json - end - end + context 'json形式' do + it 'jsonデータを返す' do + get :new, :format => :json + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end + it 'コマモデルにコマのjson出力を問い合わせている' do + Panel.any_instance.should_receive(:panel_elements_as_json).exactly(1) + get :new, :format => :json + end + end end context '作家権限がないとき' do before do @@ -377,10 +377,10 @@ describe PanelsController do post :create, :panel => @attr, :format => :json lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) end - it 'コマモデルにコマのjson出力を問い合わせている' do - Panel.any_instance.should_receive(:panel_elements_as_json).exactly(1) + it 'コマモデルにコマのjson出力を問い合わせている' do + Panel.any_instance.should_receive(:panel_elements_as_json).exactly(1) post :create, :panel => @attr, :format => :json - end + end it 'データがアレになっている' do post :create, :panel => @attr, :format => :json json = JSON.parse response.body diff --git a/spec/controllers/pictures_controller_spec.rb b/spec/controllers/pictures_controller_spec.rb index 6fc7a8f0..faeb4424 100644 --- a/spec/controllers/pictures_controller_spec.rb +++ b/spec/controllers/pictures_controller_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe PicturesController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @op = FactoryGirl.create :original_picture, :artist_id => @artist.id end diff --git a/spec/controllers/resource_pictures_controller_spec.rb b/spec/controllers/resource_pictures_controller_spec.rb index d46e807e..0854814d 100644 --- a/spec/controllers/resource_pictures_controller_spec.rb +++ b/spec/controllers/resource_pictures_controller_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe ResourcePicturesController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @op = FactoryGirl.create :original_picture, :artist_id => @artist.id end @@ -317,103 +317,103 @@ describe ResourcePicturesController do end end - describe 'クレジット表示に於いて' do - before do + describe 'クレジット表示に於いて' do + before 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) - end - context 'つつがなく終わるとき' do - it '素材モデルに単体取得を問い合わせている' do - ResourcePicture.should_receive(:show).exactly(1) - get :credit, :id => @rp.id - end - it '@resource_pictureにアレを取得している' do - get :credit, :id => @rp.id - assigns(:resource_picture).id.should eq(@rp.id) - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :credit, :id => @rp.id - response.should be_success - end - it 'creditテンプレートを描画する' do - get :credit, :id => @rp.id - response.should render_template("credit") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :credit, :id => @rp.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :credit, :id => @rp.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end + end + context 'つつがなく終わるとき' do + it '素材モデルに単体取得を問い合わせている' do + ResourcePicture.should_receive(:show).exactly(1) + get :credit, :id => @rp.id + end + it '@resource_pictureにアレを取得している' do + get :credit, :id => @rp.id + assigns(:resource_picture).id.should eq(@rp.id) + end + context 'html形式' do + it 'ステータスコード200 OKを返す' do + get :credit, :id => @rp.id + response.should be_success + end + it 'creditテンプレートを描画する' do + get :credit, :id => @rp.id + response.should render_template("credit") + end + end + context 'json形式' do + it 'ステータスコード200 OKを返す' do + get :credit, :id => @rp.id, :format => :json + response.should be_success + end + it 'jsonデータを返す' do + get :credit, :id => @rp.id, :format => :json + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end it '素材モデルにjson単体出力オプションを問い合わせている' do ResourcePicture.should_receive(:show_json_opt).exactly(1) - get :credit, :id => @rp.id, :format => :json + get :credit, :id => @rp.id, :format => :json end - it 'データがアレになっている' do - get :credit, :id => @rp.id, :format => :json - json = JSON.parse response.body - json["ext"].should match(/png/) + it 'データがアレになっている' do + get :credit, :id => @rp.id, :format => :json + json = JSON.parse response.body + json["ext"].should match(/png/) json["md5"].should_not be_nil json["picture_id"].should_not be_nil - end - end - end - context '作家権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :credit, :id => @rp.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :credit, :id => @rp.id - response.body.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :credit, :id => @rp.id, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :credit, :id => @rp.id, :format => :json - response.message.should match(/Unauthorized/) - end - end - end -=begin - context '対象素材がないとき' do - before do - ResourcePicture.unstub(:show) - end - context 'html形式' do - it '例外404 not_foundを返す' do - lambda{ - get :show, :id => 0 - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - context 'json形式' do - it '例外404 not_foundを返す' do - lambda{ - get :show, :id => 0, :format => :json - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end -=end + end + end + end + context '作家権限がないとき' do + before do + sign_out @user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :credit, :id => @rp.id + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + get :credit, :id => @rp.id + response.body.should redirect_to '/users/sign_in' + end + end + context 'json形式' do + it 'ステータスコード401 Unauthorizedを返す' do + get :credit, :id => @rp.id, :format => :json + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + get :credit, :id => @rp.id, :format => :json + response.message.should match(/Unauthorized/) + end + end + end +=begin + context '対象素材がないとき' do + before do + ResourcePicture.unstub(:show) + end + context 'html形式' do + it '例外404 not_foundを返す' do + lambda{ + get :show, :id => 0 + }.should raise_error(ActiveRecord::RecordNotFound) + end + end + context 'json形式' do + it '例外404 not_foundを返す' do + lambda{ + get :show, :id => 0, :format => :json + }.should raise_error(ActiveRecord::RecordNotFound) + end + end + end +=end end - #原画にライセンスを与えるため際の確認フォーム + #原画にライセンスを与えるため際の確認フォーム describe '新規作成フォーム表示に於いて' do before do sign_in @user @@ -588,29 +588,29 @@ describe ResourcePicturesController do end end end - context '対象ライセンスグループがないとき' do - before do + context '対象ライセンスグループがないとき' do + before do @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @op.id, :license_group_id => 0}, :resource_picture => {:original_picture_id => @op.id, :license_id => @license.id, :artist_name => @artist.name, :credit => '{}', :settings => '{}' }} - end - context 'html形式' do - it '例外404 not_foundを返す' do - lambda{ + end + context 'html形式' do + it '例外404 not_foundを返す' do + lambda{ get :new, @attr - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - context 'json形式' do + }.should raise_error(ActiveRecord::RecordNotFound) + end + end + context 'json形式' do before do @attr.merge!({:format => :js}) end - it '例外404 not_foundを返す' do - lambda{ - get :new, @attr - }.should raise_error(ActiveRecord::RecordNotFound) - end - end - end + it '例外404 not_foundを返す' do + lambda{ + get :new, @attr + }.should raise_error(ActiveRecord::RecordNotFound) + end + end + end end describe '新規作成に於いて' do @@ -711,9 +711,9 @@ describe ResourcePicturesController do assigns(:resource_picture).settings.should eq '{"new":1}' end it "作成された素材がDBにある" do - lambda{ + lambda{ post :create, @newattr - }.should change(ResourcePicture, :count) + }.should change(ResourcePicture, :count) end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -744,7 +744,7 @@ describe ResourcePicturesController do it 'データがアレになっている' do post :create, @newattr json = JSON.parse response.body - json["ext"].should match(/png/) + json["ext"].should match(/png/) json["md5"].should_not be_nil json["picture_id"].should_not be_nil end @@ -777,12 +777,12 @@ describe ResourcePicturesController do it "素材が更新される" do post :create, @attr r = ResourcePicture.find(@rp.id) - r.settings.should eq '{"new":0}' + r.settings.should eq '{"new":0}' end it "上書きなので件数は変化しない" do - lambda{ + lambda{ post :create, @attr - }.should_not change(ResourcePicture, :count) + }.should_not change(ResourcePicture, :count) end end context '作家権限がないとき' do diff --git a/spec/controllers/speech_balloon_templates_controller_spec.rb b/spec/controllers/speech_balloon_templates_controller_spec.rb index 597376f2..a107f5be 100644 --- a/spec/controllers/speech_balloon_templates_controller_spec.rb +++ b/spec/controllers/speech_balloon_templates_controller_spec.rb @@ -9,7 +9,7 @@ describe SpeechBalloonTemplatesController do @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @sbt = FactoryGirl.create :speech_balloon_template end diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 77c78eec..095b54ee 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' #ストーリー describe StoriesController do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create :user_yas - @author = @user.author #ユーザ作成時に連動して作成される + @author = FactoryGirl.create :author, :user_id => @user.id @comic = FactoryGirl.create :comic, :author_id => @user.author.id @panel = FactoryGirl.create :panel, :author_id => @author.id end @@ -58,9 +58,9 @@ describe StoriesController do it 'データがアレになっている' do get :show, :id => @story.id, :format => :json json = JSON.parse response.body - json.has_key?("panel_id").should be_true - json.has_key?("comic_id").should be_true - json.has_key?("author_id").should be_true + json.has_key?("panel_id").should be_true + json.has_key?("comic_id").should be_true + json.has_key?("author_id").should be_true end end end @@ -96,111 +96,111 @@ describe StoriesController 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) Story.stub(:count).and_return(10) - Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) + Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) sign_in @user end context 'パラメータチェックする' do - it '与えられたoffsetがセットされている' do - get :comic, :id => @comic.id, :offset => 5 - assigns(:offset).should eq 5 - end - it '省略されると@offsetに0値が入る' do - get :comic, :id => @comic.id - assigns(:offset).should eq 0 - end - it '与えられたcountがセットされている' do - get :comic, :id => @comic.id, :count => 4 - assigns(:panel_count).should eq 4 - end - it '省略されると@panel_countにデフォルト値が入る' do - get :comic, :id => @comic.id - assigns(:panel_count).should eq Story.default_panel_size - end - it '最大を超えると@panel_countにデフォルト最大値が入る' do - get :comic, :id => @comic.id, :count => 1500 - assigns(:panel_count).should eq Story.max_panel_size - end - it '不正な値が入ると@panel_countにデフォルト最大値が入る' do - get :comic, :id => @comic.id, :count => -1 - assigns(:panel_count).should eq Story.default_panel_size - end + it '与えられたoffsetがセットされている' do + get :comic, :id => @comic.id, :offset => 5 + assigns(:offset).should eq 5 + end + it '省略されると@offsetに0値が入る' do + get :comic, :id => @comic.id + assigns(:offset).should eq 0 + end + it '与えられたcountがセットされている' do + get :comic, :id => @comic.id, :count => 4 + assigns(:panel_count).should eq 4 + end + it '省略されると@panel_countにデフォルト値が入る' do + get :comic, :id => @comic.id + assigns(:panel_count).should eq Story.default_panel_size + end + it '最大を超えると@panel_countにデフォルト最大値が入る' do + get :comic, :id => @comic.id, :count => 1500 + assigns(:panel_count).should eq Story.max_panel_size + end + it '不正な値が入ると@panel_countにデフォルト最大値が入る' do + get :comic, :id => @comic.id, :count => -1 + assigns(:panel_count).should eq Story.default_panel_size + end end context '事前チェックする' do - it 'コミックモデルに単体取得を問い合わせている' do - Comic.should_receive(:show).with(@comic.id.to_s, @author).exactly(1) - get :comic, :id => @comic.id - end - it 'ストーリーモデルにプレイリスト取得を問い合わせている' do - Story.should_receive(:play_list).with(@comic, @author, 0, 30).exactly(1) - get :comic, :id => @comic.id - end + it 'コミックモデルに単体取得を問い合わせている' do + Comic.should_receive(:show).with(@comic.id.to_s, @author).exactly(1) + get :comic, :id => @comic.id + end + it 'ストーリーモデルにプレイリスト取得を問い合わせている' do + Story.should_receive(:play_list).with(@comic, @author, 0, 30).exactly(1) + get :comic, :id => @comic.id + end end context 'つつがなく終わるとき' do - it '@storiesにリストを取得している' do - get :comic, :id => @comic.id - assigns(:stories).should have_at_least(3).items - end - context 'html形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id - response.should be_success - end - it 'comicテンプレートを描画する' do - get :comic, :id => @comic.id - response.should render_template("comic") - end - end - context 'json形式' do - it 'ステータスコード200 OKを返す' do - get :comic, :id => @comic.id, :format => :json - response.should be_success - end - it 'jsonデータを返す' do - get :comic, :id => @comic.id, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end + it '@storiesにリストを取得している' do + get :comic, :id => @comic.id + assigns(:stories).should have_at_least(3).items + end + context 'html形式' do + it 'ステータスコード200 OKを返す' do + get :comic, :id => @comic.id + response.should be_success + end + it 'comicテンプレートを描画する' do + get :comic, :id => @comic.id + response.should render_template("comic") + end + end + context 'json形式' do + it 'ステータスコード200 OKを返す' do + get :comic, :id => @comic.id, :format => :json + response.should be_success + end + it 'jsonデータを返す' do + get :comic, :id => @comic.id, :format => :json + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end it 'ストーリーモデルにストーリーリストのjson出力を問い合わせている' do Story.should_receive(:list_as_json_text).exactly(1) - get :comic, :id => @comic.id, :format => :json - end - it 'データがリスト構造になっている' do - get :comic, :id => @comic.id, :format => :json - json = JSON.parse response.body - json.should have_at_least(3).items - end - it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do - get :comic, :id => @comic.id, :format => :json - json = JSON.parse response.body - json.first.has_key?("panel_id").should be_true - json.first.has_key?("comic_id").should be_true - json.first.has_key?("author_id").should be_true - end - end + get :comic, :id => @comic.id, :format => :json + end + it 'データがリスト構造になっている' do + get :comic, :id => @comic.id, :format => :json + json = JSON.parse response.body + json.should have_at_least(3).items + end + it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do + get :comic, :id => @comic.id, :format => :json + json = JSON.parse response.body + json.first.has_key?("panel_id").should be_true + json.first.has_key?("comic_id").should be_true + json.first.has_key?("author_id").should be_true + end + end end context '作家権限がないとき' do - before do - sign_out @user - end - context 'html形式' do - it 'ステータスコード302 Foundを返す' do - get :comic, :id => @comic.id - response.status.should eq 302 - end - it 'サインインページへ遷移する' do - get :comic, :id => @comic.id - response.should redirect_to '/users/sign_in' - end - end - context 'json形式' do - it 'ステータスコード401 Unauthorizedを返す' do - get :comic, :id => @comic.id, :format => :json - response.status.should eq 401 - end - it '応答メッセージにUnauthorizedを返す' do - get :comic, :id => @comic.id, :format => :json - response.message.should match(/Unauthorized/) - end - end + before do + sign_out @user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :comic, :id => @comic.id + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + get :comic, :id => @comic.id + response.should redirect_to '/users/sign_in' + end + end + context 'json形式' do + it 'ステータスコード401 Unauthorizedを返す' do + get :comic, :id => @comic.id, :format => :json + response.status.should eq 401 + end + it '応答メッセージにUnauthorizedを返す' do + get :comic, :id => @comic.id, :format => :json + response.message.should match(/Unauthorized/) + end + end end end @@ -242,10 +242,10 @@ describe StoriesController do get :new, :format => :json response.should be_success end - it 'jsonデータを返す' do + it 'jsonデータを返す' do get :new, :format => :json - lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) - end + lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError) + end it 'ストーリーモデルのストーリーのjson出力を問い合わせている' do Story.any_instance.should_receive(:story_as_json).exactly(1) get :new, :format => :json @@ -253,9 +253,9 @@ describe StoriesController do it 'データがアレになっている' do get :new, :format => :json json = JSON.parse response.body - json.has_key?("panel_id").should be_true - json.has_key?("comic_id").should be_true - json.has_key?("author_id").should be_true + json.has_key?("panel_id").should be_true + json.has_key?("comic_id").should be_true + json.has_key?("author_id").should be_true end end end diff --git a/spec/controllers/system_pictures_controller_spec.rb b/spec/controllers/system_pictures_controller_spec.rb index 701325dc..da0b8780 100644 --- a/spec/controllers/system_pictures_controller_spec.rb +++ b/spec/controllers/system_pictures_controller_spec.rb @@ -6,7 +6,7 @@ describe SystemPicturesController do before do @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group diff --git a/spec/factories.rb b/spec/factories.rb index 384ef68f..5f4781ed 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -14,7 +14,7 @@ FactoryGirl.define do end factory :author, :class => Author do |author| - author.name nil + author.name 'test' author.sequence(:user_id) { |n| n} end diff --git a/spec/models/artist_spec.rb b/spec/models/artist_spec.rb index 9dd5862b..7893a0c7 100644 --- a/spec/models/artist_spec.rb +++ b/spec/models/artist_spec.rb @@ -6,9 +6,9 @@ describe Artist do before do @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author - @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @author = FactoryGirl.create :author, :user_id => @user.id + @other_user = FactoryGirl.create( :user_yas) + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @@ -68,7 +68,7 @@ describe Artist do describe '所持判定に於いて' do before do @artist = FactoryGirl.create :artist, :author_id => @author.id - @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id + @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id end it '自分の絵師ならyes' do @artist.own?(@author).should == true @@ -90,33 +90,33 @@ describe Artist do before do MagicNumber['run_mode'] = 1 end - it '不許可を返す。' do + it '不許可を返す。' do r = @artist.visible?(nil) r.should be_false - end - end + end + end context 'オープンモードのとき' do before do MagicNumber['run_mode'] = 0 end - it '許可する' do + it '許可する' do r = @artist.visible?(nil) r.should be_true - end - end - end + end + end + end context '検査対象が作家のとき' do - it '許可する' do + it '許可する' do r = @artist.visible?(@author) r.should == true - end - end + end + end context '検査対象がそれ以外のとき' do - it '不許可を返す。' do + it '不許可を返す。' do r = @artist.visible?(@admin) r.should be_false - end - end + end + end end describe '一覧取得に於いて' do @@ -148,13 +148,13 @@ describe Artist do Artist.page_size('1000').should eq Artist.max_page_size end end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Artist.stub(:list_opt).with(any_args).and_return({}) - Artist.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + Artist.stub(:list_opt).with(any_args).and_return({}) + Artist.should_receive(:list_opt).with(any_args).exactly(1) r = Artist.list - end - end + end + end it 'リストを返す' do r = Artist.list r.should eq [@artist] @@ -234,54 +234,54 @@ describe Artist do before do @artist = FactoryGirl.create :artist, :author_id => @author.id end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Artist.stub(:show_opt).with(any_args).and_return({}) - Artist.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + Artist.stub(:show_opt).with(any_args).and_return({}) + Artist.should_receive(:show_opt).with(any_args).exactly(1) r = Artist.show @artist.id, @author - end - it '閲覧許可を問い合わせている' do - Artist.any_instance.stub(:visible?).with(any_args).and_return(true) - Artist.any_instance.should_receive(:visible?).with(any_args).exactly(1) + end + it '閲覧許可を問い合わせている' do + Artist.any_instance.stub(:visible?).with(any_args).and_return(true) + Artist.any_instance.should_receive(:visible?).with(any_args).exactly(1) r = Artist.show @artist.id, @author - end - end + end + end it '指定の絵師を返す' do a = Artist.show @artist.id, @author a.should eq @artist end - context '閲覧許可が出なかったとき' do - it '403Forbidden例外を返す' do - Artist.any_instance.stub(:visible?).and_return(false) - lambda{ - Artist.show @artist.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しない絵師を開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Artist.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end + context '閲覧許可が出なかったとき' do + it '403Forbidden例外を返す' do + Artist.any_instance.stub(:visible?).and_return(false) + lambda{ + Artist.show @artist.id, @author + }.should raise_error(ActiveRecord::Forbidden) + end + end + context '存在しない絵師を開こうとしたとき' do + it '404RecordNotFound例外を返す' do + lambda{ + Artist.show 110, @author + }.should raise_error(ActiveRecord::RecordNotFound) + end + end end describe '編集取得に於いて' do before do @artist = FactoryGirl.create :artist, :author_id => @author.id end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Artist.stub(:show_opt).with(any_args).and_return({}) - Artist.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + Artist.stub(:show_opt).with(any_args).and_return({}) + Artist.should_receive(:show_opt).with(any_args).exactly(1) r = Artist.edit @artist.id, @author - end - it '所持判定を問い合わせている' do - Artist.any_instance.stub(:own?).with(any_args).and_return(true) - Artist.any_instance.should_receive(:own?).with(any_args).exactly(1) + end + it '所持判定を問い合わせている' do + Artist.any_instance.stub(:own?).with(any_args).and_return(true) + Artist.any_instance.should_receive(:own?).with(any_args).exactly(1) r = Artist.edit @artist.id, @author - end - end + end + end it '指定の絵師を返す' do Artist.any_instance.stub(:own?).and_return(true) r = Artist.edit @artist.id, @author.id diff --git a/spec/models/author_spec.rb b/spec/models/author_spec.rb index c90208e8..dfc036ec 100644 --- a/spec/models/author_spec.rb +++ b/spec/models/author_spec.rb @@ -6,7 +6,7 @@ describe Author do before do @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id end describe '検証に於いて' do @@ -64,7 +64,7 @@ describe Author do describe '所持判定に於いて' do before do @other_user = FactoryGirl.create :user_yas -#アカウントを作ると連動して作家ができる @other_author = FactoryGirl.create :author_yas, :user_id => @other_user.id +#アカウントを作ると連動して作家ができる @other_author = FactoryGirl.create :author_yas, :user_id => @other_user.id end it '作家自身ならyes' do @author.own?(@author).should == true @@ -85,33 +85,33 @@ describe Author do before do MagicNumber['run_mode'] = 1 end - it '不許可を返す。' do + it '不許可を返す。' do r = @author.visible?(nil) r.should be_false - end - end + end + end context 'オープンモードのとき' do before do MagicNumber['run_mode'] = 0 end - it '許可する' do + it '許可する' do r = @author.visible?(nil) r.should be_true - end - end - end + end + end + end context '検査対象が作家のとき' do - it '許可する' do + it '許可する' do r = @author.visible?(@author) r.should == true - end - end + end + end context '検査対象がそれ以外のとき' do - it '不許可を返す。' do + it '不許可を返す。' do r = @author.visible?(@admin) r.should be_false - end - end + end + end end describe '絵師作家判定に於いて' do @@ -158,20 +158,20 @@ describe Author do Author.page_size('1000').should eq Author.max_page_size end end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Author.stub(:list_opt).with(any_args).and_return({}) - Author.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + Author.stub(:list_opt).with(any_args).and_return({}) + Author.should_receive(:list_opt).with(any_args).exactly(1) r = Author.list - end - end + end + end it 'リストを返す' do r = Author.list r.should eq [@author] end it '作成時系列で並んでいる' do @other_user = FactoryGirl.create :user_yas - #アカウントを作ると連動して作家ができる + @other_author = FactoryGirl.create :author, :user_id => @other_user.id n = @other_user.author n.created_at = Time.now + 100 n.save @@ -181,19 +181,19 @@ describe Author do context 'DBに5件あって1ページの件数を2件に変えたとして' do before do @other_user2 = FactoryGirl.create :user_yas - @author2 = @other_user2.author + @author2 = FactoryGirl.create :author, :user_id => @other_user2.id @author2.created_at = Time.now + 100 @author2.save @other_user3 = FactoryGirl.create :user_yas - @author3 = @other_user3.author + @author3 = FactoryGirl.create :author, :user_id => @other_user3.id @author3.created_at = Time.now + 200 @author3.save @other_user4 = FactoryGirl.create :user_yas - @author4 = @other_user4.author + @author4 = FactoryGirl.create :author, :user_id => @other_user4.id @author4.created_at = Time.now + 300 @author4.save @other_user5 = FactoryGirl.create :user_yas - @author5 = @other_user5.author + @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) @@ -219,19 +219,19 @@ describe Author do context 'DBに5件あって1ページの件数を0件に変えたとして' do before do @other_user2 = FactoryGirl.create :user_yas - @author2 = @other_user2.author + @author2 = FactoryGirl.create :author, :user_id => @other_user2.id @author2.created_at = Time.now + 100 @author2.save @other_user3 = FactoryGirl.create :user_yas - @author3 = @other_user3.author + @author3 = FactoryGirl.create :author, :user_id => @other_user3.id @author3.created_at = Time.now + 200 @author3.save @other_user4 = FactoryGirl.create :user_yas - @author4 = @other_user4.author + @author4 = FactoryGirl.create :author, :user_id => @other_user4.id @author4.created_at = Time.now + 300 @author4.save @other_user5 = FactoryGirl.create :user_yas - @author5 = @other_user5.author + @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) @@ -271,53 +271,53 @@ describe Author do describe '単体取得に於いて' do before do end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Author.stub(:show_opt).with(any_args).and_return({}) - Author.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + Author.stub(:show_opt).with(any_args).and_return({}) + Author.should_receive(:show_opt).with(any_args).exactly(1) r = Author.show @author.id, @author - end - it '閲覧許可を問い合わせている' do - Author.any_instance.stub(:visible?).with(any_args).and_return(true) - Author.any_instance.should_receive(:visible?).with(any_args).exactly(1) + end + it '閲覧許可を問い合わせている' do + Author.any_instance.stub(:visible?).with(any_args).and_return(true) + Author.any_instance.should_receive(:visible?).with(any_args).exactly(1) r = Author.show @author.id, @author - end - end + end + end it '指定の作家を返す' do r = Author.show @author.id, @author r.should eq @author end - context '閲覧許可が出なかったとき' do - it '403Forbidden例外を返す' do - Author.any_instance.stub(:visible?).and_return(false) - lambda{ - Author.show @author.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しない作家を開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Author.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end + context '閲覧許可が出なかったとき' do + it '403Forbidden例外を返す' do + Author.any_instance.stub(:visible?).and_return(false) + lambda{ + Author.show @author.id, @author + }.should raise_error(ActiveRecord::Forbidden) + end + end + context '存在しない作家を開こうとしたとき' do + it '404RecordNotFound例外を返す' do + lambda{ + Author.show 110, @author + }.should raise_error(ActiveRecord::RecordNotFound) + end + end end describe '編集取得に於いて' do before do end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Author.stub(:show_opt).with(any_args).and_return({}) - Author.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + Author.stub(:show_opt).with(any_args).and_return({}) + Author.should_receive(:show_opt).with(any_args).exactly(1) r = Author.edit @author.id, @author - end - it '所持判定を問い合わせている' do - Author.any_instance.stub(:own?).with(any_args).and_return(true) - Author.any_instance.should_receive(:own?).with(any_args).exactly(1) + end + it '所持判定を問い合わせている' do + Author.any_instance.stub(:own?).with(any_args).and_return(true) + Author.any_instance.should_receive(:own?).with(any_args).exactly(1) r = Author.edit @author.id, @author - end - end + end + end it '指定の作家を返す' do Author.any_instance.stub(:own?).and_return(true) r = Author.edit @author.id, @author.id diff --git a/spec/models/balloon_spec.rb b/spec/models/balloon_spec.rb index a7317f99..17f0b58e 100644 --- a/spec/models/balloon_spec.rb +++ b/spec/models/balloon_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' #セリフ describe Balloon do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @balloon = FactoryGirl.create :panel @@ -18,25 +18,25 @@ describe Balloon do before do @balloon = FactoryGirl.build :balloon, :speech_balloon_id => @speech_balloon.id, :system_picture_id => @system_picture.id end - context 'オーソドックスなデータのとき' do - it '下限データが通る' do - @balloon.x = 0 - @balloon.y = 0 - @balloon.width = 1 - @balloon.height = 1 - @balloon.should be_valid - end - it '上限データが通る' do - @balloon.x = 99999 - @balloon.y = 99999 - @balloon.width = 99999 - @balloon.height = 99999 - @balloon.should be_valid - end - end - + context 'オーソドックスなデータのとき' do + it '下限データが通る' do + @balloon.x = 0 + @balloon.y = 0 + @balloon.width = 1 + @balloon.height = 1 + @balloon.should be_valid + end + it '上限データが通る' do + @balloon.x = 99999 + @balloon.y = 99999 + @balloon.width = 99999 + @balloon.height = 99999 + @balloon.should be_valid + end + end + context 'speech_balloon_idを検証するとき' do - #ネストの保存はnilを許可しなければならないので数値チェックだけ + #ネストの保存はnilを許可しなければならないので数値チェックだけ it 'テストデータの確認' do @balloon.speech_balloon_id = @speech_balloon.id @balloon.should be_valid diff --git a/spec/models/color_spec.rb b/spec/models/color_spec.rb index e23354df..3d816424 100644 --- a/spec/models/color_spec.rb +++ b/spec/models/color_spec.rb @@ -6,12 +6,12 @@ describe Color do before do @f = Rails.root + 'spec/json/color.json' @fs = Rails.root + 'spec/json/colors.json' - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @@ -108,9 +108,9 @@ describe Color do before do @c = FactoryGirl.build :color end - it '許可する' do + it '許可する' do @c.visible?(@author).should == true - end + end end describe '一覧取得に於いて' do @@ -142,13 +142,13 @@ describe Color do Color.page_size('1000').should eq Color.max_page_size end end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Color.stub(:list_opt).with(any_args).and_return({}) - Color.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + Color.stub(:list_opt).with(any_args).and_return({}) + Color.should_receive(:list_opt).with(any_args).exactly(1) r = Color.list - end - end + end + end it 'リストを返す' do r = Color.list r.should eq [@c] @@ -217,37 +217,37 @@ describe Color do before do @c = FactoryGirl.create :color end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Color.stub(:show_opt).with(any_args).and_return({}) - Color.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + Color.stub(:show_opt).with(any_args).and_return({}) + Color.should_receive(:show_opt).with(any_args).exactly(1) r = Color.show @c.id, @author - end - it '閲覧許可を問い合わせている' do - Color.any_instance.stub(:visible?).with(any_args).and_return(true) - Color.any_instance.should_receive(:visible?).with(any_args).exactly(1) + end + it '閲覧許可を問い合わせている' do + Color.any_instance.stub(:visible?).with(any_args).and_return(true) + Color.any_instance.should_receive(:visible?).with(any_args).exactly(1) r = Color.show @c.id, @author - end - end + end + end it '指定の色を返す' do r = Color.show @author.id, @author r.should eq @c end - context '閲覧許可が出なかったとき' do - it '403Forbidden例外を返す' do - Color.any_instance.stub(:visible?).and_return(false) - lambda{ - Color.show @c.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しない色を開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Color.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end + context '閲覧許可が出なかったとき' do + it '403Forbidden例外を返す' do + Color.any_instance.stub(:visible?).and_return(false) + lambda{ + Color.show @c.id, @author + }.should raise_error(ActiveRecord::Forbidden) + end + end + context '存在しない色を開こうとしたとき' do + it '404RecordNotFound例外を返す' do + lambda{ + Color.show 110, @author + }.should raise_error(ActiveRecord::RecordNotFound) + end + end end describe '単体取得オプションに於いて' do diff --git a/spec/models/comic_spec.rb b/spec/models/comic_spec.rb index 5ffdb64b..4ab1750c 100644 --- a/spec/models/comic_spec.rb +++ b/spec/models/comic_spec.rb @@ -9,10 +9,10 @@ describe Comic do @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id end @@ -100,53 +100,53 @@ describe Comic do before do MagicNumber['run_mode'] = 1 end - it '不許可を返す。' do + it '不許可を返す。' do r = @comic.visible?(nil) r.should be_false - end - end + end + end context 'オープンモードのとき' do before do MagicNumber['run_mode'] = 0 end - it '公開コミックなら許可する' do - Comic.any_instance.stub(:visible).and_return(1) + 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) + end + it '非公開コミックなら許可しない' do + Comic.any_instance.stub(:visible).and_return(0) r = @comic.visible?(nil) r.should be_false - end - end - end + end + end + end context '検査対象が作家のとき' do - it '自分のコミックなら許可する' do - Comic.any_instance.stub(:own?).and_return(true) - Comic.any_instance.stub(:visible).and_return(0) + 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 - end - it '他人の非公開コミックなら許可しない' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(0) + 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 - end - it '他人のコミックでも公開なら許可する' do - Comic.any_instance.stub(:own?).and_return(false) - Comic.any_instance.stub(:visible).and_return(1) + 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 + end + end context '検査対象がそれ以外のとき' do - it '不許可を返す。' do + it '不許可を返す。' do r = @comic.visible?(@admin) r.should be_false - end - end + end + end end describe '一覧取得に於いて' do @@ -178,13 +178,13 @@ describe Comic do Comic.page_size('1000').should eq Comic.max_page_size end end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + Comic.stub(:list_opt).with(any_args).and_return({}) + Comic.should_receive(:list_opt).with(any_args).exactly(1) r = Comic.list - end - end + end + end it 'リストを返す' do c = Comic.list c.should eq [@comic] @@ -264,10 +264,10 @@ describe Comic do 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 + @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 @@ -297,13 +297,13 @@ describe Comic do before do @comic = FactoryGirl.create :comic, :author_id => @author.id end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Comic.stub(:list_opt).with(any_args).and_return({}) - Comic.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + Comic.stub(:list_opt).with(any_args).and_return({}) + Comic.should_receive(:list_opt).with(any_args).exactly(1) r = Comic.mylist @author - end - end + end + end it 'リストを返す' do c = Comic.mylist @author c.should eq [@comic] @@ -354,7 +354,7 @@ describe Comic do @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) + Author.stub(:default_comic_page_size).and_return(2) end it '通常は全件(5件)を返す' do r = Comic.mylist @author, 5, 0 @@ -367,55 +367,55 @@ describe Comic do before do @comic = FactoryGirl.create :comic, :author_id => @author.id end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Comic.stub(:show_opt).with(any_args).and_return({}) - Comic.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + Comic.stub(:show_opt).with(any_args).and_return({}) + Comic.should_receive(:show_opt).with(any_args).exactly(1) r = Comic.show @comic.id, @author - end - it '閲覧許可を問い合わせている' do - Comic.any_instance.stub(:visible?).with(any_args).and_return(true) - Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1) + end + it '閲覧許可を問い合わせている' do + Comic.any_instance.stub(:visible?).with(any_args).and_return(true) + Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1) r = Comic.show @comic.id, @author - end - end + end + end it '指定のコミックを返す' do c = Comic.show @comic.id, @author c.should eq @comic end - context '閲覧許可が出なかったとき' do - it '403Forbidden例外を返す' do - Comic.any_instance.stub(:visible?).and_return(false) - lambda{ - Comic.show @comic.id, @author - }.should raise_error(ActiveRecord::Forbidden) - end - end - context '存在しない作家を開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - Comic.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end + context '閲覧許可が出なかったとき' do + it '403Forbidden例外を返す' do + Comic.any_instance.stub(:visible?).and_return(false) + lambda{ + Comic.show @comic.id, @author + }.should raise_error(ActiveRecord::Forbidden) + end + end + context '存在しない作家を開こうとしたとき' do + it '404RecordNotFound例外を返す' do + lambda{ + Comic.show 110, @author + }.should raise_error(ActiveRecord::RecordNotFound) + end + end end describe '編集取得に於いて' do before do @comic = FactoryGirl.create :comic, :author_id => @author.id end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Comic.stub(:show_opt).with(any_args).and_return({}) - Comic.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + Comic.stub(:show_opt).with(any_args).and_return({}) + Comic.should_receive(:show_opt).with(any_args).exactly(1) r = Comic.edit @comic.id, @author - end - it '所持判定を問い合わせている' do - Comic.any_instance.stub(:own?).with(any_args).and_return(true) - Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) + end + it '所持判定を問い合わせている' do + Comic.any_instance.stub(:own?).with(any_args).and_return(true) + Comic.any_instance.should_receive(:own?).with(any_args).exactly(1) r = Comic.edit @comic.id, @author - end - end + end + end it '指定のコミックを返す' do Comic.any_instance.stub(:own?).and_return(true) c = Comic.edit @comic.id, @author.id @@ -461,10 +461,10 @@ describe Comic do 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 + @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 diff --git a/spec/models/ground_color_spec.rb b/spec/models/ground_color_spec.rb index 35ae8d84..c7123e73 100644 --- a/spec/models/ground_color_spec.rb +++ b/spec/models/ground_color_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe GroundColor do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @@ -121,13 +121,13 @@ describe GroundColor do GroundColor.page_size('1000').should eq GroundColor.max_page_size end end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - GroundColor.stub(:list_opt).with(any_args).and_return({:include => :panel}) - GroundColor.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + GroundColor.stub(:list_opt).with(any_args).and_return({:include => :panel}) + GroundColor.should_receive(:list_opt).with(any_args).exactly(1) r = GroundColor.list - end - end + end + end it 'リストを返す' do pl = GroundColor.list pl.should eq [@gc] @@ -210,10 +210,10 @@ describe GroundColor do 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 + @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 @@ -244,13 +244,13 @@ describe GroundColor do before do @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - GroundColor.stub(:list_opt).with(any_args).and_return({:include => :panel}) - GroundColor.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + GroundColor.stub(:list_opt).with(any_args).and_return({:include => :panel}) + GroundColor.should_receive(:list_opt).with(any_args).exactly(1) r = GroundColor.mylist @author - end - end + end + end it 'リストを返す' do pl = GroundColor.mylist @author pl.should eq [@gc] @@ -303,7 +303,7 @@ describe GroundColor do @gc3 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 2, :color_id => @color.id, :updated_at => Time.now + 200 @gc4 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 3, :color_id => @color.id, :updated_at => Time.now + 300 @gc5 = FactoryGirl.create :ground_color, :panel_id => @panel.id, :z => 4, :color_id => @color.id, :updated_at => Time.now + 400 - Author.stub(:default_ground_color_page_size).and_return(2) + Author.stub(:default_ground_color_page_size).and_return(2) end it '通常は全件(5件)を返す' do r = GroundColor.mylist @author, 5, 0 diff --git a/spec/models/ground_picture_spec.rb b/spec/models/ground_picture_spec.rb index 5c8c2839..07b9813f 100644 --- a/spec/models/ground_picture_spec.rb +++ b/spec/models/ground_picture_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe GroundPicture do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group diff --git a/spec/models/license_group_spec.rb b/spec/models/license_group_spec.rb index 181cb7c9..d3910a7e 100644 --- a/spec/models/license_group_spec.rb +++ b/spec/models/license_group_spec.rb @@ -105,13 +105,13 @@ describe LicenseGroup do before do @lg = FactoryGirl.create :license_group, :name => "1" end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - LicenseGroup.stub(:list_opt).with(any_args).and_return({}) - LicenseGroup.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + LicenseGroup.stub(:list_opt).with(any_args).and_return({}) + LicenseGroup.should_receive(:list_opt).with(any_args).exactly(1) r = LicenseGroup.list - end - end + end + end it 'リストを返す' do l = LicenseGroup.list l.should eq [@lg] @@ -142,12 +142,12 @@ describe LicenseGroup do @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template + @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 @@ -164,24 +164,24 @@ describe LicenseGroup do before do @lg = FactoryGirl.create :license_group end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - LicenseGroup.stub(:show_opt).with(any_args).and_return({}) - LicenseGroup.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + LicenseGroup.stub(:show_opt).with(any_args).and_return({}) + LicenseGroup.should_receive(:show_opt).with(any_args).exactly(1) r = LicenseGroup.show @lg.id - end - end + end + end it '指定のコマを返す' do l = LicenseGroup.show @lg.id l.should eq @lg end - context '存在しないライセンスグループを開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - LicenseGroup.show 110 - }.should raise_error(ActiveRecord::RecordNotFound) - end - end + context '存在しないライセンスグループを開こうとしたとき' do + it '404RecordNotFound例外を返す' do + lambda{ + LicenseGroup.show 110 + }.should raise_error(ActiveRecord::RecordNotFound) + end + end end describe '単体取得オプションに於いて' do it 'includeキーを含んでいる' do @@ -203,12 +203,12 @@ describe LicenseGroup do @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template + @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 diff --git a/spec/models/original_picture_license_group_spec.rb b/spec/models/original_picture_license_group_spec.rb index ac8dc1a7..2f789290 100644 --- a/spec/models/original_picture_license_group_spec.rb +++ b/spec/models/original_picture_license_group_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe OriginalPictureLicenseGroup do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group diff --git a/spec/models/original_picture_spec.rb b/spec/models/original_picture_spec.rb index f469895e..18ed1c44 100644 --- a/spec/models/original_picture_spec.rb +++ b/spec/models/original_picture_spec.rb @@ -6,10 +6,10 @@ describe OriginalPicture do before do @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group diff --git a/spec/models/panel_color_spec.rb b/spec/models/panel_color_spec.rb index 07e61475..b65b3fa5 100644 --- a/spec/models/panel_color_spec.rb +++ b/spec/models/panel_color_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe PanelColor do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @@ -216,10 +216,10 @@ describe PanelColor do 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 + @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 @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id @@ -244,13 +244,13 @@ describe PanelColor do before do @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - PanelColor.stub(:list_opt).with(any_args).and_return({:include => :panel}) - PanelColor.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + PanelColor.stub(:list_opt).with(any_args).and_return({:include => :panel}) + PanelColor.should_receive(:list_opt).with(any_args).exactly(1) r = PanelColor.mylist @author - end - end + end + end it 'リストを返す' do pl = PanelColor.mylist @author pl.should eq [@pc] @@ -303,7 +303,7 @@ describe PanelColor do @pc3 = FactoryGirl.create :panel_color, :panel_id => @panel.id, :z => 2, :updated_at => Time.now + 200 @pc4 = FactoryGirl.create :panel_color, :panel_id => @panel.id, :z => 3, :updated_at => Time.now + 300 @pc5 = FactoryGirl.create :panel_color, :panel_id => @panel.id, :z => 4, :updated_at => Time.now + 400 - Author.stub(:default_panel_color_page_size).and_return(2) + Author.stub(:default_panel_color_page_size).and_return(2) end it '通常は全件(5件)を返す' do r = PanelColor.mylist @author, 5, 0 diff --git a/spec/models/panel_picture_spec.rb b/spec/models/panel_picture_spec.rb index f9c1a28a..6aab0e30 100644 --- a/spec/models/panel_picture_spec.rb +++ b/spec/models/panel_picture_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' #コマ絵 describe PanelPicture do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @@ -68,8 +68,8 @@ describe PanelPicture do @pp.should_not be_valid end it 'url形式でないなら失敗する' do - @pp.link = 'a'*200 - @pp.should_not be_valid + @pp.link = 'a'*200 + @pp.should_not be_valid end end context 'xを検証するとき' do @@ -319,13 +319,13 @@ describe PanelPicture do PanelPicture.page_size('1000').should eq PanelPicture.max_page_size end end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - PanelPicture.stub(:list_opt).with(any_args).and_return({:include => :panel}) - PanelPicture.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + PanelPicture.stub(:list_opt).with(any_args).and_return({:include => :panel}) + PanelPicture.should_receive(:list_opt).with(any_args).exactly(1) r = PanelPicture.list - end - end + end + end it 'リストを返す' do r = PanelPicture.list r.should eq [@pp] @@ -425,10 +425,10 @@ describe PanelPicture do 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 + @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 @@ -475,13 +475,13 @@ describe PanelPicture do @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :width => @p.width, :height => @p.height end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - PanelPicture.stub(:list_opt).with(any_args).and_return({:include => :panel}) - PanelPicture.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + PanelPicture.stub(:list_opt).with(any_args).and_return({:include => :panel}) + PanelPicture.should_receive(:list_opt).with(any_args).exactly(1) r = PanelPicture.mylist @author - end - end + end + end it 'リストを返す' do pl = PanelPicture.mylist @author pl.should eq [@pp] @@ -545,7 +545,7 @@ describe PanelPicture do :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) + Author.stub(:default_panel_picture_page_size).and_return(2) end it '通常は全件(5件)を返す' do r = PanelPicture.mylist @author, 5, 0 diff --git a/spec/models/panel_spec.rb b/spec/models/panel_spec.rb index 03ac3d1a..15e256b8 100644 --- a/spec/models/panel_spec.rb +++ b/spec/models/panel_spec.rb @@ -9,10 +9,10 @@ describe Panel do @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @color = FactoryGirl.create :color @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @op = FactoryGirl.create :original_picture, :artist_id => @artist.id @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @@ -1181,8 +1181,6 @@ describe Panel do FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height) ) @panel2.save! - p @panel2 - p @panel2.panel_pictures end end describe 'id一致チェックに於いて' do diff --git a/spec/models/picture_spec.rb b/spec/models/picture_spec.rb index eb6e9626..a4e372e5 100644 --- a/spec/models/picture_spec.rb +++ b/spec/models/picture_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe Picture do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group diff --git a/spec/models/resource_picture_spec.rb b/spec/models/resource_picture_spec.rb index 11ac80f6..e39a6ac1 100644 --- a/spec/models/resource_picture_spec.rb +++ b/spec/models/resource_picture_spec.rb @@ -6,10 +6,10 @@ describe ResourcePicture do before do @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @@ -30,27 +30,27 @@ describe ResourcePicture do @rp = FactoryGirl.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id end - context 'オーソドックスなデータのとき' do - it '下限データが通る' do - @rp.ext = 'png' #リストにない拡張子は通らないし - @rp.width = 1 - @rp.height = 1 - @rp.filesize = 1 - @rp.md5 = 'a'*32 - @rp.classname = 'a'*1 - @rp.should be_valid - end - it '上限データが通る' do - @rp.ext = 'jpeg' - @rp.width = 99999 - @rp.height = 99999 - @rp.filesize = 2000000 - @rp.md5 = 'a'*32 - @rp.classname = 'a'*50 - @rp.should be_valid - end - end - + context 'オーソドックスなデータのとき' do + it '下限データが通る' do + @rp.ext = 'png' #リストにない拡張子は通らないし + @rp.width = 1 + @rp.height = 1 + @rp.filesize = 1 + @rp.md5 = 'a'*32 + @rp.classname = 'a'*1 + @rp.should be_valid + end + it '上限データが通る' do + @rp.ext = 'jpeg' + @rp.width = 99999 + @rp.height = 99999 + @rp.filesize = 2000000 + @rp.md5 = 'a'*32 + @rp.classname = 'a'*50 + @rp.should be_valid + end + end + context 'extを検証するとき' do it 'nullなら失敗する' do @rp.ext = '' @@ -138,10 +138,10 @@ describe ResourcePicture do @rp.md5 = '' @rp.should_not be_valid end - it '31文字なら失敗する' do - @rp.md5 = 'a'*31 - @rp.should_not be_valid - end + it '31文字なら失敗する' do + @rp.md5 = 'a'*31 + @rp.should_not be_valid + end it '32文字以上なら失敗する' do @rp.md5 = 'a'*33 @rp.should_not be_valid @@ -211,119 +211,119 @@ describe ResourcePicture do end end - describe 'デフォルト値補充に於いて' do - it 'defined' do + describe 'デフォルト値補充に於いて' do + it 'defined' do @p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id - @rp.supply_default - end - end - - describe '上書き補充に於いて' do - before do - @original_picture.attributes = {:ext => 'gif', :width => 267, :height => 268, :filesize => 269, - :artist_id => @artist.id } - @rp = FactoryGirl.build :resource_picture, :original_picture_id => @original_picture.id - end - it 'width, height, ext, filesize, md5, original_picture_id, artist_idが設定されている' do - @rp.overwrite @original_picture - @rp.width.should eq 267 - @rp.height.should eq 268 - @rp.ext.should eq 'gif' - @rp.filesize.should eq 269 - @rp.md5.should eq @rp.md5 - @rp.original_picture_id.should eq @original_picture.id - @rp.artist_id.should eq @artist.id - end - end - - describe '所持判定に於いて' do - before do + @rp.supply_default + end + end + + describe '上書き補充に於いて' do + before do + @original_picture.attributes = {:ext => 'gif', :width => 267, :height => 268, :filesize => 269, + :artist_id => @artist.id } + @rp = FactoryGirl.build :resource_picture, :original_picture_id => @original_picture.id + end + it 'width, height, ext, filesize, md5, original_picture_id, artist_idが設定されている' do + @rp.overwrite @original_picture + @rp.width.should eq 267 + @rp.height.should eq 268 + @rp.ext.should eq 'gif' + @rp.filesize.should eq 269 + @rp.md5.should eq @rp.md5 + @rp.original_picture_id.should eq @original_picture.id + @rp.artist_id.should eq @artist.id + end + end + + describe '所持判定に於いて' do + before do @p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id - end - it '素材を更新することはないので、Falseを返す' do - @rp.own?(@author).should == false - end - end - - describe '閲覧許可に於いて' do - before do + end + it '素材を更新することはないので、Falseを返す' do + @rp.own?(@author).should == false + end + end + + describe '閲覧許可に於いて' do + before do @p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id - end - context '検査対象がnil(ゲスト)のとき' do - context 'クローズドモードのとき' do - before do - MagicNumber['run_mode'] = 1 - end + end + context '検査対象がnil(ゲスト)のとき' do + context 'クローズドモードのとき' do + before do + MagicNumber['run_mode'] = 1 + end it '不許可を返す。' do - r = @rp.visible?(nil) - r.should be_false + r = @rp.visible?(nil) + r.should be_false end end - context 'オープンモードのとき' do - before do - MagicNumber['run_mode'] = 0 - end + context 'オープンモードのとき' do + before do + MagicNumber['run_mode'] = 0 + end it '許可する' do - r = @rp.visible?(nil) - r.should be_true + r = @rp.visible?(nil) + r.should be_true end end end - context '検査対象が作家のとき' do + context '検査対象が作家のとき' do it '許可する' do - r = @rp.visible?(@author) - r.should == true + r = @rp.visible?(@author) + r.should == true end end - context '検査対象がそれ以外のとき' do + context '検査対象がそれ以外のとき' do it '不許可を返す。' do - r = @rp.visible?(@admin) - r.should be_false + r = @rp.visible?(@admin) + r.should be_false end end - end - - describe 'ファイル名に於いて' do - before do + end + + describe 'ファイル名に於いて' do + before do @p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id - end - it 'id+拡張子のフォーマットで返す' do - r = @rp.filename - r.should eq "#{@rp.id}.png" - end - end - - describe 'MimeTypeに於いて' do - before do + end + it 'id+拡張子のフォーマットで返す' do + r = @rp.filename + r.should eq "#{@rp.id}.png" + end + end + + describe 'MimeTypeに於いて' do + before do @p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.build :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id - end - it 'image/拡張子のフォーマットで返す' do - r = @rp.mime_type - r.should eq "image/png" - end - end - - describe 'ファイルのurlに於いて' do - before do + end + it 'image/拡張子のフォーマットで返す' do + r = @rp.mime_type + r.should eq "image/png" + end + end + + describe 'ファイルのurlに於いて' do + before do @p = FactoryGirl.create :picture, :original_picture_id => @original_picture.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @original_picture.id, :license_id => @license.id, :picture_id => @p.id - ResourcePicture.any_instance.stub(:filename).and_return('3.gif') - end - it 'ファイル名取得を依頼している' do - ResourcePicture.any_instance.should_receive(:filename).exactly(1) - @rp.url - end - it '/resource_pictures/3.gifのフォーマットで返す' do - r = @rp.url - r.should eq "/resource_pictures/3.gif" - end - end - + ResourcePicture.any_instance.stub(:filename).and_return('3.gif') + end + it 'ファイル名取得を依頼している' do + ResourcePicture.any_instance.should_receive(:filename).exactly(1) + @rp.url + end + it '/resource_pictures/3.gifのフォーマットで返す' do + r = @rp.url + r.should eq "/resource_pictures/3.gif" + end + end + describe '一覧取得に於いて' do before do @op = FactoryGirl.create :original_picture, :artist_id => @artist.id @@ -395,8 +395,8 @@ describe ResourcePicture do r.should eq [@rp] end end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do + context 'DBに5件あって1ページの件数を2件に変えたとして' do + before do nop2 = FactoryGirl.create :original_picture, :artist_id => @artist.id @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 nop3 = FactoryGirl.create :original_picture, :artist_id => @artist.id @@ -406,64 +406,64 @@ describe ResourcePicture do nop5 = FactoryGirl.create :original_picture, :artist_id => @artist.id @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 ResourcePicture.stub(:default_page_size).and_return(2) - end - it '件数0は全件(5件)を返す' do - r = ResourcePicture.list 5, 0 - r.should have(5).items - end - end + end + it '件数0は全件(5件)を返す' do + r = ResourcePicture.list 5, 0 + r.should have(5).items + end + end end describe '一覧取得オプションに於いて' do - it 'includeキーを含んでいる' do - r = ResourcePicture.list_opt - r.has_key?(:include).should be_true - end - it '3つの項目を含んでいる' do - r = ResourcePicture.list_opt[:include] - r.should have(3).items - end - it 'ライセンスを含んでいる' do - r = ResourcePicture.list_opt[:include] - r.has_key?(:license).should be_true - end - it '絵師を含んでいる' do - r = ResourcePicture.list_opt[:include] - r.has_key?(:artist).should be_true - end - it '実素材を含んでいる' do - r = ResourcePicture.list_opt[:include] - r.has_key?(:picture).should be_true - end + it 'includeキーを含んでいる' do + r = ResourcePicture.list_opt + r.has_key?(:include).should be_true + end + it '3つの項目を含んでいる' do + r = ResourcePicture.list_opt[:include] + r.should have(3).items + end + it 'ライセンスを含んでいる' do + r = ResourcePicture.list_opt[:include] + r.has_key?(:license).should be_true + end + it '絵師を含んでいる' do + r = ResourcePicture.list_opt[:include] + r.has_key?(:artist).should be_true + end + it '実素材を含んでいる' do + r = ResourcePicture.list_opt[:include] + r.has_key?(:picture).should be_true + end end - describe 'json一覧出力オプションに於いて' do - before do + 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 = ResourcePicture.list.to_json ResourcePicture.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('license').should be_true - end - it '絵師を含んでいる' do - r = ResourcePicture.list.to_json ResourcePicture.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('artist').should be_true - end - it '実素材を含んでいる' do - r = ResourcePicture.list.to_json ResourcePicture.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('picture').should be_true - end - end + @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 = ResourcePicture.list.to_json ResourcePicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('license').should be_true + end + it '絵師を含んでいる' do + r = ResourcePicture.list.to_json ResourcePicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('artist').should be_true + end + it '実素材を含んでいる' do + r = ResourcePicture.list.to_json ResourcePicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('picture').should be_true + end + end describe '単体取得に於いて' do before do @@ -471,30 +471,30 @@ describe ResourcePicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :original_picture_id => @op.id, :license_id => @license.id, :picture_id => @p.id end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - ResourcePicture.stub(:show_opt).with(any_args).and_return({}) - ResourcePicture.should_receive(:show_opt).with(any_args).exactly(1) - r = ResourcePicture.show @rp.id, @author - end - it '閲覧許可を問い合わせている' do - ResourcePicture.any_instance.stub(:visible?).with(any_args).and_return(true) - ResourcePicture.any_instance.should_receive(:visible?).with(any_args).exactly(1) - r = ResourcePicture.show @rp.id, @author - end - end + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + ResourcePicture.stub(:show_opt).with(any_args).and_return({}) + ResourcePicture.should_receive(:show_opt).with(any_args).exactly(1) + r = ResourcePicture.show @rp.id, @author + end + it '閲覧許可を問い合わせている' do + ResourcePicture.any_instance.stub(:visible?).with(any_args).and_return(true) + ResourcePicture.any_instance.should_receive(:visible?).with(any_args).exactly(1) + r = ResourcePicture.show @rp.id, @author + end + end it '指定の素材を返す' do r = ResourcePicture.show @rp.id, @author r.should eq @rp end - context '他人の素材を開こうとしたとき' do - it '403Forbidden例外を返す' do - ResourcePicture.any_instance.stub(:visible?).and_return(false) - lambda{ - r = ResourcePicture.show @rp.id, @other_author - }.should raise_error(ActiveRecord::Forbidden) - end - end + context '他人の素材を開こうとしたとき' do + it '403Forbidden例外を返す' do + ResourcePicture.any_instance.stub(:visible?).and_return(false) + lambda{ + r = ResourcePicture.show @rp.id, @other_author + }.should raise_error(ActiveRecord::Forbidden) + end + end context '存在しない素材を開こうとしたとき' do it '404RecordNotFound例外を返す' do lambda{ @@ -504,55 +504,55 @@ describe ResourcePicture do end end describe '単体取得オプションに於いて' do - it 'includeキーを含んでいる' do - r = ResourcePicture.show_opt - r.has_key?(:include).should be_true - end - it '3つの項目を含んでいる' do - r = ResourcePicture.show_opt[:include] - r.should have(3).items - end - it 'ライセンスを含んでいる' do - r = ResourcePicture.show_opt[:include] - r.has_key?(:license).should be_true - end - it '絵師を含んでいる' do - r = ResourcePicture.show_opt[:include] - r.has_key?(:artist).should be_true - end - it '実素材を含んでいる' do - r = ResourcePicture.show_opt[:include] - r.has_key?(:picture).should be_true - end + it 'includeキーを含んでいる' do + r = ResourcePicture.show_opt + r.has_key?(:include).should be_true + end + it '3つの項目を含んでいる' do + r = ResourcePicture.show_opt[:include] + r.should have(3).items + end + it 'ライセンスを含んでいる' do + r = ResourcePicture.show_opt[:include] + r.has_key?(:license).should be_true + end + it '絵師を含んでいる' do + r = ResourcePicture.show_opt[:include] + r.has_key?(:artist).should be_true + end + it '実素材を含んでいる' do + r = ResourcePicture.show_opt[:include] + r.has_key?(:picture).should be_true + end end describe 'json単体出力オプションに於いて' do - before 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 = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt - j = JSON.parse r - i = j - i.has_key?('license').should be_true - end - it '絵師を含んでいる' do - r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt - j = JSON.parse r - i = j - i.has_key?('artist').should be_true - end - it '実素材を含んでいる' do - r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt - j = JSON.parse r - i = j - i.has_key?('picture').should be_true - end + @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 = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('license').should be_true + end + it '絵師を含んでいる' do + r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('artist').should be_true + end + it '実素材を含んでいる' do + r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('picture').should be_true + end end describe 'フォーマット変換対象判定に於いて' do @@ -588,7 +588,7 @@ describe ResourcePicture do attr = {:original_picture_id => @op.id, :license_id => @license.id, :artist_name => 'tester', :credit => '{}', :settings => {:reverse => 1, :gif_convert => 1}.to_json.to_s} @rp = FactoryGirl.build :resource_picture, attr - @imager = ImagerTest.load "abc\ndef\nghi" + @imager = ImagerTest.load "abc\ndef\nghi" end context '事前チェック' do before do @@ -635,7 +635,7 @@ describe ResourcePicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id attr = {:original_picture_id => @op.id, :picture_id => nil, :license_id => @license.id, :artist_name => 'tester', :classname => 'StandardLicense', :credit => '{}', :settings => {}.to_json.to_s} @rp = FactoryGirl.build :resource_picture, attr - @imager = ImagerTest.load "abc\ndef\nghi" + @imager = ImagerTest.load "abc\ndef\nghi" end context '事前チェック' do before do @@ -760,7 +760,7 @@ describe ResourcePicture do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id attr = {:original_picture_id => @op.id, :license_id => @license.id, :artist_name => 'tester', :credit => '{}', :settings => {}.to_json.to_s} @rp = FactoryGirl.build :resource_picture, attr - @imager = ImagerTest.load "abc\ndef\nghi" + @imager = ImagerTest.load "abc\ndef\nghi" end context '事前チェック' do before do @@ -870,7 +870,7 @@ describe ResourcePicture do attr = {:original_picture_id => @op.id, :license_id => @license.id, :artist_name => 'tester', :credit => '{}', :settings => {}.to_json.to_s} @rp = FactoryGirl.build :resource_picture, attr @rp.overwrite @op - @imager = ImagerTest.load "abc\ndef\nghi" + @imager = ImagerTest.load "abc\ndef\nghi" end context '事前チェック' do before do diff --git a/spec/models/speech_balloon_spec.rb b/spec/models/speech_balloon_spec.rb index 0414328d..395c77ec 100644 --- a/spec/models/speech_balloon_spec.rb +++ b/spec/models/speech_balloon_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' describe SpeechBalloon do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id diff --git a/spec/models/speech_balloon_template_spec.rb b/spec/models/speech_balloon_template_spec.rb index 01a5bbc5..e0f4e885 100644 --- a/spec/models/speech_balloon_template_spec.rb +++ b/spec/models/speech_balloon_template_spec.rb @@ -15,12 +15,12 @@ describe SpeechBalloonTemplate do @jes = JSON.parse @tes @admin = FactoryGirl.create :admin - @user = FactoryGirl.create( :user_yas) - @author = @user.author - @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author - @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id + @user = FactoryGirl.create( :user_yas) + @author = FactoryGirl.create :author, :user_id => @user.id + @artist = FactoryGirl.create :artist_yas, :author_id => @author.id + @other_user = FactoryGirl.create( :user_yas) + @other_author = FactoryGirl.create :author, :user_id => @other_user.id + @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id end describe '検証に於いて' do @@ -126,7 +126,7 @@ describe SpeechBalloonTemplate do @st.overwrite @st.t.should eq 2 end - context 'つつがなく終わるとき' do + context 'つつがなく終わるとき' do before do @st = FactoryGirl.create :speech_balloon_template, :t => 0 end @@ -141,22 +141,22 @@ describe SpeechBalloonTemplate do before do @st = FactoryGirl.build :speech_balloon_template end - it '許可する' do + it '許可する' do @st.visible?(@author).should == true - end + end end describe '一覧取得に於いて' do before do @st = FactoryGirl.create :speech_balloon_template end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - SpeechBalloonTemplate.stub(:list_opt).with(any_args).and_return({}) - SpeechBalloonTemplate.should_receive(:list_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '一覧取得オプションを利用している' do + SpeechBalloonTemplate.stub(:list_opt).with(any_args).and_return({}) + SpeechBalloonTemplate.should_receive(:list_opt).with(any_args).exactly(1) r = SpeechBalloonTemplate.list - end - end + end + end it 'リストを返す' do l = SpeechBalloonTemplate.list l.should eq [@st] @@ -186,13 +186,13 @@ describe SpeechBalloonTemplate do before do @st = FactoryGirl.create :speech_balloon_template end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - SpeechBalloonTemplate.stub(:show_opt).with(any_args).and_return({}) - SpeechBalloonTemplate.should_receive(:show_opt).with(any_args).exactly(1) + context 'つつがなく終わるとき' do + it '単体取得オプションを利用している' do + SpeechBalloonTemplate.stub(:show_opt).with(any_args).and_return({}) + SpeechBalloonTemplate.should_receive(:show_opt).with(any_args).exactly(1) r = SpeechBalloonTemplate.show @st.id, @author - end - end + end + end it '指定のフキダシテンプレートを返す' do l = SpeechBalloonTemplate.show @st.id, @author l.should eq @st @@ -205,13 +205,13 @@ describe SpeechBalloonTemplate do }.should raise_error(ActiveRecord::Forbidden) end end - context '存在しないフキダシテンプレートを開こうとしたとき' do - it '404RecordNotFound例外を返す' do - lambda{ - SpeechBalloonTemplate.show 110, @author - }.should raise_error(ActiveRecord::RecordNotFound) - end - end + context '存在しないフキダシテンプレートを開こうとしたとき' do + it '404RecordNotFound例外を返す' do + lambda{ + SpeechBalloonTemplate.show 110, @author + }.should raise_error(ActiveRecord::RecordNotFound) + end + end end describe '単体出力オプションに於いて' do it '空のHashを返す' do diff --git a/spec/models/speech_spec.rb b/spec/models/speech_spec.rb index 292155f0..f3481f60 100644 --- a/spec/models/speech_spec.rb +++ b/spec/models/speech_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' describe Speech do before do - FactoryGirl.create :admin - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id + @admin = FactoryGirl.create :admin + @sp = FactoryGirl.create :system_picture + @lg = FactoryGirl.create :license_group + @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @panel = FactoryGirl.create :panel @speech_balloon_template = FactoryGirl.create :speech_balloon_template @@ -20,25 +20,25 @@ describe Speech do @speech = FactoryGirl.build :speech, :speech_balloon_id => @speech_balloon.id end - context 'オーソドックスなデータのとき' do - it '下限データが通る' do - @speech.x = 0 - @speech.y = 0 - @speech.width = 1 - @speech.height = 1 - @speech.should be_valid - end - it '上限データが通る' do - @speech.x = 99999 - @speech.y = 99999 - @speech.width = 99999 - @speech.height = 99999 - @speech.should be_valid - end - end - + context 'オーソドックスなデータのとき' do + it '下限データが通る' do + @speech.x = 0 + @speech.y = 0 + @speech.width = 1 + @speech.height = 1 + @speech.should be_valid + end + it '上限データが通る' do + @speech.x = 99999 + @speech.y = 99999 + @speech.width = 99999 + @speech.height = 99999 + @speech.should be_valid + end + end + context 'speech_balloon_idを検証するとき' do - #ネストの保存はnilを許可しなければならないので数値チェックだけ + #ネストの保存はnilを許可しなければならないので数値チェックだけ it 'テストデータの確認' do @speech.speech_balloon_id = @speech_balloon.id @speech.should be_valid diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 0974b9ea..6c4a84c8 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -9,10 +9,10 @@ describe Story do @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @color = FactoryGirl.create :color @user = FactoryGirl.create( :user_yas) - @author = @user.author + @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @other_user = FactoryGirl.create( :user_yas) - @other_author = @other_user.author + @other_author = FactoryGirl.create :author, :user_id => @other_user.id @op = FactoryGirl.create :original_picture, :artist_id => @artist.id @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f9b90462..9cc64f05 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -4,23 +4,9 @@ require 'spec_helper' describe User do before do - FactoryGirl.create :admin + @admin = FactoryGirl.create :admin end - describe '作成に於いて' do - context '作家の自動作成' do - it '作家が作成されている' do - lambda { - @user = FactoryGirl.create( :user_yas) - }.should change(Author, :count) - end - it '作家とユーザがリンクされている' do - @user = FactoryGirl.create( :user_yas) - Author.find_by_user_id(@user.id).should_not eq nil - end - end - end - describe 'トークン作成に於いて' do before do @user = FactoryGirl.create( :user_yas) -- 2.11.0