.sass-cache/
public/image/*
config/aws.yaml
+lib/test/temp/
gem 'database_cleaner'
gem 'rails-erd'
gem 'factory_girl'
+ gem 'autotest'
end
GEM
remote: http://rubygems.org/
specs:
+ ZenTest (4.7.0)
actionmailer (3.1.1)
actionpack (= 3.1.1)
mail (~> 2.3.0)
activesupport (3.1.1)
multi_json (~> 1.0)
arel (2.2.1)
+ autotest (4.4.6)
+ ZenTest (>= 4.4.1)
aws-s3 (0.6.2)
builder
mime-types
x86-mingw32
DEPENDENCIES
+ autotest
aws-s3
coffee-rails (~> 3.1.1)
cucumber
before_filter :bf
def bf
- if Admin.count.to_i == 0
+ if Admin.count.to_i == 0 or License.count.to_i == 0
if params[:controller] == 'system' and params[:action] == 'start'
else
redirect_to :controller => '/system', :action => 'start'
res
end
+ def self.import_file(filename)
+ t = File.open(filename, 'r').read
+ j = JSON.parse t
+ l = CommonLicense.new j
+ l.save_save
+ p l.id
+ end
+
end
<head>
<title>Pettanr</title>
<%= stylesheet_link_tag "application" %>
- <%= javascript_include_tag "application" %>
+ <%# javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
-<p>このシステムには管理者が設定されていません。</p>
-<p>次のコマンドで管理者アカウントを作成してください。</p>
+<% if Admin.count.to_i == 0 %>
+ <p>このシステムには管理者が設定されていません。</p>
+ <p>次のコマンドで管理者アカウントを作成してください。</p>
-<div style="background-color: #dddddd">
-rails r "Admin.start('admin@mail.adr.ess', 'admin_password')"
-</div>
+ <div style="background-color: #dddddd">
+ rails r "Admin.start('admin@mail.adr.ess', 'admin_password')"
+ </div>
+<% end %>
+<% if License.count.to_i == 0 %>
+ <p>このシステムにはライセンスが設定されていません。</p>
+ <p>次のコマンドでライセンスを作成してください。</p>
+
+ <div style="background-color: #dddddd">
+ rails r "CommonLicense.import_file('filename.json')"
+ </div>
+<% end %>
--- /dev/null
+Autotest.add_discovery { "rspec2" }
--- /dev/null
+{\r
+ "name": "Public Domain", \r
+ "url": "http://ja.wikipedia.org/wiki/%E3%83%91%E3%83%96%E3%83%AA%E3%83%83%E3%82%AF%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3", \r
+ "cc_by": 0, \r
+ "cc_sa": 0, \r
+ "cc_nd": 0, \r
+ "cc_nc": 0, \r
+ "no_resize": 0, \r
+ "no_flip": 0, \r
+ "no_convert": 0, \r
+ "keep_aspect_ratio": 0\r
+}\r
end
def exist?(filename, subdir = nil)
+ res = true
begin
- File.exist?(dir(subdir) + filename)
- rescue StandardError
- false
+ res = File.exist?(dir(subdir) + filename)
+ rescue
+ res = false
end
+ res
end
def put(bindata, filename, subdir = nil)
- mkdir subdir
+ res = true
begin
- open(dir(subdir) + filename, 'wb') do |f|
+ mkdir subdir
+ File.open(dir(subdir) + filename, 'wb') do |f|
f.write bindata
end
- true
- rescue StandardError
- false
+ rescue
+ res = false
end
+ res
end
def get(filename, subdir = nil)
bindata = ''
begin
- open(dir(subdir) + filename, 'rb') do |f|
+ File.open(dir(subdir) + filename, 'rb') do |f|
bindata += f.read
end
- bindata
- rescue StandardError
- false
+ rescue
+ bindata = false
end
+ bindata
end
def delete(filename, subdir = nil)
+ res = true
begin
File.delete(dir(subdir) + filename)
- true
- rescue StandardError
- false
+ rescue
+ res = false
end
+ res
end
end
end
def exist?(filename, subdir = nil)
+ res = true
begin
- AWS::S3::S3Object.exist?(dir(subdir) + filename)
- true
- rescue S3Exception
- false
+ res = AWS::S3::S3Object.exist?(dir(subdir) + filename, base)
+ rescue
+ res = false
end
+ res
end
def put(bindata, filename, subdir = nil)
+ res = true
begin
AWS::S3::S3Object.store(dir(subdir) + filename, bindata, base)
- true
- rescue S3Exception
- false
+ rescue
+ res = false
end
+ res
end
def get(filename, subdir = nil)
+ bindata = ''
begin
- bindata = ''
- # if AWS::S3::S3Object.exists?(fn, 'pettanr')
AWS::S3::S3Object.stream(dir(subdir) + filename, base) do |st|
bindata += st if st
end
- bindata
- rescue S3Exception
- false
+ rescue
+ bindata = false
end
+ bindata
end
def delete(filename, subdir = nil)
+ res = true
begin
AWS::S3::S3Object.delete(dir(subdir) + filename, base)
-# true
- rescue S3Exception
- false
+ rescue
+ res = false
end
- end
+ res
+ end
end
end
--- /dev/null
+# -*- encoding: utf-8 -*-
+#ファイル保存
+require 'local_picture'
+require 'spec_helper'
+
+#テスト用ファイルをクリアしておく
+@path = Rails.root + 'lib/test/temp/'
+Dir.glob @path + '*' do |filename|
+ if File.directory?(filename)
+ Dir.glob filename do |filename2|
+ File.delete(filename2) unless File.directory?(filename2)
+ end
+ else
+ File.delete(filename)
+ end
+end
+describe PictureIO::LocalPicture do
+ before do
+ @path = Rails.root + 'lib/test/temp/'
+ @io = PictureIO::LocalPicture.new @path
+ end
+
+ describe 'サブディレクトリに於いて' do
+ it '配列が返る' do
+ PictureIO::LocalPicture.subdirs.is_a?(Array).should be_true
+ end
+
+ it 'カレント、サムネ、水平反転、垂直反転、水平垂直反転が返る' do
+ PictureIO::LocalPicture.subdirs.size.should eq 5
+ PictureIO::LocalPicture.subdirs.include?('').should eq true
+ PictureIO::LocalPicture.subdirs.include?('v').should eq true
+ PictureIO::LocalPicture.subdirs.include?('h').should eq true
+ PictureIO::LocalPicture.subdirs.include?('vh').should eq true
+ PictureIO::LocalPicture.subdirs.include?('thumbnail').should eq true
+ end
+ end
+
+ describe 'ファイル存在確認に於いて' do
+ before do
+ end
+ context 'ファイルがあるとき' do
+ it 'trueが返る' do
+ File.open @path + 'exist', 'w' do |f|
+ f.puts 'test data'
+ end
+ @io.exist?('exist').should be_true
+ end
+ end
+ context 'ファイルがないとき' do
+ it 'falseが返る' do
+ @io.exist?('not.exist').should be_false
+ end
+ end
+ end
+
+ describe 'ファイル取得に於いて' do
+ before do
+ File.open @path + 'test.get', 'w' do |f|
+ f.puts 'basedata'
+ end
+ File.open @path + 'v/testsub.get', 'w' do |f|
+ f.puts 'subdata'
+ end
+ end
+ context 'ベースディレクトリから取るとき' do
+ it 'basedataが返る' do
+ @io.get('test.get').should match /basedata/
+ end
+ end
+ context 'サブディレクトリvから取るとき' do
+ it 'subdataが返る' do
+ @io.get('testsub.get', 'v').should match /subdata/
+ end
+ end
+ context '例外が発生するとき' do
+ it 'falseが返る' do
+ File.stub(:open).with(any_args()).and_raise(StandardError)
+ @io.get('test.get').should be_false
+ end
+ end
+ end
+
+ describe 'ファイル作成に於いて' do
+ before do
+ File.open @path + 'test.put', 'w' do |f|
+ f.puts 'already'
+ end
+ end
+ context 'ベースディレクトリに作成するとき' do
+ before do
+ @io.put('created', 'create.put')
+ end
+ it 'ファイルが作成されている' do
+ File.exist?(@path + 'create.put').should be_true
+ end
+ it 'createdが書きこまれている' do
+ d = File.open(@path + 'create.put').read
+ d.should match /create/
+ end
+ end
+ context '既存ファイルを更新するとき' do
+ before do
+ @io.put('overwrited', 'test.put')
+ end
+ it 'overwritedが書きこまれている' do
+ d = File.open(@path + 'test.put').read
+ d.should match /overwrited/
+ end
+ it '上書きされている' do
+ d = File.open(@path + 'test.put').read
+ d.should_not match /already/
+ end
+ end
+ context 'サブディレクトリhに作成するとき' do
+ before do
+ @io.put('subdirtest', 'testsub.put', 'h')
+ end
+ it 'ファイルが作成されている' do
+ File.exist?(@path + 'h/testsub.put').should be_true
+ end
+ it 'subdirtestが書きこまれている' do
+ d = File.open(@path + 'h/testsub.put').read
+ d.should match /subdirtest/
+ end
+ end
+ context '例外が発生するとき' do
+ it 'falseが返る' do
+ File.stub(:open).with(any_args()).and_raise(StandardError)
+ @io.put('bindata', 'test.put').should be_false
+ end
+ end
+ end
+
+ describe 'ファイル削除に於いて' do
+ before do
+ File.open @path + 'test.del', 'w' do |f|
+ f.puts 'basedata'
+ end
+ File.open @path + 'thumbnail/testsub.del', 'w' do |f|
+ f.puts 'subdata'
+ end
+ end
+ context 'ベースディレクトリから削除するとき' do
+ it 'ファイルが削除されている' do
+ @io.delete('test.del')
+ File.exist?(@path + 'test.del').should be_false
+ end
+ end
+ context 'サブディレクトリthumbnailから削除するとき' do
+ it 'ファイルが削除されている' do
+ @io.delete('testsub.del', 'thumbnail')
+ File.exist?(@path + 'thumbnail/testsub.del').should be_false
+ end
+ end
+ context '例外が発生するとき' do
+ it 'falseが返る' do
+ File.stub(:delete).with(any_args()).and_raise(StandardError)
+ @io.delete('test.del.not.exist').should be_false
+ end
+ end
+ end
+end
--- /dev/null
+# -*- encoding: utf-8 -*-
+#ファイル保存
+require 's3_picture'
+require 'spec_helper'
+
+#テスト用ファイルをクリアしておく
+@path = Rails.root + 'lib/test/temp/'
+Dir.glob @path + '*' do |filename|
+ if File.directory?(filename)
+ Dir.glob filename do |filename2|
+ File.delete(filename2) unless File.directory?(filename2)
+ end
+ else
+ File.delete(filename)
+ end
+end
+describe PictureIO::S3Picture do
+ before do
+ @path = 'test'
+ @io = PictureIO::S3Picture.new @path
+ end
+
+ describe 'サブディレクトリに於いて' do
+ it '配列が返る' do
+ PictureIO::S3Picture.subdirs.is_a?(Array).should be_true
+ end
+
+ it 'カレント、サムネ、水平反転、垂直反転、水平垂直反転が返る' do
+ PictureIO::S3Picture.subdirs.size.should eq 5
+ PictureIO::S3Picture.subdirs.include?('').should eq true
+ PictureIO::S3Picture.subdirs.include?('v').should eq true
+ PictureIO::S3Picture.subdirs.include?('h').should eq true
+ PictureIO::S3Picture.subdirs.include?('vh').should eq true
+ PictureIO::S3Picture.subdirs.include?('thumbnail').should eq true
+ end
+ end
+
+ describe 'ファイル存在確認に於いて' do
+ before do
+ AWS::S3::S3Object.stub(:exist?).with(any_args).and_return(true)
+ end
+ context 'ベースディレクトリから取るとき' do
+ it 'S3に依頼している' do
+ testname = 'exist'
+ AWS::S3::S3Object.should_receive(:exist?).with(testname, @path).exactly(1)
+ @io.exist?(testname)
+ end
+ end
+ context 'サブディレクトリvから取るとき' do
+ it 'S3に依頼している' do
+ testname = 'exist'
+ subd = 'v'
+ AWS::S3::S3Object.should_receive(:exist?).with(subd + '/' + testname, @path).exactly(1)
+ @io.exist?(testname, subd)
+ end
+ end
+ context '例外が発生するとき' do
+ it 'falseが返る' do
+ AWS::S3::S3Object.stub(:exist?).with(any_args()).and_raise(StandardError)
+ @io.exist?('test.get').should be_false
+ end
+ end
+ end
+
+ describe 'ファイル取得に於いて' do
+ before do
+ end
+ context 'ベースディレクトリから取るとき' do
+ it 'S3に依頼している' do
+ testname = 'test.get'
+ AWS::S3::S3Object.should_receive(:stream).with(testname, @path).exactly(1)
+ @io.get(testname)
+ end
+ it 'データが返る' do
+ AWS::S3::S3Object.stub(:stream).with(any_args()).and_yield('data')
+ @io.get('test.get').should eq 'data'
+ end
+ end
+ context 'サブディレクトリvから取るとき' do
+ it 'S3に依頼している' do
+ testname = 'test.get'
+ subd = 'v'
+ AWS::S3::S3Object.should_receive(:stream).with(subd + '/' + testname, @path).exactly(1)
+ @io.get(testname, subd)
+ end
+ it 'データが返る' do
+ subd = 'v'
+ AWS::S3::S3Object.stub(:stream).with(any_args()).and_yield('data')
+ @io.get('test.get', subd).should eq 'data'
+ end
+ end
+ context '例外が発生するとき' do
+ it 'falseが返る' do
+ AWS::S3::S3Object.stub(:get).with(any_args()).and_raise(StandardError)
+ @io.get('test.get').should be_false
+ end
+ end
+ end
+
+ describe 'ファイル作成に於いて' do
+ before do
+ end
+ context 'ベースディレクトリに作成するとき' do
+ it 'S3に依頼している' do
+ testname = 'create'
+ AWS::S3::S3Object.should_receive(:store).with(testname, 'bindata', @path).exactly(1)
+ @io.put('bindata', testname)
+ end
+ end
+ context 'サブディレクトリvに作成するとき' do
+ it 'S3に依頼している' do
+ testname = 'create'
+ subd = 'h'
+ AWS::S3::S3Object.should_receive(:store).with(subd + '/' + testname, 'bindata', @path).exactly(1)
+ @io.put('bindata', testname, subd)
+ end
+ end
+ context '例外が発生するとき' do
+ it 'falseが返る' do
+ AWS::S3::S3Object.stub(:store).with(any_args()).and_raise(StandardError)
+ @io.put('bindata', 'test.put').should be_false
+ end
+ end
+ end
+
+ describe 'ファイル削除に於いて' do
+ before do
+ end
+ context 'ベースディレクトリから削除するとき' do
+ it 'S3に依頼している' do
+ testname = 'destroy'
+ AWS::S3::S3Object.should_receive(:delete).with(testname, @path).exactly(1)
+ @io.delete(testname)
+ end
+ end
+ context 'サブディレクトリvhから削除するとき' do
+ it 'S3に依頼している' do
+ testname = 'destroy'
+ subd = 'vh'
+ AWS::S3::S3Object.should_receive(:delete).with(subd + '/' + testname, @path).exactly(1)
+ @io.delete(testname, subd)
+ end
+ end
+ context '例外が発生するとき' do
+ it 'falseが返る' do
+ AWS::S3::S3Object.stub(:delete).with(any_args()).and_raise(StandardError)
+ @io.delete('test.del.not.exist').should be_false
+ end
+ end
+ end
+end
require 'spec_helper'
-describe Admins::SessionsController do
-
-end
--- /dev/null
+# -*- encoding: utf-8 -*-
+#ライセンス
+require 'spec_helper'
+
+describe SystemController do
+ before do
+ end
+
+ describe 'システム初期化要請に於いて' do
+ context '要請の必要がないとき' do
+ before do
+ #要請の必要がない=管理者登録済み かつ ライセンス登録済み
+ Factory :admin
+ Factory :license
+ end
+ it 'リクエスト通りのページを開く' do
+ get :index
+ response.should_not redirect_to 'system/start'
+ end
+ context 'userがサインインしているなら' do
+ before do
+ @user = Factory( :user_yas)
+ @author = @user.author
+ sign_in @user
+ end
+ it 'userにサインイン中のアカウントをセットしている' do
+ get :index
+ assigns(:user).should eq @user
+ end
+ it 'authorに作家をセットしている' do
+ get :index
+ assigns(:author).should eq @author
+ end
+ it 'artistに絵師をセットしている' do
+ @artist = Factory :artist_yas, :author_id => @author.id
+ get :index
+ assigns(:artist).should eq @artist
+ end
+ it 'ただし、絵師登録されてなければ新規の絵師をセットしている' do
+ get :index
+ assigns(:artist).should be_a_new(Artist)
+ end
+ end
+ context 'userがサインインしていないなら' do
+ before do
+ @user = Factory( :user_yas)
+ @author = @user.author
+ @artist = Factory :artist_yas, :author_id => @author.id
+ end
+ it 'userが空になっている' do
+ get :index
+ assigns(:user).should eq nil
+ end
+ it 'authorが空になっている' do
+ get :index
+ assigns(:author).should eq nil
+ end
+ it 'artistが空になっている' do
+ get :index
+ assigns(:artist).should eq nil
+ end
+ end
+ end
+ #要請の必要がある=管理者がいない または ライセンスがない
+ context '管理者がいないとき' do
+ before do
+ Factory :license
+ end
+ context '本機能を開こうとしているなら' do
+ it '初期化要請ページに遷移する' do
+ get :index
+ response.should redirect_to '/system/start'
+ end
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ end
+ context '初期化要請ページを開こうとしているなら' do
+ it '遷移しない' do
+ get :start
+ response.should_not redirect_to 'system/start'
+ end
+ it 'ステータスOkを返す' do
+ get :start
+ response.status.should eq 200
+ end
+ it '初期化要請ページを描画する' do
+ get :start
+ response.should render_template("system/start")
+ end
+ end
+ end
+ context 'ライセンスがないとき' do
+ before do
+ Factory :admin
+ end
+ context '本機能を開こうとしているなら' do
+ it '初期化要請ページに遷移する' do
+ get :index
+ response.should redirect_to '/system/start'
+ end
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ end
+ context '初期化要請ページを開こうとしているなら' do
+ it '遷移しない' do
+ get :start
+ response.should_not redirect_to 'system/start'
+ end
+ it 'ステータスOkを返す' do
+ get :start
+ response.status.should eq 200
+ end
+ it '初期化要請ページを描画する' do
+ get :start
+ response.should render_template("system/start")
+ end
+ end
+ end
+ end
+end
+# -*- encoding: utf-8 -*-
require 'spec_helper'
-
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator. If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails. There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec. Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
+#絵師
describe ArtistsController do
-
- # This should return the minimal set of attributes required to create a valid
- # Artist. As you add validations to Artist, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- {}
+ before do
+ Factory :admin
+ @user = Factory( :user_yas)
+ @author = @user.author
+ @artist = Factory :artist_yas, :author_id => @author.id
end
-
- describe "GET index" do
- it "assigns all artists as @artists" do
- artist = Artist.create! valid_attributes
- get :index
- assigns(:artists).should eq([artist])
+
+ describe '一覧表示に於いて' do
+ before do
+ Artist.stub(:list).and_return([@artist, @artist, @artist])
+ sign_in @user
end
- end
-
- describe "GET show" do
- it "assigns the requested artist as @artist" do
- artist = Artist.create! valid_attributes
- get :show, :id => artist.id
- assigns(:artist).should eq(artist)
+ context '事前チェックする' do
+ it '与えられたpageがセットされている' do
+ get :index, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :index
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :index, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :index
+ assigns(:page_size).should eq Artist.default_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 1500
+ assigns(:page_size).should eq Artist.max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 0
+ assigns(:page_size).should eq Artist.default_page_size
+ end
end
- end
-
- describe "GET new" do
- it "assigns a new artist as @artist" do
- get :new
- assigns(:artist).should be_a_new(Artist)
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it '絵師モデルに一覧を問い合わせている' do
+ Artist.should_receive(:list).exactly(1)
+ get :index
+ end
+ it '@artistsにリストを取得している' do
+ get :index
+ assigns(:artists).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがリスト構造になっている' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは絵師っぽいものであって欲しい' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("name").should be_true
+ end
+ end
end
- end
-
- describe "GET edit" do
- it "assigns the requested artist as @artist" do
- artist = Artist.create! valid_attributes
- get :edit, :id => artist.id
- assigns(:artist).should eq(artist)
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :index
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :index, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :index, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
end
end
-
- describe "POST create" do
- describe "with valid params" do
- it "creates a new Artist" do
- expect {
- post :create, :artist => valid_attributes
- }.to change(Artist, :count).by(1)
+
+ describe '閲覧に於いて' do
+ before do
+ Artist.stub(:show).and_return(@artist)
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @artist.id
+ response.should be_success
end
-
- it "assigns a newly created artist as @artist" do
- post :create, :artist => valid_attributes
- assigns(:artist).should be_a(Artist)
- assigns(:artist).should be_persisted
+ it '絵師モデルに単体取得を問い合わせている' do
+ Artist.should_receive(:show).exactly(1)
+ get :show
end
-
- it "redirects to the created artist" do
- post :create, :artist => valid_attributes
- response.should redirect_to(Artist.last)
+ it '@artistにアレを取得している' do
+ get :show, :id => @artist.id
+ assigns(:artist).should eq(@artist)
end
- end
-
- describe "with invalid params" do
- it "assigns a newly created but unsaved artist as @artist" do
- # Trigger the behavior that occurs when invalid params are submitted
- Artist.any_instance.stub(:save).and_return(false)
- post :create, :artist => {}
- assigns(:artist).should be_a_new(Artist)
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @artist.id
+ response.should render_template("show")
+ end
end
-
- it "re-renders the 'new' template" do
- # Trigger the behavior that occurs when invalid params are submitted
- Artist.any_instance.stub(:save).and_return(false)
- post :create, :artist => {}
- response.should render_template("new")
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @artist.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがアレになっている' do
+ get :show, :id => @artist.id, :format => :json
+ json = JSON.parse response.body
+ json["name"].should match(/yas/)
+ end
end
end
- end
-
- describe "PUT update" do
- describe "with valid params" do
- it "updates the requested artist" do
- artist = Artist.create! valid_attributes
- # Assuming there are no other artists in the database, this
- # specifies that the Artist created on the previous line
- # receives the :update_attributes message with whatever params are
- # submitted in the request.
- Artist.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, :id => artist.id, :artist => {'these' => 'params'}
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
end
-
- it "assigns the requested artist as @artist" do
- artist = Artist.create! valid_attributes
- put :update, :id => artist.id, :artist => valid_attributes
- assigns(:artist).should eq(artist)
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :show, :id => @artist.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :show, :id => @artist.id
+ response.body.should redirect_to '/users/sign_in'
+ end
end
-
- it "redirects to the artist" do
- artist = Artist.create! valid_attributes
- put :update, :id => artist.id, :artist => valid_attributes
- response.should redirect_to(artist)
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :show, :id => @artist.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :show, :id => @artist.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
end
end
-
- describe "with invalid params" do
- it "assigns the artist as @artist" do
- artist = Artist.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- Artist.any_instance.stub(:save).and_return(false)
- put :update, :id => artist.id, :artist => {}
- assigns(:artist).should eq(artist)
+=begin
+ context '対象作家がないとき' do
+ context 'html形式' do
+ it '例外404 not_foundを返す' do
+ lambda{
+ get :show, :id => 0
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
end
-
- it "re-renders the 'edit' template" do
- artist = Artist.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- Artist.any_instance.stub(:save).and_return(false)
- put :update, :id => artist.id, :artist => {}
- response.should render_template("edit")
+ 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 "DELETE destroy" do
- it "destroys the requested artist" do
- artist = Artist.create! valid_attributes
- expect {
- delete :destroy, :id => artist.id
- }.to change(Artist, :count).by(-1)
+
+ describe '絵師数取得に於いて' do
+ before do
+ Artist.should_receive(:visible_count).and_return(3)
+# sign_in @user
end
-
- it "redirects to the artists list" do
- artist = Artist.create! valid_attributes
- delete :destroy, :id => artist.id
- response.should redirect_to(artists_url)
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :count, :format => :json
+ response.should be_success
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :count, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがHash構造になっていてコミック数が1である' do
+ get :count, :format => :json
+ json = JSON.parse response.body
+ json["count"].should == 3
+ end
+ end
end
end
require 'spec_helper'
-describe AuthorRegistrationsController do
-
-end
require 'spec_helper'
-describe Authors::SessionsController do
-
-end
+# -*- encoding: utf-8 -*-
require 'spec_helper'
+#作家
describe AuthorsController do
+ before do
+ Factory :admin
+ @user = Factory( :user_yas)
+ @author = @user.author
+ @artist = Factory :artist_yas, :author_id => @author.id
+ end
+ describe '一覧表示に於いて' do
+ before do
+ Author.stub(:list).and_return([@author, @author, @author])
+ sign_in @user
+ end
+ context '事前チェックする' do
+ it '与えられたpageがセットされている' do
+ get :index, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :index
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :index, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :index
+ assigns(:page_size).should eq Author.default_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 1500
+ assigns(:page_size).should eq Author.max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 0
+ assigns(:page_size).should eq Author.default_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it '作家モデルに一覧を問い合わせている' do
+ Author.should_receive(:list).exactly(1)
+ get :index
+ end
+ it '@authorsにリストを取得している' do
+ get :index
+ assigns(:authors).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがリスト構造になっている' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは作家っぽいものであって欲しい' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("name").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :index
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :index, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :index, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '閲覧に於いて' do
+ before do
+ Author.stub(:show).and_return(@author)
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @author.id
+ response.should be_success
+ end
+ it '作家モデルに単体取得を問い合わせている' do
+ Author.should_receive(:show).exactly(1)
+ get :show
+ end
+ it '@authorにアレを取得している' do
+ get :show, :id => @author.id
+ assigns(:author).should eq(@author)
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @author.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがアレになっている' do
+ get :show, :id => @author.id, :format => :json
+ json = JSON.parse response.body
+ json["name"].should match(/yas/)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :show, :id => @author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :show, :id => @author.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :show, :id => @author.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :show, :id => @author.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+=begin
+ context '対象作家がないとき' do
+ context 'html形式' do
+ it '例外404 not_foundを返す' do
+ lambda{
+ get :show, :id => 0
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+ context 'json形式' do
+ it '例外404 not_foundを返す' do
+ lambda{
+ get :show, :id => 0, :format => :json
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+ end
+=end
+ end
+
+ describe '作家数取得に於いて' do
+ before do
+ Author.should_receive(:visible_count).and_return(3)
+# sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :count, :format => :json
+ response.should be_success
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :count, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがHash構造になっていてコミック数が1である' do
+ get :count, :format => :json
+ json = JSON.parse response.body
+ json["count"].should == 3
+ end
+ end
+ end
+ end
+
+ describe 'コミック一覧表示に於いて' do
+ #指定作家のコミックpage_size件を一覧形式で表示する。ただし、作者によって非公開にされたコミックは含まない。
+ before do
+ @comic = Factory :normal_comic, :author_id => @author.id
+ Comic.stub(:list_by_author).and_return([@comic, @comic, @comic])
+ sign_in @user
+ end
+ context '事前チェックする' do
+ it '与えられたpageがセットされている' do
+ get :comics, :id => @author.id, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :comics, :id => @author.id
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :comics, :id => @author.id, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :comics, :id => @author.id
+ assigns(:page_size).should eq Author.default_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :comics, :id => @author.id, :page_size => 1500
+ assigns(:page_size).should eq Author.max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :comics, :id => @author.id, :page_size => 0
+ assigns(:page_size).should eq Author.default_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :comics, :id => @author.id
+ response.should be_success
+ end
+ it 'コミックモデルに一覧を問い合わせている' do
+ Comic.should_receive(:list_by_author).exactly(1)
+ get :comics, :id => @author.id
+ end
+ it '@comicsにリストを取得している' do
+ get :comics, :id => @author.id
+ assigns(:comics).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'comicsテンプレートを描画する' do
+ get :comics, :id => @author.id
+ response.should render_template("comics")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :comics, :id => @author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがリスト構造になっている' do
+ get :comics, :id => @author.id, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
+ get :comics, :id => @author.id, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("title").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :comics, :id => @author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :comics, :id => @author.id
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :comics, :id => @author.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :comics, :id => @author.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe 'コマ一覧表示に於いて' do
+ #指定作家のコマpage_size件を一覧形式で表示する。ただし、作者によって非公開にされたコミックのコマは含まない。
+ before do
+ @comic = Factory :normal_comic, :author_id => @author.id
+ @panel = Factory :panel, :author_id => @author.id, :comic_id => @comic.id
+ Panel.stub(:list_by_author).and_return([@panel, @panel, @panel])
+ sign_in @user
+ end
+ context '事前チェックする' do
+ it '与えられたpageがセットされている' do
+ get :panels, :id => @author.id, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :panels, :id => @author.id
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :panels, :id => @author.id, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :panels, :id => @author.id
+ assigns(:page_size).should eq Author.default_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :panels, :id => @author.id, :page_size => 1500
+ assigns(:page_size).should eq Author.max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :panels, :id => @author.id, :page_size => 0
+ assigns(:page_size).should eq Author.default_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :panels, :id => @author.id
+ response.should be_success
+ end
+ it 'コマモデルに一覧を問い合わせている' do
+ Panel.should_receive(:list_by_author).exactly(1)
+ get :panels, :id => @author.id
+ end
+ it '@panelsにリストを取得している' do
+ get :panels, :id => @author.id
+ assigns(:panels).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'panelsテンプレートを描画する' do
+ get :panels, :id => @author.id
+ response.should render_template("panels")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panels, :id => @author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがリスト構造になっている' do
+ get :panels, :id => @author.id, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいはコマっぽいものであって欲しい' do
+ get :panels, :id => @author.id, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("link").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :panels, :id => @author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :panels, :id => @author.id
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :panels, :id => @author.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :panels, :id => @author.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
end
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
-describe BaloonTemplatesController do
+describe BalloonTemplatesController do
# This should return the minimal set of attributes required to create a valid
# BaloonTemplate. As you add validations to BaloonTemplate, be sure to
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
-describe BaloonsController do
+describe BalloonsController do
# This should return the minimal set of attributes required to create a valid
# Baloon. As you add validations to Baloon, be sure to
+++ /dev/null
-require 'spec_helper'
-
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator. If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails. There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec. Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
-
-describe BaloonTypesController do
-
- # This should return the minimal set of attributes required to create a valid
- # BaloonType. As you add validations to BaloonType, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- {}
- end
-
- describe "GET index" do
- it "assigns all baloon_types as @baloon_types" do
- baloon_type = BaloonType.create! valid_attributes
- get :index
- assigns(:baloon_types).should eq([baloon_type])
- end
- end
-
- describe "GET show" do
- it "assigns the requested baloon_type as @baloon_type" do
- baloon_type = BaloonType.create! valid_attributes
- get :show, :id => baloon_type.id
- assigns(:baloon_type).should eq(baloon_type)
- end
- end
-
- describe "GET new" do
- it "assigns a new baloon_type as @baloon_type" do
- get :new
- assigns(:baloon_type).should be_a_new(BaloonType)
- end
- end
-
- describe "GET edit" do
- it "assigns the requested baloon_type as @baloon_type" do
- baloon_type = BaloonType.create! valid_attributes
- get :edit, :id => baloon_type.id
- assigns(:baloon_type).should eq(baloon_type)
- end
- end
-
- describe "POST create" do
- describe "with valid params" do
- it "creates a new BaloonType" do
- expect {
- post :create, :baloon_type => valid_attributes
- }.to change(BaloonType, :count).by(1)
- end
-
- it "assigns a newly created baloon_type as @baloon_type" do
- post :create, :baloon_type => valid_attributes
- assigns(:baloon_type).should be_a(BaloonType)
- assigns(:baloon_type).should be_persisted
- end
-
- it "redirects to the created baloon_type" do
- post :create, :baloon_type => valid_attributes
- response.should redirect_to(BaloonType.last)
- end
- end
-
- describe "with invalid params" do
- it "assigns a newly created but unsaved baloon_type as @baloon_type" do
- # Trigger the behavior that occurs when invalid params are submitted
- BaloonType.any_instance.stub(:save).and_return(false)
- post :create, :baloon_type => {}
- assigns(:baloon_type).should be_a_new(BaloonType)
- end
-
- it "re-renders the 'new' template" do
- # Trigger the behavior that occurs when invalid params are submitted
- BaloonType.any_instance.stub(:save).and_return(false)
- post :create, :baloon_type => {}
- response.should render_template("new")
- end
- end
- end
-
- describe "PUT update" do
- describe "with valid params" do
- it "updates the requested baloon_type" do
- baloon_type = BaloonType.create! valid_attributes
- # Assuming there are no other baloon_types in the database, this
- # specifies that the BaloonType created on the previous line
- # receives the :update_attributes message with whatever params are
- # submitted in the request.
- BaloonType.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, :id => baloon_type.id, :baloon_type => {'these' => 'params'}
- end
-
- it "assigns the requested baloon_type as @baloon_type" do
- baloon_type = BaloonType.create! valid_attributes
- put :update, :id => baloon_type.id, :baloon_type => valid_attributes
- assigns(:baloon_type).should eq(baloon_type)
- end
-
- it "redirects to the baloon_type" do
- baloon_type = BaloonType.create! valid_attributes
- put :update, :id => baloon_type.id, :baloon_type => valid_attributes
- response.should redirect_to(baloon_type)
- end
- end
-
- describe "with invalid params" do
- it "assigns the baloon_type as @baloon_type" do
- baloon_type = BaloonType.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- BaloonType.any_instance.stub(:save).and_return(false)
- put :update, :id => baloon_type.id, :baloon_type => {}
- assigns(:baloon_type).should eq(baloon_type)
- end
-
- it "re-renders the 'edit' template" do
- baloon_type = BaloonType.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- BaloonType.any_instance.stub(:save).and_return(false)
- put :update, :id => baloon_type.id, :baloon_type => {}
- response.should render_template("edit")
- end
- end
- end
-
- describe "DELETE destroy" do
- it "destroys the requested baloon_type" do
- baloon_type = BaloonType.create! valid_attributes
- expect {
- delete :destroy, :id => baloon_type.id
- }.to change(BaloonType, :count).by(-1)
- end
-
- it "redirects to the baloon_types list" do
- baloon_type = BaloonType.create! valid_attributes
- delete :destroy, :id => baloon_type.id
- response.should redirect_to(baloon_types_url)
- end
- end
-
-end
+# -*- encoding: utf-8 -*-
+#ライセンス
require 'spec_helper'
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator. If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails. There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec. Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
-
describe LicensesController do
-
- # This should return the minimal set of attributes required to create a valid
- # License. As you add validations to License, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- {}
- end
-
- describe "GET index" do
- it "assigns all licenses as @licenses" do
- license = License.create! valid_attributes
- get :index
- assigns(:licenses).should eq([license])
- end
- end
-
- describe "GET show" do
- it "assigns the requested license as @license" do
- license = License.create! valid_attributes
- get :show, :id => license.id
- assigns(:license).should eq(license)
- end
- end
-
- describe "GET new" do
- it "assigns a new license as @license" do
- get :new
- assigns(:license).should be_a_new(License)
- end
- end
-
- describe "GET edit" do
- it "assigns the requested license as @license" do
- license = License.create! valid_attributes
- get :edit, :id => license.id
- assigns(:license).should eq(license)
- end
- end
-
- describe "POST create" do
- describe "with valid params" do
- it "creates a new License" do
- expect {
- post :create, :license => valid_attributes
- }.to change(License, :count).by(1)
- end
-
- it "assigns a newly created license as @license" do
- post :create, :license => valid_attributes
- assigns(:license).should be_a(License)
- assigns(:license).should be_persisted
- end
-
- it "redirects to the created license" do
- post :create, :license => valid_attributes
- response.should redirect_to(License.last)
- end
- end
-
- describe "with invalid params" do
- it "assigns a newly created but unsaved license as @license" do
- # Trigger the behavior that occurs when invalid params are submitted
- License.any_instance.stub(:save).and_return(false)
- post :create, :license => {}
- assigns(:license).should be_a_new(License)
- end
-
- it "re-renders the 'new' template" do
- # Trigger the behavior that occurs when invalid params are submitted
- License.any_instance.stub(:save).and_return(false)
- post :create, :license => {}
- response.should render_template("new")
- end
- end
- end
-
- describe "PUT update" do
- describe "with valid params" do
- it "updates the requested license" do
- license = License.create! valid_attributes
- # Assuming there are no other licenses in the database, this
- # specifies that the License created on the previous line
- # receives the :update_attributes message with whatever params are
- # submitted in the request.
- License.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, :id => license.id, :license => {'these' => 'params'}
- end
-
- it "assigns the requested license as @license" do
- license = License.create! valid_attributes
- put :update, :id => license.id, :license => valid_attributes
- assigns(:license).should eq(license)
- end
-
- it "redirects to the license" do
- license = License.create! valid_attributes
- put :update, :id => license.id, :license => valid_attributes
- response.should redirect_to(license)
- end
- end
-
- describe "with invalid params" do
- it "assigns the license as @license" do
- license = License.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- License.any_instance.stub(:save).and_return(false)
- put :update, :id => license.id, :license => {}
- assigns(:license).should eq(license)
- end
-
- it "re-renders the 'edit' template" do
- license = License.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- License.any_instance.stub(:save).and_return(false)
- put :update, :id => license.id, :license => {}
- response.should render_template("edit")
- end
- end
+ before do
+ Factory :admin
+ @user = Factory( :user_yas)
+ @author = @user.author
+ @artist = Factory :artist_yas, :author_id => @author.id
end
- describe "DELETE destroy" do
- it "destroys the requested license" do
- license = License.create! valid_attributes
- expect {
- delete :destroy, :id => license.id
- }.to change(License, :count).by(-1)
+ describe 'システム初期化要請に於いて' do
+ before do
+ @op = Factory :original_picture, :artist_id => @artist.id
+ sign_in @user
+ OriginalPicture.stub(:list).and_return([@op, @op, @op])
end
-
- it "redirects to the licenses list" do
- license = License.create! valid_attributes
- delete :destroy, :id => license.id
- response.should redirect_to(licenses_url)
+ context 'パラメータpageについて' do
end
end
-
end
--- /dev/null
+# -*- encoding: utf-8 -*-
+#コマ絵
+require 'spec_helper'
+
+describe PanelPicturesController do
+ before do
+ Factory :admin
+ @user = Factory( :user_yas)
+ @author = @user.author
+ @artist = Factory :artist_yas, :author_id => @author.id
+ end
+
+ describe '一覧表示に於いて' do
+ before do
+ @pp = Factory :panel_picture, :author_id => @author.id
+ sign_in @user
+ PanelPicture.stub(:list).and_return([@pp, @pp, @pp])
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :index, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :index
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :index, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :index
+ assigns(:page_size).should eq PanelPicture.default_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 1500
+ assigns(:page_size).should eq PanelPicture.max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 0
+ assigns(:page_size).should eq PanelPicture.default_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'コマ絵モデルに一覧を問い合わせている' do
+ PanelPicture.should_receive(:list).exactly(1)
+ get :index
+ end
+ it '@panel_picturesにリストを取得している' do
+ get :index
+ assigns(:panel_pictures).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがリスト構造になっている' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("link").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :index
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :index, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :index, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ context '作家が絵師でないとき' do
+ before do
+ Author.any_instance.stub(:artist?).and_return(false)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it '絵師登録ページへ遷移する' do
+ get :index
+ response.should redirect_to new_artist_path
+ end
+ end
+ context 'json形式' do
+ it '例外403 forbiddenを返す' do
+ lambda{
+ get :index, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
+ end
+ end
+ end
+ end
+
+ describe 'コマ絵数取得に於いて' do
+ before do
+ PanelPicture.should_receive(:visible_count).and_return(3)
+# sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :count, :format => :json
+ response.should be_success
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :count, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがHash構造になっていてコマ絵数が3である' do
+ get :count, :format => :json
+ json = JSON.parse response.body
+ json["count"].should == 3
+ end
+ end
+ end
+ end
+
+end
# -*- encoding: utf-8 -*-\r
-require 'spec_helper'
-
-describe PanelsController do
- before do
- Factory :admin
+require 'spec_helper'\r
+\r
+describe PanelsController do\r
+ before do\r
+ Factory :admin\r
@user = Factory :user_yas\r
- @author = @user.author #ユーザ作成時に連動して作成される
- end
-
- describe '新規作成に於いて' do
- before do
- @comic = Factory :normal_comic, :author_id => @user.author.id
- sign_in @user
- end
- context '事前チェックする' do
- before do
- controller
- Panel.stub(:count).and_return(10)
- end
- it 'panelがパラメータにあれば、展開する' do
- post :create, :panel => Factory.attributes_for(:panel, :comic_id => @comic.id)
- assigns(:prm)['border'].to_i.should eq 1
- end
- it 'jsonがパラメータにあれば、展開する' do
- post :create, :json => Factory.attributes_for(:panel, :comic_id => @comic.id, :border => 4).to_s
- assigns(:prm)['border'].to_i.should eq 4
- end
- it 'panel・json両パラメータがあれば、panelを優先して展開する' do
- post :create, {
- :panel => Factory.attributes_for(:panel, :comic_id => @comic.id),
- :json => Factory.attributes_for(:panel, :comic_id => @comic.id, :border => 4).to_s
- }
- assigns(:prm)['border'].to_i.should eq 1
- end
- end
- end
-
-end
+ @author = @user.author #ユーザ作成時に連動して作成される\r
+ end\r
+ \r
+ describe '一覧表示に於いて' do\r
+ before do\r
+ @panel = Factory :panel, :author_id => @user.author.id\r
+ Panel.stub(:list).and_return([@panel, @panel, @panel])\r
+ sign_in @user\r
+ end\r
+ context '事前チェックする' do\r
+ it '与えられたpageがセットされている' do\r
+ get :index, :page => 5\r
+ assigns(:page).should eq 5\r
+ end\r
+ it '省略されると@pageに1値が入る' do\r
+ get :index\r
+ assigns(:page).should eq 1\r
+ end\r
+ it '与えられたpage_sizeがセットされている' do\r
+ get :index, :page_size => 15\r
+ assigns(:page_size).should eq 15\r
+ end\r
+ it '省略されると@page_sizeにデフォルト値が入る' do\r
+ get :index\r
+ assigns(:page_size).should eq Panel.default_page_size\r
+ end\r
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do\r
+ get :index, :page_size => 1500\r
+ assigns(:page_size).should eq Panel.max_page_size\r
+ end\r
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do\r
+ get :index, :page_size => 0\r
+ assigns(:page_size).should eq Panel.default_page_size\r
+ end\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :index\r
+ response.should be_success \r
+ end\r
+ it 'コマモデルに一覧を問い合わせている' do\r
+ Panel.should_receive(:list).exactly(1)\r
+ get :index\r
+ end\r
+ it '@panelsにリストを取得している' do\r
+ get :index\r
+ assigns(:panels).should have_at_least(3).items\r
+ end\r
+ context 'html形式' do\r
+ it 'indexテンプレートを描画する' do\r
+ get :index\r
+ response.should render_template("index")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :index, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ it 'データがリスト構造になっている' do\r
+ get :index, :format => :json\r
+ json = JSON.parse response.body\r
+ json.should have_at_least(3).items\r
+ end\r
+ it 'リストの先頭くらいはコマっぽいものであって欲しい' do\r
+ get :index, :format => :json\r
+ json = JSON.parse response.body\r
+ json.first.has_key?("comic_id").should be_true\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :index\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :index\r
+ response.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :index, :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :index, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '単体表示に於いて' do\r
+ before do\r
+ @panel = Factory :panel, :author_id => @user.author.id\r
+ Panel.stub(:show).and_return(@panel)\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :show, :id => @panel.id\r
+ response.should be_success\r
+ end\r
+ it 'コマモデルに単体取得を問い合わせている' do\r
+ Panel.should_receive(:show).exactly(1)\r
+ get :show\r
+ end\r
+ it '@panelにアレを取得している' do\r
+ get :show, :id => @panel.id\r
+ assigns(:panel).id.should eq(@panel.id)\r
+ end\r
+ context 'html形式' do\r
+ it 'showテンプレートを描画する' do\r
+ get :show, :id => @panel.id\r
+ response.should render_template("show")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ it 'データがアレになっている' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ json = JSON.parse response.body\r
+ json["width"].should match(/438/)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :show, :id => @panel.id\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :show, :id => @panel.id\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+=begin\r
+ context '対象コマがないとき' do\r
+ context 'html形式' do\r
+ it '例外404 not_foundを返す' do\r
+ lambda{\r
+ get :show, :id => 0\r
+ }.should raise_error(ActiveRecord::RecordNotFound)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it '例外404 not_foundを返す' do\r
+ lambda{ \r
+ get :show, :id => 0, :format => :json\r
+ }.should raise_error(ActiveRecord::RecordNotFound)\r
+ end\r
+ end\r
+ end\r
+ context '非公開コマを見ようとしたとき' do\r
+ context 'html形式' do\r
+ it '例外403 forbiddenを返す' do\r
+ Panel.any_instance.stub(:visible?).with(any_args()).and_return(false)\r
+ hidden = Factory :hidden_panel, :author_id => @author.id\r
+ lambda{\r
+ get :show, :id => hidden\r
+ }.should raise_error(ActiveRecord::Forbidden)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it '例外403 forbiddenを返す' do\r
+ Panel.any_instance.stub(:visible?).with(any_args()).and_return(false)\r
+ hidden = Factory :hidden_panel, :author_id => @author.id\r
+ lambda{\r
+ get :show, :id => hidden, :format => :json\r
+ }.should raise_error(ActiveRecord::Forbidden)\r
+ end\r
+ end\r
+ end\r
+=end\r
+ end\r
+ \r
+ describe 'コマ数取得に於いて' do\r
+ before do\r
+ Panel.should_receive(:visible_count).and_return(3)\r
+# sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :count, :format => :json\r
+ response.should be_success \r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :count, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ it 'データがHash構造になっていてコマ数が1である' do\r
+ get :count, :format => :json\r
+ json = JSON.parse response.body\r
+ json["count"].should == 3\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '新規作成フォーム表示に於いて' do\r
+ before do\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :new\r
+ response.should be_success \r
+ end\r
+ it '@panelに新規データを用意している' do\r
+ get :new\r
+ assigns(:panel).should be_a_new(Panel)\r
+ end\r
+ it 'コマモデルにデフォルト値補充を依頼している' do\r
+ Panel.any_instance.should_receive(:supply_default).exactly(1)\r
+ get :new\r
+ end\r
+ context 'html形式' do\r
+ it 'newテンプレートを描画する' do\r
+ get :new\r
+ response.should render_template("new")\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'new.jsテンプレートを描画する' do\r
+ get :new, :format => :js\r
+ response.should render_template("new")\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :new\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :new\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :new, :format => :js\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :new, :format => :js\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '新規作成に於いて' do\r
+ before do\r
+ @panel = Factory :normal_panel, :author_id => @user.author.id\r
+ sign_in @user\r
+ end\r
+ context '事前チェックする' do\r
+ before do\r
+ controller\r
+ Panel.stub(:count).and_return(10)\r
+ end\r
+ it 'panelがパラメータにあれば、展開する' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :panel_id => @panel.id)\r
+ assigns(:prm)['border'].to_i.should eq 1\r
+ end\r
+ it 'jsonがパラメータにあれば、展開する' do\r
+ post :create, :json => Factory.attributes_for(:panel, :panel_id => @panel.id, :border => 4).to_s\r
+ assigns(:prm)['border'].to_i.should eq 4\r
+ end\r
+ it 'panel・json両パラメータがあれば、panelを優先して展開する' do\r
+ post :create, {\r
+ :panel => Factory.attributes_for(:panel, :panel_id => @panel.id), \r
+ :json => Factory.attributes_for(:panel, :panel_id => @panel.id, :border => 4).to_s\r
+ }\r
+ assigns(:prm)['border'].to_i.should eq 1\r
+ end\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'モデルに保存依頼する' do\r
+ Panel.any_instance.should_receive(:save).exactly(1)\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ end\r
+ it "@panelに作成されたコマを保持していて、それがDBにある" do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ assigns(:panel).should be_a(Panel)\r
+ assigns(:panel).should be_persisted\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ Panel.any_instance.stub(:save).and_return(true)\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.status.should eq 302\r
+ end\r
+ it '作成されたコマの表示ページへ遷移する' do\r
+# Panel.any_instance.stub(:save).and_return(true)\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.should redirect_to(Panel.last)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+# Panel.any_instance.stub(:save).and_return(true)\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.should be_success \r
+ end\r
+ it '作成されたコマをjsonデータで返す' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ it 'データがアレになっている' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ json = JSON.parse response.body\r
+ json["title"].should match(/normal/)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ context '検証、保存に失敗した' do\r
+ before do\r
+ Panel.any_instance.stub(:save).and_return(false)\r
+ end\r
+ it "未保存のコマを保持している" do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ assigns(:panel).should be_a_new(Panel)\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.status.should eq 200\r
+ end\r
+ it '新規ページを描画する' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.should render_template("new")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード422 unprocessable_entity を返す' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.status.should eq 422\r
+ end\r
+ it '応答メッセージUnprocessable Entityを返す' do\r
+ post :create, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.message.should match(/Unprocessable/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '編集フォーム表示に於いて' do\r
+ before do\r
+ @panel = Factory :panel, :author_id => @author.id\r
+ sign_in @user\r
+ Panel.stub(:show).and_return(@panel)\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :edit, :id => @panel.id\r
+ response.should be_success \r
+ end\r
+ it 'コマモデルに単体取得を問い合わせている' do\r
+ Panel.should_receive(:show).exactly(1)\r
+ get :edit, :id => @panel.id\r
+ end\r
+ it '@panelにデータを用意している' do\r
+ get :edit, :id => @panel.id\r
+ assigns(:panel).should eq @panel\r
+ end\r
+ context 'html形式' do\r
+ it 'editテンプレートを描画する' do\r
+ get :edit, :id => @panel.id\r
+ response.should render_template("edit")\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'edit.jsテンプレートを描画する' do\r
+ get :edit, :id => @panel.id, :format => :js\r
+ response.should render_template("edit")\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :edit, :id => @panel.id\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :edit, :id => @panel.id\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :edit, :id => @panel.id, :format => :js\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :edit, :id => @panel.id, :format => :js\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '更新に於いて' do\r
+ before do\r
+ @panel = Factory :panel, :author => @author.id\r
+ sign_in @user\r
+ end\r
+ context '事前チェックしておく' do\r
+ it 'コマモデルに単体取得を問い合わせている' do\r
+ Panel.stub(:show).with(any_args()).and_return @panel\r
+ Panel.should_receive(:show).exactly(1)\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ end\r
+ it 'モデルに更新を依頼する' do\r
+ Panel.any_instance.should_receive(:update_attributes).with(any_args)\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ end\r
+ it '@panelにアレを取得している' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ assigns(:panel).id.should eq(@panel.id)\r
+ end\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it '更新される' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ Panel.find(@panel.id).visible.should eq 0\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ Panel.any_instance.stub(:update_attributes).with(any_args()).and_return(true)\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.status.should eq 302\r
+ end\r
+ it '更新されたコマの表示ページへ遷移する' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.should redirect_to(@panel)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ Panel.any_instance.stub(:update_attributes).with(any_args()).and_return(true)\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.should be_success \r
+ end\r
+ it 'ページ本体は特に返さない' do\r
+ Panel.any_instance.stub(:update_attributes).with(any_args()).and_return(true)\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.body.should match /./\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ it 'ステータスコード302 Foundを返す' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.status.should eq 302\r
+ end\r
+ context 'html形式' do\r
+ it 'サインインページへ遷移する' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ context '検証、保存に失敗したとき' do\r
+ before do\r
+ Panel.any_instance.stub(:update_attributes).and_return(false)\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード200 Okを返す' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.status.should eq 200\r
+ end\r
+ it '編集ページを描画する' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id)\r
+ response.should render_template("edit")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード422 unprocessable_entity を返す' do\r
+ Panel.any_instance.stub(:update_attributes).and_return(false)\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.status.should eq 422\r
+ end\r
+ it '応答メッセージUnprocessable Entityを返す' do\r
+ put :update, :id => @panel.id, :panel => Factory.attributes_for(:panel, :author => @author.id), :format => :json\r
+ response.message.should match(/Unprocessable/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+end\r
+++ /dev/null
-require 'spec_helper'
-
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator. If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails. There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec. Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
-
-describe PicturesController do
-
- # This should return the minimal set of attributes required to create a valid
- # Picture. As you add validations to Picture, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- {}
- end
-
- describe "GET index" do
- it "assigns all pictures as @pictures" do
- picture = Picture.create! valid_attributes
- get :index
- assigns(:pictures).should eq([picture])
- end
- end
-
- describe "GET show" do
- it "assigns the requested picture as @picture" do
- picture = Picture.create! valid_attributes
- get :show, :id => picture.id
- assigns(:picture).should eq(picture)
- end
- end
-
- describe "GET new" do
- it "assigns a new picture as @picture" do
- get :new
- assigns(:picture).should be_a_new(Picture)
- end
- end
-
- describe "GET edit" do
- it "assigns the requested picture as @picture" do
- picture = Picture.create! valid_attributes
- get :edit, :id => picture.id
- assigns(:picture).should eq(picture)
- end
- end
-
- describe "POST create" do
- describe "with valid params" do
- it "creates a new Picture" do
- expect {
- post :create, :picture => valid_attributes
- }.to change(Picture, :count).by(1)
- end
-
- it "assigns a newly created picture as @picture" do
- post :create, :picture => valid_attributes
- assigns(:picture).should be_a(Picture)
- assigns(:picture).should be_persisted
- end
-
- it "redirects to the created picture" do
- post :create, :picture => valid_attributes
- response.should redirect_to(Picture.last)
- end
- end
-
- describe "with invalid params" do
- it "assigns a newly created but unsaved picture as @picture" do
- # Trigger the behavior that occurs when invalid params are submitted
- Picture.any_instance.stub(:save).and_return(false)
- post :create, :picture => {}
- assigns(:picture).should be_a_new(Picture)
- end
-
- it "re-renders the 'new' template" do
- # Trigger the behavior that occurs when invalid params are submitted
- Picture.any_instance.stub(:save).and_return(false)
- post :create, :picture => {}
- response.should render_template("new")
- end
- end
- end
-
- describe "PUT update" do
- describe "with valid params" do
- it "updates the requested picture" do
- picture = Picture.create! valid_attributes
- # Assuming there are no other pictures in the database, this
- # specifies that the Picture created on the previous line
- # receives the :update_attributes message with whatever params are
- # submitted in the request.
- Picture.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, :id => picture.id, :picture => {'these' => 'params'}
- end
-
- it "assigns the requested picture as @picture" do
- picture = Picture.create! valid_attributes
- put :update, :id => picture.id, :picture => valid_attributes
- assigns(:picture).should eq(picture)
- end
-
- it "redirects to the picture" do
- picture = Picture.create! valid_attributes
- put :update, :id => picture.id, :picture => valid_attributes
- response.should redirect_to(picture)
- end
- end
-
- describe "with invalid params" do
- it "assigns the picture as @picture" do
- picture = Picture.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- Picture.any_instance.stub(:save).and_return(false)
- put :update, :id => picture.id, :picture => {}
- assigns(:picture).should eq(picture)
- end
-
- it "re-renders the 'edit' template" do
- picture = Picture.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- Picture.any_instance.stub(:save).and_return(false)
- put :update, :id => picture.id, :picture => {}
- response.should render_template("edit")
- end
- end
- end
-
- describe "DELETE destroy" do
- it "destroys the requested picture" do
- picture = Picture.create! valid_attributes
- expect {
- delete :destroy, :id => picture.id
- }.to change(Picture, :count).by(-1)
- end
-
- it "redirects to the pictures list" do
- picture = Picture.create! valid_attributes
- delete :destroy, :id => picture.id
- response.should redirect_to(pictures_url)
- end
- end
-
-end
--- /dev/null
+# -*- encoding: utf-8 -*-
+#素材
+require 'spec_helper'
+
+describe ResourcePicturesController do
+ before do
+ Factory :admin
+ @user = Factory( :user_yas)
+ @author = @user.author
+ @artist = Factory :artist_yas, :author_id => @author.id
+ end
+
+ describe '一覧表示に於いて' do
+ before do
+ @rp = Factory :resource_picture, :artist_id => @artist.id
+ sign_in @user
+ ResourcePicture.stub(:list).and_return([@rp, @rp, @rp])
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :index, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :index
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :index, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :index
+ assigns(:page_size).should eq ResourcePicture.default_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 1500
+ assigns(:page_size).should eq ResourcePicture.max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 0
+ assigns(:page_size).should eq ResourcePicture.default_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it '素材モデルに一覧を問い合わせている' do
+ ResourcePicture.should_receive(:list).exactly(1)
+ get :index
+ end
+ it '@resource_picturesにリストを取得している' do
+ get :index
+ assigns(:resource_pictures).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがリスト構造になっている' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは素材っぽいものであって欲しい' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("ext").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :index
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :index, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :index, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ @pic = Factory :resource_picture, :artist_id => @artist.id
+ sign_in @user
+ ResourcePicture.stub(:show).and_return(@pic)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @pic.id
+ response.should be_success
+ end
+ it '素材モデルに単体取得を問い合わせている' do
+ ResourcePicture.should_receive(:show).exactly(1)
+ get :show
+ end
+ it '@resource_pictureにアレを取得している' do
+ get :show, :id => @pic.id
+ assigns(:resource_picture).id.should eq(@pic.id)
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @pic.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @pic.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがアレになっている' do
+ get :show, :id => @pic.id, :format => :json
+ json = JSON.parse response.body
+ json["ext"].should match(/png/)
+ end
+ end
+ #画像送信では、send_dataにスタブをおいてテストしたいが、ここに噛ませると
+ #renderが働かず、エラーとなってしまう。そこで、素材のファイル取得部分に
+ #スタブをおいてsend_dataがデータを返す体裁でテストする。
+ context 'png形式' do
+ it '画像モデルに画像データを問い合わせる' do
+ ResourcePicture.any_instance.should_receive(:restore).exactly(1)
+ get :show, :id => @pic.id, :format => :png
+ end
+ it '画像を送信する' do
+ ResourcePicture.any_instance.stub(:restore).and_return('aaa')
+ get :show, :id => @pic.id, :format => :png
+ response.body.should eq 'aaa'
+ end
+ end
+ context 'gif形式' do
+ it '画像モデルに画像データを問い合わせる' do
+ ResourcePicture.any_instance.should_receive(:restore).exactly(1)
+ get :show, :id => @pic.id, :format => :gif
+ end
+ it '画像を送信する' do
+ ResourcePicture.any_instance.stub(:restore).and_return('bbb')
+ get :show, :id => @pic.id, :format => :gif
+ response.body.should eq 'bbb'
+ end
+ end
+ context 'jpeg形式' do
+ it '画像モデルに画像データを問い合わせる' do
+ ResourcePicture.any_instance.should_receive(:restore).exactly(1)
+ get :show, :id => @pic.id, :format => :jpeg
+ end
+ it '画像を送信する' do
+ ResourcePicture.any_instance.stub(:restore).and_return('ccc')
+ get :show, :id => @pic.id, :format => :jpeg
+ response.body.should eq 'ccc'
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :show, :id => @pic.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :show, :id => @pic.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :show, :id => @pic.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :show, :id => @pic.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
+ context '他人の素材を見ようとしたとき' do
+ before do
+ ResourcePicture.stub(:show).and_return(@pic)
+ ResourcePicture.any_instance.stub(:own?).with(any_args()).and_return(false)
+ end
+ context 'html形式' do
+ it '例外403 forbiddenを返す' do
+ lambda{
+ get :show, :id => @pic.id
+ }.should raise_error(ActiveRecord::Forbidden)
+ end
+ end
+ context 'json形式' do
+ it '例外403 forbiddenを返す' do
+ lambda{
+ get :show, :id => @pic.id, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
+ end
+ end
+ end
+=end
+ end
+
+ describe '素材数取得に於いて' do
+ before do
+ ResourcePicture.should_receive(:visible_count).and_return(3)
+# sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :count, :format => :json
+ response.should be_success
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :count, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがHash構造になっていてコマ絵数が3である' do
+ get :count, :format => :json
+ json = JSON.parse response.body
+ json["count"].should == 3
+ end
+ end
+ end
+ end
+
+end
+++ /dev/null
-require 'spec_helper'
-
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator. If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails. There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec. Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
-
-describe SourcePicturesController do
-
- # This should return the minimal set of attributes required to create a valid
- # SourcePicture. As you add validations to SourcePicture, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- {}
- end
-
- describe "GET index" do
- it "assigns all source_pictures as @source_pictures" do
- source_picture = SourcePicture.create! valid_attributes
- get :index
- assigns(:source_pictures).should eq([source_picture])
- end
- end
-
- describe "GET show" do
- it "assigns the requested source_picture as @source_picture" do
- source_picture = SourcePicture.create! valid_attributes
- get :show, :id => source_picture.id
- assigns(:source_picture).should eq(source_picture)
- end
- end
-
- describe "GET new" do
- it "assigns a new source_picture as @source_picture" do
- get :new
- assigns(:source_picture).should be_a_new(SourcePicture)
- end
- end
-
- describe "GET edit" do
- it "assigns the requested source_picture as @source_picture" do
- source_picture = SourcePicture.create! valid_attributes
- get :edit, :id => source_picture.id
- assigns(:source_picture).should eq(source_picture)
- end
- end
-
- describe "POST create" do
- describe "with valid params" do
- it "creates a new SourcePicture" do
- expect {
- post :create, :source_picture => valid_attributes
- }.to change(SourcePicture, :count).by(1)
- end
-
- it "assigns a newly created source_picture as @source_picture" do
- post :create, :source_picture => valid_attributes
- assigns(:source_picture).should be_a(SourcePicture)
- assigns(:source_picture).should be_persisted
- end
-
- it "redirects to the created source_picture" do
- post :create, :source_picture => valid_attributes
- response.should redirect_to(SourcePicture.last)
- end
- end
-
- describe "with invalid params" do
- it "assigns a newly created but unsaved source_picture as @source_picture" do
- # Trigger the behavior that occurs when invalid params are submitted
- SourcePicture.any_instance.stub(:save).and_return(false)
- post :create, :source_picture => {}
- assigns(:source_picture).should be_a_new(SourcePicture)
- end
-
- it "re-renders the 'new' template" do
- # Trigger the behavior that occurs when invalid params are submitted
- SourcePicture.any_instance.stub(:save).and_return(false)
- post :create, :source_picture => {}
- response.should render_template("new")
- end
- end
- end
-
- describe "PUT update" do
- describe "with valid params" do
- it "updates the requested source_picture" do
- source_picture = SourcePicture.create! valid_attributes
- # Assuming there are no other source_pictures in the database, this
- # specifies that the SourcePicture created on the previous line
- # receives the :update_attributes message with whatever params are
- # submitted in the request.
- SourcePicture.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, :id => source_picture.id, :source_picture => {'these' => 'params'}
- end
-
- it "assigns the requested source_picture as @source_picture" do
- source_picture = SourcePicture.create! valid_attributes
- put :update, :id => source_picture.id, :source_picture => valid_attributes
- assigns(:source_picture).should eq(source_picture)
- end
-
- it "redirects to the source_picture" do
- source_picture = SourcePicture.create! valid_attributes
- put :update, :id => source_picture.id, :source_picture => valid_attributes
- response.should redirect_to(source_picture)
- end
- end
-
- describe "with invalid params" do
- it "assigns the source_picture as @source_picture" do
- source_picture = SourcePicture.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- SourcePicture.any_instance.stub(:save).and_return(false)
- put :update, :id => source_picture.id, :source_picture => {}
- assigns(:source_picture).should eq(source_picture)
- end
-
- it "re-renders the 'edit' template" do
- source_picture = SourcePicture.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- SourcePicture.any_instance.stub(:save).and_return(false)
- put :update, :id => source_picture.id, :source_picture => {}
- response.should render_template("edit")
- end
- end
- end
-
- describe "DELETE destroy" do
- it "destroys the requested source_picture" do
- source_picture = SourcePicture.create! valid_attributes
- expect {
- delete :destroy, :id => source_picture.id
- }.to change(SourcePicture, :count).by(-1)
- end
-
- it "redirects to the source_pictures list" do
- source_picture = SourcePicture.create! valid_attributes
- delete :destroy, :id => source_picture.id
- response.should redirect_to(source_pictures_url)
- end
- end
-
-end
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
-describe SpeachBaloonsController do
+describe SpeachBalloonsController do
# This should return the minimal set of attributes required to create a valid
# SpeachBaloon. As you add validations to SpeachBaloon, be sure to
+++ /dev/null
-require 'spec_helper'
-
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator. If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails. There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec. Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
-
-describe SpeachbaloonsController do
-
- # This should return the minimal set of attributes required to create a valid
- # Speachbaloon. As you add validations to Speachbaloon, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- {}
- end
-
- describe "GET index" do
- it "assigns all speachbaloons as @speachbaloons" do
- speachbaloon = Speachbaloon.create! valid_attributes
- get :index
- assigns(:speachbaloons).should eq([speachbaloon])
- end
- end
-
- describe "GET show" do
- it "assigns the requested speachbaloon as @speachbaloon" do
- speachbaloon = Speachbaloon.create! valid_attributes
- get :show, :id => speachbaloon.id
- assigns(:speachbaloon).should eq(speachbaloon)
- end
- end
-
- describe "GET new" do
- it "assigns a new speachbaloon as @speachbaloon" do
- get :new
- assigns(:speachbaloon).should be_a_new(Speachbaloon)
- end
- end
-
- describe "GET edit" do
- it "assigns the requested speachbaloon as @speachbaloon" do
- speachbaloon = Speachbaloon.create! valid_attributes
- get :edit, :id => speachbaloon.id
- assigns(:speachbaloon).should eq(speachbaloon)
- end
- end
-
- describe "POST create" do
- describe "with valid params" do
- it "creates a new Speachbaloon" do
- expect {
- post :create, :speachbaloon => valid_attributes
- }.to change(Speachbaloon, :count).by(1)
- end
-
- it "assigns a newly created speachbaloon as @speachbaloon" do
- post :create, :speachbaloon => valid_attributes
- assigns(:speachbaloon).should be_a(Speachbaloon)
- assigns(:speachbaloon).should be_persisted
- end
-
- it "redirects to the created speachbaloon" do
- post :create, :speachbaloon => valid_attributes
- response.should redirect_to(Speachbaloon.last)
- end
- end
-
- describe "with invalid params" do
- it "assigns a newly created but unsaved speachbaloon as @speachbaloon" do
- # Trigger the behavior that occurs when invalid params are submitted
- Speachbaloon.any_instance.stub(:save).and_return(false)
- post :create, :speachbaloon => {}
- assigns(:speachbaloon).should be_a_new(Speachbaloon)
- end
-
- it "re-renders the 'new' template" do
- # Trigger the behavior that occurs when invalid params are submitted
- Speachbaloon.any_instance.stub(:save).and_return(false)
- post :create, :speachbaloon => {}
- response.should render_template("new")
- end
- end
- end
-
- describe "PUT update" do
- describe "with valid params" do
- it "updates the requested speachbaloon" do
- speachbaloon = Speachbaloon.create! valid_attributes
- # Assuming there are no other speachbaloons in the database, this
- # specifies that the Speachbaloon created on the previous line
- # receives the :update_attributes message with whatever params are
- # submitted in the request.
- Speachbaloon.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, :id => speachbaloon.id, :speachbaloon => {'these' => 'params'}
- end
-
- it "assigns the requested speachbaloon as @speachbaloon" do
- speachbaloon = Speachbaloon.create! valid_attributes
- put :update, :id => speachbaloon.id, :speachbaloon => valid_attributes
- assigns(:speachbaloon).should eq(speachbaloon)
- end
-
- it "redirects to the speachbaloon" do
- speachbaloon = Speachbaloon.create! valid_attributes
- put :update, :id => speachbaloon.id, :speachbaloon => valid_attributes
- response.should redirect_to(speachbaloon)
- end
- end
-
- describe "with invalid params" do
- it "assigns the speachbaloon as @speachbaloon" do
- speachbaloon = Speachbaloon.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- Speachbaloon.any_instance.stub(:save).and_return(false)
- put :update, :id => speachbaloon.id, :speachbaloon => {}
- assigns(:speachbaloon).should eq(speachbaloon)
- end
-
- it "re-renders the 'edit' template" do
- speachbaloon = Speachbaloon.create! valid_attributes
- # Trigger the behavior that occurs when invalid params are submitted
- Speachbaloon.any_instance.stub(:save).and_return(false)
- put :update, :id => speachbaloon.id, :speachbaloon => {}
- response.should render_template("edit")
- end
- end
- end
-
- describe "DELETE destroy" do
- it "destroys the requested speachbaloon" do
- speachbaloon = Speachbaloon.create! valid_attributes
- expect {
- delete :destroy, :id => speachbaloon.id
- }.to change(Speachbaloon, :count).by(-1)
- end
-
- it "redirects to the speachbaloons list" do
- speachbaloon = Speachbaloon.create! valid_attributes
- delete :destroy, :id => speachbaloon.id
- response.should redirect_to(speachbaloons_url)
- end
- end
-
-end
# user.author Factory(:author_yas)
end
+Factory.define :author, :class => Author do |author|
+ author.name nil
+ author.sequence(:user_id) { |n| n}
+end
+
Factory.define :author_yas, :class => Author do |author|
author.name 'yassan'
author.sequence(:user_id) { |n| n}
# author.artist Factory(:artist_yas)
end
+Factory.define :artist, :class => Artist do |artist|
+ artist.sequence(:email) { |n| "hoge#{n}@gmail.com"}
+ artist.name nil
+# artist.association :author_yas
+end
+
Factory.define :artist_yas, :class => Artist do |artist|
artist.sequence(:email) { |n| "hoge#{n}@gmail.com"}
artist.name 'yas'
# end
# end
# end
-describe Admins::SessionsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
+++ /dev/null
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the AuthorRegistrationsHelper. For example:
-#
-# describe AuthorRegistrationsHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe AuthorRegistrationsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
# end
# end
# end
-describe Authors::SessionsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
# end
# end
# end
-describe BaloonTemplatesHelper do
+describe BalloonTemplatesHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
# end
# end
# end
-describe BaloonsHelper do
+describe BalloonsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
+++ /dev/null
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the BaloonTypesHelper. For example:
-#
-# describe BaloonTypesHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe BaloonTypesHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
# end
# end
# end
-describe PicturesHelper do
+describe PanelPicturesHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
# end
# end
# end
-describe SourcePicturesHelper do
+describe ResourcePicturesHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
# end
# end
# end
-describe SpeachBaloonsHelper do
+describe SpeachBalloonsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
+++ /dev/null
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the SpeachbaloonsHelper. For example:
-#
-# describe SpeachbaloonsHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe SpeachbaloonsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
+# -*- encoding: utf-8 -*-
+#
require 'spec_helper'
describe Artist do
- pending "add some examples to (or delete) #{__FILE__}"
+ before do
+ Factory :admin
+ @user = Factory( :user_yas)
+ @author = @user.author
+ end
+
+ describe '自動補充に於いて' do
+ it '名前がno nameになっている' do
+ @artist = Factory :artist
+ @artist.name.should eq 'no name'
+ end
+ end
+
end
+# -*- encoding: utf-8 -*-
+#作家
require 'spec_helper'
describe Author do
- pending "add some examples to (or delete) #{__FILE__}"
+ before do
+ Factory :admin
+ @user = Factory( :user_yas)
+ @author = @user.author
+ end
+
+ describe '自動補充に於いて' do
+ #作家はユーザ作成で自動作成されちゃってる
+ it '名前がno nameになっている' do
+ @author.name.should eq 'no name'
+ end
+ end
+
+ describe '絵師作家判定に於いて' do
+ before do
+ end
+ context 'Trueのケース' do
+ it 'リンクされた絵師がある' do
+ artist = Factory :artist, :author_id => @author.id
+ @author.artist?.should eq true
+ end
+ end
+ context 'Falseのケース' do
+ it 'リンクされた絵師がない' do
+ @author.artist?.should eq false
+ end
+ end
+ end
+
end
require 'spec_helper'
-describe Baloon do
+describe Balloon do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
-describe BaloonTemplate do
+describe BalloonTemplate do
pending "add some examples to (or delete) #{__FILE__}"
end
+++ /dev/null
-require 'spec_helper'
-
-describe BaloonType do
- pending "add some examples to (or delete) #{__FILE__}"
-end
+++ /dev/null
-require 'spec_helper'
-
-describe Picture do
- pending "add some examples to (or delete) #{__FILE__}"
-end
require 'spec_helper'
-describe SpeachBaloon do
+describe SpeachBalloon do
pending "add some examples to (or delete) #{__FILE__}"
end
+++ /dev/null
-require 'spec_helper'
-
-describe Speachbaloon do
- pending "add some examples to (or delete) #{__FILE__}"
-end
+# -*- encoding: utf-8 -*-
+#ユーザアカウント
require 'spec_helper'
describe User do
- pending "add some examples to (or delete) #{__FILE__}"
+ before do
+ Factory :admin
+ end
+
+ describe '作成に於いて' do
+ context '作家の自動作成' do
+ it '作家が作成されている' do
+ lambda {
+ @user = Factory( :user_yas)
+ }.should change(Author, :count)
+ end
+ it '作家とユーザがリンクされている' do
+ @user = Factory( :user_yas)
+ Author.find_by_user_id(@user.id).should_not eq nil
+ end
+ end
+ end
+
+ describe 'トークン作成に於いて' do
+ before do
+ @user = Factory( :user_yas)
+ end
+ it 'トークンが変更されている' do
+ lambda {
+ @user.create_token
+ }.should change(@user, :authentication_token)
+ end
+ it 'トークンが作成されている' do
+ @user.create_token
+ @user.authentication_token.should_not be_empty
+ end
+ end
+
+ describe 'トークン削除に於いて' do
+ before do
+ @user = Factory( :user_yas)
+ @user.create_token
+ end
+ it 'トークンが変更されている' do
+ lambda {
+ @user.delete_token
+ }.should change(@user, :authentication_token)
+ end
+ it 'トークンが削除されている' do
+ @user.delete_token
+ @user.authentication_token.should be_blank
+ end
+ end
end
describe "GET /baloon_templates" do
it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get baloon_templates_path
+ get balloon_templates_path
response.status.should be(200)
end
end
+++ /dev/null
-require 'spec_helper'
-
-describe "Pictures" do
- describe "GET /pictures" do
- it "works! (now write some real specs)" do
- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get pictures_path
- response.status.should be(200)
- end
- end
-end
require 'spec_helper'
-describe "BaloonTypes" do
- describe "GET /baloon_types" do
+describe "ResourcePictures" do
+ describe "GET /resource_pictures" do
it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get baloon_types_path
+ get resource_pictures_path
response.status.should be(200)
end
end
require 'spec_helper'
-describe "SourcePictures" do
- describe "GET /source_pictures" do
+describe "SpeachBalloons" do
+ describe "GET /speach_balloons" do
it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get source_pictures_path
+ get speach_balloons_path
response.status.should be(200)
end
end
+++ /dev/null
-require 'spec_helper'
-
-describe "SpeachBaloons" do
- describe "GET /speach_baloons" do
- it "works! (now write some real specs)" do
- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get speach_baloons_path
- response.status.should be(200)
- end
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "Speachbaloons" do
- describe "GET /speachbaloons" do
- it "works! (now write some real specs)" do
- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get speachbaloons_path
- response.status.should be(200)
- end
- end
-end
--- /dev/null
+require "spec_helper"
+
+describe BalloonTemplatesController do
+ describe "routing" do
+
+ it "routes to #index" do
+ get("/balloon_templates").should route_to("balloon_templates#index")
+ end
+
+ it "routes to #new" do
+ get("/balloon_templates/new").should route_to("balloon_templates#new")
+ end
+
+ it "routes to #show" do
+ get("/balloon_templates/1").should route_to("balloon_templates#show", :id => "1")
+ end
+
+ it "routes to #edit" do
+ get("/balloon_templates/1/edit").should route_to("balloon_templates#edit", :id => "1")
+ end
+
+ it "routes to #create" do
+ post("/balloon_templates").should route_to("balloon_templates#create")
+ end
+
+ it "routes to #update" do
+ put("/balloon_templates/1").should route_to("balloon_templates#update", :id => "1")
+ end
+
+ it "routes to #destroy" do
+ delete("/balloon_templates/1").should route_to("balloon_templates#destroy", :id => "1")
+ end
+
+ end
+end
--- /dev/null
+require "spec_helper"
+
+describe BalloonsController do
+ describe "routing" do
+
+ it "routes to #index" do
+ get("/balloons").should route_to("balloons#index")
+ end
+
+ it "routes to #new" do
+ get("/balloons/new").should route_to("balloons#new")
+ end
+
+ it "routes to #show" do
+ get("/balloons/1").should route_to("balloons#show", :id => "1")
+ end
+
+ it "routes to #edit" do
+ get("/balloons/1/edit").should route_to("balloons#edit", :id => "1")
+ end
+
+ it "routes to #create" do
+ post("/balloons").should route_to("balloons#create")
+ end
+
+ it "routes to #update" do
+ put("/balloons/1").should route_to("balloons#update", :id => "1")
+ end
+
+ it "routes to #destroy" do
+ delete("/balloons/1").should route_to("balloons#destroy", :id => "1")
+ end
+
+ end
+end
+++ /dev/null
-require "spec_helper"
-
-describe BaloonTemplatesController do
- describe "routing" do
-
- it "routes to #index" do
- get("/baloon_templates").should route_to("baloon_templates#index")
- end
-
- it "routes to #new" do
- get("/baloon_templates/new").should route_to("baloon_templates#new")
- end
-
- it "routes to #show" do
- get("/baloon_templates/1").should route_to("baloon_templates#show", :id => "1")
- end
-
- it "routes to #edit" do
- get("/baloon_templates/1/edit").should route_to("baloon_templates#edit", :id => "1")
- end
-
- it "routes to #create" do
- post("/baloon_templates").should route_to("baloon_templates#create")
- end
-
- it "routes to #update" do
- put("/baloon_templates/1").should route_to("baloon_templates#update", :id => "1")
- end
-
- it "routes to #destroy" do
- delete("/baloon_templates/1").should route_to("baloon_templates#destroy", :id => "1")
- end
-
- end
-end
+++ /dev/null
-require "spec_helper"
-
-describe BaloonTypesController do
- describe "routing" do
-
- it "routes to #index" do
- get("/baloon_types").should route_to("baloon_types#index")
- end
-
- it "routes to #new" do
- get("/baloon_types/new").should route_to("baloon_types#new")
- end
-
- it "routes to #show" do
- get("/baloon_types/1").should route_to("baloon_types#show", :id => "1")
- end
-
- it "routes to #edit" do
- get("/baloon_types/1/edit").should route_to("baloon_types#edit", :id => "1")
- end
-
- it "routes to #create" do
- post("/baloon_types").should route_to("baloon_types#create")
- end
-
- it "routes to #update" do
- put("/baloon_types/1").should route_to("baloon_types#update", :id => "1")
- end
-
- it "routes to #destroy" do
- delete("/baloon_types/1").should route_to("baloon_types#destroy", :id => "1")
- end
-
- end
-end
+++ /dev/null
-require "spec_helper"
-
-describe BaloonsController do
- describe "routing" do
-
- it "routes to #index" do
- get("/baloons").should route_to("baloons#index")
- end
-
- it "routes to #new" do
- get("/baloons/new").should route_to("baloons#new")
- end
-
- it "routes to #show" do
- get("/baloons/1").should route_to("baloons#show", :id => "1")
- end
-
- it "routes to #edit" do
- get("/baloons/1/edit").should route_to("baloons#edit", :id => "1")
- end
-
- it "routes to #create" do
- post("/baloons").should route_to("baloons#create")
- end
-
- it "routes to #update" do
- put("/baloons/1").should route_to("baloons#update", :id => "1")
- end
-
- it "routes to #destroy" do
- delete("/baloons/1").should route_to("baloons#destroy", :id => "1")
- end
-
- end
-end
+++ /dev/null
-require "spec_helper"
-
-describe PicturesController do
- describe "routing" do
-
- it "routes to #index" do
- get("/pictures").should route_to("pictures#index")
- end
-
- it "routes to #new" do
- get("/pictures/new").should route_to("pictures#new")
- end
-
- it "routes to #show" do
- get("/pictures/1").should route_to("pictures#show", :id => "1")
- end
-
- it "routes to #edit" do
- get("/pictures/1/edit").should route_to("pictures#edit", :id => "1")
- end
-
- it "routes to #create" do
- post("/pictures").should route_to("pictures#create")
- end
-
- it "routes to #update" do
- put("/pictures/1").should route_to("pictures#update", :id => "1")
- end
-
- it "routes to #destroy" do
- delete("/pictures/1").should route_to("pictures#destroy", :id => "1")
- end
-
- end
-end
--- /dev/null
+require "spec_helper"
+
+describe ResourcePicturesController do
+ describe "routing" do
+
+ it "routes to #index" do
+ get("/resource_pictures").should route_to("resource_pictures#index")
+ end
+
+ it "routes to #new" do
+ get("/resource_pictures/new").should route_to("resource_pictures#new")
+ end
+
+ it "routes to #show" do
+ get("/resource_pictures/1").should route_to("resource_pictures#show", :id => "1")
+ end
+
+ it "routes to #edit" do
+ get("/resource_pictures/1/edit").should route_to("resource_pictures#edit", :id => "1")
+ end
+
+ it "routes to #create" do
+ post("/resource_pictures").should route_to("resource_pictures#create")
+ end
+
+ it "routes to #update" do
+ put("/resource_pictures/1").should route_to("resource_pictures#update", :id => "1")
+ end
+
+ it "routes to #destroy" do
+ delete("/resource_pictures/1").should route_to("resource_pictures#destroy", :id => "1")
+ end
+
+ end
+end
+++ /dev/null
-require "spec_helper"
-
-describe SourcePicturesController do
- describe "routing" do
-
- it "routes to #index" do
- get("/source_pictures").should route_to("source_pictures#index")
- end
-
- it "routes to #new" do
- get("/source_pictures/new").should route_to("source_pictures#new")
- end
-
- it "routes to #show" do
- get("/source_pictures/1").should route_to("source_pictures#show", :id => "1")
- end
-
- it "routes to #edit" do
- get("/source_pictures/1/edit").should route_to("source_pictures#edit", :id => "1")
- end
-
- it "routes to #create" do
- post("/source_pictures").should route_to("source_pictures#create")
- end
-
- it "routes to #update" do
- put("/source_pictures/1").should route_to("source_pictures#update", :id => "1")
- end
-
- it "routes to #destroy" do
- delete("/source_pictures/1").should route_to("source_pictures#destroy", :id => "1")
- end
-
- end
-end
require "spec_helper"
-describe SpeachBaloonsController do
+describe SpeachBalloonsController do
describe "routing" do
it "routes to #index" do
- get("/speach_baloons").should route_to("speach_baloons#index")
+ get("/speach_balloons").should route_to("speach_balloons#index")
end
it "routes to #new" do
- get("/speach_baloons/new").should route_to("speach_baloons#new")
+ get("/speach_balloons/new").should route_to("speach_balloons#new")
end
it "routes to #show" do
- get("/speach_baloons/1").should route_to("speach_baloons#show", :id => "1")
+ get("/speach_balloons/1").should route_to("speach_balloons#show", :id => "1")
end
it "routes to #edit" do
- get("/speach_baloons/1/edit").should route_to("speach_baloons#edit", :id => "1")
+ get("/speach_balloons/1/edit").should route_to("speach_balloons#edit", :id => "1")
end
it "routes to #create" do
- post("/speach_baloons").should route_to("speach_baloons#create")
+ post("/speach_balloons").should route_to("speach_balloons#create")
end
it "routes to #update" do
- put("/speach_baloons/1").should route_to("speach_baloons#update", :id => "1")
+ put("/speach_balloons/1").should route_to("speach_balloons#update", :id => "1")
end
it "routes to #destroy" do
- delete("/speach_baloons/1").should route_to("speach_baloons#destroy", :id => "1")
+ delete("/speach_balloons/1").should route_to("speach_balloons#destroy", :id => "1")
end
end
+++ /dev/null
-require "spec_helper"
-
-describe SpeachbaloonsController do
- describe "routing" do
-
- it "routes to #index" do
- get("/speachbaloons").should route_to("speachbaloons#index")
- end
-
- it "routes to #new" do
- get("/speachbaloons/new").should route_to("speachbaloons#new")
- end
-
- it "routes to #show" do
- get("/speachbaloons/1").should route_to("speachbaloons#show", :id => "1")
- end
-
- it "routes to #edit" do
- get("/speachbaloons/1/edit").should route_to("speachbaloons#edit", :id => "1")
- end
-
- it "routes to #create" do
- post("/speachbaloons").should route_to("speachbaloons#create")
- end
-
- it "routes to #update" do
- put("/speachbaloons/1").should route_to("speachbaloons#update", :id => "1")
- end
-
- it "routes to #destroy" do
- delete("/speachbaloons/1").should route_to("speachbaloons#destroy", :id => "1")
- end
-
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "baloon_types/edit.html.erb" do
- before(:each) do
- @baloon_type = assign(:baloon_type, stub_model(BaloonType))
- end
-
- it "renders the edit baloon_type form" do
- render
-
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => baloon_types_path(@baloon_type), :method => "post" do
- end
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "baloon_types/index.html.erb" do
- before(:each) do
- assign(:baloon_types, [
- stub_model(BaloonType),
- stub_model(BaloonType)
- ])
- end
-
- it "renders a list of baloon_types" do
- render
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "baloon_types/new.html.erb" do
- before(:each) do
- assign(:baloon_type, stub_model(BaloonType).as_new_record)
- end
-
- it "renders new baloon_type form" do
- render
-
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => baloon_types_path, :method => "post" do
- end
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "baloon_types/show.html.erb" do
- before(:each) do
- @baloon_type = assign(:baloon_type, stub_model(BaloonType))
- end
-
- it "renders attributes in <p>" do
- render
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "pictures/edit.html.erb" do
- before(:each) do
- @picture = assign(:picture, stub_model(Picture))
- end
-
- it "renders the edit picture form" do
- render
-
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => pictures_path(@picture), :method => "post" do
- end
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "pictures/index.html.erb" do
- before(:each) do
- assign(:pictures, [
- stub_model(Picture),
- stub_model(Picture)
- ])
- end
-
- it "renders a list of pictures" do
- render
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "pictures/new.html.erb" do
- before(:each) do
- assign(:picture, stub_model(Picture).as_new_record)
- end
-
- it "renders new picture form" do
- render
-
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => pictures_path, :method => "post" do
- end
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "pictures/show.html.erb" do
- before(:each) do
- @picture = assign(:picture, stub_model(Picture))
- end
-
- it "renders attributes in <p>" do
- render
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "speachbaloons/edit.html.erb" do
- before(:each) do
- @speachbaloon = assign(:speachbaloon, stub_model(Speachbaloon))
- end
-
- it "renders the edit speachbaloon form" do
- render
-
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => speachbaloons_path(@speachbaloon), :method => "post" do
- end
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "speachbaloons/index.html.erb" do
- before(:each) do
- assign(:speachbaloons, [
- stub_model(Speachbaloon),
- stub_model(Speachbaloon)
- ])
- end
-
- it "renders a list of speachbaloons" do
- render
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "speachbaloons/new.html.erb" do
- before(:each) do
- assign(:speachbaloon, stub_model(Speachbaloon).as_new_record)
- end
-
- it "renders new speachbaloon form" do
- render
-
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => speachbaloons_path, :method => "post" do
- end
- end
-end
+++ /dev/null
-require 'spec_helper'
-
-describe "speachbaloons/show.html.erb" do
- before(:each) do
- @speachbaloon = assign(:speachbaloon, stub_model(Speachbaloon))
- end
-
- it "renders attributes in <p>" do
- render
- end
-end