<%= render 'original_picture_license_groups/form' %>
diff --git a/app/views/resource_pictures/_form.html.erb b/app/views/resource_pictures/_form.html.erb
index 809410cf..b8ef2701 100644
--- a/app/views/resource_pictures/_form.html.erb
+++ b/app/views/resource_pictures/_form.html.erb
@@ -1,4 +1,4 @@
-<%= 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 %>
@@ -13,14 +13,14 @@
<%= f.hidden_field :settings %>
- <%= 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) %>
- <%= render @resource_picture.classname.tableize + '/confirm' %>
+ <%= render :partial => @resource_picture.classname.tableize + '/attributes/confirm' %>
<%= f.submit %>
diff --git a/app/views/resource_pictures/browse.html.erb b/app/views/resource_pictures/browse.html.erb
index 76b40949..f43b1718 100644
--- a/app/views/resource_pictures/browse.html.erb
+++ b/app/views/resource_pictures/browse.html.erb
@@ -1,4 +1,12 @@
<%= notice %>
+credit
+
+ <%= @resource_picture.credit %>
+
+settings
+
+ <%= @resource_picture.settings %>
+
ãã¼ãã«
diff --git a/app/views/resource_pictures/list.html.erb b/app/views/resource_pictures/list.html.erb
index 6e9fd441..2141011a 100644
--- a/app/views/resource_pictures/list.html.erb
+++ b/app/views/resource_pictures/list.html.erb
@@ -10,10 +10,12 @@
artist |
license_id |
original_picture_id |
+
artist_name |
+
classname |
+
picture |
created_at |
updated_at |
-
<% @resource_pictures.each do |resource_picture| %>
<%= link_to resource_picture.id, :action => :browse, :id => resource_picture.id%> |
@@ -24,6 +26,9 @@
<%= link_to resource_picture.artist_id, :controller => 'artists', :action => :browse, :id => resource_picture.artist_id %> |
<%= link_to resource_picture.license_id, :controller => 'licenses', :action => :browse, :id => resource_picture.license_id %> |
<%= link_to resource_picture.original_picture_id, :controller => 'original_pictures', :action => :browse, :id => resource_picture.original_picture_id%> |
+ <%= resource_picture.artist_name %> |
+ <%= resource_picture.classname %> |
+ <%= link_to resource_picture.picture_id, main_app.picture_path(resource_picture.picture_id) %> |
<%= resource_picture.created_at %> |
<%= resource_picture.updated_at %> |
diff --git a/app/views/standard_licenses/_confirm.html.erb b/app/views/standard_licenses/_confirm.html.erb
deleted file mode 100644
index 9d0eb302..00000000
--- a/app/views/standard_licenses/_confirm.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<% @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 )
-%>
diff --git a/app/views/standard_licenses/_credit.html.erb b/app/views/standard_licenses/_credit.html.erb
deleted file mode 100644
index cfa175fd..00000000
--- a/app/views/standard_licenses/_credit.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-
-<%= 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 )
-%>
-
-èä½è
:<%= link_to h(picture.artist_name), :controller => 'artists', :action => :show, :id => picture.artist.id %>
diff --git a/app/views/standard_licenses/_form.html.erb b/app/views/standard_licenses/_form.html.erb
deleted file mode 100644
index 44e3daa2..00000000
--- a/app/views/standard_licenses/_form.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-<%
- unless @standard_license
- @standard_license = StandardLicense.new
- @standard_license.supply_default @artist
- end
- %>
-<%= form_for(@standard_license) do |f| %>
- <% if @standard_license.errors.any? %>
-
-
<%= pluralize(@standard_license.errors.count, "error") %> prohibited this comic from being saved:
-
-
- <% @standard_license.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
- <% end %>
-
-
- <%= f.label :license_id %>
- <%= f.collection_select :license_id, @license_group.licenses.map {|l| [l.name, l.id] }, :last, :first %>
- <%= f.text_field :artist_name %>
-
- <%= 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 %>
-
-
- <%= f.submit %>
-
-<% end %>
diff --git a/app/views/standard_licenses/new.html.erb b/app/views/standard_licenses/new.html.erb
deleted file mode 100644
index d1e2498a..00000000
--- a/app/views/standard_licenses/new.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render 'standard_licenses/form' %>
diff --git a/app/views/standard_licenses/new.js.erb b/app/views/standard_licenses/new.js.erb
deleted file mode 100644
index ed93c2b1..00000000
--- a/app/views/standard_licenses/new.js.erb
+++ /dev/null
@@ -1 +0,0 @@
-$("#oplg").html("<%= escape_javascript(render('form')) -%>");
diff --git a/config/routes.rb b/config/routes.rb
index e2e60d66..02264de4 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,7 +2,9 @@ Pettanr::Application.routes.draw do
devise_for :users , :controllers => { :registrations => "user_registrations" }
devise_for :admins
-
+
+ mount StandardLicenses::Engine => "/standard_licenses"
+
resources :authors do
collection do
get :index
@@ -123,14 +125,6 @@ Pettanr::Application.routes.draw do
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
diff --git a/spec/controllers/original_picture_license_groups_controller_spec.rb b/spec/controllers/original_picture_license_groups_controller_spec.rb
index 9791a6c0..598fa8a8 100644
--- a/spec/controllers/original_picture_license_groups_controller_spec.rb
+++ b/spec/controllers/original_picture_license_groups_controller_spec.rb
@@ -9,7 +9,7 @@ describe OriginalPictureLicenseGroupsController do
@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
@@ -143,7 +143,7 @@ describe OriginalPictureLicenseGroupsController do
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
@@ -176,7 +176,7 @@ describe OriginalPictureLicenseGroupsController do
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
@@ -186,7 +186,7 @@ describe OriginalPictureLicenseGroupsController 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
diff --git a/spec/controllers/standard_licenses_controller_spec.rb b/spec/controllers/standard_licenses_controller_spec.rb
deleted file mode 100644
index d802b8ac..00000000
--- a/spec/controllers/standard_licenses_controller_spec.rb
+++ /dev/null
@@ -1,319 +0,0 @@
-# -*- 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)
- 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)
- 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)
- 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)
- 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)
- 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
diff --git a/spec/factories.rb b/spec/factories.rb
index c84bf258..18cb73bd 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -100,11 +100,6 @@ FactoryGirl.define do
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
diff --git a/spec/helpers/standard_licenses_helper_spec.rb b/spec/helpers/standard_licenses_helper_spec.rb
deleted file mode 100644
index 7caad3a3..00000000
--- a/spec/helpers/standard_licenses_helper_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-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
diff --git a/spec/models/standard_license_spec.rb b/spec/models/standard_license_spec.rb
deleted file mode 100644
index bfcbc304..00000000
--- a/spec/models/standard_license_spec.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- 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
--
2.11.0