--- /dev/null
+// Place all the styles related to the LicenseGroup controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
--- /dev/null
+// Place all the styles related to the ResourcePictureLicense controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
before_filter :bf
def bf
- if Admin.count.to_i == 0 or License.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'
--- /dev/null
+class LicenseGroupsController < ApplicationController
+ layout 'test' if Pettanr::TestLayout
+ before_filter :authenticate_admin!, :only => [:list, :browse]
+
+ # GET /license_groups
+ # GET /license_groups.json
+ def index
+ @license_groups = LicenseGroup.list({})
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @license_groups.to_json(LicenseGroup.list_json_opt) }
+ end
+ end
+
+ # GET /license_groups/1
+ # GET /license_groups/1.json
+ def show
+ @license_group = LicenseGroup.show(params[:id])
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @license_group.to_json(LicenseGroup.show_json_include_opt) }
+ end
+ end
+
+ def list
+ @license_groups = LicenseGroup.all
+
+ respond_to do |format|
+ format.html { render layout: 'system' }
+ end
+ end
+
+ def browse
+ @license_group = LicenseGroup.find(params[:id])
+
+ respond_to do |format|
+ format.html { render layout: 'system' }
+ end
+ end
+end
class LicensesController < ApplicationController
+ layout 'test' if Pettanr::TestLayout
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /licenses
# GET /licenses.json
def index
- @page = License.page params[:page]
- @page_size = License.page_size params[:page_size]
- @licenses = License.list({}, @page, @page_size)
+ @licenses = License.list({})
respond_to do |format|
format.html # index.html.erb
--- /dev/null
+class ResourcePictureLicenseController < ApplicationController
+end
--- /dev/null
+module LicenseGroupsHelper
+end
--- /dev/null
+module ResourcePictureLicenseHelper
+end
+#
class License < ActiveRecord::Base
- has_one :original_license
- has_one :common_license
+ belongs_to :license_group
+ belongs_to :system_picture
+
+ validates :license_group_id, :presence => true, :numericality => true, :existence => true
validates :name, :presence => true, :length => {:maximum => 50}
- validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => {:allow_blank => true}
+ validates :caption, :presence => true, :length => {:maximum => 30}
+ validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => true #{:allow_blank => true}
+ validates :system_picture_id, :presence => true, :numericality => true, :existence => true
- def self.update_license cl
- l = License.find_by_url cl.url
- l = License.new unless l
- l.attributes = {
- :name => cl.name, :url => cl.url, :cc_by => cl.cc_by, :cc_sa => cl.cc_sa, :cc_nd => cl.cc_nd, :cc_nc => cl.cc_nc,
- :no_resize => cl.no_resize, :no_flip => cl.no_flip, :no_convert => cl.no_convert, :keep_aspect_ratio => cl.keep_aspect_ratio
- }
- if cl.new_record? and l.new_record? == false
- l.errors.add :base, 'dupulicate url'
+ def self.store name, attr
+ r = License.replace_system_picture attr
+ l = License.modify_object name, attr
+ if r == false
+ l.errors.add :base, 'system picture can not create'
+ else
+ l.save
end
l
end
- def self.default_page_size
- 25
- end
-
- def self.max_page_size
- 100
- end
-
- def self.page prm = nil
- page = prm.to_i
- page = 1 if page < 1
- page
- end
-
- def self.page_size prm = self.default_page_size
- page_size = prm.to_i
- page_size = self.max_page_size if page_size > self.max_page_size
- page_size = self.default_page_size if page_size < 1
- page_size
- end
-
- def self.offset cnt, prm = nil
- offset = prm.to_i
- offset = cnt - 1 if offset >= cnt
- offset = cnt - offset.abs if offset < 0
- offset = 0 if offset < 0
- offset
+ def self.stores attrs, lg_id
+ res = 0
+ return 0 unless attrs.is_a?(Hash)
+ attrs.each do |name, attr|
+ attr["license_group_id"] = lg_id
+ l = License.store name, attr
+ res += 1 unless l.valid?
+ end
+ res
end
- def self.list opt = {}, page = 1, page_size = self.default_page_size
+ def self.list opt = {}
opt.merge!(self.list_opt) unless opt[:include]
- opt.merge!({:order => 'name', :limit => page_size, :offset => (page -1) * page_size})
+ opt.merge!({:order => 'name'})
License.find(:all, opt)
end
def self.list_opt
- {:include => {:common_license => {}, :original_license => {}}}
+ {:include => {:license_group => {}}}
end
def self.list_json_opt
- {:include => {:common_license => {}, :original_license => {}}}
+ {:include => {:license_group => {}}}
end
def self.show rid, opt = {}
end
def self.show_include_opt opt = {}
- res = [:common_license, :original_license]
+ res = [:license_group]
res.push(opt[:include]) if opt[:include]
res
end
def self.show_json_include_opt
- {:include => {:common_license => {}, :original_license => {}}}
+ {:include => {:license_group => {}}}
end
end
--- /dev/null
+#ライセンスグループ
+class LicenseGroup < ActiveRecord::Base
+ has_many :licenses
+
+ validates :name, :presence => true, :length => {:maximum => 50}, :uniqueness => true
+ validates :classname, :presence => true, :length => {:maximum => 50}
+ validates :caption, :presence => true, :length => {:maximum => 30}
+ validates :url, :presence => true, :length => {:maximum => 200}, :url => true
+
+ def self.store name, attr
+ #ライセンスデータがあるとライセンスグループのデータ生成で邪魔するので移しておく
+ lattr = attr["licenses_attributes"]
+ attr.delete "licenses_attributes"
+ #ライセンスグループを先に保存してidを決める
+ r = LicenseGroup.modify_object name, attr
+ r.save
+ #取っておいたライセンスデータとidでライセンス作成
+ if (c = License.stores(lattr, r.id)) > 0
+ r.errors.add :base, 'licenses can not create'
+ end
+ r
+ end
+
+ def self.import filename
+ LicenseGroup.import_file(filename) {|name, attr| LicenseGroup.store(name, attr)}
+ end
+
+ def self.list opt = {}
+ opt.merge!(self.list_opt) unless opt[:include]
+ opt.merge!({:order => 'license_groups.name asc'})
+ LicenseGroup.find(:all, opt)
+ end
+
+ def self.list_opt
+ {:include => {:licenses => {}}}
+ end
+
+ def self.list_json_opt
+ {:include => {:licenses => {}}}
+ end
+
+ def self.show rid, opt = {}
+ r = LicenseGroup.find(rid, :include => self.show_include_opt(opt))
+# raise ActiveRecord::Forbidden unless c.visible?(au)
+ r
+ end
+
+ def self.show_include_opt opt = {}
+ res = {:licenses => {}}
+ res.push(opt[:include]) if opt[:include]
+ res
+ end
+
+ def self.show_json_include_opt
+ {:include => {:licenses => {}}}
+ end
+
+end
--- /dev/null
+class ResourcePictureLicense < ActiveRecord::Base
+end
class SystemPicture < ActiveRecord::Base
has_many :balloons
has_many :balloon_templates
+ has_many :licenses
validates :ext, :presence => true, :length => {:maximum => 4}, :inclusion => {:in => ['png', 'jpeg', 'gif']}
validates :width, :presence => true, :numericality => true, :natural_number => true
--- /dev/null
+<div>
+<p>
+<div>id</div>
+<%= @license_group.id %>
+</p>
+<p>
+<%= h @license_group.name %>
+</p>
+<p>
+<div>name</div>
+<%= h @license_group.name %>
+</p>
+<p>
+<div>classname</div>
+<%= h @license_group.classname %>
+</p>
+<p>
+<div>caption</div>
+<%= h @license_group.caption %>
+</p>
+<p>
+<div>url</div>
+<%= h @license_group.url %>
+</p>
+<p>
+<%= @license_group.created_at %>
+</p>
+<p>
+<%= @license_group.updated_at %>
+</p>
+</div>
+<h1>Listing licenses</h1>
+
+<table>
+ <tr>
+ <th>id</th>
+ <th>license_group_id</th>
+ <th>name</th>
+ <th>caption</th>
+ <th>url</th>
+ <th>system_picture_id</th>
+ <th>settings</th>
+ <th>created_at</th>
+ <th>updated_at</th>
+ </tr>
+
+<% @license_group.licenses.each do |license| %>
+ <tr>
+ <td><%= link_to license.id, :action => :browse, :id => license.id %></td>
+ <td><%= link_to license.license_group_id, :controller => 'license_groups', :action => :browse, :id => license.license_group_id %></td>
+ <td><%= h license.name %></td>
+ <td><%= h license.caption %></td>
+ <td><%= h license.url %></td>
+ <td><%= link_to license.system_picture_id, :controller => 'system_pictures', :action => :browse, :id => license.system_picture_id %></td>
+ <td><%= h license.settings %></td>
+ <td><%= license.created_at %></td>
+ <td><%= license.updated_at %></td>
+ </tr>
+<% end -%>
+</table>
+
+<%= link_to 'Back', :action => :list %>
--- /dev/null
+<h1>Listing license Groups</h1>
+
+<table>
+ <tr>
+ <th>id</th>
+ <th>name</th>
+ <th>caption</th>
+ </tr>
+
+<% @license_groups.each do |lg| %>
+ <tr>
+ <td><%= link_to lg.id, license_group_path(lg) %></td>
+ <td><%= h lg.name %></td>
+ <td><%= content_tag(:a, h(lg.caption), :href => lg.url) %></td>
+ </tr>
+<% end -%>
+</table>
--- /dev/null
+<h1>Listing license Groups</h1>
+
+<table>
+ <tr>
+ <th>id</th>
+ <th>name</th>
+ <th>classname</th>
+ <th>caption</th>
+ <th>url</th>
+ <th>created_at</th>
+ <th>updated_at</th>
+ </tr>
+
+<% @license_groups.each do |lg| %>
+ <tr>
+ <td><%= link_to lg.id, :action => :browse, :id => lg.id %></td>
+ <td><%= h lg.name %></td>
+ <td><%= h lg.classname %></td>
+ <td><%= h lg.caption %></td>
+ <td><%= h lg.url %></td>
+ <td><%= lg.created_at %></td>
+ <td><%= lg.updated_at %></td>
+ </tr>
+<% end -%>
+</table>
--- /dev/null
+<p id="notice"><%= notice %></p>
+
+<p>
+<%= h @license_group.name %>
+</p>
+<p>
+<%= h @license_group.classname %>
+</p>
+<p>
+<%= h @license_group.caption %>
+</p>
+<p>
+<%= h @license_group.url %>
+</p>
+<p>
+<%= @license_group.created_at %>
+</p>
+<p>
+<%= @license_group.updated_at %>
+</p>
+
+<%= link_to 'Back', license_groups_path %>
+ <th>license_group_id</th>
+ <th>name</th>
+ <th>caption</th>
+ <th>url</th>
+ <th>system_picture_id</th>
+ <th>settings</th>
<div>
-<% if @license.common_license -%>
- <%= link_to 'to common_licenses', :controller => 'common_licenses', :action => :browse, :id => @license.common_license.id %>
-<% else -%>
- <%= link_to 'to original_licenses', :controller => 'original_licenses', :action => :browse, :id => @license.original_license.id %>
-<% end -%>
+<p>
+<div>id</div>
+<%= @license.id %>
+</p>
+<p>
+<div>license_group_id</div>
+<%= h @license.license_group_id %>
+</p>
+<p>
+<div>name</div>
+<%= h @license.name %>
+</p>
+<p>
+<div>caption</div>
+<%= h @license.caption %>
+</p>
+<p>
+<div>url</div>
+<%= h @license.url %>
+</p>
+<div>system_picture_id</div>
+<%= @license.system_picture_id %>
+</p>
+<div>settings</div>
+<%= h @license.settings %>
+</p>
+<p>
+<%= @license.created_at %>
+</p>
+<p>
+<%= @license.updated_at %>
+</p>
</div>
<%= link_to 'Back', :action => :list %>
<table>
<tr>
<th>name</th>
+ <th>caption</th>
<th>url</th>
- <th>cc_by</th>
- <th>cc_sa</th>
- <th>cc_nd</th>
- <th>cc_nc</th>
- <th>no_resize</th>
- <th>no_flip</th>
- <th>no_convert</th>
- <th>keep_aspect_ratio</th>
+ <th>created_at</th>
+ <th>updated_at</th>
<th></th>
</tr>
<% @licenses.each do |license| %>
<tr>
<td><%= h license.name %></td>
+ <td><%= h license.caption %></td>
<td><%= h license.url %></td>
- <td><%= license.cc_by %></td>
- <td><%= license.cc_sa %></td>
- <td><%= license.cc_nd %></td>
- <td><%= license.cc_nc %></td>
- <td><%= license.no_resize %></td>
- <td><%= license.no_flip %></td>
- <td><%= license.no_convert %></td>
- <td><%= license.keep_aspect_ratio %></td>
- <td>
- <% if license.common_license -%>
- <%= link_to 'Show', license.common_license %>
- <% else -%>
- <%= link_to 'Show', license.original_license %>
- <% end -%>
- </td>
+ <td><%= license.created_at %></td>
+ <td><%= license.updated_at %></td>
</tr>
<% end -%>
</table>
-<%= link_to 'new original license', new_original_license_path %>
<table>
<tr>
<th>id</th>
+ <th>license_group_id</th>
<th>name</th>
+ <th>caption</th>
<th>url</th>
- <th>cc_by</th>
- <th>cc_sa</th>
- <th>cc_nd</th>
- <th>cc_nc</th>
- <th>no_resize</th>
- <th>no_flip</th>
- <th>no_convert</th>
- <th>keep_aspect_ratio</th>
+ <th>system_picture_id</th>
+ <th>settings</th>
<th>created_at</th>
<th>updated_at</th>
- <th></th>
</tr>
<% @licenses.each do |license| %>
<tr>
<td><%= link_to license.id, :action => :browse, :id => license.id %></td>
+ <td><%= link_to license.license_group_id, :controller => 'license_groups', :action => :browse, :id => license.license_group_id %></td>
<td><%= h license.name %></td>
+ <td><%= h license.caption %></td>
<td><%= h license.url %></td>
- <td><%= license.cc_by %></td>
- <td><%= license.cc_sa %></td>
- <td><%= license.cc_nd %></td>
- <td><%= license.cc_nc %></td>
- <td><%= license.no_resize %></td>
- <td><%= license.no_flip %></td>
- <td><%= license.no_convert %></td>
- <td><%= license.keep_aspect_ratio %></td>
+ <td><%= link_to license.system_picture_id, :controller => 'system_pictures', :action => :browse, :id => license.system_picture_id %></td>
+ <td><%= h license.settings %></td>
<td><%= license.created_at %></td>
<td><%= license.updated_at %></td>
</tr>
</tr>
<tr>
<td>
- <%= link_to 'lesences', :controller => 'licenses', :action => :list %>
+ <%= link_to 'licenses', :controller => 'licenses', :action => :list %>
</td>
</tr>
<tr>
<td>
- <%= link_to 'common lesences', :controller => 'common_licenses', :action => :list %>
- </td>
- </tr>
- <tr>
- <td>
- <%= link_to 'original lesences', :controller => 'original_licenses', :action => :list %>
+ <%= link_to 'license_groups', :controller => 'license_groups', :action => :list %>
</td>
</tr>
<tr>
get :browse
end
end
+ resources :license_groups do
+ collection do
+ get :index
+ get :show
+ get :list
+ get :browse
+ end
+ end
resources :original_licenses do
collection do
get :index
--- /dev/null
+{\r
+ "PublicDomaina": {\r
+ "classname": "PublicDomain", \r
+ "caption": "Public Domain", \r
+ "url": "http://test.com/",\r
+ "licenses_attributes": {\r
+ "PublicDomain": {\r
+ "caption": "Public Domain", \r
+ "url": "http://test.com/",\r
+ "system_picture": "Data"\r
+ }\r
+ }\r
+ },\r
+ "Unknowna": {\r
+ "classname": "Unknown", \r
+ "caption": "Unknown owner", \r
+ "url": "http://test.uk/",\r
+ "licenses_attributes": {\r
+ "UnknownF1": {\r
+ "caption": "Unknown Flag1", \r
+ "url": "http://test.com/f1",\r
+ "system_picture": "Dataf1"\r
+ },\r
+ "UnknownF2": {\r
+ "caption": "Unknown Flag2", \r
+ "url": "http://test.com/f2",\r
+ "system_picture": "Dataf2"\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+class CreateLicenseGroups < ActiveRecord::Migration
+ def change
+ create_table :license_groups do |t|
+ t.string :name, :null => false, :limit => 50
+ t.string :classname, :null => false, :limit => 50
+ t.string :caption, :null => false, :limit => 30
+ t.string :url, :null => false
+
+ t.timestamps
+ end
+ end
+end
--- /dev/null
+class CreateResourcePictureLicenses < ActiveRecord::Migration
+ def change
+ create_table :resource_picture_licenses do |t|
+ t.integer :resource_picture_id, :null => false
+ t.integer :license_id, :null => false
+ t.string :artist_name, :null => false
+ t.string :credit
+ t.string :settings
+
+ t.timestamps
+ end
+ end
+end
--- /dev/null
+class ChangeLicense < ActiveRecord::Migration
+ def up
+ remove_index :licenses, :column => [:url]
+ drop_table :licenses
+ create_table :licenses do |t|
+ t.integer :license_group_id, :null => false, :default => 0
+ t.string :name, :null => false, :limit => 50, :default => 'Default'
+ t.string :caption, :null => false, :limit => 30, :default => 'no name'
+ t.integer :system_picture_id, :null => false, :default => 0
+ t.string :url, :null => false\r
+ t.string :settings
+ t.timestamps
+ end
+ add_index :licenses, [:name], :unique => true
+ add_index :licenses, [:url], :unique => true
+ end
+
+ def down
+ remove_index :licenses, :column => [:name]
+ remove_index :licenses, :column => [:url]
+ drop_table :licenses
+ create_table :licenses do |t|
+ t.string :name, :null => false\r
+ t.string :url, :null => false\r
+ t.integer :cc_by, :null => false, :default => 0\r
+ t.integer :cc_sa, :null => false, :default => 0\r
+ t.integer :cc_nd, :null => false, :default => 0\r
+ t.integer :cc_nc, :null => false, :default => 0\r
+ t.integer :no_resize, :null => false, :default => 0\r
+ t.integer :no_flip, :null => false, :default => 0\r
+ t.integer :no_convert, :null => false, :default => 0\r
+ t.integer :keep_aspect_ratio, :null => false, :default => 0\r
+
+ t.timestamps
+ end
+ add_index :licenses, [:url], :unique => true
+ end
+end
before do
#要請の必要がない=管理者登録済み かつ ライセンス登録済み
Factory :admin
- Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
it 'リクエスト通りのページを開く' do
get :index
#要請の必要がある=管理者がいない または ライセンスがない
context '管理者がいないとき' do
before do
- Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
context '本機能を開こうとしているなら' do
it '初期化要請ページに遷移する' do
describe ArtistsController do
before do
Factory :admin
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
describe AuthorsController do
before do
Factory :admin
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
describe ComicsController do
before do
Factory :admin
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory :user_yas\r
@author = @user.author #ユーザ作成時に連動して作成される
end
-# -*- encoding: utf-8 -*-
-#コモンライセンス
-require 'spec_helper'
-
-describe CommonLicensesController do
- before do
- @admin = Factory :admin
- @lc = Factory :license
- @cl = Factory :common_license, :license_id => @lc.id
- @user = Factory( :user_yas)
- @author = @user.author
- @artist = Factory :artist_yas, :author_id => @author.id
- end
-=begin
- describe '一覧表示に於いて' do
- before do
- sign_in @admin
- sign_in @user
- CommonLicense.stub(:list).and_return([@cl, @cl, @cl])
- 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 CommonLicense.default_page_size
- end
- it '最大を超えると@page_sizeにデフォルト最大値が入る' do
- get :index, :page_size => 1500
- assigns(:page_size).should eq CommonLicense.max_page_size
- end
- it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
- get :index, :page_size => 0
- assigns(:page_size).should eq CommonLicense.default_page_size
- end
- end
- context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :index
- response.should be_success
- end
- it 'コモンライセンスモデルに一覧を問い合わせている' do
- CommonLicense.should_receive(:list).exactly(1)
- get :index
- end
- it '@common_licensesにリストを取得している' do
- get :index
- assigns(:common_licenses).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?("url").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
- sign_out @admin
- end
- context 'html形式' do
- it 'ステータスコード200 OKを返す' do
- get :index
- response.should be_success
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
- get :index, :format => :json
- response.should be_success
- end
- end
- end
- end
-
- describe '単体表示に於いて' do
- before do
- sign_in @admin
- sign_in @user
- CommonLicense.stub(:show).and_return(@cl)
- end
- context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :show, :id => @cl.id
- response.should be_success
- end
- it 'コモンライセンスモデルに単体取得を問い合わせている' do
- CommonLicense.should_receive(:show).exactly(1)
- get :show
- end
- it '@common_licenseにアレを取得している' do
- get :show, :id => @cl.id
- assigns(:common_license).id.should eq(@cl.id)
- end
- context 'html形式' do
- it 'showテンプレートを描画する' do
- get :show, :id => @cl.id
- response.should render_template("show")
- end
- end
- context 'json形式' do
- it 'jsonデータを返す' do
- get :show, :id => @cl.id, :format => :json
- lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
- end
- it 'データがアレになっている' do
- get :show, :id => @cl.id, :format => :json
- json = JSON.parse response.body
- json["name"].should match(/peta/)
- end
- end
- end
- context '作家権限がないとき' do
- before do
- sign_out @user
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- get :show, :id => @cl.id
- response.status.should eq 302
- end
- it 'サインインページへ遷移する' do
- get :show, :id => @cl.id
- response.body.should redirect_to '/users/sign_in'
- end
- end
- context 'json形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- get :show, :id => @cl.id, :format => :json
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- get :show, :id => @cl.id, :format => :json
- response.message.should match(/Unauthorized/)
- end
- end
- end
- context '管理者権限がないとき' do
- before do
- sign_out @admin
- end
- context 'html形式' do
- it 'ステータスコード200 OKを返す' do
- get :show, :id => @cl.id
- response.should be_success
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
- get :show, :id => @cl.id, :format => :json
- response.should be_success
- end
- end
- end
- end
-=end
-
- describe 'インポートに於いて' do
- before do
- sign_in @admin
- sign_in @user
- #テストデータを用意してね
- @f = Rails.root + 'spec/json/common_license.json'
- @t = File.open(@f, 'r').read
- @j = JSON.parse @t
- @fs = Rails.root + 'spec/json/common_licenses.json'
- @ts = File.open(@fs, 'r').read
- @js = JSON.parse @ts
- @fes = Rails.root + 'spec/json/invalid_common_licenses.json'
- @tes = File.open(@fes, 'r').read
- @jes = JSON.parse @tes
- end
- context '事前チェックしておく' do
- before do
- #異常な行を返すから、正常の意味で空を返す
- CommonLicense.stub(:import).with(any_args()).and_return([])
- end
- it "@dataに渡したデータを保持している" do
- post :import, :file => @t
- assigns(:data).should_not be_nil
- end
- it 'モデルにインポート依頼する' do
- CommonLicense.should_receive(:import).with(any_args()).exactly(1)
- post :import, :file => @t
- end
- it "@errorsに結果を保持している" do
- post :import, :file => @t
- assigns(:errors).should eq []
- end
- end
- context 'つつがなく終わるとき' do
- before do
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :import, :file => @t
- response.status.should eq 302
- end
- it '管理者向けコモンライセンス一覧ページへ遷移する' do
- post :import, :file => @t
- response.should redirect_to('/common_licenses/list')
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
- post :import, :file => @t, :format => :json
- response.should be_success
- end
- end
- end
- context '管理者権限がないとき' do
- before do
- sign_out @admin
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :import, :file => @t
- response.status.should eq 302
- end
- it '管理者サインインページへ遷移する' do
- post :import, :file => @t
- response.body.should redirect_to '/admins/sign_in'
- end
- end
- context 'json形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- post :import, :file => @t, :format => :json
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- post :import, :file => @t, :format => :json
- response.message.should match(/Unauthorized/)
- end
- end
- end
- context '作家権限がないとき' do
- #必要なのは管理者権限であって作家権限ではない。成功を見届ける
- before do
- sign_out @user
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :import, :file => @t
- response.status.should eq 302
- end
- it '管理者向けコモンライセンス一覧ページへ遷移する' do
- post :import, :file => @t
- response.should redirect_to('/common_licenses/list')
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
- post :import, :file => @t, :format => :json
- response.should be_success
- end
- end
- end
- context '検証、保存に失敗した' do
- before do
- #異常な行を返す
- CommonLicense.stub(:import).with(any_args()).and_return(
- [CommonLicense.new(Factory.attributes_for(:common_license))]
- )
- end
- context 'html形式' do
- it 'ステータスコード200 OKを返す' do
- post :import, :file => @t
- response.status.should eq 200
- end
- it 'resultページを描画する' do
- post :import, :file => @t
- response.should render_template("result")
- end
- end
- context 'json形式' do
- it 'ステータスコード422 unprocessable_entity を返す' do
- post :import, :file => @t, :format => :json
- response.status.should eq 422
- end
- it '応答メッセージUnprocessable Entityを返す' do
- post :import, :file => @t, :format => :json
- response.message.should match(/Unprocessable/)
- end
- end
- end
- end
-end
--- /dev/null
+# -*- encoding: utf-8 -*-
+#ライセンスグループ
+require 'spec_helper'
+
+describe LicenseGroupsController do
+ before do
+ @admin = Factory :admin
+ @user = Factory( :user_yas)
+ @lg = Factory :license_group, :name => 'peta'
+ end
+
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ LicenseGroup.stub(:list).and_return([@lg, @lg, @lg])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'ライセンスモデルに一覧を問い合わせている' do
+ LicenseGroup.should_receive(:list).exactly(1)
+ get :index
+ end
+ it '@license_groupsにリストを取得している' do
+ get :index
+ assigns(:license_groups).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
+ json.first.has_key?("classname").should be_true
+ json.first.has_key?("caption").should be_true
+ json.first.has_key?("url").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :index
+ response.status.should eq 200
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ LicenseGroup.stub(:show).and_return(@lg)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @lg.id
+ response.should be_success
+ end
+ it 'ライセンスモデルに単体取得を問い合わせている' do
+ LicenseGroup.should_receive(:show).exactly(1)
+ get :show
+ end
+ it '@license_groupにアレを取得している' do
+ get :show, :id => @lg.id
+ assigns(:license_group).id.should eq(@lg.id)
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @lg.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @lg.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'データがアレになっている' do
+ get :show, :id => @lg.id, :format => :json
+ json = JSON.parse response.body
+ json["name"].should match(/peta/)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :show, :id => @lg.id
+ response.status.should eq 200
+ end
+ end
+ end
+
+
+end
describe LicensesController do
before do
@admin = Factory :admin
- @lc = Factory :license
- @cl = Factory :common_license, :license_id => @lc.id
+ @lg = Factory :license_group
+ @sp = Factory :system_picture
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
describe '一覧表示に於いて' do
before do
+ @l = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
sign_in @user
- License.stub(:list).and_return([@lc, @lc, @lc])
+ License.stub(:list).and_return([@l, @l, @l])
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 License.default_page_size
- end
- it '最大を超えると@page_sizeにデフォルト最大値が入る' do
- get :index, :page_size => 1500
- assigns(:page_size).should eq License.max_page_size
- end
- it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
- get :index, :page_size => 0
- assigns(:page_size).should eq License.default_page_size
- end
- end
- context 'つつがなく終わるとき' do
+ context 'つつがなく終わるとき' do
it 'ステータスコード200 OKを返す' do
get :index
response.should be_success
describe '単体表示に於いて' do
before do
sign_in @user
- License.stub(:show).and_return(@lc)
+ @l = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+ License.stub(:show).and_return(@l)
end
context 'つつがなく終わるとき' do
it 'ステータスコード200 OKを返す' do
- get :show, :id => @lc.id
+ get :show, :id => @l.id
response.should be_success
end
it 'ライセンスモデルに単体取得を問い合わせている' do
get :show
end
it '@licenseにアレを取得している' do
- get :show, :id => @lc.id
- assigns(:license).id.should eq(@lc.id)
+ get :show, :id => @l.id
+ assigns(:license).id.should eq(@l.id)
end
context 'html形式' do
it 'showテンプレートを描画する' do
- get :show, :id => @lc.id
+ get :show, :id => @l.id
response.should render_template("show")
end
end
context 'json形式' do
it 'jsonデータを返す' do
- get :show, :id => @lc.id, :format => :json
+ get :show, :id => @l.id, :format => :json
lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
end
it 'データがアレになっている' do
- get :show, :id => @lc.id, :format => :json
+ get :show, :id => @l.id, :format => :json
json = JSON.parse response.body
json["name"].should match(/peta/)
end
sign_out @user
end
it 'ステータスコード200 okを返す' do
- get :show, :id => @lc.id
+ get :show, :id => @l.id
response.status.should eq 200
end
end
-# -*- encoding: utf-8 -*-
-#オリジナルライセンス
-require 'spec_helper'
-
-describe OriginalLicensesController do
- before do
- @admin = Factory :admin
- @lc = Factory :license
- @user = Factory( :user_yas)
- @author = @user.author
- @artist = Factory :artist_yas, :author_id => @author.id
- end
- describe '一覧表示に於いて' do
- before do
- sign_in @user
- @ol = Factory :original_license, :license_id => @lc.id
- OriginalLicense.stub(:list).and_return([@ol, @ol, @ol])
- 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 OriginalLicense.default_page_size
- end
- it '最大を超えると@page_sizeにデフォルト最大値が入る' do
- get :index, :page_size => 1500
- assigns(:page_size).should eq OriginalLicense.max_page_size
- end
- it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
- get :index, :page_size => 0
- assigns(:page_size).should eq OriginalLicense.default_page_size
- end
- end
- context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :index
- response.should be_success
- end
- it 'ライセンスモデルに一覧を問い合わせている' do
- OriginalLicense.should_receive(:list).exactly(1)
- get :index
- end
- it '@original_licensesにリストを取得している' do
- get :index
- assigns(:original_licenses).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?("url").should be_true
- end
- end
- end
- context '作家権限がないとき' do
- before do
- sign_out @user
- end
- it 'ステータスコード200 okを返す' do
- get :index
- response.status.should eq 200
- end
- end
- end
-
- describe '単体表示に於いて' do
- before do
- sign_in @user
- @ol = Factory :original_license, :license_id => @lc.id
- OriginalLicense.stub(:show).and_return(@ol)
- end
- context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :show, :id => @ol.id
- response.should be_success
- end
- it 'ライセンスモデルに単体取得を問い合わせている' do
- OriginalLicense.should_receive(:show).exactly(1)
- get :show
- end
- it '@original_licenseにアレを取得している' do
- get :show, :id => @ol.id
- assigns(:original_license).id.should eq(@ol.id)
- end
- context 'html形式' do
- it 'showテンプレートを描画する' do
- get :show, :id => @ol.id
- response.should render_template("show")
- end
- end
- context 'json形式' do
- it 'jsonデータを返す' do
- get :show, :id => @ol.id, :format => :json
- lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
- end
- it 'データがアレになっている' do
- get :show, :id => @ol.id, :format => :json
- json = JSON.parse response.body
- json["name"].should match(/peta/)
- end
- end
- end
- context '作家権限がないとき' do
- before do
- sign_out @user
- end
- it 'ステータスコード200 okを返す' do
- get :show, :id => @ol.id
- response.status.should eq 200
- end
- end
- end
-
- describe '新規作成フォーム表示に於いて' do
- before do
- sign_in @admin
- sign_in @user
- end
- context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :new
- response.should be_success
- end
- it '@original_licenseに新規データを用意している' do
- get :new
- assigns(:original_license).should be_a_new(OriginalLicense)
- end
- it 'オリジナルライセンスモデルにデフォルト値補充を依頼している' do
- OriginalLicense.any_instance.should_receive(:supply_default).exactly(1)
- get :new
- end
- context 'html形式' do
- it 'newテンプレートを描画する' do
- get :new
- response.should render_template("new")
- end
- end
- context 'js形式' do
- it 'new.jsテンプレートを描画する' do
- get :new, :format => :js
- response.should render_template("new")
- end
- end
- end
- context '管理者権限がないとき' do
- before do
- sign_out @admin
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- get :new
- response.status.should eq 302
- end
- it 'サインインページへ遷移する' do
- get :new
- response.body.should redirect_to '/admins/sign_in'
- end
- end
- context 'js形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- get :new, :format => :js
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- get :new, :format => :js
- response.message.should match(/Unauthorized/)
- end
- end
- end
- end
-
- describe '新規作成に於いて' do
- before do
- sign_in @admin
- sign_in @user
- end
- context 'つつがなく終わるとき' do
- it 'モデルに保存依頼する' do
- OriginalLicense.any_instance.should_receive(:store).exactly(1)
- post :create, :original_license => Factory.attributes_for(:original_license)
- end
- it "@original_licenseに作成されたオリジナルライセンスを保持していて、それがDBにある" do
- post :create, :original_license => Factory.attributes_for(:original_license)
- assigns(:original_license).should be_a(OriginalLicense)
- assigns(:original_license).should be_persisted
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- OriginalLicense.any_instance.stub(:store).and_return(true)
- post :create, :original_license => Factory.attributes_for(:original_license)
- response.status.should eq 302
- end
- it '作成されたオリジナルライセンスの表示ページへ遷移する' do
-# OriginalLicense.any_instance.stub(:save).and_return(true)
- post :create, :original_license => Factory.attributes_for(:original_license)
- response.should redirect_to(OriginalLicense.last)
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
-# OriginalLicense.any_instance.stub(:save).and_return(true)
- post :create, :original_license => Factory.attributes_for(:original_license), :format => :json
- response.should be_success
- end
- it '作成されたオリジナルライセンスをjsonデータで返す' do
- post :create, :original_license => Factory.attributes_for(:original_license), :format => :json
- lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
- end
- it 'データがアレになっている' do
- post :create, :original_license => Factory.attributes_for(:original_license), :format => :json
- json = JSON.parse response.body
- json["name"].should match(/peta/)
- end
- end
- end
- context '管理者権限がないとき' do
- before do
- sign_out @admin
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :create, :original_license => Factory.attributes_for(:original_license)
- response.status.should eq 302
- end
- it 'サインインページへ遷移する' do
- post :create, :original_license => Factory.attributes_for(:original_license)
- response.body.should redirect_to '/admins/sign_in'
- end
- end
- context 'json形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- post :create, :original_license => Factory.attributes_for(:original_license), :format => :json
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- post :create, :original_license => Factory.attributes_for(:original_license), :format => :json
- response.message.should match(/Unauthorized/)
- end
- end
- end
- context '検証、保存に失敗した' do
- before do
- OriginalLicense.any_instance.stub(:save).and_return(false)
- end
- it "未保存のオリジナルライセンスを保持している" do
- post :create, :original_license => {}
- assigns(:original_license).should be_a_new(OriginalLicense)
- end
- context 'html形式' do
- it 'ステータスコード200 OKを返す' do
- post :create, :original_license => {}
- response.status.should eq 200
- end
- it '新規ページを描画する' do
- post :create, :original_license => {}
- response.should render_template("new")
- end
- end
- context 'json形式' do
- it 'ステータスコード422 unprocessable_entity を返す' do
- post :create, :original_license => {}, :format => :json
- response.status.should eq 422
- end
- it '応答メッセージUnprocessable Entityを返す' do
- post :create, :original_license => {}, :format => :json
- response.message.should match(/Unprocessable/)
- end
- end
- end
- end
-
- describe '編集フォーム表示に於いて' do
- before do
- @ol = Factory :original_license, :license_id => @lc.id
- sign_in @admin
- sign_in @user
- OriginalLicense.stub(:show).and_return(@ol)
- end
- context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :edit, :id => @ol.id
- response.should be_success
- end
- it 'オリジナルライセンスモデルに単体取得を問い合わせている' do
- OriginalLicense.should_receive(:show).exactly(1)
- get :edit, :id => @ol.id
- end
- it '@original_licenseにデータを用意している' do
- get :edit, :id => @ol.id
- assigns(:original_license).should eq @ol
- end
- context 'html形式' do
- it 'editテンプレートを描画する' do
- get :edit, :id => @ol.id
- response.should render_template("edit")
- end
- end
- context 'js形式' do
- it 'edit.jsテンプレートを描画する' do
- get :edit, :id => @ol.id, :format => :js
- response.should render_template("edit")
- end
- end
- end
- context '管理者権限がないとき' do
- before do
- sign_out @admin
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- get :edit, :id => @ol.id
- response.status.should eq 302
- end
- it 'サインインページへ遷移する' do
- get :edit, :id => @ol.id
- response.body.should redirect_to '/admins/sign_in'
- end
- end
- context 'js形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- get :edit, :id => @ol.id, :format => :js
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- get :edit, :id => @ol.id, :format => :js
- response.message.should match(/Unauthorized/)
- end
- end
- end
- end
-
- describe '更新に於いて' do
- before do
- @ol = Factory :original_license, :license_id => @lc.id
- sign_in @admin
- sign_in @user
- @attr = Factory.attributes_for(:original_license, :name => 'new lc')
- end
- context '事前チェックしておく' do
- it 'オリジナルライセンスモデルに単体取得を問い合わせている' do
- OriginalLicense.stub(:show).with(any_args()).and_return @ol
- OriginalLicense.should_receive(:show).exactly(1)
- put :update, :id => @ol.id, :original_license => @attr
- end
- it 'モデルに更新を依頼する' do
- OriginalLicense.any_instance.should_receive(:store).with(any_args)
- put :update, :id => @ol.id, :original_license => @attr
- end
- it '@original_licenseにアレを取得している' do
- put :update, :id => @ol.id, :original_license => @attr
- assigns(:original_license).id.should eq(@ol.id)
- end
- end
- context 'つつがなく終わるとき' do
- it '更新される' do
- put :update, :id => @ol.id, :original_license => @attr
- OriginalLicense.find(@ol.id).name.should eq 'new lc'
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- OriginalLicense.any_instance.stub(:store).with(any_args()).and_return(true)
- put :update, :id => @ol.id, :original_license => @attr
- response.status.should eq 302
- end
- it '更新されたオリジナルライセンスの表示ページへ遷移する' do
- put :update, :id => @ol.id, :original_license => @attr
- response.should redirect_to(@ol)
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
- OriginalLicense.any_instance.stub(:store).with(any_args()).and_return(true)
- put :update, :id => @ol.id, :original_license => @attr, :format => :json
- response.should be_success
- end
- it 'ページ本体は特に返さない' do
- OriginalLicense.any_instance.stub(:store).with(any_args()).and_return(true)
- put :update, :id => @ol.id, :original_license => @attr, :format => :json
- response.body.should match /./
- end
- end
- end
- context '管理者権限がないとき' do
- before do
- sign_out @admin
- end
- it 'ステータスコード302 Foundを返す' do
- put :update, :id => @ol.id, :original_license => @attr
- response.status.should eq 302
- end
- context 'html形式' do
- it 'サインインページへ遷移する' do
- put :update, :id => @ol.id, :original_license => @attr
- response.body.should redirect_to '/admins/sign_in'
- end
- end
- context 'json形式' do
- it '応答メッセージにUnauthorizedを返す' do
- put :update, :id => @ol.id, :original_license => @attr, :format => :json
- response.message.should match(/Unauthorized/)
- end
- end
- end
- context '検証、保存に失敗したとき' do
- before do
- OriginalLicense.any_instance.stub(:store).and_return(false)
- end
- context 'html形式' do
- it 'ステータスコード200 Okを返す' do
- put :update, :id => @ol.id, :original_license => @attr
- response.status.should eq 200
- end
- it '編集ページを描画する' do
- put :update, :id => @ol.id, :original_license => @attr
- response.should render_template("edit")
- end
- end
- context 'json形式' do
- it 'ステータスコード422 unprocessable_entity を返す' do
- OriginalLicense.any_instance.stub(:store).and_return(false)
- put :update, :id => @ol.id, :original_license => @attr, :format => :json
- response.status.should eq 422
- end
- it '応答メッセージUnprocessable Entityを返す' do
- put :update, :id => @ol.id, :original_license => @attr, :format => :json
- response.message.should match(/Unprocessable/)
- end
- end
- end
- end
-
- describe 'インポートに於いて' do
- before do
- sign_in @admin
- sign_in @user
- #テストデータを用意してね
- @f = Rails.root + 'spec/json/original_license.json'
- @t = File.open(@f, 'r').read
- @j = JSON.parse @t
- @fs = Rails.root + 'spec/json/original_licenses.json'
- @ts = File.open(@fs, 'r').read
- @js = JSON.parse @ts
- @fes = Rails.root + 'spec/json/invalid_original_licenses.json'
- @tes = File.open(@fes, 'r').read
- @jes = JSON.parse @tes
- end
- context '事前チェックしておく' do
- before do
- #異常な行を返すから、正常の意味で空を返す
- OriginalLicense.stub(:import).with(any_args()).and_return([])
- end
- it "@dataに渡したデータを保持している" do
- post :import, :file => @t
- assigns(:data).should_not be_nil
- end
- it 'モデルにインポート依頼する' do
- OriginalLicense.should_receive(:import).with(any_args()).exactly(1)
- post :import, :file => @t
- end
- it "@errorsに結果を保持している" do
- post :import, :file => @t
- assigns(:errors).should eq []
- end
- end
- context 'つつがなく終わるとき' do
- before do
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :import, :file => @t
- response.status.should eq 302
- end
- it '管理者向けオリジナルライセンス一覧ページへ遷移する' do
- post :import, :file => @t
- response.should redirect_to('/original_licenses/list')
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
- post :import, :file => @t, :format => :json
- response.should be_success
- end
- end
- end
- context '管理者権限がないとき' do
- before do
- sign_out @admin
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :import, :file => @t
- response.status.should eq 302
- end
- it '管理者サインインページへ遷移する' do
- post :import, :file => @t
- response.body.should redirect_to '/admins/sign_in'
- end
- end
- context 'json形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- post :import, :file => @t, :format => :json
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- post :import, :file => @t, :format => :json
- response.message.should match(/Unauthorized/)
- end
- end
- end
- context '作家権限がないとき' do
- #必要なのは管理者権限であって作家権限ではない。成功を見届ける
- before do
- sign_out @user
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :import, :file => @t
- response.status.should eq 302
- end
- it '管理者向けオリジナルライセンス一覧ページへ遷移する' do
- post :import, :file => @t
- response.should redirect_to('/original_licenses/list')
- end
- end
- context 'json形式' do
- it 'ステータスコード200 OKを返す' do
- post :import, :file => @t, :format => :json
- response.should be_success
- end
- end
- end
- context '検証、保存に失敗した' do
- before do
- #異常な行を返す
- OriginalLicense.stub(:import).with(any_args()).and_return(
- [OriginalLicense.new(Factory.attributes_for(:original_license))]
- )
- end
- context 'html形式' do
- it 'ステータスコード200 OKを返す' do
- post :import, :file => @t
- response.status.should eq 200
- end
- it 'resultページを描画する' do
- post :import, :file => @t
- response.should render_template("result")
- end
- end
- context 'json形式' do
- it 'ステータスコード422 unprocessable_entity を返す' do
- post :import, :file => @t, :format => :json
- response.status.should eq 422
- end
- it '応答メッセージUnprocessable Entityを返す' do
- post :import, :file => @t, :format => :json
- response.message.should match(/Unprocessable/)
- end
- end
- end
- end
-
-end
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
describe '一覧表示に於いて' do
describe PanelPicturesController do
before do
Factory :admin
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
describe PanelsController do\r
before do\r
Factory :admin\r
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory :user_yas\r
@author = @user.author #ユーザ作成時に連動して作成される\r
@comic = Factory :comic, :author_id => @author.id\r
--- /dev/null
+require 'spec_helper'
+
+describe ResourcePictureLicenseController do
+
+end
describe ResourcePicturesController do
before do
Factory :admin
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
before do
@admin = Factory :admin
- @sbt = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory( :user_yas)
@author = @user.author
@sbt = Factory :speech_balloon_template
# artist.association :author_yas
end
+Factory.define :license_group, :class => LicenseGroup do |license_group|
+ license_group.name 'pettan_public_01'
+ license_group.classname 'PettanPublicLicense'
+ license_group.caption 'pettan public 0.1'
+ license_group.url 'http://test.lc/'
+end
+
Factory.define :license, :class => License do |license|
+ license.license_group_id 1
license.name 'peta2.5'
+ license.caption 'flag'
license.url 'http://test.lc/'
- license.cc_by 0
- license.cc_sa 0
- license.cc_nd 0
- license.cc_nc 0
- license.no_resize 0
- license.no_flip 0
- license.no_convert 0
- license.keep_aspect_ratio 0
+ license.system_picture_id 1
end
Factory.define :common_license, :class => CommonLicense do |license|
--- /dev/null
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the LicenseGroupHelper. For example:
+#
+# describe LicenseGroupsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe LicenseGroupsHelper 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 ResourcePictureLicenseHelper. For example:
+#
+# describe ResourcePictureLicenseHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe ResourcePictureLicenseHelper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
--- /dev/null
+{\r
+ "PublicDomain": {\r
+ "classname": "PublicDomain", \r
+ "caption": "Public Domain", \r
+ "url": "http://test.com/"\r
+ },\r
+ "UnknownUrl": {\r
+ "classname": "Unknown", \r
+ "caption": "Unknown owner"\r
+ },\r
+ "UnknownClassname": {\r
+ "caption": "Unknown owner", \r
+ "url": "http://test.uk/"\r
+ }\r
+}\r
--- /dev/null
+{\r
+ "PublicDomain": {\r
+ "name": "PublicDomain", \r
+ "classname": "PublicDomain", \r
+ "caption": "Public Domain", \r
+ "url": "http://test.com/",\r
+ "licenses_attributes": {\r
+ "PublicDomain": {\r
+ "caption": "Public Domain", \r
+ "url": "http://test.com/",\r
+ "system_picture": "Data"\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+{\r
+ "PublicDomain": {\r
+ "classname": "PublicDomain", \r
+ "caption": "Public Domain", \r
+ "url": "http://test.com/"\r
+ },\r
+ "Unknown": {\r
+ "classname": "Unknown", \r
+ "caption": "Unknown owner", \r
+ "url": "http://test.uk/",\r
+ "licenses_attributes": {\r
+ "UnknownF1": {\r
+ "caption": "Unknown Flag1", \r
+ "url": "http://test.com/f1",\r
+ "system_picture": "Dataf1"\r
+ },\r
+ "UnknownF2": {\r
+ "caption": "Unknown Flag2", \r
+ "url": "http://test.com/f2",\r
+ "system_picture": "Dataf2"\r
+ }\r
+ }\r
+ }\r
+}\r
Factory :admin
@user = Factory( :user_yas)
@author = @user.author
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
describe '検証に於いて' do
@user = Factory( :user_yas)\r
@author = @user.author\r
@artist = Factory :artist_yas, :author_id => @author.id\r
- @license = Factory :license\r
\r
@balloon = Factory :panel\r
@speech_balloon_template = Factory :speech_balloon_template\r
-# -*- encoding: utf-8 -*-
-#コモンライセンス
-require 'spec_helper'
-
-describe CommonLicense do
- before do
- #テストデータを用意してね
- @f = Rails.root + 'spec/json/common_license.json'
- @t = File.open(@f, 'r').read
- @j = JSON.parse @t
- @fs = Rails.root + 'spec/json/common_licenses.json'
- @ts = File.open(@fs, 'r').read
- @js = JSON.parse @ts
- @fes = Rails.root + 'spec/json/invalid_common_licenses.json'
- @tes = File.open(@fes, 'r').read
- @jes = JSON.parse @tes
- end
- describe '検証に於いて' do
- before do
- @l = Factory :license
- end
-
- it 'オーソドックスなデータなら通る' do
- @cl = Factory.build :common_license, :license_id => @l.id
- @cl.should be_valid
- end
-
- context 'nameを検証するとき' do
- before do
- @cl = Factory.build :common_license, :license_id => @l.id
- end
- it 'テストデータの確認' do
- @cl.name = 'CC by'
- @cl.should be_valid
- end
- it 'nullなら失敗する' do
- @cl.name = ''
- @cl.should_not be_valid
- end
- it '51文字以上なら失敗する' do
- @cl.name = 'a'*51
- @cl.should_not be_valid
- end
- end
- context 'urlを検証するとき' do
- before do
- @cl = Factory.build :common_license, :license_id => @l.id
- end
- it 'テストデータの確認' do
- @cl.url = 'CC by'
- @cl.should be_valid
- end
- it 'nullなら失敗する' do
- @cl.url = ''
- @cl.should_not be_valid
- end
- it '201文字以上なら失敗する' do
- @cl.url = 'a'*201
- @cl.should_not be_valid
- end
- it '重複していたら失敗する' do
- cl = Factory :common_license, :license_id => @l.id
- @cl.should_not be_valid
- end
- it 'url形式でなら失敗する' do
- @cl.url = ''
- pending
- end
- end
- context 'license_idを検証するとき' do
- before do
- @cl = Factory.build :common_license
- end
- it 'テストデータの確認' do
- @cl.license_id = @l.id
- @cl.should be_valid
- end
- it 'nullなら失敗する' do
- @cl.license_id = nil
- @cl.should_not be_valid
- end
- it '数値でなければ失敗する' do
- @cl.license_id = 'a'
- @cl.should_not be_valid
- end
- it '存在するlicenseでなければ失敗する' do
- @cl.license_id = 0
- @cl.should_not be_valid
- end
- end
- end
-
- describe '対象コモンライセンスの取得に於いて' do
- before do
- @lc = Factory :license
- @cl = Factory :common_license, :license_id => @lc.id
- end
- context 'urlが一致するコモンライセンスがないとき' do
- it '新規コモンライセンスを準備して返す' do
- r = CommonLicense.update_common_license Factory.attributes_for(:common_license, :url => 'http://domain.no')
- r.should be_a_new CommonLicense
- end
- end
- context 'urlが一致するコモンライセンスがあるとき' do
- it '該当コモンライセンスを返す' do
- prm = Factory.attributes_for(:common_license)
- r = CommonLicense.update_common_license prm
- r.is_a?(CommonLicense).should be_true
- r.should_not be_a_new CommonLicense
- r[:url].should eq prm[:url]
- end
- end
- end
-
- describe 'コモンライセンス更新に於いて' do
- before do
- @lc = Factory :license
- @cl = Factory :common_license, :license_id => @lc.id
- @attr = Factory.attributes_for(:common_license, :name => 'exist case')
- @newattr = Factory.attributes_for(:common_license, :url => 'http://domain.no')
- end
- context 'つつがなく終わるとき' do
- it '対象コモンライセンスを問い合わせている' do
- CommonLicense.stub(:update_common_license).with(any_args).and_return(CommonLicense.new(@attr))
- CommonLicense.should_receive(:update_common_license).exactly(1)
- CommonLicense.store @attr
- end
- context '新規のとき' do
- it 'コモンライセンスを保存しようとしている' do
- CommonLicense.any_instance.should_receive(:save).exactly(1)
- CommonLicense.store @newattr
- end
- it 'コモンライセンスが作成されている' do
- lambda {
- CommonLicense.store @newattr
- }.should change CommonLicense, :count
- end
- context 'ライセンスとの連動' do
- it 'ライセンスが作成されている' do
- lambda {
- CommonLicense.store @newattr
- }.should change License, :count
- end
- it '両者がリンクされている' do
- r = CommonLicense.store @newattr
- l = License.find(r.license_id)
- l.should be_true
- end
- it '属性が一致している' do
- r = CommonLicense.store @newattr
- l = License.find(r.license_id)
- l.url.should eq r.url
- l.name.should eq r.name
- end
- end
- end
- context '更新のとき' do
- it 'コモンライセンスを保存しようとしている' do
- CommonLicense.any_instance.should_receive(:save).exactly(1)
- CommonLicense.store @attr
- end
- it 'コモンライセンスの数に変化がない' do
- lambda {
- CommonLicense.store @attr
- }.should_not change CommonLicense, :count
- end
- context 'ライセンスとの連動' do
- it 'ライセンスの数に変化がない' do
- lambda {
- CommonLicense.store @attr
- }.should_not change License, :count
- end
- it '両者がリンクされている' do
- r = CommonLicense.store @attr
- l = License.find(r.license_id)
- l.should be_true
- end
- it '属性が一致している' do
- r = CommonLicense.store @attr
- l = License.find(r.license_id)
- l.url.should eq r.url
- l.name.should eq r.name
- end
- end
- end
- it '属性が一致している' do
- r = CommonLicense.store @newattr
- r.url.should eq @newattr[:url]
- r.name.should eq @newattr[:name]
- end
- it '保存されたCommonLicenseオブジェクトを返す' do
- r = CommonLicense.store @newattr
- r.should_not be_a_new CommonLicense
- end
- end
- context 'ライセンスの作成に失敗するとき' do
- before do
- License.any_instance.stub(:save).with(any_args).and_return(false)
- end
- context '新規のとき' do
- it 'ライセンスに変化がない' do
- lambda {
- r = CommonLicense.store @newattr
- }.should_not change License, :count
- end
- it 'コモンライセンスに変化がない' do
- lambda {
- r = CommonLicense.store @newattr
- }.should_not change CommonLicense, :count
- end
- end
- context '更新のとき' do
- it 'コモンライセンス属性に変化がない' do
- lambda {
- r = CommonLicense.store @attr
- }.should_not change License.find(@cl.id), :name
- end
- it 'ライセンス属性に変化がない' do
- lambda {
- r = CommonLicense.store @attr
- }.should_not change License.find(@lc.id), :name
- end
- end
- end
- context 'コモンライセンスの作成に失敗するとき' do
- before do
- CommonLicense.any_instance.stub(:save).with(any_args).and_return(false)
- end
- context '新規のとき' do
- it 'ライセンスに変化がない' do
- lambda {
- r = CommonLicense.store @newattr
- }.should_not change License, :count
- end
- it 'コモンライセンスに変化がない' do
- lambda {
- r = CommonLicense.store @newattr
- }.should_not change CommonLicense, :count
- end
- end
- context '更新のとき' do
- it 'コモンライセンス属性に変化がない' do
- lambda {
- r = CommonLicense.store @attr
- }.should_not change License.find(@cl.id), :name
- end
- it 'ライセンス属性に変化がない' do
- lambda {
- r = CommonLicense.store @attr
- }.should_not change License.find(@lc.id), :name
- end
- end
- end
- end
-=begin
- describe '単体取得に於いて' do
- before do
- @cl = Factory.build :common_license
- @cl.store
- end
- it '指定のライセンスを返す' do
- l = CommonLicense.show @cl.id
- l.should eq @cl
- end
- context '関連テーブルオプションがないとき' do
- it 'ライセンスだけを含んでいる' do
- r = CommonLicense.show_include_opt
- r.should eq [:license]
- end
- end
- context '関連テーブルオプションでコマを含ませたとき' do
- it 'ライセンスと作家を含んでいる' do
- r = CommonLicense.show_include_opt(:include => :author)
- r.should eq [:license, :author]
- end
- end
- end
- describe '一覧取得に於いて' do
- before do
- @cl = Factory.build :common_license
- @cl.store
- end
- context 'page補正について' do
- it '文字列から数値に変換される' do
- CommonLicense.page('8').should eq 8
- end
- it 'nilの場合は1になる' do
- CommonLicense.page().should eq 1
- end
- it '0以下の場合は1になる' do
- CommonLicense.page('0').should eq 1
- end
- end
- context 'page_size補正について' do
- it '文字列から数値に変換される' do
- CommonLicense.page_size('7').should eq 7
- end
- it 'nilの場合はCommonLicense.default_page_sizeになる' do
- CommonLicense.page_size().should eq CommonLicense.default_page_size
- end
- it '0以下の場合はCommonLicense.default_page_sizeになる' do
- CommonLicense.page_size('0').should eq CommonLicense.default_page_size
- end
- it 'CommonLicense.max_page_sizeを超えた場合はCommonLicense.max_page_sizeになる' do
- CommonLicense.page_size('1000').should eq CommonLicense.max_page_size
- end
- end
- it 'リストを返す' do
- l = CommonLicense.list
- l.should eq [@cl]
- end
- it '名前順で並んでいる' do
- n = Factory.build :common_license, :url => 'tes.to', :name => 'peta2.2'
- n.store
- l = CommonLicense.list
- l.should eq [@cl, n]
- end
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
- @license2 = Factory.build :common_license, :url => 'tes.to2', :name => 'peta2.2'
- @license2.store
- @license3 = Factory.build :common_license, :url => 'tes.to3', :name => 'peta2.3'
- @license3.store
- @license4 = Factory.build :common_license, :url => 'tes.to4', :name => 'peta2.4'
- @license4.store
- @license5 = Factory.build :common_license, :url => 'tes.to5', :name => 'peta2.5'
- @license5.store
- CommonLicense.stub(:default_page_size).and_return(2)
- end
- it '通常は2件を返す' do
- l = CommonLicense.list
- l.should have(2).items
- end
- it 'page=1なら末尾2件を返す' do
- #時系列で並んでいる
- l = CommonLicense.list({}, 1)
- l.should eq [@cl, @license2]
- end
- it 'page=2なら中間2件を返す' do
- l = CommonLicense.list({}, 2)
- l.should eq [@license3, @license4]
- end
- it 'page=3なら先頭1件を返す' do
- l = CommonLicense.list({}, 3)
- l.should eq [@license5]
- end
- end
- end
-=end
-
- describe 'Json解析に於いて' do
- before do
- end
- context 'テキストを渡されたとき' do
- it 'Json解析している' do
- JSON.should_receive(:parse).with(@t).exactly(1)
- r = CommonLicense.parse @t
- end
- it '単数データならHashで返す' do
- r = CommonLicense.parse @t
- r.is_a?(Hash).should be_true
- end
- it '複数データならArrayで返す' do
- r = CommonLicense.parse @ts
- r.is_a?(Array).should be_true
- end
- end
- context 'パース失敗したとき' do
- it 'Falseを返す' do
- JSON.should_receive(:parse).with(any_args).and_raise('StandardError')
- r = CommonLicense.parse @t
- r.should be_false
- end
- end
- end
-
- describe 'Jsonの繰り返し処理に於いて' do
- before do
- end
- context '単体データを渡されたとき' do
- it '一回処理' do
- r = []
- CommonLicense.each_license @j do |i|
- r << i
- end
- r.size.should eq 1
- end
- end
- context '複数を渡されたとき' do
- it '二回処理' do
- r = []
- CommonLicense.each_license @js do |i|
- r << i
- end
- r.size.should eq 2
- end
- end
- end
-
- describe 'テキスト取り込みに於いて' do
- #成功でTrue、パース失敗でFalse、失敗は保存エラーのモデルを配列で返す
- #Licenseとの連動が完成していること
- before do
- end
- context 'つつがなく終わるとき' do
- it 'Json解析を依頼する' do
- CommonLicense.should_receive(:parse).with(any_args).exactly(1)
- CommonLicense.stub(:parse).with(any_args).and_return(@j)
- CommonLicense.import(@t)
- end
- it '繰り返し処理を依頼する' do
- CommonLicense.should_receive(:each_license).with(any_args).exactly(1)
- CommonLicense.import(@t)
- end
- it 'ライセンス更新を一回依頼する' do
- CommonLicense.stub(:store).with(any_args).and_return(CommonLicense.new)
- CommonLicense.any_instance.stub(:valid?).with(any_args).and_return(true)
- CommonLicense.should_receive(:store).with(any_args).exactly(1)
- CommonLicense.import(@t)
- end
- it 'コモンライセンスが追加される' do
- lambda {
- CommonLicense.import(@t)
- }.should change CommonLicense, :count
- end
- it '[]を返す' do
- CommonLicense.import(@t).should eq []
- end
- end
- context '複数データがつつがなく終わるとき' do
- it 'ライセンス更新を二回依頼する' do
- CommonLicense.stub(:store).with(any_args).and_return(CommonLicense.new)
- CommonLicense.any_instance.stub(:valid?).with(any_args).and_return(true)
- CommonLicense.should_receive(:store).with(any_args).exactly(2)
- CommonLicense.import(@ts)
- end
- it 'コモンライセンスが二個追加される' do
- lambda {
- CommonLicense.import(@ts)
- }.should change(CommonLicense, :count).by 2
- end
- it '[]を返す' do
- CommonLicense.import(@ts).should eq []
- end
- end
- #例外ケース
- context 'Json解析に失敗したとき' do
- before do
- CommonLicense.stub(:parse).with(any_args).and_return(false)
- end
- it 'コモンライセンスの数に変化がない' do
- lambda {
- CommonLicense.import(@t)
- }.should_not change CommonLicense, :count
- end
- it 'Falseを返す' do
- CommonLicense.import(@t).should be_false
- end
- end
- context 'コモンライセンス作成に失敗したとき' do
- before do
- CommonLicense.any_instance.stub(:save).with(any_args).and_return(false)
- CommonLicense.any_instance.stub(:valid?).with(any_args).and_return(false)
- end
- it 'コモンライセンスの数に変化がない' do
- lambda {
- CommonLicense.import(@t)
- }.should_not change CommonLicense, :count
- end
- it '配列を返す' do
- r = CommonLicense.import(@t)
- r.is_a?(Array).should be_true
- end
- it '配列の中身は一件' do
- r = CommonLicense.import(@t)
- r.should have(1).items
- end
- it 'コモンライセンスオブジェクトが入っている' do
- r = CommonLicense.import(@t)
- r.first.is_a?(CommonLicense).should be_true
- end
- end
- context '複数のコモンライセンス作成に失敗したとき' do
- #三件中、二件の失敗、一件を成功させ、成功データは戻り値に含まないことを確認する
- it 'コモンライセンスの数に変化がない' do
- lambda {
- CommonLicense.import(@tes)
- }.should_not change CommonLicense, :count
- end
- it '途中で保存に失敗しても全件更新依頼する' do
- CommonLicense.stub(:store).with(any_args).and_return(CommonLicense.new)
- CommonLicense.should_receive(:store).with(any_args).exactly(3)
- CommonLicense.import(@tes)
- end
- it '配列を返す' do
- r = CommonLicense.import(@tes)
- r.is_a?(Array).should be_true
- end
- it '配列の中身は2件' do
- r = CommonLicense.import(@tes)
- r.should have(2).items
- end
- it '配列の中身は失敗したコモンライセンスオブジェクトが入っている' do
- r = CommonLicense.import(@tes)
- r[0].is_a?(CommonLicense).should be_true
- r[0]["name"].should eq 'fail1'
- r[1].is_a?(CommonLicense).should be_true
- r[1]["name"].should eq 'fail2'
- end
- end
- end
-
- describe 'インポートエラーの表示に於いて' do
- end
-
- describe 'ファイル取り込みに於いて' do
- before do
- CommonLicense.stub(:import).with(any_args).and_return(true)
- end
- context 'つつがなく終わるとき' do
- before do
- CommonLicense.stub(:import).with(any_args).and_return(true)
- end
- it 'ファイルを開いてテキストを読む' do
- File.should_receive(:open).with(@f, 'r').exactly(1)
- CommonLicense.import_file(@f)
- end
- it 'テキスト取り込みを依頼する' do
- CommonLicense.should_receive(:import).with(any_args).exactly(1)
- CommonLicense.import_file(@f)
- end
- #テキスト取り込み成功でTrueが返る
- it 'Trueを返す' do
- CommonLicense.import_file(@f).should be_true
- end
- end
- context 'ファイルが開けないとき' do
- before do
- File.stub(:open).with(any_args).and_raise('StandardError')
- end
- it 'ファイルエラーのメッセージを出力する' do
- pending
- end
- it 'Falseを返す' do
- CommonLicense.import_file(@f).should be_false
- end
- end
- #失敗したときは、失敗したライセンスが配列で返る
- context 'テキスト取り込みが失敗したとき' do
- before do
- CommonLicense.stub(:import).with(any_args).and_return(false)
- end
- it '各コモンライセンスのエラーメッセージを出力する' do
- pending
- end
- it 'Falseを返す' do
- CommonLicense.import_file(@f).should be_false
- end
- end
- end
-
-end
--- /dev/null
+# -*- encoding: utf-8 -*-
+#ライセンスグループ
+require 'spec_helper'
+
+describe LicenseGroup do
+ before do
+ #テストデータを用意してね
+ @f = Rails.root + 'spec/json/license_group.json'
+ @t = File.open(@f, 'r').read
+ @j = JSON.parse @t
+ @fs = Rails.root + 'spec/json/license_groups.json'
+ @fes = Rails.root + 'spec/json/invalid_license_groups.json'
+ end
+ describe '検証に於いて' do
+ before do
+ end
+
+ it 'オーソドックスなデータなら通る' do
+ @lg = Factory.build :license_group
+ @lg.should be_valid
+ end
+
+ context 'nameを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.name = 'a'*50
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.name = ''
+ @lg.should_not be_valid
+ end
+ it '51文字以上なら失敗する' do
+ @lg.name = 'a'*51
+ @lg.should_not be_valid
+ end
+ it '重複していたら失敗する' do
+ l = Factory :license_group
+ @lg.should_not be_valid
+ end
+ end
+ context 'classnameを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.classname = 'a'*50
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.classname = ''
+ @lg.should_not be_valid
+ end
+ it '51文字以上なら失敗する' do
+ @lg.classname = 'a'*51
+ @lg.should_not be_valid
+ end
+ end
+ context 'captionを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.caption = 'a'*30
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.caption = ''
+ @lg.should_not be_valid
+ end
+ it '51文字以上なら失敗する' do
+ @lg.caption = 'a'*51
+ @lg.should_not be_valid
+ end
+ end
+ context 'urlを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.url = 'http://test.com/'
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.url = ''
+ @lg.should_not be_valid
+ end
+ it '201文字以上なら失敗する' do
+ @lg.url = 'a'*201
+ @lg.should_not be_valid
+ end
+ it 'url形式でないなら失敗する' do
+ @lg.url = 'aaaaaaa'
+ @lg.should_not be_valid
+ end
+ end
+ end
+
+ describe '更新に於いて' do
+ before do
+ @n = @j.keys.first
+ @a = @j.values.first
+ end
+ context 'つつがなく終わるとき' do
+ it 'データ更新準備を依頼する' do
+ LicenseGroup.stub(:modify_object).with(any_args).and_return(LicenseGroup.new)
+ LicenseGroup.should_receive(:modify_object).with(any_args).exactly(1)
+ License.stub(:stores).with(any_args).and_return(0)
+ LicenseGroup.any_instance.stub(:save).with(any_args).and_return(true)
+ r = LicenseGroup.store(@n, @a)
+ end
+ it 'ライセンスに複数の更新を依頼する' do
+ LicenseGroup.stub(:modify_object).with(any_args).and_return(LicenseGroup.new)
+ License.stub(:stores).with(any_args).and_return(0)
+ License.should_receive(:stores).with(any_args).exactly(1)
+ LicenseGroup.any_instance.stub(:save).with(any_args).and_return(true)
+ r = LicenseGroup.store(@n, @a)
+ end
+ it '保存を依頼する' do
+ LicenseGroup.stub(:modify_object).with(any_args).and_return(LicenseGroup.new)
+ License.stub(:stores).with(any_args).and_return(0)
+ LicenseGroup.any_instance.stub(:save).with(any_args).and_return(true)
+ LicenseGroup.any_instance.should_receive(:save).with(any_args).exactly(1)
+ r = LicenseGroup.store(@n, @a)
+ end
+ it 'オブジェクトを返す' do
+ r = LicenseGroup.store(@n, @a)
+ r.is_a?(LicenseGroup).should be_true
+ r.name.should eq @n
+ r.url.should eq @a["url"]
+ end
+ it 'カラム値からlicenses_attributesが削除されている' do
+ @a["licenses_attributes"].should_not be_nil
+ r = LicenseGroup.store(@n, @a)
+ @a["licenses_attributes"].should be_nil
+ end
+ end
+ context 'ライセンス複数更新が失敗するとき' do
+ before do
+ LicenseGroup.stub(:modify_object).with(any_args).and_return(LicenseGroup.new)
+ License.stub(:stores).with(any_args).and_return(1)
+ LicenseGroup.any_instance.stub(:save).with(any_args).and_return(true)
+ end
+ it '全体エラーメッセージがセットされている' do
+ r = LicenseGroup.store(@n, @a)
+ r.errors[:base].should_not be_blank
+ end
+ it 'ライセンスが作成されていない' do
+ lambda {
+ r = LicenseGroup.store(@n, @a)
+ }.should_not change License, :count
+ end
+ it 'ライセンスグループが作成されていない' do
+ lambda {
+ r = LicenseGroup.store(@n, @a)
+ }.should_not change LicenseGroup, :count
+ end
+ end
+ end
+
+ describe 'インポートに於いて' do
+ before do
+ end
+ context 'つつがなく終わるとき' do
+ it 'ファイルインポートを依頼する' do
+ LicenseGroup.should_receive(:import_file).with(any_args).exactly(1)
+ LicenseGroup.stub(:import_file).with(any_args).and_return([])
+ LicenseGroup.import(@f)
+ end
+ it 'ライセンスグループ更新を一回依頼する' do
+ LicenseGroup.stub(:store).with(any_args).and_return(LicenseGroup.new)
+ LicenseGroup.should_receive(:store).with(any_args).exactly(1)
+ LicenseGroup.import(@f)
+ end
+ it 'ライセンスグループが追加される' do
+ lambda {
+ LicenseGroup.import(@f)
+ }.should change LicenseGroup, :count
+ end
+ it 'ライセンスが追加される' do
+ lambda {
+ LicenseGroup.import(@f)
+ }.should change License, :count
+ end
+ it '[]を返す' do
+ r = LicenseGroup.import(@f)
+ r.should eq []
+ end
+ end
+ context '複数データがつつがなく終わるとき' do
+ it 'ライセンスグループ更新を二回依頼する' do
+ LicenseGroup.stub(:store).with(any_args).and_return(LicenseGroup.new)
+ LicenseGroup.should_receive(:store).with(any_args).exactly(2)
+ LicenseGroup.import(@fs)
+ end
+ it 'ライセンスグループが二個追加される' do
+ lambda {
+ r = LicenseGroup.import(@fs)
+ }.should change(LicenseGroup, :count).by 2
+ end
+ it 'ライセンスが追加される' do
+ lambda {
+ r = LicenseGroup.import(@fs)
+ }.should change(License, :count)
+ end
+ it '[]を返す' do
+ r = LicenseGroup.import(@fs)
+ r.should eq []
+ end
+ end
+ context 'ライセンスグループ作成に失敗したとき' do
+ before do
+ LicenseGroup.any_instance.stub(:save).with(any_args).and_return(false)
+ LicenseGroup.any_instance.stub(:valid?).with(any_args).and_return(false)
+ end
+ it 'ライセンスグループの数に変化がない' do
+ lambda {
+ LicenseGroup.import(@f)
+ }.should_not change LicenseGroup, :count
+ end
+ it '配列を返す' do
+ r = LicenseGroup.import(@f)
+ r.is_a?(Array).should be_true
+ end
+ it '配列の中身は一件' do
+ r = LicenseGroup.import(@f)
+ r.should have(1).items
+ end
+ it 'ライセンスグループオブジェクトが入っている' do
+ r = LicenseGroup.import(@f)
+ r.first.is_a?(LicenseGroup).should be_true
+ end
+ end
+ context '複数のライセンスグループ作成に失敗したとき' do
+ #三件中、二件の失敗、一件を成功させ、成功データは戻り値に含まないことを確認する
+ it 'ライセンスグループの数に変化がない' do
+ lambda {
+ LicenseGroup.import(@fes)
+ }.should_not change LicenseGroup, :count
+ end
+ it '途中で保存に失敗しても全件更新依頼する' do
+ LicenseGroup.stub(:store).with(any_args).and_return(LicenseGroup.new)
+ LicenseGroup.should_receive(:store).with(any_args).exactly(3)
+ LicenseGroup.import(@fes)
+ end
+ it '配列を返す' do
+ r = LicenseGroup.import(@fes)
+ r.is_a?(Array).should be_true
+ end
+ it '配列の中身は2件' do
+ r = LicenseGroup.import(@fes)
+ r.should have(2).items
+ end
+ it '配列の中身は失敗したライセンスグループオブジェクトが入っている' do
+ r = LicenseGroup.import(@fes)
+ r[0].is_a?(LicenseGroup).should be_true
+ r[0]["name"].should eq 'UnknownUrl'
+ r[1].is_a?(LicenseGroup).should be_true
+ r[1]["name"].should eq 'UnknownClassname'
+ end
+ end
+ end
+
+ describe '単体取得に於いて' do
+ before do
+ @lg = Factory :license_group
+ end
+ it '指定のコマを返す' do
+ l = LicenseGroup.show @lg.id
+ l.should eq @lg
+ end
+ end
+ describe '関連テーブルプションに於いて' do
+ context 'オプションがないとき' do
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.show_include_opt
+ r.has_key?(:licenses).should be_true
+ end
+ end
+ end
+ describe 'json単体出力オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = LicenseGroup.show_json_include_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = LicenseGroup.show_json_include_opt[:include]
+ r.should have(1).items
+ end
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.show_json_include_opt[:include]
+ r.has_key?(:licenses).should be_true
+ end
+ end
+ describe '一覧取得に於いて' do
+ before do
+ @lg = Factory :license_group, :name => "1"
+ end
+ it 'リストを返す' do
+ l = LicenseGroup.list
+ l.should eq [@lg]
+ end
+ it '名前順で並んでいる' do
+ @lg2 = Factory :license_group, :name => "5", :url => 'http://test.ptn/10'
+ l = LicenseGroup.list
+ l.should eq [@lg, @lg2]
+ end
+ end
+ describe 'list関連テーブルプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = LicenseGroup.list_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = LicenseGroup.list_opt[:include]
+ r.should have(1).items
+ end
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.list_opt[:include]
+ r.has_key?(:licenses).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = LicenseGroup.list_json_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = LicenseGroup.list_json_opt[:include]
+ r.should have(1).items
+ end
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.list_json_opt[:include]
+ r.has_key?(:licenses).should be_true
+ end
+ end
+
+end
end
describe '検証に於いて' do
before do
- @l = Factory.build :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @l = Factory.build :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
it 'オーソドックスなデータなら通る' do
@l.should be_valid
end
+ context 'license_group_idを検証するとき' do
+ it 'テストデータの確認' do\r
+ @l.license_group_id = @lg.id\r
+ @l.should be_valid\r
+ end\r
+ it 'nullなら失敗する' do
+ @l.license_group_id = ''
+ @l.should_not be_valid
+ end
+ it '数値でなければ失敗する' do\r
+ @l.license_group_id = 'a'\r
+ @l.should_not be_valid\r
+ end\r
+ it '存在するライセンスグループでなければ失敗する' do\r
+ @l.license_group_id = 0\r
+ @l.should_not be_valid\r
+ end\r
+ end
context 'nameを検証するとき' do
+ it 'テストデータの確認' do\r
+ @l.name = 'a'*50\r
+ @l.should be_valid\r
+ end\r
it 'nullなら失敗する' do
@l.name = ''
@l.should_not be_valid
@l.name = 'a'*51
@l.should_not be_valid
end
+ it '重複していたら失敗する' do
+ lc = Factory :license
+ @l.should_not be_valid
+ end
+ end
+ context 'captionを検証するとき' do
+ it 'テストデータの確認' do\r
+ @l.caption = 'a'*30\r
+ @l.should be_valid\r
+ end\r
+ it 'nullなら失敗する' do
+ @l.caption = ''
+ @l.should_not be_valid
+ end
+ it '31文字以上なら失敗する' do
+ @l.caption = 'a'*31
+ @l.should_not be_valid
+ end
end
context 'urlを検証するとき' do
+ it 'テストデータの確認' do\r
+ @l.url = 'http://test.jp/aaaaa' + 'a' * 180
+ @l.save!\r
+ @l.should be_valid\r
+ end\r
it 'nullなら失敗する' do
@l.url = ''
@l.should_not be_valid
end
it '201文字以上なら失敗する' do
- @l.url = 'a'*201
+ @l.url = 'http://test.jp/aaaaa' + 'a' * 181
@l.should_not be_valid
end
- it '重複していたら失敗する' do
- lc = Factory :license
+ it 'url形式でなら失敗する' do
+ @l.url = 'a'*200\r
+ @l.should_not be_valid\r
+ end
+ end
+ context 'system_picture_idを検証するとき' do
+ it 'テストデータの確認' do\r
+ @l.system_picture_id = @sp.id\r
+ @l.should be_valid\r
+ end\r
+ it 'nullなら失敗する' do
+ @l.system_picture_id = ''
@l.should_not be_valid
end
- it 'url形式でなら失敗する' do
- @l.url = ''
- pending
+ it '数値でなければ失敗する' do\r
+ @l.system_picture_id = 'a'\r
+ @l.should_not be_valid\r
+ end\r
+ it '存在するシステム画像でなければ失敗する' do\r
+ @l.system_picture_id = 0\r
+ @l.should_not be_valid\r
+ end\r
+ end
+ end
+
+ describe '更新に於いて' do
+ before do
+ @lg = Factory :license_group
+ @f = Rails.root + 'spec/json/license_group.json'
+ @t = File.open(@f, 'r').read
+ @j = JSON.parse @t
+ @n = @j.keys.first
+ @a = @j.values.first
+ @attr = @a["licenses_attributes"]
+ @ln = @attr.keys.first
+ @la = @attr.values.first
+ @la["license_group_id"] = @lg.id
+ end
+ context 'つつがなく終わるとき' do
+ it 'システム画像置換を依頼する' do
+ License.stub(:replace_system_picture).with(any_args).and_return(true)
+ License.should_receive(:replace_system_picture).with(any_args).exactly(1)
+ License.stub(:modify_object).with(any_args).and_return(License.new)
+ License.any_instance.stub(:save).with(any_args).and_return(true)
+ r = License.store(@ln, @la)
+ end
+ it 'データ更新準備を依頼する' do
+ License.stub(:replace_system_picture).with(any_args).and_return(true)
+ License.stub(:modify_object).with(any_args).and_return(License.new)
+ License.should_receive(:modify_object).with(any_args).exactly(1)
+ License.any_instance.stub(:save).with(any_args).and_return(true)
+ r = License.store(@ln, @la)
+ end
+ it '保存を依頼する' do
+ License.stub(:replace_system_picture).with(any_args).and_return(true)
+ License.stub(:modify_object).with(any_args).and_return(License.new)
+ License.any_instance.stub(:save).with(any_args).and_return(true)
+ License.any_instance.should_receive(:save).with(any_args).exactly(1)
+ r = License.store(@ln, @la)
+ end
+ it 'オブジェクトを返す' do
+ r = License.store(@ln, @la)
+ r.is_a?(License).should be_true
+ r.name.should eq @ln
+ r.url.should eq @la["url"]
+ end
+ it 'ライセンスが作成されている' do
+ lambda {
+ r = License.store(@ln, @la)
+ }.should change License, :count
+ end
+ it 'システム画像が作成されている' do
+ lambda {
+ r = License.store(@ln, @la)
+ }.should change SystemPicture, :count
+ end
+ end
+ context 'システム画像置換が失敗するとき' do
+ before do
+ License.stub(:replace_system_picture).with(any_args).and_return(false)
+ License.stub(:modify_object).with(any_args).and_return(License.new)
+ end
+ it '全体エラーメッセージがセットされている' do
+ r = License.store(@ln, @la)
+ r.errors[:base].should_not be_blank
+ end
+ it 'ライセンスが作成されていない' do
+ lambda {
+ r = License.store(@ln, @la)
+ }.should_not change License, :count
end
end
end
- describe '対象ライセンスの取得に於いて' do
+ describe '複数の更新に於いて' do
before do
- @lc = Factory :license
+ @lg = Factory :license_group
+ @fs = Rails.root + 'spec/json/license_groups.json'
+ @ts = File.open(@fs, 'r').read
+ @js = JSON.parse @ts
+ @n = @js.keys.last
+ @a = @js.values.last
+ @attr = @a["licenses_attributes"]
end
- context 'urlが一致するライセンスがないとき' do
- it '新規ライセンスを準備して返す' do
- cl = Factory.build(:common_license, :url => 'http://domain.no')
- r = License.update_license cl
- r.should be_a_new License
+ context '2件データでつつがなく終わるとき' do
+ it '更新を2回依頼する' do
+ License.stub(:store).with(any_args).and_return(License.new)
+ License.should_receive(:store).with(any_args).exactly(2)
+ License.any_instance.stub(:valid?).with(any_args).and_return(true)
+ r = License.stores(@attr, @lg.id)
+ end
+ it '失敗件数0を返す' do
+ License.stub(:store).with(any_args).and_return(License.new)
+ License.any_instance.stub(:valid?).with(any_args).and_return(true)
+ r = License.stores(@attr, @lg.id)
+ r.should eq 0
end
end
- context 'urlが一致するライセンスがあるとき' do
- it '該当ライセンスを返す' do
- r = License.update_license @lc
- r.is_a?(License).should be_true
- r.should_not be_a_new License
- r.url.should eq @lc.url
- r.name.should eq @lc.name
+ context '2件データで失敗するとき' do
+ it '更新を2回依頼する' do
+ License.stub(:store).with(any_args).and_return(License.new)
+ License.should_receive(:store).with(any_args).exactly(2)
+ License.any_instance.stub(:valid?).with(any_args).and_return(false)
+ r = License.stores(@attr, @lg.id)
+ end
+ it '失敗件数2を返す' do
+ License.stub(:store).with(any_args).and_return(License.new)
+ License.any_instance.stub(:valid?).with(any_args).and_return(false)
+ r = License.stores(@attr, @lg.id)
+ r.should eq 2
end
end
- #コモンライセンスとオリジナルライセンスをまたいだUrl重複チェックはここでやるよりない
- #コモンライセンスが新規オブジェクトなのにライセンスが取得できるのは、
- #そのUrlがオリジナルライセンスから登録されているということ
- context '新規でユニークチェックするとき' do
- it 'ライセンスの全体エラーに重複メッセージを入れて返す' do
- cl = Factory.build(:common_license, :url => 'http://domain.no')
- License.stub(:find_by_url).with(any_args).and_return(@lc)
- r = License.update_license cl
- r.errors[:base].should_not be_empty
+ context 'attrsがnilなどのHashでないとき' do
+ it '処理にかけず0を返す' do
+ r = License.stores(nil, @lg.id)
+ r.should eq 0
end
end
end
- #作成が
describe '単体取得に於いて' do
before do
- @lcl = Factory :license
- @cl = Factory :common_license, :license_id => @lcl.id
- @lol = Factory :license, :url => 'http://test.ptn/10'
- @ol = Factory :original_license, :license_id => @lol.id, :url => 'http://test.ptn/10'
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @l = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
it '指定のコマを返す' do
- l = License.show @lcl.id
- l.should eq @lcl
+ l = License.show @l.id
+ l.should eq @l
end
end
describe '関連テーブルプションに於いて' do
context 'オプションがないとき' do
- it 'ã\82³ã\83¢ã\83³ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81¨ã\82ªã\83ªã\82¸ã\83\8aã\83«ã\83©ã\82¤ã\82»ã\83³ã\82¹を含んでいる' do
+ it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\82°ã\83«ã\83¼ã\83\97を含んでいる' do
r = License.show_include_opt
- r.should eq [:common_license, :original_license]
+ r.should eq [:license_group]
end
end
- context 'オプションで原画を含ませたとき' do
- it 'ã\82³ã\83¢ã\83³ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81¨ã\82ªã\83ªã\82¸ã\83\8aã\83«ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81¨å\8e\9fç\94»ã\83\87ã\83¼ã\82¿を含んでいる' do
- r = License.show_include_opt(:include => :original_picture)
- r.should eq [:common_license, :original_license, :original_picture]
+ context 'オプションで素材ライセンスを含ませたとき' do
+ it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\82°ã\83«ã\83¼ã\83\97ã\81¨ç´ æ\9d\90ã\83©ã\82¤ã\82»ã\83³ã\82¹を含んでいる' do
+ r = License.show_include_opt(:include => :resource_picture_license)
+ r.should eq [:license_group, :resource_picture_license]
end
end
end
r = License.show_json_include_opt
r.has_key?(:include).should be_true
end
- it '2つの項目を含んでいる' do
+ it '1つの項目を含んでいる' do
r = License.show_json_include_opt[:include]
- r.should have(2).items
+ r.should have(1).items
end
- it 'ã\82³ã\83¢ã\83³ã\83©ã\82¤ã\82»ã\83³ã\82¹を含んでいる' do
+ it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\82°ã\83«ã\83¼ã\83\97を含んでいる' do
r = License.show_json_include_opt[:include]
- r.has_key?(:common_license).should be_true
- end
- it 'オリジナルライセンスを含んでいる' do
- r = License.show_json_include_opt[:include]
- r.has_key?(:original_license).should be_true
+ r.has_key?(:license_group).should be_true
end
end
describe '一覧取得に於いて' do
before do
- @lcl = Factory :license, :name => 'peta2.0'
- @cl = Factory :common_license, :license_id => @lcl.id
- end
- context 'page補正について' do
- it '文字列から数値に変換される' do
- License.page('8').should eq 8
- end
- it 'nilの場合は1になる' do
- License.page().should eq 1
- end
- it '0以下の場合は1になる' do
- License.page('0').should eq 1
- end
- end
- context 'page_size補正について' do
- it '文字列から数値に変換される' do
- License.page_size('7').should eq 7
- end
- it 'nilの場合はLicense.default_page_sizeになる' do
- License.page_size().should eq License.default_page_size
- end
- it '0以下の場合はLicense.default_page_sizeになる' do
- License.page_size('0').should eq License.default_page_size
- end
- it 'License.max_page_sizeを超えた場合はLicense.max_page_sizeになる' do
- License.page_size('1000').should eq License.max_page_size
- end
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @l = Factory :license, :name => 'peta2.0', :license_group_id => @lg.id, :system_picture_id => @sp.id
+ @lg2 = Factory :license_group, :name => 'pubdm'
end
it 'リストを返す' do
- pl = License.list
- pl.should eq [@lcl]
+ l = License.list
+ l.should eq [@l]
end
it '名前順で並んでいる' do
- @lol = Factory :license, :name => 'peta1.0', :url => 'http://test.ptn/10'
- @ol = Factory :original_license, :license_id => @lol.id, :name => 'peta1.0', :url => 'http://test.ptn/10'
+ @l2 = Factory :license, :name => 'peta3.0', :url => 'http://pe.ta/3.0', :license_group_id => @lg.id, :system_picture_id => @sp.id
+ @l3 = Factory :license, :name => 'pd1.0', :url => 'http://pb.dm/1.0', :license_group_id => @lg2.id, :system_picture_id => @sp.id
l = License.list
- l.should eq [@lol, @lcl]
- end
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
- @lol2 = Factory :license, :name => 'peta2.1', :url => 'http://test.ptn/21'
- @ol2 = Factory :original_license, :license_id => @lol2.id, :name => 'peta2.1', :url => 'http://test.ptn/21'
- @lol3 = Factory :license, :name => 'peta2.2', :url => 'http://test.ptn/22'
- @ol3 = Factory :original_license, :license_id => @lol3.id, :name => 'peta2.2', :url => 'http://test.ptn/22'
- @lol4 = Factory :license, :name => 'peta2.3', :url => 'http://test.ptn/23'
- @ol4 = Factory :original_license, :license_id => @lol4.id, :name => 'peta2.3', :url => 'http://test.ptn/23'
- @lol5 = Factory :license, :name => 'peta2.4', :url => 'http://test.ptn/24'
- @ol5 = Factory :original_license, :license_id => @lol5.id, :name => 'peta2.4', :url => 'http://test.ptn/24'
- License.stub(:default_page_size).and_return(2)
- end
- it '通常は2件を返す' do
- l = License.list
- l.should have(2).items
- end
- it 'page=1なら末尾2件を返す' do
- #名前順で並んでいる
- l = License.list( {}, 1)
- l.should eq [@lcl, @lol2]
- end
- it 'page=2なら中間2件を返す' do
- l = License.list({}, 2)
- l.should eq [@lol3, @lol4]
- end
- it 'page=3なら先頭1件を返す' do
- l = License.list({}, 3)
- l.should eq [@lol5]
- end
+ l.should eq [@l3, @l, @l2]
end
end
describe 'list関連テーブルプションに於いて' do
r = License.list_opt
r.has_key?(:include).should be_true
end
- it '2つの項目を含んでいる' do
+ it '1つの項目を含んでいる' do
r = License.list_opt[:include]
- r.should have(2).items
+ r.should have(1).items
end
- it 'ã\82³ã\83¢ã\83³ã\83©ã\82¤ã\82»ã\83³ã\82¹を含んでいる' do
+ it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\82°ã\83«ã\83¼ã\83\97を含んでいる' do
r = License.list_opt[:include]
- r.has_key?(:common_license).should be_true
- end
- it 'オリジナルライセンスを含んでいる' do
- r = License.list_opt[:include]
- r.has_key?(:original_license).should be_true
+ r.has_key?(:license_group).should be_true
end
end
describe 'json一覧出力オプションに於いて' do
r = License.list_json_opt
r.has_key?(:include).should be_true
end
- it '2つの項目を含んでいる' do
- r = License.list_json_opt[:include]
- r.should have(2).items
- end
- it 'コモンライセンスを含んでいる' do
+ it '1つの項目を含んでいる' do
r = License.list_json_opt[:include]
- r.has_key?(:common_license).should be_true
+ r.should have(1).items
end
- it 'ã\82ªã\83ªã\82¸ã\83\8aã\83«ã\83©ã\82¤ã\82»ã\83³ã\82¹を含んでいる' do
+ it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\82°ã\83«ã\83¼ã\83\97を含んでいる' do
r = License.list_json_opt[:include]
- r.has_key?(:original_license).should be_true
+ r.has_key?(:license_group).should be_true
end
end
-# -*- encoding: utf-8 -*-
-#オリジナルライセンス
-require 'spec_helper'
-
-describe OriginalLicense do
- before do
- #テストデータを用意してね
- @f = Rails.root + 'spec/json/original_license.json'
- @t = File.open(@f, 'r').read
- @j = JSON.parse @t
- @fs = Rails.root + 'spec/json/original_licenses.json'
- @ts = File.open(@fs, 'r').read
- @js = JSON.parse @ts
- @fes = Rails.root + 'spec/json/invalid_original_licenses.json'
- @tes = File.open(@fes, 'r').read
- @jes = JSON.parse @tes
- end
- describe '検証に於いて' do
- before do
- @l = Factory :license
- end
-
- it 'オーソドックスなデータなら通る' do
- @ol = Factory.build :original_license, :license_id => @l.id
- @ol.should be_valid
- end
-
- context 'nameを検証するとき' do
- before do
- @ol = Factory.build :original_license, :license_id => @l.id
- end
- it 'テストデータの確認' do
- @ol.name = 'CC by'
- @ol.should be_valid
- end
- it 'nullなら失敗する' do
- @ol.name = ''
- @ol.should_not be_valid
- end
- it '51文字以上なら失敗する' do
- @ol.name = 'a'*51
- @ol.should_not be_valid
- end
- end
- context 'urlを検証するとき' do
- before do
- @ol = Factory.build :original_license, :license_id => @l.id
- end
- it 'テストデータの確認' do
- @ol.url = 'CC by'
- @ol.should be_valid
- end
- it 'nullなら失敗する' do
- @ol.url = ''
- @ol.should_not be_valid
- end
- it '201文字以上なら失敗する' do
- @ol.url = 'a'*201
- @ol.should_not be_valid
- end
- it '重複していたら失敗する' do
- cl = Factory :original_license, :license_id => @l.id
- @ol.should_not be_valid
- end
- it 'url形式でなら失敗する' do
- @ol.url = ''
- pending
- end
- end
- context 'license_idを検証するとき' do
- before do
- @ol = Factory.build :original_license
- end
- it 'テストデータの確認' do
- @ol.license_id = @l.id
- @ol.should be_valid
- end
- it 'nullなら失敗する' do
- @ol.license_id = nil
- @ol.should_not be_valid
- end
- it '数値でなければ失敗する' do
- @ol.license_id = 'a'
- @ol.should_not be_valid
- end
- it '存在するlicenseでなければ失敗する' do
- @ol.license_id = 0
- @ol.should_not be_valid
- end
- end
- end
-
- describe '対象オリジナルライセンスの取得に於いて' do
- before do
- @lc = Factory :license
- @ol = Factory :original_license, :license_id => @lc.id
- end
- context 'urlが一致するオリジナルライセンスがないとき' do
- it '新規オリジナルライセンスを準備して返す' do
- r = OriginalLicense.update_original_license Factory.attributes_for(:original_license, :url => 'http://domain.no')
- r.should be_a_new OriginalLicense
- end
- end
- context 'urlが一致するオリジナルライセンスがあるとき' do
- it '該当オリジナルライセンスを返す' do
- prm = Factory.attributes_for(:original_license)
- r = OriginalLicense.update_original_license prm
- r.is_a?(OriginalLicense).should be_true
- r.should_not be_a_new OriginalLicense
- r[:url].should eq prm[:url]
- end
- end
- end
-
- describe 'オリジナルライセンス更新に於いて' do
- before do
- @lc = Factory :license
- @ol = Factory :original_license, :license_id => @lc.id, :url => @lc.url
- @attr = Factory.attributes_for(:original_license, :name => 'exist case', :url => @lc.url)
- @newattr = Factory.attributes_for(:original_license, :url => 'http://domain.no')
- end
- context 'つつがなく終わるとき' do
- it '対象オリジナルライセンスを問い合わせている' do
- OriginalLicense.stub(:update_original_license).with(any_args).and_return(OriginalLicense.new(@attr))
- OriginalLicense.should_receive(:update_original_license).exactly(1)
- OriginalLicense.store @attr
- end
- context '新規のとき' do
- it 'オリジナルライセンスを保存しようとしている' do
- OriginalLicense.any_instance.should_receive(:save).exactly(1)
- OriginalLicense.store @newattr
- end
- it 'オリジナルライセンスが作成されている' do
- lambda {
- OriginalLicense.store @newattr
- }.should change OriginalLicense, :count
- end
- context 'ライセンスとの連動' do
- it 'ライセンスが作成されている' do
- lambda {
- OriginalLicense.store @newattr
- }.should change License, :count
- end
- it '両者がリンクされている' do
- r = OriginalLicense.store @newattr
- l = License.find(r.license_id)
- l.should be_true
- end
- it '属性が一致している' do
- r = OriginalLicense.store @newattr
- l = License.find(r.license_id)
- l.url.should eq r.url
- l.name.should eq r.name
- end
- end
- end
- context '更新のとき' do
- it 'オリジナルライセンスを保存しようとしている' do
- OriginalLicense.any_instance.should_receive(:save).exactly(1)
- OriginalLicense.store @attr
- end
- it 'オリジナルライセンスの数に変化がない' do
- lambda {
- OriginalLicense.store @attr
- }.should_not change OriginalLicense, :count
- end
- context 'ライセンスとの連動' do
- it 'ライセンスの数に変化がない' do
- lambda {
- OriginalLicense.store @attr
- }.should_not change License, :count
- end
- it '両者がリンクされている' do
- r = OriginalLicense.store @attr
- l = License.find(r.license_id)
- l.should be_true
- end
- it '属性が一致している' do
- r = OriginalLicense.store @attr
- l = License.find(r.license_id)
- l.url.should eq r.url
- l.name.should eq r.name
- end
- end
- end
- it '属性が一致している' do
- r = OriginalLicense.store @newattr
- r.url.should eq @newattr[:url]
- r.name.should eq @newattr[:name]
- end
- it '保存されたOriginalLicenseオブジェクトを返す' do
- r = OriginalLicense.store @newattr
- r.should_not be_a_new OriginalLicense
- end
- end
- context 'ライセンスの作成に失敗するとき' do
- before do
- License.any_instance.stub(:save).with(any_args).and_return(false)
- end
- context '新規のとき' do
- it 'ライセンスに変化がない' do
- lambda {
- r = OriginalLicense.store @newattr
- }.should_not change License, :count
- end
- it 'オリジナルライセンスに変化がない' do
- lambda {
- r = OriginalLicense.store @newattr
- }.should_not change OriginalLicense, :count
- end
- end
- context '更新のとき' do
- it 'オリジナルライセンス属性に変化がない' do
- lambda {
- r = OriginalLicense.store @attr
- }.should_not change License.find(@ol.id), :name
- end
- it 'ライセンス属性に変化がない' do
- lambda {
- r = OriginalLicense.store @attr
- }.should_not change License.find(@lc.id), :name
- end
- end
- end
- context 'オリジナルライセンスの作成に失敗するとき' do
- before do
- OriginalLicense.any_instance.stub(:save).with(any_args).and_return(false)
- end
- context '新規のとき' do
- it 'ライセンスに変化がない' do
- lambda {
- r = OriginalLicense.store @newattr
- }.should_not change License, :count
- end
- it 'オリジナルライセンスに変化がない' do
- lambda {
- r = OriginalLicense.store @newattr
- }.should_not change OriginalLicense, :count
- end
- end
- context '更新のとき' do
- it 'オリジナルライセンス属性に変化がない' do
- lambda {
- r = OriginalLicense.store @attr
- }.should_not change License.find(@ol.id), :name
- end
- it 'ライセンス属性に変化がない' do
- lambda {
- r = OriginalLicense.store @attr
- }.should_not change License.find(@lc.id), :name
- end
- end
- end
- end
-
- describe '単体取得に於いて' do
- before do
- @ol = Factory.build :original_license
- @ol.store
- end
- it '指定のライセンスを返す' do
- l = OriginalLicense.show @ol.id
- l.should eq @ol
- end
- context '関連テーブルオプションがないとき' do
- it 'ライセンスだけを含んでいる' do
- r = OriginalLicense.show_include_opt
- r.should eq [:license]
- end
- end
- context '関連テーブルオプションで作家を含ませたとき' do
- it 'ライセンスと作家を含んでいる' do
- r = OriginalLicense.show_include_opt(:include => :author)
- r.should eq [:license, :author]
- end
- end
- end
- describe '一覧取得に於いて' do
- before do
- @ol = Factory.build :original_license
- @ol.store
- end
- context 'page補正について' do
- it '文字列から数値に変換される' do
- OriginalLicense.page('8').should eq 8
- end
- it 'nilの場合は1になる' do
- OriginalLicense.page().should eq 1
- end
- it '0以下の場合は1になる' do
- OriginalLicense.page('0').should eq 1
- end
- end
- context 'page_size補正について' do
- it '文字列から数値に変換される' do
- OriginalLicense.page_size('7').should eq 7
- end
- it 'nilの場合はOriginalLicense.default_page_sizeになる' do
- OriginalLicense.page_size().should eq OriginalLicense.default_page_size
- end
- it '0以下の場合はOriginalLicense.default_page_sizeになる' do
- OriginalLicense.page_size('0').should eq OriginalLicense.default_page_size
- end
- it 'OriginalLicense.max_page_sizeを超えた場合はOriginalLicense.max_page_sizeになる' do
- OriginalLicense.page_size('1000').should eq OriginalLicense.max_page_size
- end
- end
- it 'リストを返す' do
- l = OriginalLicense.list
- l.should eq [@ol]
- end
- it '名前順で並んでいる' do
- n = Factory.build :original_license, :url => 'http://tes.to', :name => 'peta2.2'
- n.store
- l = OriginalLicense.list
- l.should eq [@ol, n]
- end
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
- @license2 = Factory.build :original_license, :url => 'http://tes.to2', :name => 'peta2.2'
- @license2.store
- @license3 = Factory.build :original_license, :url => 'http://tes.to3', :name => 'peta2.3'
- @license3.store
- @license4 = Factory.build :original_license, :url => 'http://tes.to4', :name => 'peta2.4'
- @license4.store
- @license5 = Factory.build :original_license, :url => 'http://tes.to5', :name => 'peta2.5'
- @license5.store
- OriginalLicense.stub(:default_page_size).and_return(2)
- end
- it '通常は2件を返す' do
- l = OriginalLicense.list
- l.should have(2).items
- end
- it 'page=1なら末尾2件を返す' do
- #時系列で並んでいる
- l = OriginalLicense.list({}, 1)
- l.should eq [@ol, @license2]
- end
- it 'page=2なら中間2件を返す' do
- l = OriginalLicense.list({}, 2)
- l.should eq [@license3, @license4]
- end
- it 'page=3なら先頭1件を返す' do
- l = OriginalLicense.list({}, 3)
- l.should eq [@license5]
- end
- end
- end
-
- describe 'Json解析に於いて' do
- before do
- end
- context 'テキストを渡されたとき' do
- it 'Json解析している' do
- JSON.should_receive(:parse).with(@t).exactly(1)
- r = OriginalLicense.parse @t
- end
- it '単数データならHashで返す' do
- r = OriginalLicense.parse @t
- r.is_a?(Hash).should be_true
- end
- it '複数データならArrayで返す' do
- r = OriginalLicense.parse @ts
- r.is_a?(Array).should be_true
- end
- end
- context 'パース失敗したとき' do
- it 'Falseを返す' do
- JSON.should_receive(:parse).with(any_args).and_raise('StandardError')
- r = OriginalLicense.parse @t
- r.should be_false
- end
- end
- end
-
- describe 'Jsonの繰り返し処理に於いて' do
- before do
- end
- context '単体データを渡されたとき' do
- it '一回処理' do
- r = []
- OriginalLicense.each_license @j do |i|
- r << i
- end
- r.size.should eq 1
- end
- end
- context '複数を渡されたとき' do
- it '二回処理' do
- r = []
- OriginalLicense.each_license @js do |i|
- r << i
- end
- r.size.should eq 2
- end
- end
- end
-
- describe 'テキスト取り込みに於いて' do
- #成功でTrue、パース失敗でFalse、失敗は保存エラーのモデルを配列で返す
- #Licenseとの連動が完成していること
- before do
- end
- context 'つつがなく終わるとき' do
- it 'Json解析を依頼する' do
- OriginalLicense.should_receive(:parse).with(any_args).exactly(1)
- OriginalLicense.stub(:parse).with(any_args).and_return(@j)
- OriginalLicense.import(@t)
- end
- it '繰り返し処理を依頼する' do
- OriginalLicense.should_receive(:each_license).with(any_args).exactly(1)
- OriginalLicense.import(@t)
- end
- it 'ライセンス更新を一回依頼する' do
- OriginalLicense.stub(:store).with(any_args).and_return(OriginalLicense.new)
- OriginalLicense.any_instance.stub(:valid?).with(any_args).and_return(true)
- OriginalLicense.should_receive(:store).with(any_args).exactly(1)
- OriginalLicense.import(@t)
- end
- it 'オリジナルライセンスが追加される' do
- lambda {
- OriginalLicense.import(@t)
- }.should change OriginalLicense, :count
- end
- it '[]を返す' do
- OriginalLicense.import(@t).should eq []
- end
- end
- context '複数データがつつがなく終わるとき' do
- it 'ライセンス更新を二回依頼する' do
- OriginalLicense.stub(:store).with(any_args).and_return(OriginalLicense.new)
- OriginalLicense.any_instance.stub(:valid?).with(any_args).and_return(true)
- OriginalLicense.should_receive(:store).with(any_args).exactly(2)
- OriginalLicense.import(@ts)
- end
- it 'オリジナルライセンスが二個追加される' do
- lambda {
- OriginalLicense.import(@ts)
- }.should change(OriginalLicense, :count).by 2
- end
- it '[]を返す' do
- OriginalLicense.import(@ts).should eq []
- end
- end
- #例外ケース
- context 'Json解析に失敗したとき' do
- before do
- OriginalLicense.stub(:parse).with(any_args).and_return(false)
- end
- it 'オリジナルライセンスの数に変化がない' do
- lambda {
- OriginalLicense.import(@t)
- }.should_not change OriginalLicense, :count
- end
- it 'Falseを返す' do
- OriginalLicense.import(@t).should be_false
- end
- end
- context 'オリジナルライセンス作成に失敗したとき' do
- before do
- OriginalLicense.any_instance.stub(:save).with(any_args).and_return(false)
- OriginalLicense.any_instance.stub(:valid?).with(any_args).and_return(false)
- end
- it 'オリジナルライセンスの数に変化がない' do
- lambda {
- OriginalLicense.import(@t)
- }.should_not change OriginalLicense, :count
- end
- it '配列を返す' do
- r = OriginalLicense.import(@t)
- r.is_a?(Array).should be_true
- end
- it '配列の中身は一件' do
- r = OriginalLicense.import(@t)
- r.should have(1).items
- end
- it 'オリジナルライセンスオブジェクトが入っている' do
- r = OriginalLicense.import(@t)
- r.first.is_a?(OriginalLicense).should be_true
- end
- end
- context '複数のオリジナルライセンス作成に失敗したとき' do
- #三件中、二件の失敗、一件を成功させ、成功データは戻り値に含まないことを確認する
- it 'オリジナルライセンスの数に変化がない' do
- lambda {
- OriginalLicense.import(@tes)
- }.should_not change OriginalLicense, :count
- end
- it '途中で保存に失敗しても全件更新依頼する' do
- OriginalLicense.stub(:store).with(any_args).and_return(OriginalLicense.new)
- OriginalLicense.should_receive(:store).with(any_args).exactly(3)
- OriginalLicense.import(@tes)
- end
- it '配列を返す' do
- r = OriginalLicense.import(@tes)
- r.is_a?(Array).should be_true
- end
- it '配列の中身は2件' do
- r = OriginalLicense.import(@tes)
- r.should have(2).items
- end
- it '配列の中身は失敗したオリジナルライセンスオブジェクトが入っている' do
- r = OriginalLicense.import(@tes)
- r[0].is_a?(OriginalLicense).should be_true
- r[0]["name"].should eq 'fail1'
- r[1].is_a?(OriginalLicense).should be_true
- r[1]["name"].should eq 'fail2'
- end
- end
- end
-
- describe 'ファイル取り込みに於いて' do
- before do
- OriginalLicense.stub(:import).with(any_args).and_return(true)
- end
- context 'つつがなく終わるとき' do
- before do
- OriginalLicense.stub(:import).with(any_args).and_return(true)
- end
- it 'ファイルを開いてテキストを読む' do
- File.should_receive(:open).with(@f, 'r').exactly(1)
- OriginalLicense.import_file(@f)
- end
- it 'テキスト取り込みを依頼する' do
- OriginalLicense.should_receive(:import).with(any_args).exactly(1)
- OriginalLicense.import_file(@f)
- end
- #テキスト取り込み成功でTrueが返る
- it 'Trueを返す' do
- OriginalLicense.import_file(@f).should be_true
- end
- end
- context 'ファイルが開けないとき' do
- before do
- File.stub(:open).with(any_args).and_raise('StandardError')
- end
- it 'ファイルエラーのメッセージを出力する' do
- pending
- end
- it 'Falseを返す' do
- OriginalLicense.import_file(@f).should be_false
- end
- end
- #失敗したときは、失敗したライセンスが配列で返る
- context 'テキスト取り込みが失敗したとき' do
- before do
- OriginalLicense.stub(:import).with(any_args).and_return(false)
- end
- it '各オリジナルライセンスのエラーメッセージを出力する' do
- pending
- end
- it 'Falseを返す' do
- OriginalLicense.import_file(@f).should be_false
- end
- end
- end
-
-end
@other_user = Factory( :user_yas)
@other_author = @other_user.author
@other_artist = Factory :artist_yas, :author_id => @other_author.id
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
describe '検証に於いて' do
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@op = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
@rp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id
@panel = Factory :panel, :author_id => @author.id
describe Panel do\r
before do\r
Factory :admin\r
- @license = Factory :license\r
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory( :user_yas)\r
@author = @user.author\r
@artist = Factory :artist_yas, :author_id => @author.id\r
--- /dev/null
+require 'spec_helper'
+
+describe ResourcePictureLicense do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@other_user = Factory( :user_yas)
@other_author = @other_user.author
@other_artist = Factory :artist_yas, :author_id => @other_author.id
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@original_picture = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id\r
class Mgk ; class Image ; end ; end
@user = Factory( :user_yas)
@author = @user.author
@artist = Factory :artist_yas, :author_id => @author.id
- @license = Factory :license
@panel = Factory :panel, :author_id => @author.id
@speech_balloon_template = Factory :speech_balloon_template
@jes = JSON.parse @tes
@admin = Factory :admin
- @license = Factory :license
end
describe '検証に於いて' do
describe Speech do\r
before do\r
Factory :admin\r
- @license = Factory :license\r
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @l = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = Factory( :user_yas)\r
@author = @user.author\r
\r
describe SystemPicture do
before do
@admin = Factory :admin
- @license = Factory :license
end
describe '検証に於いて' do