OSDN Git Service

リリース後のバグ修正 #26 初回のSHOPマスタ登録時にエラー
authorcho <cho@06daa6dd-5c14-464e-8a85-0d68c524be32>
Thu, 28 Jan 2010 06:59:31 +0000 (06:59 +0000)
committercho <cho@06daa6dd-5c14-464e-8a85-0d68c524be32>
Thu, 28 Jan 2010 06:59:31 +0000 (06:59 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/elecoma/trunk@38 06daa6dd-5c14-464e-8a85-0d68c524be32

17 files changed:
app/controllers/admin/shops_controller.rb
app/controllers/admin/suppliers_controller.rb
app/controllers/application_controller.rb
app/models/shop.rb
app/views/admin/base/_depot_submenu.html.erb
app/views/admin/home/index.html.erb
app/views/admin/products/_form.html.erb
app/views/admin/products/_search.html.erb
app/views/admin/shops/_form.html.erb
app/views/admin/shops/_settings_form.html.erb
app/views/admin/stock_histories/show.html.erb
app/views/admin/stock_in/_info.html.erb
app/views/admin/stock_in/_search.html.erb
app/views/admin/stock_modify/_info.html.erb
app/views/admin/stock_modify/_search.html.erb
app/views/layouts/admin/base.html.erb
spec/models/shop_spec.rb

index b03d1f0..504c11e 100644 (file)
@@ -21,26 +21,20 @@ class Admin::ShopsController < Admin::BaseController
 
 
   def update
-    if params[:id]
-      @shop = Shop.find(:first)#1件のみ返す
-      @system = System.find(:first)
-      @shop.attributes = params[:shop]
-      @system.attributes = params[:system]
-    else
-      @shop = Shop.new params[:shop]
-      @system = System.new params[:system]
-    end
+    @shop = Shop.find(:first) || Shop.new
+    @shop.attributes = params[:shop]
+    @system = System.find(:first) || System.new
+    @system.attributes = params[:system]
 
     unless @shop.valid? && @system.valid?
-      flash.now[:error] = "保存に失敗しました"
       render :action => "index"
       return
     end
 
     if @system.save && @shop.save
-      flash.now[:notice] = "データを保存しました"
+      flash[:shop_update] = "データを保存しました"
     else
-      flash.now[:error] = "データの保存に失敗しました"
+      flash[:shop_update_e] = "データの保存に失敗しました"
     end
 
     redirect_to :action => "index"
@@ -444,7 +438,9 @@ class Admin::ShopsController < Admin::BaseController
   end
   #使用機能一覧
   def settings
-    
+    #初期化
+    @system ||= System.new
+    @system.supplier_use_flag ||= false
   end
   #使用機能設定
   def settings_update
@@ -487,19 +483,23 @@ class Admin::ShopsController < Admin::BaseController
   end
   #仕入先を使用するかどうか設定
   def supplier_update
+    @system ||= System.new
     @system.attributes =  params[:system]
     if @system.save
       if @system.supplier_use_flag
         #使用する->使用しない変更する時、既存の仕入先をそのまま
         #supplier_use_flagの変更のみ        
         redirect_to :controller => "suppliers",:action => ""
+        return
       else
-        flash.now[:notice] = "仕入先を使用しないように設定しました"
-        render :action => "settings"
+        flash[:system_update] = "仕入先を使用しないように設定しました"
+        redirect_to :controller => "shops",:action => "settings"
+        return
       end
     else
       flash.now[:error] = "設定に失敗しました"
       render :action => "settings"
+      return
     end     
   end
 
index d8e702b..9f479ef 100644 (file)
@@ -53,7 +53,7 @@ class Admin::SuppliersController < Admin::BaseController
   end
   #仕入先を使用しているかしないと判断のフィルタ
   def check_supplier_use
-    unless @system.supplier_use_flag
+    unless @system_supplier_use_flag
       redirect_to :controller=>"/admin/home"
       return
     end
index 4a1d8b6..af362b2 100644 (file)
@@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
 
   def load_system
     @system = System.find(:first)
-    @system.supplier_use_flag ||= false
+    @system_supplier_use_flag = true if @system && @system.supplier_use_flag
   end
 
   #郵便番号から住所を取得
index 98e19f0..469f535 100644 (file)
@@ -20,8 +20,8 @@ class Shop < ActiveRecord::Base
 
   validates_length_of :businesstime, :maximum => 50
 
-  validates_presence_of :mail_faq,:mail_sender,:mail_admin, :mail_shop
-  validates_length_of :mail_shop,:mail_faq,:mail_sender,:mail_admin, :maximum => 50, :allow_blank => true
+  validates_presence_of :mail_faq,:mail_sender,:mail_admin
+  validates_length_of :mail_faq,:mail_sender,:mail_admin, :maximum => 50, :allow_blank => true
 
   validates_length_of :trade_item,:introduction, :maximum => 99999
 
index 36bb808..5056910 100644 (file)
@@ -5,7 +5,7 @@
 </script>\r
 <div id="sub"><!-- サブメニュー -->\r
   <div id="menu" class="clearfix"><!-- g_menu -->\r
-    <% if @system.supplier_use_flag %>\r
+    <% if @system_supplier_use_flag %>\r
        <p><a href="JavaScript:onClick=Tree('display1');ImgC('img1');"><img src="/images/menu_icon.gif" width="36" height="36" alt="" id="img1" /><span>仕入先管理</span></a></p>\r
     <ul id="display1" style="display:block">\r
       <li><%= link_to '仕入先マスタ管理', {:controller => 'suppliers', :action => 'index'} %></li>\r
index 205b52b..fa4869b 100644 (file)
@@ -5,7 +5,7 @@
     <p id="category_info">編集したいカテゴリをクリックして下さい。</p>
     <a href="/admin/shops"><img src="/images/store_btn_l.gif" width="222" height="138" alt="店舗管理" /></a>
     <a href="/admin/products"><img src="/images/goods_btn_l.gif" width="222" height="138" alt="商品管理" id="category_img" /></a>
-    <% if @system.supplier_use_flag %>
+    <% if @system_supplier_use_flag %>
        <a href="/admin/suppliers"><img src="/images/order_btn_l.gif" width="222" height="138" alt="発注・出荷管理" /></a>
        <%else%>
        <a href="/admin/stock_in"><img src="/images/order_btn_l.gif" width="222" height="138" alt="発注・出荷管理" /></a>
index 6e7f10e..5db7fd6 100644 (file)
@@ -15,7 +15,7 @@
       <%= confirm_tag :text_field, :product, :name, :class=>"data_m" %> (上限50文字)
     </td>
   </tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
   <tr>
     <th>仕入先名<span class="pnt">※</span></th>
     <td><%suppliers = Supplier.find(:all,:order=>'id')%>
index d1dd7da..9da2198 100644 (file)
@@ -18,7 +18,7 @@
         <th>商品名</th>
         <td><%= f.text_field :name, :class=>"data_m" %></td>
       </tr>
-        <%if @system.supplier_use_flag%>
+        <%if @system_supplier_use_flag%>
          <tr>
            <th>仕入先名</th>
            <td><%suppliers = Supplier.find(:all,:order=>'id')%>
index e4b8bca..3b8a06e 100644 (file)
@@ -1,5 +1,5 @@
-<%=h flash[:notice] %>
-<%=h flash[:error] %>
+<%=h flash[:shop_update] %>
+<%=h flash[:shop_update_e] %>
 <%= error_messages_for :shop %>
 <%= error_messages_for :system %>
 <p class="req"><span class="pnt">※</span>は必須入力です</p>
index 0f0430a..4875b82 100644 (file)
@@ -1,6 +1,6 @@
-<%=h flash[:notice] %>
+<%=h flash[:system_update] %>
 <%=h flash[:error] %>
-<%= error_messages_for :shop %>
+<%= error_messages_for :system %>
 <!--仕入先-->
 <% form_for :system, :url =>{:action => "settings_update"} do |f|%>
 <table cellspacing="1" cellpadding="0" class="data" >
index b721c7f..34d8a1c 100644 (file)
@@ -17,7 +17,7 @@
       <%= h(@stock_history.product.name) %>
     </td>
   </tr>
-  <%if @system.supplier_use_flag%>
+  <%if @system_supplier_use_flag%>
   <tr>
     <th>仕入先名</th>
     <td><%= h(@stock_history.product.supplier_name) %></td>
index 0b3dc02..96154f3 100644 (file)
@@ -13,7 +13,7 @@
       <%= h(@product_style.product_name) %>
     </td>
   </tr>
-  <%if @system.supplier_use_flag%>
+  <%if @system_supplier_use_flag%>
   <tr>
     <th>仕入先名</th>
     <td><%= h(@product_style.product.supplier_name) %></td>
index ed3d6c1..25c1d8a 100644 (file)
@@ -15,7 +15,7 @@
         <th>商品型番</th>
         <td><%= f.text_field :manufacturer, :class=>"data_m" %></td>
       </tr>
-        <%if @system.supplier_use_flag%>
+        <%if @system_supplier_use_flag%>
          <tr>
            <th>仕入先名</th>
            <td><%suppliers = Supplier.find(:all,:order=>'id')%>
index 0b3dc02..96154f3 100644 (file)
@@ -13,7 +13,7 @@
       <%= h(@product_style.product_name) %>
     </td>
   </tr>
-  <%if @system.supplier_use_flag%>
+  <%if @system_supplier_use_flag%>
   <tr>
     <th>仕入先名</th>
     <td><%= h(@product_style.product.supplier_name) %></td>
index ed3d6c1..25c1d8a 100644 (file)
@@ -15,7 +15,7 @@
         <th>商品型番</th>
         <td><%= f.text_field :manufacturer, :class=>"data_m" %></td>
       </tr>
-        <%if @system.supplier_use_flag%>
+        <%if @system_supplier_use_flag%>
          <tr>
            <th>仕入先名</th>
            <td><%suppliers = Supplier.find(:all,:order=>'id')%>
index 48556f8..b277ed4 100644 (file)
@@ -21,7 +21,7 @@
       <ul id="con_menu" class="clearfix">
         <li><a href="/admin/shops" id="shop"><img src="/images/store_btn.gif" width="122" height="51" alt="店舗管理" class="hoverImg" /></a></li>
         <li><a href="/admin/products" id="product"><img src="/images/goods_btn.gif" width="122" height="51" alt="商品管理" class="hoverImg" /></a></li>
-    <% if @system.supplier_use_flag %>
+    <% if @system_supplier_use_flag %>
         <li><a href="/admin/suppliers" id="depot"><img src="/images/order_btn.gif" width="122" height="51" alt="発注出荷管理" class="hoverImg" /></a></li>
        <%else%>
                <li><a href="/admin/stock_in" id="depot"><img src="/images/order_btn.gif" width="122" height="51" alt="発注出荷管理" class="hoverImg" /></a></li>
index a90d471..35e3381 100644 (file)
@@ -188,43 +188,6 @@ describe Shop do
       @shop.should_not be_valid
     end
     
-    it "注文受付メールアドレス : 必須" do
-      @shop.mail_shop = ""
-      @shop.should_not be_valid
-    end
-    
-    it "注文受付メールアドレス フォーマット" do
-      @shop.mail_shop = 'foo@example.com'
-      @shop.should be_valid
-      @shop.mail_shop = 'foo.bar@example.com'
-      @shop.should be_valid
-      @shop.mail_shop = 'foo+bar@example.com'
-      @shop.should be_valid
-      @shop.mail_shop = 'foo@example'
-      @shop.should_not be_valid
-      @shop.mail_shop = 'foo@example.'
-      @shop.should_not be_valid
-      @shop.mail_shop = 'foo@.com'
-      @shop.should_not be_valid
-      @shop.mail_shop = 'foo'
-      @shop.should_not be_valid
-      @shop.mail_shop = 'foo@'
-      @shop.should_not be_valid
-      @shop.mail_shop = '@example.com'
-      @shop.should_not be_valid
-    end
-    
-    it "注文受付メールアドレス 50 文字まで" do
-      suffix = '@example.com'
-      name = 'x' * (50 - suffix.size)
-      email = name + suffix
-      email.size.should == 50
-      @shop.mail_shop = email
-      @shop.should be_valid
-      @shop.mail_shop = 'x'+email
-      @shop.should_not be_valid
-    end
-    
     it "問合せ受付メールアドレス : 必須" do
       @shop.mail_faq = ""
       @shop.should_not be_valid