gem 'aws-s3'
gem 'validates_existence'
gem "validate_url"
+gem "standard_licenses"
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6-x86-mingw32)
+ standard_licenses (0.0.1)
+ rails (~> 3.1.1)
therubyracer-heroku (0.8.1.pre3)
thor (0.14.6)
tilt (1.3.3)
rspec-rails
sass-rails (~> 3.1.4)
sqlite3
+ standard_licenses
therubyracer-heroku
uglifier (>= 1.0.3)
validate_url
respond_to do |format|
if @original_picture_license_group.valid?
- format.html { render :template => "#{@ctl}/new" }
- format.js { render :template => "#{@ctl}/new" }
+ format.html { render :template => "#{@ctl}/attributes/new" }
+ format.js { render :template => "#{@ctl}/attributes/new" }
else
format.html { render action: "new" }
format.js { render action: "new" }
+++ /dev/null
-class StandardLicensesController < ApplicationController
- layout 'test' if Pettanr::TestLayout
- before_filter :authenticate_user!, :only => [:new, :create]
- before_filter :authenticate_artist, :only => [:new, :create]
-
- private
-
- def authenticate_artist
- if @author.artist?
- true
- else
- respond_to do |format|
- format.html { redirect_to new_artist_path, :status => :found }
- format.js { render "artists/new" }
- format.json {
- raise ActiveRecord::Forbidden
- }
- end
- false
- end
- end
-
- public
-
- # GET /standard_licenses/new
- # GET /standard_licenses/new.js
- def new
- @original_picture = OriginalPicture.show params[:original_picture_id], @artist
- @original_picture_license_group = OriginalPictureLicenseGroup.new(params[:original_picture_license_group])
- @license_group = LicenseGroup.show @original_picture_license_group.license_group_id
- @standard_license = StandardLicense.new
- @standard_license.supply_default @artist
-
- respond_to do |format|
- format.html # new.html.erb
- format.js
- end
- end
-
- # POST /standard_licenses
- # POST /standard_licenses.js
- def create
- @original_picture = OriginalPicture.show params[:original_picture_id], @artist
- @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
- @license_group = LicenseGroup.show @original_picture_license_group.license_group_id
- @standard_license = StandardLicense.new params[:standard_license]
- @license = License.show @standard_license.license_id
- @resource_picture = @original_picture.resource_picture || ResourcePicture.new
- @resource_picture.attributes = {
- :original_picture_id => @original_picture.id, :license_id => @license.id,
- :artist_name => @standard_license.artist_name, :classname => @license_group.classname,
- :credit => @standard_license.credit, :settings => @license.settings
- }
- respond_to do |format|
- if @standard_license.valid?
- format.html { render :template => "resource_pictures/new" }
- format.js { render :template => "resource_pictures/new" }
- else
- format.html { render action: "new" }
- format.js { render action: "new" }
- end
- end
- end
-
-end
+++ /dev/null
-module StandardLicensesHelper
-end
class OriginalPicture < ActiveRecord::Base
belongs_to :artist
+ belongs_to :original_picture_license_group
has_one :resource_picture
validates :ext, :presence => true, :length => {:maximum => 4}, :inclusion => {:in => ['png', 'jpeg', 'gif']}\r
end
def credit_template
- "#{self.classname.tableize}/credit"
+ "#{self.classname.tableize}/attributes/credit"
end
def credit_data
end
def credit_template
- "#{self.classname.tableize}/credit"
+ "#{self.classname.tableize}/attributes/credit"
end
def credit_data
+++ /dev/null
-class StandardLicense < ActiveRecord::Base
- belongs_to :license
-
- validates :license_id, :presence => true, :numericality => true, :existence => true
- validates :artist_name, :presence => true
-
- def supply_default ar
- self.artist_name = ar.name
- end
-
- def credit
- {
- :system_picture_id => self.license.system_picture_id
- }.to_json.to_s
- end
-
-end
<a href="/">ぺったんR</a>
<div>
<% if user_signed_in? %>
- <%= link_to "my home", :controller => '/home' %>
- <%= link_to "ログアウト", destroy_user_session_path, :method => :delete %>
+ <%= link_to "my home", '/home' %>
+ <%= link_to "ログアウト", main_app.destroy_user_session_path, :method => :delete %>
<% else %>
- <%= link_to "ログイン", new_user_session_path %>
+ <%= link_to "ログイン", main_app.new_user_session_path %>
<% end %>
</div>
<div>
<% if admin_signed_in? %>
- <%= link_to "system", :controller => '/system' %>
- <%= link_to "ログアウト", destroy_admin_session_path, :method => :delete %>
+ <%= link_to "system", '/system' %>
+ <%= link_to "ログアウト", main_app.destroy_admin_session_path, :method => :delete %>
<% else %>
- <%= link_to "管理者", new_admin_session_path %>
+ <%= link_to "管理者", main_app.new_admin_session_path %>
<% end %>
</div>
<div>
<p class="alert"><%= alert %></p>
</div>
<div>
- <%= link_to "browse", :controller => '/system', :action => :browse%>
- <%= link_to "approve", :controller => '/system', :action => :waiting_list%>
- <%= link_to "token", :controller => '/system', :action => :auth_token%>
+ <%= link_to "browse", '/system/browse' %>
+ <%= link_to "approve", '/system/waiting_list' %>
+ <%= link_to "token", '/system/auth_token' %>
</div>
<%= yield %>
\r
<div>\r
<% if user_signed_in? %>\r
- <%= link_to "my home", :controller => '/home' %>\r
- <%= link_to "sign out", destroy_user_session_path, :method => :delete %>\r
+ <%= link_to "my home", '/home' %>\r
+ <%= link_to "sign out", main_app.destroy_user_session_path, :method => :delete %>\r
<% else %>\r
- <%= link_to "sign in", new_user_session_path %>\r
+ <%= link_to "sign in", main_app.new_user_session_path %>\r
<% end %>\r
</div>\r
<div>\r
<% if admin_signed_in? %>\r
- <%= link_to "system", :controller => '/system' %>\r
- <%= link_to "sign out", destroy_admin_session_path, :method => :delete %>\r
+ <%= link_to "system", '/system' %>\r
+ <%= link_to "sign out", main_app.destroy_admin_session_path, :method => :delete %>\r
<% else %>\r
- <%= link_to "sign in", new_admin_session_path %>\r
+ <%= link_to "sign in", main_app.new_admin_session_path %>\r
<% end %>\r
</div>\r
<div>\r
<p class="notice"><%= notice %></p>\r
<p class="alert"><%= alert %></p>\r
-<%= link_to 'comics', comics_path %>\r
-<%= link_to 'panels', panels_path %>\r
-<%= link_to 'original_pictures', original_pictures_path %>\r
-<%= link_to 'resource_pictures', resource_pictures_path %>\r
-<%= link_to 'panel_pictures', panel_pictures_path %>\r
-<%= link_to 'speech_balloons', speech_balloons_path %>\r
-<%= link_to 'balloons', balloons_path %>\r
-<%= link_to 'speeches', speeches_path %>\r
+<%= link_to 'comics', main_app.comics_path %>\r
+<%= link_to 'panels', main_app.panels_path %>\r
+<%= link_to 'original_pictures', main_app.original_pictures_path %>\r
+<%= link_to 'resource_pictures', main_app.resource_pictures_path %>\r
+<%= link_to 'panel_pictures', main_app.panel_pictures_path %>\r
+<%= link_to 'speech_balloons', main_app.speech_balloons_path %>\r
+<%= link_to 'balloons', main_app.balloons_path %>\r
+<%= link_to 'speeches', main_app.speeches_path %>\r
: \r
-<%= link_to 'speech_balloon_templates', speech_balloon_templates_path %>\r
+<%= link_to 'speech_balloon_templates', main_app.speech_balloon_templates_path %>\r
: \r
-<%= link_to 'artists', artists_path %>\r
-<%= link_to 'system_pictures', system_pictures_path %>\r
+<%= link_to 'artists', main_app.artists_path %>\r
+<%= link_to 'system_pictures', main_app.system_pictures_path %>\r
</div>\r
<%= yield %>\r
\r
<div class="field">
<%= f.label :license_group_id %><br />
- <%= f.collection_select :license_group_id, LicenseGroup.list.map {|l| [l.name, l.id] }, :last, :first %>
+ <%= f.collection_select :license_group_id, LicenseGroup.list.map {|l| [l.caption, l.id] }, :last, :first %>
<%= f.hidden_field :original_picture_id %>
</div>
<%= hidden_field_tag :original_picture_id, @original_picture.id %>
<a href="<%= @original_picture.url %>">browse picture</a>
</p>
<p>
-Select License
+<%= link_to 'Select License', :controller => 'original_picture_license_groups', :action => :new, :original_picture_id => @original_picture.id %>
</p>
<div>
<%= render 'original_picture_license_groups/form' %>
-<%= form_for(@resource_picture) do |f| %>
+<%= form_for(@resource_picture, :url => '/resource_pictures', :method => :post) do |f| %>
<%= hidden_field_tag :original_picture_id, @original_picture.id %>
<%= f.hidden_field :settings %>
<div>
- <%= link_to h(@license_group.caption), license_group_path(@license_group) %>
- <%= link_to h(@license.caption), license_path(@license) %>
+ <%= link_to h(@license_group.caption), main_app.license_group_path(@license_group) %>
+ <%= link_to h(@license.caption), main_app.license_path(@license) %>
</div>
<div>
artist name:<%= @resource_picture.artist_name %>
</div>
- <%= render @resource_picture.classname.tableize + '/confirm' %>
+ <%= render :partial => @resource_picture.classname.tableize + '/attributes/confirm' %>
<div class="actions">
<%= f.submit %>
<p id="notice"><%= notice %></p>
+credit
+<p>
+ <%= @resource_picture.credit %>
+</p>
+settings
+<p>
+ <%= @resource_picture.settings %>
+</p>
<p>
<a href="<%= @resource_picture.url %>">ノーマル</a>
<th>artist</th>
<th>license_id</th>
<th>original_picture_id</th>
+ <th>artist_name</th>
+ <th>classname</th>
+ <th>picture</th>
<th>created_at</th>
<th>updated_at</th>
</tr>
-
<% @resource_pictures.each do |resource_picture| %>
<tr>
<td><%= link_to resource_picture.id, :action => :browse, :id => resource_picture.id%></td>
<td><%= link_to resource_picture.artist_id, :controller => 'artists', :action => :browse, :id => resource_picture.artist_id %></td>
<td><%= link_to resource_picture.license_id, :controller => 'licenses', :action => :browse, :id => resource_picture.license_id %></td>
<td><%= link_to resource_picture.original_picture_id, :controller => 'original_pictures', :action => :browse, :id => resource_picture.original_picture_id%></td>
+ <td><%= resource_picture.artist_name %></td>
+ <td><%= resource_picture.classname %></td>
+ <td><%= link_to resource_picture.picture_id, main_app.picture_path(resource_picture.picture_id) %></td>
<td><%= resource_picture.created_at %></td>
<td><%= resource_picture.updated_at %></td>
</tr>
+++ /dev/null
-<% @sp = SystemPicture.find(@resource_picture.credit_data["system_picture_id"]) %>
-<%= content_tag(:a,
- tag(:img, :src => @sp.url, :alt => h(@license_group.caption.to_s + '[' + @license.caption.to_s + ']')),
- :href => @license.url )
-%>
+++ /dev/null
-<div>
-<%= content_tag(:a,
- tag(:img, :src => picture.license.system_picture.url, :alt => h(picture.license.license_group.caption.to_s + '[' + picture.license.caption.to_s + ']')),
- :href => picture.license.url )
-%>
-</div>
-著作者:<%= link_to h(picture.artist_name), :controller => 'artists', :action => :show, :id => picture.artist.id %>
+++ /dev/null
-<%
- unless @standard_license
- @standard_license = StandardLicense.new
- @standard_license.supply_default @artist
- end
- %>
-<%= form_for(@standard_license) do |f| %>
- <% if @standard_license.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@standard_license.errors.count, "error") %> prohibited this comic from being saved:</h2>
-
- <ul>
- <% @standard_license.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <div class="field">
- <%= f.label :license_id %><br />
- <%= f.collection_select :license_id, @license_group.licenses.map {|l| [l.name, l.id] }, :last, :first %>
- <%= f.text_field :artist_name %>
- </div>
- <%= hidden_field_tag :original_picture_id, @original_picture.id %>
- <%= hidden_field_tag 'original_picture_license_group[original_picture_id]', @original_picture_license_group.original_picture_id %>
- <%= hidden_field_tag 'original_picture_license_group[license_group_id]', @original_picture_license_group.license_group_id %>
-
- <div class="actions">
- <%= f.submit %>
- </div>
-<% end %>
+++ /dev/null
-<%= render 'standard_licenses/form' %>
+++ /dev/null
-$("#oplg").html("<%= escape_javascript(render('form')) -%>");
devise_for :users , :controllers => { :registrations => "user_registrations" }
devise_for :admins
-
+
+ mount StandardLicenses::Engine => "/standard_licenses"
+
resources :authors do
collection do
get :index
post :create
end
end
- resources :standard_licenses do
- new do
- get :new
- end
- collection do
- post :create
- end
- end
resources :panels do
new do
get :new
@author = @user.author
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id
@sp = FactoryGirl.create :system_picture
- @lg = FactoryGirl.create :license_group, :classname => 'OriginalPicture'
+ @lg = FactoryGirl.create :license_group, :classname => 'StandardLicense'
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
end
it '@ctlにコントローラを用意している' do
post :create, @attr
- assigns(:ctl).should eq 'original_pictures'
+ assigns(:ctl).should eq 'standard_licenses'
end
it '@original_picture_license_groupにデータを用意している' do
post :create, @attr
end
it 'ライセンスクラスの新規作成テンプレートnewを描画する' do
post :create, @attr
- response.should render_template("original_pictures/new")
+ response.should render_template("standard_licenses/attributes/new")
end
end
context 'js形式' do
end
it 'ライセンスクラスの新規作成部分テンプレートnew.jsを描画する' do
post :create, @attrj
- response.should render_template("original_pictures/new")
+ response.should render_template("standard_licenses/attributes/new")
end
end
end
+++ /dev/null
-# -*- encoding: utf-8 -*-
-#ライセンス選択
-require 'spec_helper'
-
-describe StandardLicensesController do
- before do
- FactoryGirl.create :admin
- @user = FactoryGirl.create( :user_yas)
- @author = @user.author
- @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
- @sp = FactoryGirl.create :system_picture
- @lg = FactoryGirl.create :license_group, :classname => 'OriginalPicture'
- @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
- @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
- end
-
- describe '新規作成フォーム表示に於いて' do
- before do
- sign_in @user
- end
- context 'つつがなく終わるとき' do
- before do
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id}}
- @attrj = @attr.merge({:format => :js})
- end
- it 'ステータスコード200 OKを返す' do
- get :new, @attr
- response.should be_success
- end
- it '原画モデルに単体取得を問い合わせている' do
- OriginalPicture.stub(:show).with(any_args()).and_return(@op)
- OriginalPicture.should_receive(:show).with(any_args()).exactly(1)\r
- get :new, @attr
- end
- it '@original_pictureにデータを用意している' do
- get :new, @attr
- assigns(:original_picture).should eq @op
- end
- it '@original_picture_license_groupに新規データを用意している' do
- get :new, @attr
- assigns(:original_picture_license_group).should be_a_new(OriginalPictureLicenseGroup)
- end
- it 'ライセンスグループモデルに単体取得を問い合わせている' do
- LicenseGroup.stub(:show).with(any_args()).and_return(@lg)
- LicenseGroup.should_receive(:show).with(any_args()).exactly(1)\r
- get :new, @attr
- end
- it '@license_groupにデータを用意している' do
- get :new, @attr
- assigns(:license_group).should eq @lg
- end
- it '@standard_licenseにライセンス選択新規データを用意している' do
- get :new, @attr
- assigns(:standard_license).should be_a_new(StandardLicense)
- end
- it 'ライセンス選択にデフォルト値補充を依頼している' do
- StandardLicense.any_instance.should_receive(:supply_default).exactly(1)\r
- get :new, @attr
- end
- context 'html形式' do
- it 'ページテンプレートnewを描画する' do
- get :new, @attr
- response.should render_template("new")
- end
- end
- context 'js形式' do
- it '部分テンプレートnew.jsを描画する' do
- get :new, @attrj
- response.should render_template("new")
- end
- end
- end
- context '作家権限がないとき' do
- before do
- sign_out @user
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id}}
- @attrj = @attr.merge({:format => :js})
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- get :new, @attr
- response.status.should eq 302
- end
- it 'サインインページへ遷移する' do
- get :new, @attr
- response.body.should redirect_to '/users/sign_in'
- end
- end
- context 'js形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- get :new, @attrj
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- get :new, @attrj
- response.message.should match(/Unauthorized/)
- end
- end
- end
- context '作家が絵師でないとき' do
- before do
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id}}
- @attrj = @attr.merge({:format => :js})
- Author.any_instance.stub(:artist?).and_return(false)
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- get :new, @attr
- response.status.should eq 302
- end
- it '絵師登録ページへ遷移する' do
- get :new, @attr
- response.should redirect_to new_artist_path
- end
- end
- context 'js形式' do
- it 'ステータスコード200 Okを返す' do
- get :new, @attrj
- response.status.should eq 200
- end
- it '絵師登録部分テンプレートartists/new.jsを描画する' do
- get :new, @attrj
- response.should render_template("artists/new")
- end
- end
- end
- end
-
- describe '新規作成に於いて' do
- before do
- sign_in @user
- end
- context '事前チェックしておく' do
- before do
- StandardLicense.any_instance.stub(:valid?).with(any_args()).and_return(true)
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id},
- :standard_license => {:license_id => @license.id, :artist_name => @artist.name}
- }
- @attrj = @attr.merge({:format => :js})
- end
- it '原画モデルに単体取得を問い合わせている' do
- OriginalPicture.stub(:show).with(any_args()).and_return(@op)
- OriginalPicture.should_receive(:show).exactly(1)\r
- post :create, @attr
- end
- it '@original_pictureにデータを用意している' do
- post :create, @attr
- assigns(:original_picture).should eq @op
- end
- it '@original_picture_license_groupにデータを用意している' do
- post :create, @attr
- assigns(:original_picture_license_group).should be_a_new OriginalPictureLicenseGroup
- end
- it 'ライセンスグループモデルに単体取得を問い合わせている' do
- LicenseGroup.stub(:show).with(any_args()).and_return(@lg)
- LicenseGroup.should_receive(:show).exactly(1)\r
- post :create, @attr
- end
- it '@license_groupにデータを用意している' do
- post :create, @attr
- assigns(:license_group).should eq @lg
- end
- it '@standard_licenseにデータを用意している' do
- post :create, @attr
- assigns(:standard_license).should be_a_new StandardLicense
- end
- it '@licenseにデータを用意している' do
- post :create, @attr
- assigns(:license).should eq @license
- end
- it '@creditにデータを用意している' do
- post :create, @attr
- assigns(:credit).should eq nil
- end
- it 'モデルに検証依頼する' do
- StandardLicense.any_instance.stub(:valid?).with(any_args()).and_return(true)
- StandardLicense.any_instance.should_receive(:valid?).exactly(1)
- post :create, @attr
- end
- end
- context 'つつがなく終わるとき' do
- before do
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id},
- :standard_license => {:license_id => @license.id, :artist_name => @artist.name}
- }
- @attrj = @attr.merge({:format => :js})
- end
- it "検証が通る" do
- post :create, @attr
- assigns(:standard_license).valid?.should eq true
- end
- it "DBに変化がない" do
- lambda {
- post :create, @attr
- }.should_not change StandardLicense, :count
- end
- context 'html形式' do
- it 'ステータスコード200 OKを返す' do
- post :create, @attr
- response.should be_success
- end
- it 'ライセンスクラスの新規作成テンプレートnewを描画する' do
- post :create, @attr
- response.should render_template("resource_pictures/new")
- end
- end
- context 'js形式' do
- it 'ステータスコード200 OKを返す' do
- post :create, @attrj
- response.should be_success
- end
- it 'ライセンスクラスの新規作成部分テンプレートnew.jsを描画する' do
- post :create, @attrj
- response.should render_template("resource_pictures/new")
- end
- end
- end
- context '作家権限がないとき' do
- before do
- sign_out @user
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id},
- :standard_license => {:license_id => @license.id, :artist_name => @artist.name}
- }
- @attrj = @attr.merge({:format => :js})
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :create, @attr
- response.status.should eq 302
- end
- it 'サインインページへ遷移する' do
- post :create, @attr
- response.body.should redirect_to '/users/sign_in'
- end
- end
- context 'json形式' do
- it 'ステータスコード401 Unauthorizedを返す' do
- post :create, @attrj
- response.status.should eq 401
- end
- it '応答メッセージにUnauthorizedを返す' do
- post :create, @attrj
- response.message.should match(/Unauthorized/)
- end
- end
- end
- context '作家が絵師でないとき' do
- before do
- Author.any_instance.stub(:artist?).and_return(false)
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id},
- :standard_license => {:license_id => @license.id, :artist_name => @artist.name}
- }
- @attrj = @attr.merge({:format => :js})
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- post :create, @attr
- response.status.should eq 302
- end
- it '絵師登録ページへ遷移する' do
- post :create, @attr
- response.should redirect_to new_artist_path
- end
- end
- context 'js形式' do
- it 'ステータスコード200 OKを返す' do
- post :create, @attrj
- response.status.should eq 200
- end
- it '絵師登録ページへ遷移する' do
- post :create, @attrj
- response.should render_template("artists/new")
- end
- end
- end
- context '検証、保存に失敗した' do
- before do
- StandardLicense.any_instance.stub(:valid?).and_return(false)
- @oplg = FactoryGirl.build :oplg, :original_picture_id => @op.id, :license_group_id => @lg.id
- @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @oplg.original_picture_id, :license_group_id => @oplg.license_group_id},
- :standard_license => {:license_id => @license.id, :artist_name => @artist.name}
- }
- @attrj = @attr.merge({:format => :js})
- end
- it "未保存の原画ライセンスグループを保持している" do
- post :create, @attr
- assigns(:standard_license).should be_a_new(StandardLicense)
- end
- context 'html形式' do
- it 'ステータスコード200 OKを返す' do
- post :create, @attr
- response.status.should eq 200
- end
- it '新規ページを描画する' do
- post :create, @attr
- response.should render_template("new")
- end
- end
- context 'js形式' do
- it 'ステータスコード200 OKを返す' do
- post :create, @attrj
- response.status.should eq 200
- end
- it '新規ページを描画する' do
- post :create, @attrj
- response.should render_template("new")
- end
- end
- end
- end
-
-end
oplg.license_group_id 1
end
- factory :standard_license, :class => StandardLicense do |sl|
- sl.license_id 1
- sl.artist_name 'no name'
- end
-
factory :resource_picture, :class => ResourcePicture do |rp|
rp.ext 'png'
rp.width 222
+++ /dev/null
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the StandardLicensesHelper. For example:
-#
-# describe StandardLicensesHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe StandardLicensesHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
+++ /dev/null
-# -*- encoding: utf-8 -*-
-#ライセンス選択
-require 'spec_helper'
-
-describe StandardLicense do
- before do
- FactoryGirl.create :admin
- @user = FactoryGirl.create( :user_yas)
- @author = @user.author
- @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
- @other_user = FactoryGirl.create( :user_yas)
- @other_author = @other_user.author
- @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
- @sp = FactoryGirl.create :system_picture
- @lg = FactoryGirl.create :license_group
- @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
- @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
- end
-
- describe '検証に於いて' do
- before do
- end
-
- it 'オーソドックスなデータなら通る' do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- @sl.should be_valid
- end
-
- context 'license_idを検証するとき' do
- before do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- end
- it 'テストデータの確認' do
- @sl.license_id = @license.id
- @sl.should be_valid
- end
- it 'nullなら失敗する' do
- @sl.license_id = nil
- @sl.should_not be_valid
- end
- it '数値でなければ失敗する' do
- @sl.license_id = 'a'
- @sl.should_not be_valid
- end
- it '存在するライセンスグループでなければ失敗する' do
- @sl.license_id = 0
- @sl.should_not be_valid
- end
- end
- context 'artist_nameを検証するとき' do
- before do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- end
- it 'テストデータの確認' do
- @sl.artist_name = 'a'
- @sl.should be_valid
- end
- it 'nullなら失敗する' do
- @sl.artist_name = nil
- @sl.should_not be_valid
- end
- end
- end
- describe '補充に於いて' do
- it '原画idを補充している' do
- @sl = StandardLicense.new
- @sl.artist_name = nil
- @sl.supply_default @artist
- @sl.artist_name.should eq @artist.name
- end
- end
- describe 'クレジットデータに於いて' do
- before do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- end
- it 'jsonテキストを返す' do
- r = @sl.credit
- lambda{
- JSON.parse @sl.credit
- }.should_not raise_error
- end
- it 'system_picture_idを含んでいて値はライセンスに割り当てたシステム画像になっている' do
- r = JSON.parse @sl.credit
- r.has_key?('system_picture_id').should be_true
- r['system_picture_id'].should eq @sl.license.system_picture_id
- end
- end
-end