OSDN Git Service

特定商取引に関する法律に基づく表記をHTMLでも記述できるように修正
authorTaro Matsuzawa <tmatsuzawa@kbmj.com>
Thu, 22 Jul 2010 10:02:33 +0000 (19:02 +0900)
committerTaro Matsuzawa <tmatsuzawa@kbmj.com>
Thu, 22 Jul 2010 10:02:33 +0000 (19:02 +0900)
18 files changed:
app/controllers/admin/laws_controller.rb [new file with mode: 0644]
app/controllers/admin/shops_controller.rb
app/controllers/portal_controller.rb
app/helpers/admin/laws_helper.rb [new file with mode: 0644]
app/models/law.rb
app/views/admin/base/_shop_submenu.html.erb
app/views/admin/laws/_form.html.erb [new file with mode: 0644]
app/views/admin/laws/_submenu.html.erb [new file with mode: 0644]
app/views/admin/laws/index.html.erb [new file with mode: 0644]
app/views/portal/_footer_mobile.html.erb
app/views/portal/show_tradelaw.html.erb
app/views/portal/show_tradelaw_mobile.html.erb
config/locales/translation_ja.yml
db/migrate/20100511095346_add_retailer_and_mobile_fields_to_laws.rb [new file with mode: 0644]
db/migrate/20100512025204_set_data_to_laws_new_columns.rb [new file with mode: 0644]
spec/controllers/admin/laws_controller_spec.rb [new file with mode: 0644]
spec/fixtures/laws.yml
spec/models/laws_spec.rb

diff --git a/app/controllers/admin/laws_controller.rb b/app/controllers/admin/laws_controller.rb
new file mode 100644 (file)
index 0000000..353deff
--- /dev/null
@@ -0,0 +1,32 @@
+class Admin::LawsController < Admin::BaseController
+  before_filter :admin_permission_check_commerce_low
+  
+  def index
+    @law = Law.find_by_retailer_id(session[:admin_user].retailer_id)
+    unless @law
+      @law = Law.new
+    end
+  end
+
+  def update
+    @law = Law.find_by_retailer_id(session[:admin_user].retailer_id)
+    unless @law
+      @law = Law.new
+      @law.retailer_id = session[:admin_user].retailer_id
+    end
+    @law.attributes = params[:law]
+
+    unless @law.valid?
+      flash.now[:error] = "保存に失敗しました"
+      render :action => "index"
+      return
+    end
+    if @law && @law.save
+      flash.now[:notice] = "データを保存しました"
+    else
+      flash.now[:error] = "保存に失敗しました"
+    end
+    redirect_to :action => "index"
+  end
+
+end
index 3721e9f..a348234 100644 (file)
@@ -13,7 +13,7 @@ class Admin::ShopsController < Admin::BaseController
     :only => [:kiyaku_index, :kiyaku_create, :kiyaku_update, :destroy, :sort]
   before_filter :admin_permission_check_privacy, :only => [:privacy, :privacy_update]
   before_filter :admin_permission_check_setting, :only => [:settings, :settings_update]
-  before_filter :master_shop_check, :except => [:delivery_index, :delivery_new, :delivery_edit, :delivery_create, :delivery_update, :destroy, :sort]
+  before_filter :master_shop_check, :except => [:delivery_index, :delivery_new, :delivery_edit, :delivery_create, :delivery_update, :destroy, :sort, :get_address]
 
   def index
     @shop = Shop.find(:first)
index 5b114d6..aae3437 100644 (file)
@@ -11,7 +11,17 @@ class PortalController < BaseController
   end
 
   def show_tradelaw
-    @law = Law.find(:first)
+    if params[:retailer_id]
+      @law = Law.find_by_retailer_id(params[:retailer_id])
+    end
+    unless @law
+      @law = Law.find_by_retailer_id(Retailer::DEFAULT_ID)
+    end
+    if @law.retailer_id == Retailer::DEFAULT_ID
+      @shopname = Shop.find(:first).name
+    else
+      @shopname = Retailer.find(@law.retailer_id).name
+    end
   end
 
   def privacy
diff --git a/app/helpers/admin/laws_helper.rb b/app/helpers/admin/laws_helper.rb
new file mode 100644 (file)
index 0000000..9bebe04
--- /dev/null
@@ -0,0 +1,2 @@
+module Admin::LawsHelper
+end
index 77f51e3..3ffb29d 100644 (file)
@@ -2,12 +2,20 @@ class Law < ActiveRecord::Base
 
   acts_as_paranoid
 
+  TEXT_MAXLENGTH = 200
+
+  RENDER_TYPE_TEXT = 0
+  RENDER_TYPE_HTML = 1
+
   belongs_to :prefecture
 
   validates_presence_of :company,:manager,:zipcode01, :zipcode02,
                       :prefecture_id,:address_city,:address_detail,
                       :tel01,:tel02,:tel03,:email,:url,
-                      :necessary_charge,:order_method,:payment_method,:payment_time_limit,:delivery_time,:return_exchange
+                      :necessary_charge,:order_method,:payment_method,:payment_time_limit,:delivery_time,:return_exchange,
+                      :necessary_charge_mobile,:order_method_mobile,:payment_method_mobile,:payment_time_limit_mobile,:delivery_time_mobile,:return_exchange_mobile,
+                      :retailer_id,:render_type
+                      
 
   validates_length_of :company,:manager,:address_city,:address_detail,:email,:url, :maximum => 50
 
@@ -20,13 +28,16 @@ class Law < ActiveRecord::Base
 
   validates_inclusion_of :prefecture_id, :in => 1..47,:message => "を選択してください"
 
-  validates_length_of :necessary_charge,:order_method,:payment_method,:payment_time_limit,:delivery_time,:return_exchange , :maximum => 200
+  validates_length_of :necessary_charge,:order_method,:payment_method,:payment_time_limit,:delivery_time,:return_exchange, :maximum => TEXT_MAXLENGTH
+  validates_length_of :necessary_charge_mobile,:order_method_mobile,:payment_method_mobile,:payment_time_limit_mobile,:delivery_time_mobile,:return_exchange_mobile, :maximum => TEXT_MAXLENGTH
 
   validates_format_of :url, :with=>%r{^(https?://.*|)$}, :message=>"が不正です"
 
-  def validate_on_create
-    errors.add "","複数のデータは登録できません。"  if Law.count > 0
-  end
+  validates_inclusion_of :render_type, :in => 0..1, :message => "を選択してください"
+
+#  def validate_on_create
+#    errors.add "","複数のデータは登録できません。"  if Law.count > 0
+#  end
 
   # 表示系のメソッド
   def zipcode
@@ -44,4 +55,9 @@ class Law < ActiveRecord::Base
   def fax 
     "#{fax01}-#{fax02}-#{fax03}"
   end
+
+  def html?
+    return render_type == RENDER_TYPE_HTML
+  end
+
 end
index 6589087..357d062 100644 (file)
@@ -11,7 +11,7 @@
     <ul id="display1" style="display:block">
       <% if session[:admin_user].master_shop? %>
         <li><%= link_to 'SHOPマスタ', {:controller => 'shops', :action => 'index'} %></li>
-        <li><%= link_to '特定商取引法', {:controller => 'shops', :action => 'tradelaw_index'} %></li>
+        <li><%= link_to '特定商取引法', {:controller => 'laws', :action => 'index'} %></li>
       <% end %>
       <% unless session[:admin_user].master_shop? %>
         <li><%= link_to '販売元管理', {:controller => 'retailers', :action => 'edit', :id => session[:admin_user].retailer_id} %></li>
diff --git a/app/views/admin/laws/_form.html.erb b/app/views/admin/laws/_form.html.erb
new file mode 100644 (file)
index 0000000..24bcb94
--- /dev/null
@@ -0,0 +1,101 @@
+<%=h flash[:notice] %>
+<%=h flash[:error] %>
+<%= error_messages_for :law %>
+<% fields_for :law do | f | %>
+  <p class="req"><span class="pnt">※</span>は必須入力です</p>
+  <table cellspacing="1" cellpadding="0" class="data" >
+    <tr>
+      <th>販売業者 <span class="pnt">※</span></th>
+      <td><%= f.text_field :company, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>運営責任者 <span class="pnt">※</span></th>
+      <td><%= f.text_field :manager, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>郵便番号 <span class="pnt">※</span></th>
+      <td>
+        〒<%= f.text_field :zipcode01, :size=>3 %>-&nbsp;&nbsp;<%= f.text_field :zipcode02, :size=>4 %>
+        <input name="zipcode_input" value="住所入力" onclick="address_by_zip('law_zipcode01','law_zipcode02', 'law_prefecture_name', 'law_address_city', 'law_address_detail', 'law_prefecture_id', 'admin/shops', '<%=h ActionController::Base.relative_url_root %>');" type="button" class="btn_s" />
+      </td>
+    </tr>
+    <tr>
+      <th>所在地 <span class="pnt">※</span></th>
+      <td>
+        <%= f.collection_select :prefecture_id, Prefecture.find(:all, :order=>'position'), :id, :name %><br /><br />
+        <%= f.text_field :address_city, :class=>"data_m" %><br /><br />
+        <%= f.text_field :address_detail, :class=>"data_l" %>
+      </td>
+    </tr>
+    <tr>
+      <th>TEL <span class="pnt">※</span></th>
+      <td><%= f.text_field :tel01, :size=>4 %>-&nbsp;&nbsp;<%= f.text_field :tel02, :size=>4 %>-&nbsp;&nbsp;<%= f.text_field :tel03, :size=>4 %></td>
+    </tr>
+    <tr>
+      <th>FAX</th>
+      <td><%= f.text_field :fax01, :size=>4 %>-&nbsp;&nbsp;<%= f.text_field :fax02, :size=>4 %>-&nbsp;&nbsp;<%= f.text_field :fax03, :size=>4 %></td>
+    </tr>
+    <tr>
+      <th>メールアドレス<span class="pnt">※</span></th>
+      <td><%= f.text_field :email, :class => "data_m" %></td>
+    </tr>
+    <tr>
+      <th>URL <span class="pnt">※</span></th>
+      <td><%= f.text_field :url, :class=>"data_m" %></td>
+    </tr>
+    <tr>
+      <th>表示方法 <span class="pnt">*</span></th>
+      <td><%= f.radio_button :render_type, Law::RENDER_TYPE_TEXT %>テキスト表示(自動改行)&nbsp;
+        <%= f.radio_button :render_type, Law::RENDER_TYPE_HTML %>HTML表示
+      </td>
+    </tr>
+    <tr>
+      <th>商品代金以外の必要代金<span class="pnt">※</span></th>
+      <td><%= f.text_area :necessary_charge, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>注文方法 <span class="pnt">※</span></th>
+      <td><%= f.text_area :order_method, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>支払方法 <span class="pnt">※</span></th>
+      <td><%= f.text_area :payment_method, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>支払期限 <span class="pnt">※</span></th>
+      <td><%= f.text_area :payment_time_limit, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>引き渡し時期 <span class="pnt">※</span></th>
+      <td><%= f.text_area :delivery_time, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>返品・交換について <span class="pnt">※</span></th>
+      <td><%= f.text_area :return_exchange, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>商品代金以外の必要代金(モバイル) <span class="pnt">※</span></th>
+      <td><%= f.text_area :necessary_charge_mobile, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>注文方法(モバイル) <span class="pnt">※</span></th>
+      <td><%= f.text_area :order_method_mobile, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>支払方法(モバイル) <span class="pnt">※</span></th>
+      <td><%= f.text_area :payment_method_mobile, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>支払期限(モバイル) <span class="pnt">※</span></th>
+      <td><%= f.text_area :payment_time_limit_mobile, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>引き渡し時期(モバイル) <span class="pnt">※</span></th>
+      <td><%= f.text_area :delivery_time_mobile, :class=>"data_l" %></td>
+    </tr>
+    <tr>
+      <th>返品・交換について(モバイル) <span class="pnt">※</span></th>
+      <td><%= f.text_area :return_exchange_mobile, :class=>"data_l" %></td>
+    </tr>
+  </table>
+<% end %>
diff --git a/app/views/admin/laws/_submenu.html.erb b/app/views/admin/laws/_submenu.html.erb
new file mode 100644 (file)
index 0000000..0da4554
--- /dev/null
@@ -0,0 +1 @@
+<%= render :partial => '/admin/base/shop_submenu' %>
diff --git a/app/views/admin/laws/index.html.erb b/app/views/admin/laws/index.html.erb
new file mode 100644 (file)
index 0000000..60aaade
--- /dev/null
@@ -0,0 +1,14 @@
+<%= render :partial => "submenu" %>
+
+<div id="main"><!-- メイン -->
+
+  <h2>特定商取引法</h2>
+  <% form_tag :action => "update" do%>
+    <%= render :partial => "form" %>
+    <div class="btn_box">
+      <%= submit_tag "この内容で登録する", :onclick => "return #{confirm_javascript_function("登録しても宜しいですか")}", :class=>"btn" %>
+      <%= image_tag("btn_side.gif", :width => "6", :height => "34", :class => "btn_side") %>
+    </div>
+  <% end %>
+
+</div><!-- /メイン -->
index ce83d57..ab5536e 100644 (file)
@@ -15,6 +15,5 @@
 <span style="color:#666666">&#xE689;</span> <%= link_to '個人情報保護方針・個人情報の取扱いについて', {:controller => 'portal', :action => 'privacy'} %><br />
 <span style="color:#009944">&#xE741;</span> <%= link_to '通信販売について', {:controller => 'portal', :action => 'show_tradelaw'} %><br />
 <span style="color:#666666">&#xE6D3;</span> <%= link_to 'お問い合わせ', {:controller => 'inquiries', :action => 'show'} %><br />
-<span style="color:#0068B7">&#xE688;</span> <%= link_to '対応端末一覧', {:controller => 'portal', :action => 'supported_device'} %><br />
 <div style="background-color:#F3F3EC;"><%= image_tag_mobile "spacer", :width => "1", :height => "3" %><br /></div>
 <div style="text-align:center;"><%= image_tag_mobile "border", :width => "226", :height => "2", :alt => "" %></div>
index 9a5792f..6072a7d 100644 (file)
@@ -3,12 +3,12 @@
   <%= stylesheet_link_tag "front/portal" %>\r
   <%= javascript_include_tag js_url(:action => "application") %>\r
 <% end %>\r
-  <ol id="bread_list" class="m_btm"><li class="bread_top"><%= link_to "トップページ", :controller => 'portal', :action => 'show' %></li><li>特定商取引に関する法律に基づく表記</li></ol>\r
-  <p class="tb_t">特定商取引に関する法律に基づく表記</p>\r
-  <%- if false %>\r
-  <%# FIXME 当サイトについてみたいなロゴがあると幸せです %>\r
-  <%= image_tag '/images/shop/about.gif', :size => "583x31", :alt => "当サイトについて", :class => "route" %> \r
-  <%- end %>\r
+<ol id="bread_list" class="m_btm"><li class="bread_top"><%= link_to "トップページ", :controller => 'portal', :action => 'show' %></li><li>特定商取引に関する法律に基づく表記</li></ol>\r
+<h2 class="main_t"><%= @shopname %>: 特定商取引に関する法律に基づく表記</h2>\r
+<%- if false %>\r
+<%# FIXME 当サイトについてみたいなロゴがあると幸せです %>\r
+<%= image_tag '/images/shop/about.gif', :size => "583x31", :alt => "当サイトについて", :class => "route" %> \r
+<%- end %>\r
 <%unless @law.blank?%>  \r
   <table class="tb2">\r
     <tr>\r
       <th>URL</th>\r
       <td><%=h @law.url %></td>\r
     </tr>\r
-    <tr>\r
-      <th>商品以外の必要代金</th>\r
-      <td><%=h_br @law.necessary_charge %></td>\r
-    </tr>\r
-    <tr>\r
-      <th>注文方法</th>\r
-      <td><%=h_br @law.order_method %></td>\r
-    </tr>\r
-    <tr>\r
-      <th>支払方法</th>\r
-      <td><%=h_br @law.payment_method %></td>\r
-    </tr>\r
-    <tr>\r
-      <th>支払期限</th>\r
-      <td><%=h_br @law.payment_time_limit %></td>\r
-    </tr>\r
-    <tr>\r
-      <th>引渡し時期</th>\r
-      <td><%=h_br @law.delivery_time %></td>\r
-    </tr>\r
-    <tr>\r
-      <th>返品・交換について</th>\r
-      <td><%=h_br @law.return_exchange %></td>\r
-    </tr>\r
+    <%- unless @law.html? %>\r
+      <tr>\r
+        <th>商品以外の必要代金</th>\r
+        <td><%=h_br @law.necessary_charge %></td>\r
+      </tr>\r
+      <tr>\r
+        <th>注文方法</th>\r
+        <td><%=h_br @law.order_method %></td>\r
+      </tr>\r
+      <tr>\r
+        <th>支払方法</th>\r
+        <td><%=h_br @law.payment_method %></td>\r
+      </tr>\r
+      <tr>\r
+        <th>支払期限</th>\r
+        <td><%=h_br @law.payment_time_limit %></td>\r
+      </tr>\r
+      <tr>\r
+        <th>引渡し時期</th>\r
+        <td><%=h_br @law.delivery_time %></td>\r
+      </tr>\r
+      <tr>\r
+        <th>返品・交換について</th>\r
+        <td><%=h_br @law.return_exchange %></td>\r
+      </tr>\r
+    <% end %>\r
   </table>\r
+  <%- if @law.html? %>\r
+    <h3 class="tb_t">商品以外の必要代金</h3>\r
+    <div class="law_info">\r
+      <%= render :inline => @law.necessary_charge %>\r
+    </div>\r
+    <h3 class="tb_t">注文方法</h3>\r
+    <div class="law_info">\r
+      <%= render :inline => @law.order_method %>\r
+    </div>\r
+    <h3 class="tb_t">支払方法</h3>\r
+    <div class="law_info">\r
+      <%= render :inline => @law.payment_method %>\r
+    </div>\r
+    <h3 class="tb_t">支払期限</h3>\r
+    <div class="law_info">\r
+      <%= render :inline => @law.payment_time_limit %>\r
+    </div>\r
+    <h3 class="tb_t">引渡し時期</h3>\r
+    <div class="law_info">\r
+      <%= render :inline => @law.delivery_time %>\r
+    </div>\r
+    <h3 class="tb_t">返品・交換について</h3>\r
+    <div class="law_info">\r
+      <%= render :inline => @law.return_exchange %>\r
+    </div>\r
+  <% end %>\r
 <%end%>\r
index ce771ad..2da3775 100644 (file)
@@ -24,6 +24,7 @@
 ■URL<br />\r
 <%=h @law.url %><br /><br />\r
 \r
+<%- unless @law.html? %>\r
 ■商品以外の必要代金<br />\r
 <%=h_br @law.necessary_charge %><br /><br />\r
 \r
 \r
 ■返品・交換について<br />\r
 <%=h_br @law.return_exchange %><br /><br />\r
+<% else %>\r
+■商品以外の必要代金<br />\r
+<%= render :inline => @law.necessary_charge %><br /><br />\r
+\r
+■注文方法<br />\r
+<%= render :inline => @law.order_method %><br /><br />\r
+\r
+■支払方法<br />\r
+<%= render :inline => @law.payment_method %><br /><br />\r
+\r
+■支払期限<br />\r
+<%= render :inline => @law.payment_time_limit %><br /><br />\r
+\r
+■引渡し時期<br />\r
+<%= render :inline => @law.delivery_time %><br /><br />\r
+\r
+■返品・交換について<br />\r
+<%= render :inline => @law.return_exchange %><br /><br />\r
+\r
+<% end %>\r
+\r
 <%end%>\r
 →<%= link_to '戻る', {:controller => 'portal', :action => 'show'} %><br />\r
 \r
index 55fe091..fa1b758 100644 (file)
@@ -373,6 +373,14 @@ ja:
         payment_time_limit: "支払期限"
         delivery_time: "引き渡し時期"
         return_exchange: "返品・交換について"
+        necessary_charge_mobile: "商品以外の必要料金(モバイル)"
+        order_method_mobile: "注文方法(モバイル)"
+        payment_method_mobile: "支払方法(モバイル)"
+        payment_time_limit_mobile: "支払期限(モバイル)"
+        delivery_time_mobile: "引き渡し時期(モバイル)"
+        return_exchange_mobile: "返品・交換について(モバイル)"
+        render_type: "表示タイプ"
+        retailer: "販売元"
         created_at: "で作成された"
         updated_at: "で更新"
         deleted_at: "で削除"
@@ -838,4 +846,4 @@ ja:
         can_daibiki: "代引きフラグ"
     errors:
       messages:
-        record_invalid: "Validation failed: {{errors}}"
\ No newline at end of file
+        record_invalid: "Validation failed: {{errors}}"
diff --git a/db/migrate/20100511095346_add_retailer_and_mobile_fields_to_laws.rb b/db/migrate/20100511095346_add_retailer_and_mobile_fields_to_laws.rb
new file mode 100644 (file)
index 0000000..8db5076
--- /dev/null
@@ -0,0 +1,23 @@
+class AddRetailerAndMobileFieldsToLaws < ActiveRecord::Migration
+  def self.up
+    add_column :laws, :render_type, :integer, :default => 0, :comment => "表示タイプ(0:text, 1:html)"
+    add_column :laws, :retailer_id, :integer, :comment => "販売元ID"
+    add_column :laws, :necessary_charge_mobile, :text, :comment => "商品代金以外の必要料金(モバイル)"
+    add_column :laws, :order_method_mobile, :text, :comment => "注文方法(モバイル)"
+    add_column :laws, :payment_method_mobile, :text, :comment => "支払方法(モバイル)"
+    add_column :laws, :payment_time_limit_mobile, :text, :comment => "支払期限(モバイル)"
+    add_column :laws, :delivery_time_mobile, :text, :comment => "引き渡し時期(モバイル)"
+    add_column :laws, :return_exchange_mobile, :text, :comment => "返品・交換について(モバイル)"
+  end
+
+  def self.down
+    remove_column :laws, :return_exchange_mobile
+    remove_column :laws, :delivery_time_mobile
+    remove_column :laws, :payment_time_limit_mobile
+    remove_column :laws, :payment_method_mobile
+    remove_column :laws, :order_method_mobile
+    remove_column :laws, :necessary_charge_mobile
+    remove_column :laws, :retailer_id
+    remove_column :laws, :render_type
+  end
+end
diff --git a/db/migrate/20100512025204_set_data_to_laws_new_columns.rb b/db/migrate/20100512025204_set_data_to_laws_new_columns.rb
new file mode 100644 (file)
index 0000000..1f89de1
--- /dev/null
@@ -0,0 +1,17 @@
+class SetDataToLawsNewColumns < ActiveRecord::Migration
+  def self.up
+    law = Law.first
+    law.retailer_id = Retailer::DEFAULT_ID
+    law.necessary_charge_mobile = law.necessary_charge
+    law.order_method_mobile = law.order_method
+    law.payment_method_mobile = law.payment_method
+    law.payment_time_limit_mobile = law.payment_time_limit
+    law.delivery_time_mobile = law.delivery_time
+    law.return_exchange_mobile = law.return_exchange
+    law.render_type = 0
+    law.save!
+  end
+
+  def self.down
+  end
+end
diff --git a/spec/controllers/admin/laws_controller_spec.rb b/spec/controllers/admin/laws_controller_spec.rb
new file mode 100644 (file)
index 0000000..ae10e2e
--- /dev/null
@@ -0,0 +1,27 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Admin::LawsController do
+  fixtures :authorities, :functions, :admin_users
+
+  before(:each) do
+    @controller.class.skip_before_filter @controller.class.before_filter
+    @admin1 = admin_users(:load_by_admin_user_test_id_1)
+    @admin2 = admin_users(:admin18_retailer_id_is_another_shop)
+  end
+
+  describe "GET 'index'" do
+    describe "retailer_id = 1" do
+      before(:each) do
+        session[:admin_user] = @admin1
+      end
+
+      it "should be successful" do
+        get 'index'
+        response.should render_template("admin/laws/index")
+      end
+    end
+   
+
+  end
+
+end
index d257696..e7693cd 100644 (file)
@@ -27,4 +27,12 @@ shoutorihiki:
     payment_method: 支払方法
     payment_time_limit: 支払期限
     delivery_time: 引き渡し時期
-    return_exchange: 返品・交換について
\ No newline at end of file
+    return_exchange: 返品・交換について
+    necessary_charge_mobile: 商品代金以外の必要料金
+    order_method_mobile: 注文方法
+    payment_method_mobile: 支払方法
+    payment_time_limit_mobile: 支払期限
+    delivery_time_mobile: 引き渡し時期
+    return_exchange_mobile: 返品・交換について
+    retailer_id: 1
+    render_type: 0
index 4c3124b..fe6fd22 100644 (file)
@@ -4,6 +4,8 @@ describe Law do
   fixtures :laws
   before(:each) do
     @laws = laws(:shoutorihiki)
+    @text_field_maxlength = 200
+    @text_field_overlength = @text_field_maxlength + 1
   end
   describe "validateチェック" do
     
@@ -202,10 +204,19 @@ describe Law do
       #必須チェック
       @laws.necessary_charge  = ""
       @laws.should_not be_valid
+      @laws.necessary_charge  = "x"
+      @laws.necessary_charge_mobile  = ""
+      @laws.should_not be_valid
+      @laws.necessary_charge_mobile = "x"
+      @laws.should be_valid
       #文字数(200以下)
-      @laws.necessary_charge = 'x' * 200
+      @laws.necessary_charge = 'x' * @text_field_maxlength
+      @laws.necessary_charge_mobile = 'x' * @text_field_maxlength
       @laws.should be_valid
-      @laws.necessary_charge = 'x' * 201
+      @laws.necessary_charge = 'x' * @text_field_overlength
+      @laws.should_not be_valid
+      @laws.necessary_charge = 'x' * @text_field_maxlength
+      @laws.necessary_charge_mobile = 'x' * @text_field_overlength
       @laws.should_not be_valid
     end
     
@@ -213,10 +224,19 @@ describe Law do
       #必須チェック
       @laws.order_method  = ""
       @laws.should_not be_valid
+      @laws.order_method  = "x"
+      @laws.order_method_mobile = ""
+      @laws.should_not be_valid
+      @laws.order_method_mobile = "x"
+      @laws.should be_valid
       #文字数(200以下)
-      @laws.order_method = 'x' * 200
+      @laws.order_method = 'x' * @text_field_maxlength
+      @laws.order_method_mobile = 'x' * @text_field_maxlength
       @laws.should be_valid
-      @laws.order_method = 'x' * 201
+      @laws.order_method = 'x' * @text_field_overlength
+      @laws.should_not be_valid
+      @laws.order_method = 'x' * @text_field_maxlength
+      @laws.order_method_mobile = 'x' * @text_field_overlength
       @laws.should_not be_valid
     end
     
@@ -224,10 +244,19 @@ describe Law do
       #必須チェック
       @laws.payment_method  = ""
       @laws.should_not be_valid
+      @laws.payment_method  = "x"
+      @laws.payment_method_mobile  = ""
+      @laws.should_not be_valid
+      @laws.payment_method_mobile  = "x"
+      @laws.should be_valid
       #文字数(200以下)
-      @laws.payment_method = 'x' * 200
+      @laws.payment_method = 'x' * @text_field_maxlength
+      @laws.payment_method_mobile = 'x' * @text_field_maxlength
       @laws.should be_valid
-      @laws.payment_method = 'x' * 201
+      @laws.payment_method = 'x' * @text_field_overlength
+      @laws.should_not be_valid
+      @laws.payment_method = 'x' * @text_field_maxlength
+      @laws.payment_method_mobile = 'x' * @text_field_overlength
       @laws.should_not be_valid
     end
     
@@ -235,10 +264,19 @@ describe Law do
       #必須チェック
       @laws.payment_time_limit  = ""
       @laws.should_not be_valid
+      @laws.payment_time_limit  = "x"
+      @laws.payment_time_limit_mobile  = ""
+      @laws.should_not be_valid
+      @laws.payment_time_limit_mobile  = "x"
+      @laws.should be_valid
       #文字数(200以下)
-      @laws.payment_time_limit = 'x' * 200
+      @laws.payment_time_limit = 'x' * @text_field_maxlength
+      @laws.payment_time_limit_mobile = 'x' * @text_field_maxlength
       @laws.should be_valid
-      @laws.payment_time_limit = 'x' * 201
+      @laws.payment_time_limit = 'x' * @text_field_overlength
+      @laws.should_not be_valid
+      @laws.payment_time_limit = 'x' * @text_field_maxlength
+      @laws.payment_time_limit_mobile = 'x' * @text_field_overlength
       @laws.should_not be_valid
     end
     
@@ -246,10 +284,19 @@ describe Law do
       #必須チェック
       @laws.delivery_time  = ""
       @laws.should_not be_valid
+      @laws.delivery_time  = "x"
+      @laws.delivery_time_mobile  = ""
+      @laws.should_not be_valid
+      @laws.delivery_time_mobile  = "x"
+      @laws.should be_valid
       #文字数(200以下)
-      @laws.delivery_time = 'x' * 200
+      @laws.delivery_time = 'x' * @text_field_maxlength
+      @laws.delivery_time_mobile = 'x' * @text_field_maxlength
       @laws.should be_valid
-      @laws.delivery_time = 'x' * 201
+      @laws.delivery_time = 'x' * @text_field_overlength
+      @laws.should_not be_valid
+      @laws.delivery_time = 'x' * @text_field_maxlength
+      @laws.delivery_time_mobile = 'x' * @text_field_overlength
       @laws.should_not be_valid
     end
     
@@ -257,15 +304,42 @@ describe Law do
       #必須チェック
       @laws.return_exchange  = ""
       @laws.should_not be_valid
+      @laws.return_exchange  = "x"
+      @laws.return_exchange_mobile  = ""
+      @laws.should_not be_valid
+      @laws.return_exchange_mobile  = "x"
+      @laws.should be_valid
       #文字数(200以下)
-      @laws.return_exchange = 'x' * 200
+      @laws.return_exchange = 'x' * @text_field_maxlength
+      @laws.return_exchange_mobile = 'x' * @text_field_maxlength
+      @laws.should be_valid
+      @laws.return_exchange = 'x' * @text_field_overlength
+      @laws.should_not be_valid
+      @laws.return_exchange = 'x' * @text_field_maxlength
+      @laws.return_exchange_mobile = 'x' * @text_field_overlength
+      @laws.should_not be_valid
+    end
+
+    it "販売元ID" do
+      @laws.retailer_id = nil
+      @laws.should_not be_valid
+      @laws.retailer_id = 1
+      @laws.should be_valid
+    end
+
+    it "表示フラグ" do
+      @laws.render_type = nil
+      @laws.should_not be_valid
+      @laws.render_type = 0
       @laws.should be_valid
-      @laws.return_exchange = 'x' * 201
+      @laws.render_type = 2
       @laws.should_not be_valid
     end
-    it "重複登録不可" do
+
+    it "重複登録が可能" do
       laws = Law.new(@laws.attributes)
-      laws.should_not be_valid
+      laws.retailer_id = 3
+      laws.should be_valid
     end
   end
   describe "表示系" do
@@ -281,5 +355,14 @@ describe Law do
       laws = Law.new(:fax01=>"010",:fax02=>"1234",:fax03=>"5678")
       laws.fax.should == "010-1234-5678"
     end
-  end  
+  end
+  describe "表示メソッド" do
+    it "HTML表示" do
+      @laws.render_type = 0
+      @laws.should_not be_html
+      @laws.render_type = 1
+      @laws.should be_html
+    end
+  end
+
 end