OSDN Git Service

2.0開発:他店舗対応
author松澤 太郎 <tmatsuzawa@kbmj.com>
Tue, 30 Mar 2010 09:03:50 +0000 (18:03 +0900)
committer松澤 太郎 <tmatsuzawa@kbmj.com>
Tue, 30 Mar 2010 09:03:50 +0000 (18:03 +0900)
- Retailerモデルの追加
- 管理ユーザ検索分離作業
- 商品登録商品マスタ登録前まで

63 files changed:
README
app/controllers/admin/products_controller.rb
app/controllers/admin/return_items_controller.rb
app/controllers/admin/stock_base_controller.rb
app/controllers/admin/stock_csv_controller.rb
app/controllers/admin/stock_histories_controller.rb
app/controllers/admin/style_categories_controller.rb
app/controllers/admin/styles_controller.rb
app/controllers/admin/suppliers_controller.rb
app/controllers/admin/totals_controller.rb
app/models/admin_user.rb
app/models/category.rb
app/models/customer_search_form.rb
app/models/delivery_trader.rb
app/models/product.rb
app/models/product_access_log.rb
app/models/recommend.rb
app/models/retailer.rb [new file with mode: 0644]
app/models/return_item_search_form.rb
app/models/stock_search_form.rb
app/models/style.rb
app/models/supplier.rb
app/models/supplier_search_form.rb
app/views/admin/admin_users/_form.html.erb
app/views/admin/admin_users/index.html.erb
app/views/admin/admin_users/new.html.erb
app/views/admin/products/_form.html.erb
app/views/admin/style_categories/index.html.erb
app/views/admin/styles/_form.html.erb
app/views/admin/suppliers/_form.html.erb
config/locales/translation_ja.yml
db/migrate/20100315054019_create_retailers.rb [new file with mode: 0644]
db/migrate/20100315062449_add_retailer_id_to_many_tables.rb [new file with mode: 0644]
spec/controllers/admin/admin_users_controller_spec.rb
spec/controllers/admin/new_informations_controller_spec.rb
spec/controllers/admin/products_controller_spec.rb
spec/controllers/admin/return_items_controller_spec.rb
spec/controllers/admin/shops_controller_spec.rb
spec/controllers/admin/stock_base_controller_spec.rb
spec/controllers/admin/stock_csv_controller_spec.rb
spec/controllers/admin/stock_histories_controller_spec.rb
spec/controllers/admin/stock_in_controller_spec.rb
spec/controllers/admin/style_categories_controller_spec.rb
spec/controllers/admin/styles_controller_spec.rb
spec/controllers/admin/suppliers_controller_spec.rb
spec/fixtures/admin_users.yml
spec/fixtures/delivery_traders.yml
spec/fixtures/products.yml
spec/fixtures/retailers.yml [new file with mode: 0644]
spec/fixtures/style_categories.yml
spec/fixtures/styles.yml
spec/fixtures/suppliers.yml
spec/models/admin_user_spec.rb
spec/models/category_spec.rb
spec/models/delivery_trader_spec.rb
spec/models/product_spec.rb
spec/models/retailer_spec.rb [new file with mode: 0644]
spec/models/style_spec.rb
spec/models/supplier_spec.rb
spec/product_csv_upload_for_spec.csv
spec/product_sample.csv
test/fixtures/retailers.yml [new file with mode: 0644]
test/unit/retailer_test.rb [new file with mode: 0644]

diff --git a/README b/README
index dd076b3..752385e 100644 (file)
--- a/README
+++ b/README
@@ -140,7 +140,7 @@ $ sudo gem install postgres
 # /etc/init.d/postgresql start
 # su - postgres
 $ psql template1
-# alert user postgres with password 'xxxx';
+# alter user postgres with password 'xxxx';
 # q\
 $ createuser ec
 Shall the new role be a superuser? (y/n) y
index 5f31bf3..086dfbe 100644 (file)
@@ -205,6 +205,10 @@ class Admin::ProductsController < Admin::BaseController
   end
 
   def get_search_form(actual_flg=false)
+    unless session[:admin_user].master_shop?
+      addparam = {'retailer_id' => session[:admin_user].retailer_id}
+      params[:search].merge! addparam unless params[:search].nil?
+    end
     @search = SearchForm.new(params[:search])
     @search, @search_list = Product.get_conditions(@search, params, actual_flg)
   end
index d524887..dda3040 100644 (file)
@@ -67,6 +67,7 @@ class Admin::ReturnItemsController < Admin::BaseController
   end
 
   def search
+    add_retailer_condition
     @condition = ReturnItemSearchForm.new(params[:condition])
     unless @condition.valid?
       render :action => :index
@@ -107,7 +108,8 @@ class Admin::ReturnItemsController < Admin::BaseController
     if params[:id].blank?
       render :status => :not_found
     end
-    rows = ReturnItem.find(:all).map do |ri|
+    condition, join = get_csv_condition
+    rows = ReturnItem.find(:all, :conditions => flatten_conditions(condition), :joins => join).map do |ri|
       a = []
       a << ri.product_id
       a << ri.product_style.code
@@ -132,6 +134,7 @@ class Admin::ReturnItemsController < Admin::BaseController
 
   private
   def get_return_items
+    add_retailer_condition
     @condition = ReturnItemSearchForm.new(params[:condition])
     unless @condition.valid?
       render :action => :index
@@ -142,7 +145,8 @@ class Admin::ReturnItemsController < Admin::BaseController
       :page => params[:page], 
       :per_page => @condition.per_page || 10,
       :conditions => flatten_conditions(@search_list),
-      :order => "id"
+      :include => [:product],
+      :order => "return_items.id"
     }
     @return_items = ReturnItem.paginate(find_options)
   end
@@ -151,4 +155,20 @@ class Admin::ReturnItemsController < Admin::BaseController
     url_for(:action => :csv, :id => date.strftime('%Y%m%d_%H%M%S'),:format => "csv")
   end  
 
+  def add_retailer_condition
+    unless session[:admin_user].master_shop?
+      addparam = {'retailer_id' => session[:admin_user].retailer_id}
+      params[:condition].merge! addparam unless params[:condition].nil?
+    end
+  end
+
+  def get_csv_condition
+    condition = []
+    unless session[:admin_user].master_shop?
+      condition << ["products.retailer_id = ?", session[:admin_user].retailer_id]
+      return condition, "LEFT JOIN product_styles ON product_styles.id = return_items.product_style_id " + "LEFT JOIN products ON products.id = product_styles.product_id "
+    end
+    return condition, nil
+  end
+
 end
index 13cba0b..8a99df5 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 #在庫管理の親クラス
 #共通ロジック
 class Admin::StockBaseController < Admin::BaseController
@@ -5,6 +6,10 @@ class Admin::StockBaseController < Admin::BaseController
   
   #検索
   def search
+    unless session[:admin_user].master_shop?
+      addparam = {'retailer_id' => session[:admin_user].retailer_id}
+      params[:condition].merge! addparam unless params[:condition].nil?
+    end
     @condition = StockSearchForm.new(params[:condition])
     unless @condition.valid?
       render :action => "index"
index 221e389..e4f8659 100644 (file)
@@ -28,9 +28,11 @@ class Admin::StockCsvController < Admin::BaseController
   def csv
     # params[:id] はページキャッシュのキーにするだけで抽出条件にはしない
     if params[:id].blank?
-      render :status => :not_found
+      render :file => 'public/404.html', :status => :not_found
+      return
     end
-    rows = ProductStyle.find(:all).map do |ps|
+    condition, join = get_condition
+    rows = ProductStyle.find(:all, :conditions => flatten_conditions(condition), :joins => join).map do |ps|
       a = []
       a << ps.code
       a << ps.product.name
@@ -54,5 +56,14 @@ class Admin::StockCsvController < Admin::BaseController
 
   def url_for_date(date)
     url_for(:action => :csv, :id => date.strftime('%Y%m%d_%H%M%S'),:format => "csv")
-  end  
+  end
+
+  def get_condition
+    condition = []
+    unless session[:admin_user].master_shop?
+      condition << ["products.retailer_id = ?", session[:admin_user].retailer_id]
+      return condition, "LEFT JOIN products ON products.id = product_styles.product_id "
+    end
+    return condition, nil
+  end
 end
index ff695d9..0fc9c7b 100644 (file)
@@ -4,6 +4,10 @@ class Admin::StockHistoriesController < Admin::BaseController
   before_filter :admin_permission_check_stock
   
   def search
+    unless session[:admin_user].master_shop?
+      addparam = {'retailer_id' => session[:admin_user].retailer_id}
+      params[:condition].merge! addparam unless params[:condition].nil?
+    end
     @condition = StockSearchForm.new(params[:condition])
     unless @condition.valid?
       render :action => "index"
@@ -15,7 +19,8 @@ class Admin::StockHistoriesController < Admin::BaseController
       :page => params[:page],
       :per_page => @condition.per_page || 10,
       :conditions => flatten_conditions(@search_list),
-      :order => "id"
+      :include => [:product],
+      :order => "stock_histories.id"
     }
     @stock_histories = StockHistory.paginate(find_options) 
   end
index bc989e3..75cd0cc 100644 (file)
@@ -35,4 +35,16 @@ class Admin::StyleCategoriesController < Admin::BaseController
     redirect_to :action => :index, :style_id => params[:style_id]
   end
 
+  private
+  def object
+    if params[:id]
+      style_category = StyleCategory.find_by_id(params[:id])
+      raise ActiveRecord::RecordNotFound unless style_category.style.retailer_id == session[:admin_user].retailer_id
+    elsif params[:style_category] && params[:style_category][:style_id]
+      style = Style.find(:all, :conditions => ["id = ? and retailer_id = ? ", params[:style_category][:style_id], session[:admin_user].retailer_id])
+      raise ActiveRecord::RecordNotFound if style.nil? or style == []
+    end
+    super
+  end
+
 end
index 167b775..2f2eaf7 100644 (file)
@@ -3,8 +3,8 @@ class Admin::StylesController < Admin::BaseController
   before_filter :admin_permission_check_standard
   
   index.before do
-    @styles = Style.find(:all, :order => "position")
-    @style = Style.find_by_id(params[:id]) || Style.new
+    @styles = Style.find(:all, :conditions=>["retailer_id = ? ", session[:admin_user].retailer_id], :order => "position")
+    @style = Style.find(:last, :conditions=>["id = ? and retailer_id = ? ", params[:id], session[:admin_user].retailer_id]) || Style.new
   end
   
   new_action.wants.html do
@@ -17,7 +17,7 @@ class Admin::StylesController < Admin::BaseController
     end
 
     action.failure.wants.html do
-      @styles = Style.find(:all, :order => "position")
+      @styles = Style.find(:all, :conditions=>["retailer_id = ? ", session[:admin_user].retailer_id], :order => "position")
       render :action => "index"
     end
   end
@@ -32,4 +32,9 @@ class Admin::StylesController < Admin::BaseController
     redirect_to :action => :index
   end
 
+  private
+  def object
+    @object ||= Style.find(:last, :conditions => ["id = ? and retailer_id = ? ", params[:id], session[:admin_user].retailer_id])
+  end
+
 end
index 9f479ef..2709a30 100644 (file)
@@ -6,6 +6,12 @@ class Admin::SuppliersController < Admin::BaseController
   before_filter :check_default,:only => [:edit,:confirm]
   
   def search
+
+    if params[:condition].nil?
+      render :action => "index"
+      return
+    end
+    params[:condition].merge!({"retailer_id" => session[:admin_user].retailer_id}) unless params[:condition].nil?
     @condition = SupplierSearchForm.new(params[:condition])
     unless @condition.valid?
       render :action => "index"
index 0d1fe60..651fde1 100644 (file)
@@ -26,7 +26,8 @@ class Admin::TotalsController < Admin::BaseController
     begin
       @records = @agent.get_records(params)
     rescue => e
-      p e
+      logger.error e.message
+      e.backtrace.each{|bt|logger.error(bt)}
     end
     @total = @agent.total
     begin
index 008ebc3..fd80f87 100644 (file)
@@ -5,6 +5,7 @@ class AdminUser < ActiveRecord::Base
   acts_as_list
 
   belongs_to :authority
+  belongs_to :retailer
   
   def self.validates_uniqueness_of(*attr_names)
     configuration = { :message => I18n.translate("activerecord.errors.messages")[:taken], :case_sensitive => true }
@@ -69,6 +70,8 @@ class AdminUser < ActiveRecord::Base
   validates_presence_of :authority
   
   validates_presence_of :login_id
+
+  validates_presence_of :retailer
   validates_length_of :login_id, :maximum => 15
   validates_format_of :login_id, :with => /^[a-zA-Z0-9]*$/
   validates_uniqueness_of :login_id
@@ -103,6 +106,14 @@ class AdminUser < ActiveRecord::Base
     [columns, titles]
   end
 
+  #
+  # 管理者ユーザの販売元がマスターショップであるかどうかを判定する
+  #
+  def master_shop?
+    return true if retailer_id == Retailer::DEFAULT_ID
+    return false
+  end
+
   protected
 
   def crypt_password
index 978bc42..0b678f1 100644 (file)
@@ -114,7 +114,7 @@ class Category < ActiveRecord::Base
   #1.エントリー
   def self.renew_children_ids_with_command
     begin
-      p "batch update start..."
+      logger.info "batch update start..."
       Category.transaction {
         #clear all
         Category.clear_children_ids
@@ -130,9 +130,9 @@ class Category < ActiveRecord::Base
           Category.childs_re_position(category)
         end
       }
-      p "batch update end..."
+      logger.info "batch update end..."
     rescue
-      p "batch update error.rollback..."
+      logger.info "batch update error.rollback..."
     end
 
   end
index 85c855b..71ba201 100644 (file)
@@ -51,7 +51,6 @@ class CustomerSearchForm < SearchForm
     CSV::Writer.generate(f) do | writer |\r
       writer << col_names\r
       customers.each do |c|\r
-#        p c\r
         arr = []\r
         syms.each do |sym|\r
           if sym == "sex".to_sym\r
index 1f0c64e..9d94a06 100644 (file)
@@ -7,8 +7,10 @@ class DeliveryTrader < ActiveRecord::Base
   has_many :delivery_fees, :dependent => :destroy, :order => :prefecture_id
   has_many :payments
   has_many :orders
+  belongs_to :retailer
   
   validates_presence_of :name
+  validates_presence_of :retailer
   
   validates_length_of :name,:url, :maximum => 50
   
index 14242e5..fcb2835 100644 (file)
@@ -24,6 +24,7 @@ class Product < ActiveRecord::Base
   has_many :order_details
   has_one :campaign
   belongs_to :supplier
+  belongs_to :retailer
 
   validates_length_of :name , :maximum => 50
   validates_length_of :name , :minimum => 1
@@ -35,6 +36,7 @@ class Product < ActiveRecord::Base
   validates_presence_of :description
   validates_presence_of :introduction
   validates_presence_of :supplier
+  validates_presence_of :retailer
   validates_associated :sub_products
 
   attr_accessor :small_resource_path
@@ -127,6 +129,9 @@ class Product < ActiveRecord::Base
   def supplier_name
     self.supplier && self.supplier.name
   end
+  def retailer_name
+    self.retailer && self.retailer.name
+  end
   # 送料無料?
   def free_delivery?
     statuses.exists?(['name=?', '送料無料'])
@@ -263,6 +268,9 @@ class Product < ActiveRecord::Base
       unless search.sale_start_at_end.blank?
         search_list << ["products.sale_start_at <= ?", search.sale_start_at_end + 1.day]
       end
+      unless search.retailer_id.blank?
+        search_list << ["products.retailer_id = ?", search.retailer_id]
+      end
     end
     unless params["product_status_ids"].blank?
       product_status = ProductStatus.find(:all, :select => "distinct product_id",  :conditions => "status_id IN (#{ params["product_status_ids"].join(",") })" )
@@ -292,7 +300,7 @@ class Product < ActiveRecord::Base
             end
           elsif column.to_s == "delivery_dates_label"
             product.delivery_dates_label
-          elsif ![:small_resource_path,:medium_resource_path,:large_resource_path,:category_name,:delivery_dates_label,:supplier_name].include?(column)&& Product.columns_hash[column.to_s].type == :datetime
+          elsif ![:small_resource_path,:medium_resource_path,:large_resource_path,:category_name,:delivery_dates_label,:supplier_name,:retailer_name].include?(column)&& Product.columns_hash[column.to_s].class == :datetime
             (product[column] + (60*60*9)).strftime("%Y-%m-%d %H:%M") if product[column]
           else
             product[column] || product.send(column)
@@ -386,6 +394,8 @@ class Product < ActiveRecord::Base
       product.free_comment = arr[29]
       setDelivery_dates(product,arr[30])
       setSupplierId(product,arr[31])
+      # todo: csvupload retailer対応
+      setRetailerId(product,arr[32])
     end
 
     def setPermit(product, permit)
@@ -411,6 +421,19 @@ class Product < ActiveRecord::Base
         end        
       end
     end
+
+    def setRetailerId(product, name)
+      if name.blank?
+        product.retailer_id = Retailer::DEFAULT_ID
+      else
+        r = Retailer.find_by_name(name)
+        if !r.blank?
+          product.retailer_id = r.id
+        else
+          raise ActiveRecord::RecordNotFound
+        end
+      end
+    end
     #画像データセット
     def setImageId(product,arr)
       #画像IDと画像パスの項目を別々に設定して画像パスがあった場合は、その先にある画像を登録し、なかった場合は画像IDを登録する
@@ -530,6 +553,7 @@ class Product < ActiveRecord::Base
       :free_comment,
       :delivery_dates_label,
       :supplier_name,
+      :retailer_name,
       :created_at,
       :updated_at
     ]
@@ -569,6 +593,7 @@ class Product < ActiveRecord::Base
       :free_comment => "フリー入力",
       :delivery_dates_label => "配送日",
       :supplier_name => "仕入先名",
+      :retailer_name => "販売元名",
       :created_at => "登録日",
       :updated_at => "更新日"
     }
index eb7afa7..4a0334a 100644 (file)
@@ -27,7 +27,6 @@ class ProductAccessLog < ActiveRecord::Base
           product_access_log.save!
         }
     rescue TimeoutError => e
-      p "err: #{ e }"
       logger.info "err: #{ e }"
       return false
     rescue 
index 7c92232..1cc4b3d 100644 (file)
@@ -66,7 +66,6 @@ class Recommend < ActiveRecord::Base
       end
       return true
     rescue TimeoutError => e
-      p "err: #{ e }"
       logger.info "err: #{ e }"
       return false
     rescue 
diff --git a/app/models/retailer.rb b/app/models/retailer.rb
new file mode 100644 (file)
index 0000000..a0d13bd
--- /dev/null
@@ -0,0 +1,10 @@
+# -*- coding: undecided -*-
+class Retailer < ActiveRecord::Base
+
+  has_many :product
+  validates_presence_of :name
+
+  #DEFAULT_IDは標準の販売元として利用
+  DEFAULT_ID = 1
+
+end
index 312f704..4dba538 100644 (file)
@@ -49,6 +49,10 @@ class ReturnItemSearchForm < SearchForm
       unless search.returned_at_to.blank?
         search_list << ["return_items.returned_at <= ?", search.returned_at_to]
       end
+      unless search.retailer_id.blank?
+        search_list << ["products.retailer_id = ?", search.retailer_id]
+      end
+
     end
     search_list
   end
index 630ef93..d1d5aa8 100644 (file)
@@ -50,6 +50,9 @@ class StockSearchForm < SearchForm
       unless search.moved_at_to.blank?
         search_list << ["stock_histories.moved_at <= ?", search.moved_at_to]
       end
+      unless search.retailer_id.blank?
+        search_list << ["products.retailer_id = ?", search.retailer_id]
+      end
     end
     search_list
   end
index 2240f29..763218b 100644 (file)
@@ -1,6 +1,6 @@
 class Style < ActiveRecord::Base
   acts_as_paranoid
-  acts_as_list
+  acts_as_list :scope => :retailer_id
   has_many :style_categories, :order => 'position'
   has_many :product_styles,
            :class_name => "ProductStyle",
@@ -8,10 +8,11 @@ class Style < ActiveRecord::Base
   has_many :product_styles,
            :class_name => "ProductStyle",
            :foreign_key => "style_id2"
-  validates_uniqueness_of :name, :message=>'は、既に使われています。'
-  def self.select_options(id = nil) 
+  belongs_to :retailer
+  validates_uniqueness_of :name, :scope => :retailer_id, :message=>'は、既に使われています。'
+  def self.select_options(id = nil, retailer_id = 1) 
     array = "<option value=\"\">選択して下さい</option>"
-    find(:all).each{|s| 
+    find(:all, :conditions => ["retailer_id = ? ", retailer_id], :order => "id").each{|s| 
       if s.style_categories.size > 0
         array += "<option value='#{s.id}'#{ (id &&  id.to_s == s.id.to_s ) ? " selected=\"selected\"" : ""}>#{s.name}</otpion> "  
       end
@@ -20,6 +21,7 @@ class Style < ActiveRecord::Base
   end
 
   validates_presence_of :name
+  validates_presence_of :retailer
 
   def has_product?
     style_categories.any?(&:has_product?)
index 5bc9a81..8fa3764 100644 (file)
@@ -7,7 +7,8 @@ class Supplier < ActiveRecord::Base
   DEFAULT_SUPPLIER_ID = 1
   SHISYAGONYU, KIRISUTE, KIRIAGE = 0, 1, 2
   TAX_RULE_NAMES = { SHISYAGONYU => "四捨五入", KIRISUTE => "切り捨て", KIRIAGE => "切り上げ"}  
-  
+  belongs_to :retailer
+
   validates_presence_of :name
   validates_uniqueness_of :name
   validates_length_of :name, :maximum => 50
@@ -37,6 +38,8 @@ class Supplier < ActiveRecord::Base
   validates_length_of :free_comment, :maximum => 10000 , :allow_blank => true
   validates_inclusion_of :tax_rule, :in => [SHISYAGONYU, KIRISUTE, KIRIAGE] , :allow_blank => true
 
+  validates_presence_of :retailer
+
   before_update :check_default
   before_destroy :check_default_and_products
   
@@ -77,4 +80,8 @@ class Supplier < ActiveRecord::Base
       raise ActiveRecord::ReadOnlyRecord
     end
   end
+
+  def self.list_by_retailer(retailer_id = Retailer::DEFAULT_ID)
+    return find(:all, :conditions => ["retailer_id = ? or id = ?", retailer_id, Retailer::DEFAULT_ID], :order => "id")
+  end
 end
index 4e14189..cb4cf03 100644 (file)
@@ -25,7 +25,7 @@ class SupplierSearchForm < SearchForm
 from\r
 suppliers s\r
 where\r
-(s.deleted_at IS NULL OR s.deleted_at > '#{Time.now.gmtime.strftime("%Y-%m-%d %H:%M:%S")}')\r
+(s.deleted_at IS NULL OR s.deleted_at > '#{Time.now.gmtime.strftime("%Y-%m-%d %H:%M:%S")}') \r
 #{unless condition.supplier_id.blank?\r
     conditions << condition.supplier_id.to_i\r
     "and s.id = ?"\r
@@ -50,6 +50,10 @@ where
     conditions << "%#{condition.email}%"\r
     "and s.email like ? "\r
   end}\r
+#{unless condition.retailer_id.blank?\r
+    conditions << condition.retailer_id.to_i\r
+    "and (s.retailer_id = ? or s.id = 1) "\r
+end}\r
 order by s.id\r
 EOS\r
   return [sql_condition, conditions] \r
index d13882d..b05be9a 100644 (file)
         select :admin_user, :authority_id, auths, :include_blank=>true %>
     </td>
   </tr>
+  <tr>
+    <th>販売元 <span class="pnt">※</span></th>
+    <td>
+      <%= retailers = Retailer.find(:all, :order => :id).map {|r| [r.name, r.id]}
+         select :admin_user, :retailer_id, retailers, :include_blank=>true %>
+    </td>
+  </tr>
 </table>
 
 <div class="btn_box">
index 4aa084f..b908c40 100644 (file)
@@ -17,6 +17,7 @@
     <th>権限</th>
     <th>名前</th>
     <th>所属</th>
+    <th>販売元</th>
     <th>稼働</th>
     <th>非稼働</th>
     <th>編集</th>
@@ -30,6 +31,7 @@
     <td><%=h authority_name(record.authority_id) %></td>
     <td><%=h record.name %></td>
     <td><%=h record.belongs_to %></td>
+    <td><%=h record.retailer.name %></td>
     <td class="t_center"><%= radio_button_tag "activity_#{index}", "true", checked=record.activity==1, {:onclick=>"fnUpdateActivity(#{record.id}, 'true')"} %></td>
     <td class="t_center"><%= radio_button_tag "activity_#{index}", "false", checked=record.activity==0, {:onclick=>"fnUpdateActivity(#{record.id}, 'false')"} %></td>
     <td class="t_center"><%= link_to "編集", edit_admin_admin_user_path(record) %></td>
index cb58f71..a5e04f5 100644 (file)
@@ -1,4 +1,3 @@
-<%= stylesheet_link_tag "admin_user/admin_user" %>
 <%= javascript_include_tag "admin/admin_user" %>
 
 <%= render :partial => "submenu" %>
index 5db7fd6..700445e 100644 (file)
  <%if @system_supplier_use_flag%>
   <tr>
     <th>仕入先名<span class="pnt">※</span></th>
-    <td><%suppliers = Supplier.find(:all,:order=>'id')%>
+    <td><%suppliers = Supplier.list_by_retailer(session[:admin_user].retailer_id)%>
       <%= confirm_select(confirm_tag(:select, :product, :supplier_id, suppliers.map{|s| [s.name,s.id]}), @product.supplier.name, "product") %>
     </td>
   </tr>  
  <% end %>
+ <%if session[:admin_user].master_shop? %>
+  <tr>
+    <th>販売元<span class="pnt">※</span></th>
+    <td><% retailers = Retailer.find(:all,:order=>'id')%>
+      <%= confirm_select(confirm_tag(:select, :product, :retailer_id, retailers.map{|s| [s.name,s.id]}), @product.retailer.name, "product") %>
+    </td>
+  </tr>  
+  <% else %>
+    <%= hidden_field_tag :retailer_id, session[:admin_user].retailer_id %>
+ <% end %>
   <tr>
     <th>カテゴリー名<span class="pnt">※</span></th>
     <td>
index 810006e..df70531 100644 (file)
@@ -7,7 +7,7 @@
 <p><%= link_to "規格管理に戻る", admin_styles_path %></p>
 <br />
 <ul>
-  <% Style.find(:all).each do | style | %>
+  <% Style.find(:all, :conditions=> ["retailer_id = ? ", session[:admin_user].retailer_id]).each do | style | %>
     <li>
       <%= style.id.to_s != params[:style_id].to_s ?  link_to(h(style.name), :style_id => style.id) : h(style.name)%><br>
     </li>
index 216d609..2feb0ec 100644 (file)
@@ -5,6 +5,7 @@
       <th>規格名</th>
       <td>
         <%= f.text_field :name %>
+       <%= f.hidden_field :retailer_id, {:value => session[:admin_user].retailer_id.to_s} %>
         <%= f.submit "登録", :confirm=>"この内容で登録して宜しいですか?", :class=>"btn_s" %>
       </td>
     </tr>
index 5380ae9..9db6a12 100644 (file)
@@ -78,3 +78,4 @@
   </tr>  
 </table>
 <%= hidden_field_tag "id", params[:id] %>
+<%= hidden_field_tag "supplier[retailer_id]", session[:admin_user].retailer_id %>
index af57a52..5c18975 100644 (file)
@@ -84,6 +84,7 @@ ja:
       mobile_device: "携帯対応端末"
       input: "入力内容"
       return_item: "返品情報"
+      retailer: "販売元"
     attributes:
       admin_user:
         name: "名前"
@@ -96,6 +97,7 @@ ja:
         created_at: "で作成された"
         updated_at: "で更新"
         deleted_at: "で削除"
+        retailer: "販売元"
       authorities_function:
         create_at: "で作成"
         update_at: "更新時に"
@@ -585,6 +587,7 @@ ja:
         created_at: "で作成された"
         updated_at: "で更新"
         deleted_at: "で削除"
+        retailer: "販売元名"
       product_access_log:
         docomo_flg: "ドコモフラグ"
         send_flg: "送信フラグ"
@@ -699,6 +702,11 @@ ja:
         created_at: "で作成された"
         updated_at: "で更新"
         deleted_at: "で削除"
+      retailer:
+        name: "販売元名"
+        created_at: "で作成された"
+        updated_at: "で更新"
+        deleted_at: "で削除"
       return_item:
         returned_at: "返品日時"
         returned_count: "返品数"
diff --git a/db/migrate/20100315054019_create_retailers.rb b/db/migrate/20100315054019_create_retailers.rb
new file mode 100644 (file)
index 0000000..f407c62
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+class CreateRetailers < ActiveRecord::Migration
+  def self.up
+    create_table :retailers, :comment => '販売元テーブル' do |t|
+      t.column :name, :string, :comment => '販売元名称'
+      t.column :name_kana, :string, :comment => '販売元名称(カナ)'
+      t.column :corp_name, :string, :comment => '会社名'
+      t.column :corp_name_kana, :string, :comment => '会社名(カナ)'
+      t.column :deleted_at, :datetime
+      t.timestamps
+    end
+    r = Retailer.new
+    s = Shop.find(:first)
+    unless s.nil?
+      r.name = s.name
+      r.name_kana = s.name_kana
+      r.corp_name = s.corp_name
+      r.corp_name_kana = s.corp_name_kana
+      r.save
+    end
+  end
+
+  def self.down
+    drop_table :retailers
+  end
+end
diff --git a/db/migrate/20100315062449_add_retailer_id_to_many_tables.rb b/db/migrate/20100315062449_add_retailer_id_to_many_tables.rb
new file mode 100644 (file)
index 0000000..d54259f
--- /dev/null
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+class AddRetailerIdToManyTables < ActiveRecord::Migration
+  def self.up
+    add_column :products, :retailer_id, :integer, :default => 1, :comment => "販売元ID"
+    execute("UPDATE products SET retailer_id = 1")
+    add_column :admin_users, :retailer_id, :integer, :default => 1, :comment => "販売元ID"
+    execute("UPDATE admin_users SET retailer_id = 1")
+    add_column :delivery_traders, :retailer_id, :integer, :default => 1, :comment => "販売元ID"
+    execute("UPDATE delivery_traders SET retailer_id = 1")
+    add_column :suppliers, :retailer_id, :integer, :default => 1, :comment => "販売元ID"
+    execute("UPDATE suppliers SET retailer_id = 1")
+    add_column :styles, :retailer_id, :integer, :default => 1, :comment => "販売元ID"
+    execute("UPDATE styles SET retailer_id = 1")
+  end
+
+  def self.down
+    remove_columns :styles, :retailer_id
+    remove_columns :suppliers, :retailer_id
+    remove_columns :delivery_traders, :retailer_id
+    remove_columns :admin_users, :retailer_id
+    remove_columns :products, :retailer_id
+  end
+end
index 7978555..40dde98 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 describe Admin::AdminUsersController do
@@ -44,7 +45,7 @@ describe Admin::AdminUsersController do
  
   describe "GET '新規登録'" do
     before do
-      @record = AdminUser.new({:name=>"gundam", :login_id=>"zak", :password=>"hyakushiki", :authority_id => 1})
+      @record = AdminUser.new({:name=>"gundam", :login_id=>"zak", :password=>"hyakushiki", :authority_id => 1, :retailer_id => 1})
     end
     it "登録に成功する" do
       post 'create', :admin_user => @record.attributes
index b398bc6..bd47dc0 100644 (file)
@@ -68,7 +68,6 @@ describe Admin::NewInformationsController do
       post 'confirm', :new_information => record
       get 'update', :new_information => record
       assigns[:new_information].id.should == id
-      p assigns[:new_information].date.class
       assigns[:new_information].date.should == DateTime.parse("2008-01-01")
       response.should_not be_redirect
     end
index fd27ee9..6ee3433 100644 (file)
@@ -1,8 +1,9 @@
+# -*- coding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 describe Admin::ProductsController do
   fixtures :products, :admin_users, :authorities, :functions, :authorities_functions, :admin_users, :categories, :resource_datas, :image_resources
-  fixtures :styles, :product_styles, :style_categories,:suppliers
+  fixtures :styles, :product_styles, :style_categories,:suppliers, :retailers
 
   before do
     session[:admin_user] = admin_users(:admin10)
@@ -96,6 +97,10 @@ describe Admin::ProductsController do
       get "search", :search => search
     end
 
+    it "retailer_id" do
+      get "search", :search => {:retailer_id => @valid_product.retailer_id, :product_id => @valid_product.id.to_s}
+    end
+
     after(:each) do
       assigns[:products][0].should == @valid_product
     end
@@ -130,7 +135,7 @@ describe Admin::ProductsController do
 
     it "confirm単体" do
       resource_max = ImageResource.maximum(:id)
-      post 'confirm', :product => {:small_resource => @small_pic, :medium_resource => @medium_pic, :large_resource => @large_pic, :name => "test", :category_id => 1, :introduction => "test intro", :description => "test desc"}
+      post 'confirm', :product => {:small_resource => @small_pic, :medium_resource => @medium_pic, :large_resource => @large_pic, :name => "test", :category_id => 1, :introduction => "test intro", :description => "test desc", :retailer_id => 1}
       assigns[:product].small_resource_id.should_not be_nil
       assigns[:product].small_resource_id.should > resource_max
       response.should render_template("admin/products/confirm.html.erb")
@@ -139,9 +144,9 @@ describe Admin::ProductsController do
     it "confirm and create" do
       last_product = Product.find(:last)
       resource_max = ImageResource.maximum(:id)
-      post 'confirm', :product => {:small_resource => @small_pic, :medium_resource => @medium_pic, :large_resource => @large_pic, :name => "test", :category_id => 1, :introduction => "test intro", :description => "test desc"}
+      post 'confirm', :product => {:small_resource => @small_pic, :medium_resource => @medium_pic, :large_resource => @large_pic, :name => "test", :category_id => 1, :introduction => "test intro", :description => "test desc", :retailer_id => 1}
       product = assigns[:product]
-      post 'create', :product => {:small_resource_id => product.small_resource_id, :medium_resource_id => product.medium_resource_id, :large_resource_id => product.large_resource_id, :name => "test", :category_id => 1, :introduction => "test intro", :description => "test desc"}
+      post 'create', :product => {:small_resource_id => product.small_resource_id, :medium_resource_id => product.medium_resource_id, :large_resource_id => product.large_resource_id, :name => "test", :category_id => 1, :introduction => "test intro", :description => "test desc", :retailer_id => 1}
       ImageResource.maximum(:id).should_not == resource_max
       Product.find(:last).should_not == last_product
       response.should redirect_to(:action => "show", :id => assigns[:product].id)
@@ -182,6 +187,64 @@ describe Admin::ProductsController do
     end
   end
 
+  describe "GET 'search' from retailer_fail" do
+    before(:each) do
+      session[:admin_user] = admin_users(:admin17_retailer_id_is_fails)
+      @valid_product = products(:valid_product)
+    end
+
+    it "product_id" do
+      get "search", :search => {:product_id => @valid_product.id.to_s}
+    end
+
+    it "name" do
+      get "search", :search => {:name => @valid_product.name}
+    end
+
+    it "style" do
+      get "search", :search => {:style => "valid_category"}
+    end
+
+    it "code" do
+      get "search", :search => {:code => "AC001"}
+    end
+    it "code" do
+      get "search", :search => {:supplier => 2}
+    end
+    it "category" do
+      get "search", :search => {:category => @valid_product.category_id}
+    end
+
+    it "created_at" do
+      search = {}
+      search.merge! date_to_select(@valid_product.created_at, 'created_at_from')
+      search.merge! date_to_select(@valid_product.created_at, 'created_at_to')
+      get "search", :search => search
+    end
+
+    it "updated_at" do
+      search = {}
+      search.merge! date_to_select(@valid_product.updated_at, 'updated_at_from')
+      search.merge! date_to_select(@valid_product.updated_at, 'updated_at_to')
+      get "search", :search => search
+    end
+
+    it "sale_start_at" do
+      search = {}
+      search.merge! date_to_select(@valid_product.sale_start_at, 'sale_start_at_start')
+      search.merge! date_to_select(@valid_product.sale_start_at, 'sale_start_at_end')
+      get "search", :search => search
+    end
+
+    it "retailer_id" do
+      get "search", :search => {:retailer_id => @valid_product.retailer_id}
+    end
+
+    after(:each) do
+      assigns[:products].should == []
+    end
+  end
+
 
 end
 
index 34d78a1..4bd1af5 100644 (file)
@@ -60,6 +60,14 @@ describe Admin::ReturnItemsController do
       assigns[:product_styles][0].manufacturer_id.should == @ps.manufacturer_id
     end
 
+    it "with fail_retailer" do
+      session[:admin_user] = admin_users(:admin17_retailer_id_is_fails)
+      search = {}
+      get "search", :condition => search
+      response.should be_success
+      assigns[:product_styles].should == []
+    end
+
   end
 
   describe "GET 'new'" do
@@ -168,6 +176,16 @@ describe Admin::ReturnItemsController do
       assigns[:return_items][0].product_style.manufacturer_id.should == @ri.product_style.manufacturer_id
       response.should be_success
     end
+
+    it "is fail_retailer" do
+      session[:admin_user] = admin_users(:admin17_retailer_id_is_fails)
+      condition = {:name => ""}
+      get 'history_search', :condition => condition
+      assigns[:return_items].size.should == 0
+      response.should be_success
+    end
+
+
   end
 
   describe "GET 'edit'" do
@@ -261,6 +279,14 @@ describe Admin::ReturnItemsController do
       get 'csv', :id => id
       response.body.count("\n").should == csv_line_count
     end      
+
+    it "is retailer_fail" do 
+      session[:admin_user] = admin_users(:admin17_retailer_id_is_fails)
+      get 'csv', :id => DateTime.now.strftime('%Y%m%d_%H%M%S')
+      response.headers['Content-Type'].should =~ %r(^application/octet-stream)
+      rows = response.body.chomp.split("\n")
+      rows.size.should == 1
+    end
   end
 end
 
index f4324c6..a1237e7 100644 (file)
@@ -1,7 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 describe Admin::ShopsController do
-  fixtures :authorities, :functions, :admin_users , :shops
+  fixtures :authorities, :functions, :admin_users , :shops, :retailers
   
   before(:each) do
     session[:admin_user] = AdminUser.first
@@ -151,7 +151,7 @@ describe Admin::ShopsController do
   
   describe "GET 'delivery_create'" do
     before do
-      @delivery_trader = {:name=>"追加",:url=>"http://www.hoge.com"}
+      @delivery_trader = {:name=>"追加",:url=>"http://www.hoge.com", :retailer_id => Retailer::DEFAULT_ID}
       @delivery_time = {}
       DeliveryTime::MAX_SIZE.times do |i|
         @delivery_time["#{i}"]={:name=>"午前中なら#{i}"}
@@ -186,6 +186,24 @@ describe Admin::ShopsController do
       DeliveryTrader.find(:first,:order=>"id desc",:limit=>1).delivery_fees.size.should == DeliveryFee::MAX_SIZE
       DeliveryTrader.find(:first,:order=>"id desc",:limit=>1).delivery_fees[47].prefecture_id == nil
     end
+
+    it "retailer_idが無効なものは登録できない" do
+      delivery_trader = {:name=>"追加",:url=>"http://www.hoge.com", :retailer_id => nil}
+      trader_count = DeliveryTrader.count
+      time_count = DeliveryTime.count
+      fee_count = DeliveryFee.count
+      get 'delivery_create', :delivery_trader=>delivery_trader,:delivery_time=>@delivery_time,:delivery_fee=>@delivery_fee
+      response.should render_template("admin/shops/delivery_new.html.erb")
+    end
+
+    it "存在しないretailer_idは登録できない" do
+      retailer_max = Retailer.find(:last).id + 100
+      delivery_trader = @delivery_trader.merge({:name => "fail_trader", :retailer_id => retailer_max})
+      get 'delivery_create', :delivery_trader=>delivery_trader,:delivery_time=>@delivery_time,:delivery_fee=>@delivery_fee
+      response.should render_template("admin/shops/delivery_new.html.erb")
+    end
+
+
   end
   
   
index 9432e64..ba454cc 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 require 'spec_helper'
 
 describe Admin::StockBaseController do
@@ -71,5 +72,13 @@ describe Admin::StockBaseController do
       assigns[:product_styles].size.should == 1
       assigns[:product_styles][0].attributes.should == product_styles(:valid_product).attributes      
     end      
+
+    it "販売元が商品を持っていない時に検索すると空になる" do
+      session[:admin_user] = admin_users(:admin17_retailer_id_is_fails)
+      get 'search', :condition => {}
+      assigns[:product_styles].should == []
+    end
+
+
   end
 end
index 62be0f0..e58fd67 100644 (file)
@@ -1,10 +1,38 @@
 require 'spec_helper'
 
 describe Admin::StockCsvController do
+  fixtures :admin_users,:products,:product_styles,:suppliers
+  before do 
+    session[:admin_user] = admin_users(:admin10)
+    @controller.class.skip_before_filter @controller.class.before_filter
+    @controller.class.skip_after_filter @controller.class.after_filter    
+  end
 
   #Delete this example and add some real ones
   it "should use Admin::StockCsvController" do
     controller.should be_an_instance_of(Admin::StockCsvController)
   end
 
+  describe "csv" do 
+    it "get csv" do 
+      get 'csv', :id => "20100101"
+      response.headers['Content-Type'].should =~ %r(^application/octet-stream)
+      rows = response.body.chomp.split("\n")
+      rows.size.should >= 10
+    end
+
+    it "idが無ければ、csvは取得できない" do
+      get 'csv'
+      response.should render_template("public/404.html")
+    end
+
+    it "is retailer_fail" do 
+      session[:admin_user] = admin_users(:admin17_retailer_id_is_fails)
+      get 'csv', :id => "20100101"
+      response.headers['Content-Type'].should =~ %r(^application/octet-stream)
+      rows = response.body.chomp.split("\n")
+      rows.size.should == 1      
+    end
+  end
+
 end
index cc050fc..e2d5e8a 100644 (file)
@@ -2,9 +2,29 @@ require 'spec_helper'
 
 describe Admin::StockHistoriesController do
 
+  fixtures :admin_users,:products,:product_styles,:suppliers, :stock_histories
+  before do 
+    session[:admin_user] = admin_users(:admin10)
+    @controller.class.skip_before_filter @controller.class.before_filter
+    @controller.class.skip_after_filter @controller.class.after_filter    
+  end
+
   #Delete this example and add some real ones
   it "should use Admin::StockHistoriesController" do
     controller.should be_an_instance_of(Admin::StockHistoriesController)
   end
 
+  describe 'get search' do 
+    it "all log" do 
+      get 'search', :condition => {}
+      assigns[:stock_histories].size.should > 0
+    end
+
+    it "is fail_retailer" do 
+      session[:admin_user] = admin_users(:admin17_retailer_id_is_fails)
+      get 'search', :condition => {}
+      assigns[:stock_histories].size.should == 0
+    end
+  end
+
 end
index dcdca7f..7526f17 100644 (file)
@@ -1,7 +1,8 @@
+# -*- coding: utf-8 -*-
 require 'spec_helper'
 
 describe Admin::StockInController do
-  fixtures :admin_users,:products,:product_styles,:suppliers,:stock_histories
+  fixtures :admin_users,:products,:product_styles,:suppliers,:stock_histories, :retailers
   before do 
     session[:admin_user] = admin_users(:admin10)
     @controller.class.skip_before_filter @controller.class.before_filter
@@ -65,4 +66,5 @@ describe Admin::StockInController do
       response.should render_template("admin/stock_in/edit.html.erb")
     end
   end  
+
 end
index b2fb58a..ae8e316 100644 (file)
@@ -53,6 +53,13 @@ describe Admin::StyleCategoriesController do
       post "create", :style_category => {:style_id => 1, :name => "test"}
       StyleCategory.find(:last).name.should == "test"
     end
+
+    it "other shop should not be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      lambda { post "create", :style_category => {:style_id => 1, :name => "test2"} }.should raise_error(ActiveRecord::RecordNotFound)
+      StyleCategory.find(:last).name.should_not == "test2"
+    end
+
   end
   
   describe "POST 'update'" do
@@ -60,6 +67,13 @@ describe Admin::StyleCategoriesController do
       post "update", :id => 60, :style_category => {:style_id => 6, :name => "test"}
       StyleCategory.find_by_id(60).name.should == "test"
     end
+
+    it "other shop should not be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      lambda { post "update", :id => 60, :style_category => {:style_id => 6, :name => "test2"} }.should raise_error(ActiveRecord::RecordNotFound)
+      StyleCategory.find_by_id(60).name.should_not == "test2"
+    end
+
   end
 
   describe "GET 'destroy'" do
@@ -67,6 +81,13 @@ describe Admin::StyleCategoriesController do
       get 'destroy', :id => 60
       StyleCategory.find_by_id(60).should be_nil
     end
+
+    it "other shop should not be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      lambda { get 'destroy', :id => 60 }.should raise_error(ActiveRecord::RecordNotFound)
+      StyleCategory.find_by_id(60).should_not be_nil
+    end
+
   end
 
 
index b45fe03..e230d38 100644 (file)
@@ -19,6 +19,7 @@ describe Admin::StylesController do
     it "should be successful" do
       get 'index'
       assigns[:styles].should_not be_nil
+      assigns[:styles].size.should == 7
       assigns[:style].should_not be_nil
     end
 
@@ -28,6 +29,19 @@ describe Admin::StylesController do
       assigns[:style].should == Style.find_by_id(1)
     end
 
+    it "other shop should be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      get 'index'
+      assigns[:styles].should_not be_nil
+      assigns[:styles].size.should == 1
+    end
+
+    it "other shop will not get main shop style" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      get 'index', :id => 1
+      assigns[:style].id.should be_nil
+    end
+
   end
 
   describe "GET 'new'" do
@@ -39,10 +53,19 @@ describe Admin::StylesController do
 
   describe "create" do
     it "should be successful" do
-      post 'create', :style => {:name => "test"}
+      post 'create', :style => {:name => "test", :retailer_id => session[:admin_user].retailer_id}
       response.should redirect_to(:action => "index")
       Style.find(:last).name.should == "test"
     end
+
+    it "other shop should be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      post 'create', :style => {:name => "test2", :retailer_id => session[:admin_user].retailer_id}
+      response.should redirect_to(:action => "index")
+      Style.find(:last).name.should == "test2"
+      Style.find(:last).retailer_id.should == session[:admin_user].retailer_id
+    end
+
   end
   
   describe "update" do
@@ -52,6 +75,13 @@ describe Admin::StylesController do
       response.should redirect_to(:action => "index")
       Style.find_by_id(1).name.should == "test"
     end
+
+    it "other_user should not be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      get 'index', :id => 1
+      lambda { post "update", :id => 1, :style => {:name => "test"} }.should raise_error(NoMethodError)
+    end
+
   end
 
   describe "GET 'destroy'" do
@@ -60,6 +90,20 @@ describe Admin::StylesController do
       response.should redirect_to(:action => "index")
       Style.find_by_id(1).should be_nil
     end
+
+    it "other_user should not be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      lambda { get 'destroy', :id => 1 }.should raise_error(NoMethodError)
+    end
+
+    it "same retailer_id should be successful" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      other_shop_style1 = styles(:other_shop_style1)
+      get 'destroy', :id => other_shop_style1.id
+      Style.find_by_id(other_shop_style1.id).should be_nil
+    end
+
+
   end
 
   describe "GET 'up'" do
@@ -68,6 +112,12 @@ describe Admin::StylesController do
       Style.find_by_id(1).position.should == 1
       Style.find_by_id(3).position.should == 2
     end
+
+    it "should be successful" do
+      get 'up', :id => 8
+      Style.find_by_id(8).position.should == 8
+    end
+
   end
   
   describe "GET 'up'" do
@@ -76,6 +126,13 @@ describe Admin::StylesController do
       Style.find_by_id(1).position.should == 3
       Style.find_by_id(4).position.should == 2
     end
+
+    it "should be successful" do
+      get 'down', :id => 7
+      Style.find_by_id(7).position.should == 7
+      Style.find_by_id(8).position.should == 8
+    end
+
   end
 
 
index 911cc3b..5b95324 100644 (file)
@@ -1,7 +1,7 @@
 require 'spec_helper'
 
 describe Admin::SuppliersController do
-  fixtures :admin_users,:suppliers,:prefectures
+  fixtures :admin_users,:suppliers,:prefectures, :retailers
   before do 
     session[:admin_user] = admin_users(:admin10)
     @controller.class.skip_before_filter @controller.class.before_filter
@@ -19,8 +19,14 @@ describe Admin::SuppliersController do
   describe "GET 'search'" do
    
     it "should be successful" do
-      get 'search'
+      get 'search', :condition => {}
       response.should be_success
+      assigns[:suppliers].size.should == 4
+    end
+
+    it "conditionがないと検索ができない" do 
+      get 'search'
+      response.should render_template("admin/suppliers/index.html.erb")      
     end
     
     it "仕入先ID" do
@@ -70,6 +76,28 @@ describe Admin::SuppliersController do
       assigns[:suppliers].size.should == 1
       assigns[:suppliers][0].attributes.should == suppliers(:three).attributes      
     end    
+
+    it "違う販売元検索" do 
+      not_master_shop = suppliers(:not_master_shop_1)
+      get 'search', :condition => {:name => not_master_shop.name}
+      response.should be_success
+      assigns[:suppliers].size.should == 0      
+    end
+    it "違う販売元検索、admin_userが正しいケース" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      not_master_shop = suppliers(:not_master_shop_1)
+      get 'search', :condition => {:name => not_master_shop.name}
+      response.should be_success
+      assigns[:suppliers].size.should == 1
+    end
+
+    it "admin_userがメインショップじゃない場合" do
+      session[:admin_user] = admin_users(:admin18_retailer_id_is_another_shop)
+      get 'search', :condition => {}
+      response.should be_success
+      assigns[:suppliers].size.should == 2
+    end
+
   end
   describe "GET 'new'" do
     it "成功" do
@@ -133,6 +161,16 @@ describe Admin::SuppliersController do
       response.should_not be_redirect
       response.should render_template("admin/suppliers/new.html.erb")
     end
+
+    it "retailer_idが不正なパターン" do
+      retailer_max = Retailer.find(:last).id + 100
+      post 'create', :supplier => @supplier.attributes.merge({"name" => "retailer_fail", "retailer_id" => retailer_max})
+      assigns[:supplier].should_not be_nil
+      assigns[:supplier].id.should be_nil
+      response.should_not be_redirect
+      response.should render_template("admin/suppliers/new.html.erb")
+    end
+
   end
   
   describe "POST 'update'" do
index e805ee5..c68ac97 100644 (file)
@@ -13,6 +13,7 @@ load_by_admin_user_test_id_1:
   password: <%= AdminUser.encode_password 'hoge' %>
   authority_id: 1
   activity: true
+  retailer_id: 1
 
 load_by_admin_user_mim_position_1:
   id: 2
@@ -22,18 +23,21 @@ load_by_admin_user_mim_position_1:
   created_at: Wed May 21 13:14:11 +0900 2008
   password: <%= AdminUser.encode_password 'hoge' %>
   authority_id: 1
+  retailer_id: 1
 
 load_by_admin_user_max_position_100:
   id: 3
   name: max_position_100
   position: 100
   created_at: Wed May 22 13:14:11 +0900 2008
+  retailer_id: 1
 
 load_by_admin_user_created_at_23:
   id: 4
   name: created_at_23
   position: 4
   created_at: Wed May 23 13:14:11 +0900 2008
+  retailer_id: 1
 
 load_by_admin_user_created_at_24:
   id: 5
@@ -41,6 +45,7 @@ load_by_admin_user_created_at_24:
   position: 5
   created_at: Wed May 24 13:14:11 +0900 2008
   activity : true
+  retailer_id: 1
 
 load_by_admin_user_created_at_22:
   id: 6
@@ -48,6 +53,7 @@ load_by_admin_user_created_at_22:
   position: 6
   created_at: Wed May 22 13:14:11 +0900 2008
   activity : false
+  retailer_id: 1
 
 load_by_admin_user_activity_true:
   id: 7
@@ -58,6 +64,7 @@ load_by_admin_user_activity_true:
   activity : true
   authority_id: 1
   password: <%= AdminUser.encode_password 'hoge' %>
+  retailer_id: 1
 
 login_admin_user:
   id: 8
@@ -68,6 +75,7 @@ login_admin_user:
   created_at: Wed May 21 13:14:11 +0900 2008
   activity : true
   authority_id: 1
+  retailer_id: 1
   
 load_by_admin_user_activity_false:
   id: 9
@@ -78,6 +86,7 @@ load_by_admin_user_activity_false:
   login_id: admin9
   password: <%= AdminUser.encode_password 'hoge' %>
   authority_id: 1
+  retailer_id: 1
 
 admin10:
   id: 10
@@ -88,6 +97,7 @@ admin10:
   created_at: Wed May 21 13:14:11 +0900 2008
   activity : true
   authority_id: 1
+  retailer_id: 1
 
 admin_user_00011: 
   name: "KBMJリーダー"
@@ -101,6 +111,7 @@ admin_user_00011:
   login_id: kbmjadmin
   created_at: 2008-08-22 08:52:03.953000 Z
   belongs_to: KBMJ
+  retailer_id: 1
   
 admin_user_00012: 
   name: "KBMJ担当者"
@@ -114,6 +125,7 @@ admin_user_00012:
   login_id: kbmj
   created_at: 2008-08-22 08:55:33.140000 Z
   belongs_to: KBMJ
+  retailer_id: 1
   
 admin_user_00013: 
   name: "KBMJ管理者"
@@ -127,6 +139,7 @@ admin_user_00013:
   login_id: kbmjadmin
   created_at: 2008-08-22 08:56:02.453000 Z
   belongs_to: KBMJ
+  retailer_id: 1
   
 admin_user_00014: 
   name: "KBMJ運用者"
@@ -140,6 +153,7 @@ admin_user_00014:
   login_id: kbmj
   created_at: 2008-08-22 08:56:29.171000 Z
   belongs_to: KBMJ
+  retailer_id: 1
   
 admin_user_00015: 
   name: "KBMJ顧客対応"
@@ -153,6 +167,7 @@ admin_user_00015:
   login_id: kbmjs
   created_at: 2008-08-22 08:56:58.156000 Z
   belongs_to: KBMJ
+  retailer_id: 1
   
 admin_user_00016: 
   name: "KBMJ"
@@ -166,5 +181,27 @@ admin_user_00016:
   login_id: nitsu
   created_at: 2008-08-22 08:57:28.421000 Z
   belongs_to: "KBMJ"
+  retailer_id: 1  
   
-  
+admin17_retailer_id_is_fails:
+  id: 17
+  name: admin17
+  login_id: admin17
+  password: <%= AdminUser.encode_password 'hoge' %>
+  position: 17
+  created_at: Wed May 21 13:14:11 +0900 2008
+  activity : true
+  authority_id: 1
+  retailer_id: 100
+
+admin18_retailer_id_is_another_shop:
+  id: 18
+  name: admin18
+  login_id: admin18
+  password: <%= AdminUser.encode_password 'hoge' %>
+  position: 18
+  created_at: Wed May 21 13:14:11 +0900 2008
+  activity : true
+  authority_id: 1
+  retailer_id: 2
+
index 6510319..74f1a34 100644 (file)
@@ -5,9 +5,11 @@ witch:
   name: キキ
   url: http://example.org/
   position: 1
+  retailer_id: 1
 
 yamato:
   id: 2
   name: ヤマト
   url: http://example.org/
   position: 2
+  retailer_id: 1
index 22e1230..d00572f 100644 (file)
@@ -197,6 +197,7 @@ valid_product:
   created_at: 2009-10-01 00:00:00
   updated_at: 2009-10-01 00:00:00
   supplier_id: 2
+  retailer_id: 1
 #未公開商品   +CSVアップロード元データとして使用
 not_permit_product:
   id: 17
diff --git a/spec/fixtures/retailers.yml b/spec/fixtures/retailers.yml
new file mode 100644 (file)
index 0000000..9701351
--- /dev/null
@@ -0,0 +1,6 @@
+valid_retailer:
+  id: 1
+  name: メイン販売元
+other_retailer_2:
+  id: 2
+  name: サブ販売元
index a2f7476..ac62115 100644 (file)
@@ -41,3 +41,9 @@ valid_category:
   style_id: 7
   name: valid_category
   position: 7
+
+other_shop_category1:
+  id: 80
+  style_id: 8
+  name: other_shop_category1
+  position: 8
index 125570f..93645a1 100644 (file)
@@ -35,3 +35,8 @@ valid_style:
   name: valid_style
   position: 7
 
+other_shop_style1:
+  id: 8
+  name: other_shop_style1
+  position: 8
+  retailer_id: 2
index 3b6fe2e..c990dde 100644 (file)
@@ -39,4 +39,20 @@ three:
   tel03: '1111'
   fax01: '03'
   fax02: '9999'
-  fax03: '9999'  
\ No newline at end of file
+  fax03: '9999'  
+not_master_shop_1:
+  id: 5
+  name: 'not_master_shop_1'
+  contact_name: 'not_master_shop_1_contact'
+  zipcode01: '103'
+  zipcode02: '0003'
+  prefecture_id: 13
+  address_city: '東京都テスト区テスト町'
+  address_detail: '2-2-2'
+  tel01: '03'
+  tel02: '9998'
+  tel03: '9998'
+  fax01: '03'
+  fax02: '9998'
+  fax03: '9998'  
+  retailer_id: 2
\ No newline at end of file
index 5c4eab4..b672d79 100644 (file)
@@ -1,7 +1,8 @@
+# -*- coding: utf-8 -*-
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
 describe AdminUser do
-  fixtures :admin_users, :authorities
+  fixtures :admin_users, :authorities, :retailers
   before(:each) do
     @admin_user = admin_users(:login_admin_user)
   end
@@ -60,7 +61,7 @@ describe AdminUser do
     end
 
     it "入力されたパスワードを暗号化(新規作成の場合)" do
-      admin_user = AdminUser.new({:name=>"zak", :login_id=>"gundam", :password=>"zak", :authority_id => authorities(:auth01).id })
+      admin_user = AdminUser.new({:name=>"zak", :login_id=>"gundam", :password=>"zak", :authority_id => authorities(:auth01).id, :retailer_id => 1 })
       admin_user.save
       AdminUser.find(:first, :conditions=>["login_id=?","gundam"]).password.should == AdminUser.encode_password("zak")
     end
@@ -98,4 +99,16 @@ describe AdminUser do
     end
   end
 
+  describe "販売元IDを追加" do
+    it "販売元IDがないとvalidateに失敗する" do
+      @admin_user.retailer_id = nil
+      @admin_user.should_not be_valid
+    end
+
+    it "マスターショップかどうか判定" do 
+      @admin_user.should be_master_shop
+      not_master_retailer = admin_users(:admin17_retailer_id_is_fails)
+      not_master_retailer.should_not be_master_shop
+    end
+  end
 end
index 579c232..f8a4ad2 100644 (file)
@@ -1,7 +1,8 @@
+# -*- coding: utf-8 -*-
 require File.dirname(__FILE__) + '/../spec_helper'
 
 describe Category do
-  fixtures :categories, :products, :image_resources,:suppliers
+  fixtures :categories, :products, :image_resources,:suppliers, :retailers
 
   before(:each) do
     @category = categories(:dai_category)
index 5dc7ea2..150fb94 100644 (file)
@@ -1,7 +1,7 @@
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
 describe DeliveryTrader do
-  fixtures :delivery_traders
+  fixtures :delivery_traders, :retailers
   
   before(:each) do
     @delivery_trader = delivery_traders :witch
index 7e7166b..f02fecf 100644 (file)
@@ -1,7 +1,8 @@
+# -*- coding: utf-8 -*-
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
 describe Product do
-  fixtures :products, :image_resources, :product_statuses,:categories,:product_styles,:statuses,:suppliers
+  fixtures :products, :image_resources, :product_statuses,:categories,:product_styles,:statuses,:suppliers,:retailers
   
   include ActionView::Helpers::NumberHelper
   
@@ -236,6 +237,12 @@ describe Product do
       Product.delivery_dates_select.should == arr
     end
   end
+
+  describe "販売元を追加" do
+    it "販売元にアクセスが可能" do
+      @product.retailer.should_not be_nil
+    end
+  end
   
   #=====================================================
   private
diff --git a/spec/models/retailer_spec.rb b/spec/models/retailer_spec.rb
new file mode 100644 (file)
index 0000000..68bcd8f
--- /dev/null
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe Retailer do
+  
+  describe "validateチェック" do
+    before do
+      @retailer = Retailer.new
+    end
+    it "初期状態" do
+      @retailer.should_not be_valid
+    end
+    it "販売元名称を追加" do
+      @retailer.name = "販売元テスト"
+      @retailer.should be_valid
+    end
+  end
+end
index 5d6ddca..ededd94 100644 (file)
@@ -1,7 +1,7 @@
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
 describe Style do
-  fixtures :styles, :style_categories,:product_styles,:products
+  fixtures :styles, :style_categories,:product_styles,:products, :retailers
   before(:each) do
     @style = styles(:can_incriment)
   end
@@ -17,6 +17,13 @@ describe Style do
       @style.name = styles(:can_not_incriment).name
       @style.should_not be_valid
     end
+    it "retailer_idのチェック" do 
+      max_retailer = Retailer.find(:last).id + 100
+      @style.retailer_id = max_retailer
+      @style.should_not be_valid
+      @style.retailer_id = Retailer::DEFAULT_ID
+      @style.should be_valid
+    end
   end
   describe "その他" do
     it "商品を持っているか判断" do
@@ -32,4 +39,16 @@ describe Style do
       @style.has_product?.should be_true
     end
   end  
+
+  describe "select_options" do
+    it "retailer_id = 1のケース" do
+      array = Style.select_options
+      array.size.should >= 300
+    end
+
+    it "retailer_id = 2のケース" do
+      array = Style.select_options(nil, 2)
+      array.size.should <= 300
+    end
+  end
 end
index 5f6f34e..c384270 100644 (file)
@@ -1,7 +1,7 @@
 require 'spec_helper'
 
 describe Supplier do
-  fixtures :suppliers
+  fixtures :suppliers, :retailers
   before(:each) do
     @supplier = suppliers(:one)
   end
@@ -164,6 +164,15 @@ describe Supplier do
       @supplier.tax_rule = 2
       @supplier.should be_valid
     end    
+    it "販売元" do
+      @supplier.retailer_id = nil
+      @supplier.should_not be_valid
+      retailer_max = Retailer.find(:last).id + 100
+      @supplier.retailer_id = retailer_max
+      @supplier.should_not be_valid
+      @supplier.retailer_id = Retailer::DEFAULT_ID
+      @supplier.should be_valid      
+    end
   end
   describe "その他" do
     fixtures :prefectures
@@ -172,5 +181,25 @@ describe Supplier do
       supplier.prefecture_name.should == prefectures(:prefecture_00011).name
     end
   end
-  
+
+  describe "販売元一覧メソッド" do
+    fixtures :admin_users
+
+    it "引数なしの場合はDEFAILT_IDで検索" do 
+      suppliers = Supplier.list_by_retailer
+      suppliers.size.should == 4
+    end
+    it "検索が正常にできる(マスターショップ)" do 
+      admin_user = admin_users(:load_by_admin_user_test_id_1)
+      suppliers = Supplier.list_by_retailer(admin_user.retailer_id)
+      suppliers.size.should == 4
+    end
+
+    it "検索が正常にできる(マスター以外のショップ)" do 
+      admin_user = admin_users(:admin18_retailer_id_is_another_shop)
+      suppliers = Supplier.list_by_retailer(admin_user.retailer_id)
+      suppliers.size.should == 2
+    end
+
+  end
 end
index 2d6f3f9..ce68a69 100644 (file)
@@ -1,3 +1,3 @@
-\8f¤\95iID,\8cö\8aJ\90Ý\92è,\96¼\91O,\8eQ\8fÆURL,\88ê\97\97\83R\83\81\83\93\83g,\8fÚ\8d×\83R\83\81\83\93\83g,\83L\81[\83\8f\81[\83h,\8es\8fê\8eQ\8dl\89¿\8ai,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9cID,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9c\83R\83\81\83\93\83g,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9c\83p\83X,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9cID,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9c\83R\83\81\83\93\83g,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9c\83p\83X,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9cID,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9c\83R\83\81\83\93\83g,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9c\83p\83X,\8dw\93ü\90§\8cÀ,\83|\83C\83\93\83g\95t\97^\97¦,\94Ì\94\84\8aJ\8en\93ú,\94Ì\94\84\8fI\97¹\93ú,\8f¤\95i\83J\83e\83S\83\8a,\93ü\89×\97\\92è\93ú,\83T\83C\83Y,\91f\8dÞ,\8c´\8eY\92n,\8fd\82³,\93ü\89×\93ú,\82»\82Ì\91¼\8ed\97l,\83t\83\8a\81[\93ü\97Í,\94z\91\97\93ú,\8ed\93ü\90æ\96¼,\93o\98^\93ú,\8dX\90V\93ú\r
-17,\94ñ\8cö\8aJ,\89º\92\85,,\83e\83X\83g01,\83e\83X\83g01,\83t\83@\83b\83V\83\87\83\93,5000,18,,,18,,,,,,,,,,\91å\83J\83e\83S\83\8a,2009/10/1,,,japan,,,,,3\93ú\8cã,,,\r
-,\8cö\8aJ,\83\8d\83\93\83O\83R\81[\83g,,\83e\83X\83g02,\83e\83X\83g02,\83t\83@\83b\83V\83\87\83\93,15000,18,,,18,,,,,,,,,,\91å\83J\83e\83S\83\8a,2009/10/1,,,english,,,,,,\82Ä\82·\82Æ\81i\8a\94\81j,,\r
+\8f¤\95iID,\8cö\8aJ\90Ý\92è,\96¼\91O,\8eQ\8fÆURL,\88ê\97\97\83R\83\81\83\93\83g,\8fÚ\8d×\83R\83\81\83\93\83g,\83L\81[\83\8f\81[\83h,\8es\8fê\8eQ\8dl\89¿\8ai,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9cID,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9c\83R\83\81\83\93\83g,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9c\83p\83X,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9cID,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9c\83R\83\81\83\93\83g,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9c\83p\83X,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9cID,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9c\83R\83\81\83\93\83g,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9c\83p\83X,\8dw\93ü\90§\8cÀ,\83|\83C\83\93\83g\95t\97^\97¦,\94Ì\94\84\8aJ\8en\93ú,\94Ì\94\84\8fI\97¹\93ú,\8f¤\95i\83J\83e\83S\83\8a,\93ü\89×\97\\92è\93ú,\83T\83C\83Y,\91f\8dÞ,\8c´\8eY\92n,\8fd\82³,\93ü\89×\93ú,\82»\82Ì\91¼\8ed\97l,\83t\83\8a\81[\93ü\97Í,\94z\91\97\93ú,\8ed\93ü\90æ\96¼,\94Ì\94\84\8c³\96¼,\93o\98^\93ú,\8dX\90V\93ú\r
+17,\94ñ\8cö\8aJ,\89º\92\85,,\83e\83X\83g01,\83e\83X\83g01,\83t\83@\83b\83V\83\87\83\93,5000,18,,,18,,,,,,,,,,\91å\83J\83e\83S\83\8a,2009/10/1,,,japan,,,,,3\93ú\8cã,,,,\r
+,\8cö\8aJ,\83\8d\83\93\83O\83R\81[\83g,,\83e\83X\83g02,\83e\83X\83g02,\83t\83@\83b\83V\83\87\83\93,15000,18,,,18,,,,,,,,,,\91å\83J\83e\83S\83\8a,2009/10/1,,,english,,,,,,\82Ä\82·\82Æ\81i\8a\94\81j,\83\81\83C\83\93\94Ì\94\84\8c³,,\r
index 5ffb35e..8cde9b8 100644 (file)
@@ -1,3 +1,3 @@
 \8f¤\95iID,\8cö\8aJ\90Ý\92è,\96¼\91O,\8eQ\8fÆURL,\88ê\97\97\83R\83\81\83\93\83g,\8fÚ\8d×\83R\83\81\83\93\83g,\83L\81[\83\8f\81[\83h,\8eQ\8dl\8es\8fê\89¿\8ai,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9cID,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9c\83R\83\81\83\93\83g,\88ê\97\97\81E\83\81\83C\83\93\89æ\91\9c\83p\83X,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9cID,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9c\83R\83\81\83\93\83g,\8fÚ\8d×\81E\83\81\83C\83\93\89æ\91\9c\83p\83X,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9cID,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9c\83R\83\81\83\93\83g,\8fÚ\8d×\81E\83\81\83C\83\93\8ag\91å\89æ\91\9c\83p\83X,\8dw\93ü\90§\8cÀ,\83|\83C\83\93\83g\95t\97^\97¦,\94Ì\94\84\8aJ\8en\93ú,\94Ì\94\84\8fI\97¹\93ú,\8f¤\95i\83J\83e\83S\83\8a,\93ü\89×\97\\92è\93ú,\83T\83C\83Y,\91f\8dÞ,\8c´\8eY\8d\91,\8fd\82³,\93ü\89×\93ú,\82»\82Ì\91¼\8ed\97l,\83t\83\8a\81[\93ü\97Í,\94z\91\97\93ú,\8ed\93ü\90æ\96¼,\93o\98^\93ú,\8dX\90V\93ú\r
-18,\8cö\8aJ,\83X\83J\81[\83g,,\83e\83X\83g,\83e\83X\83g,,1000,70,,,69,,,,,,,,2009/10/1 9:00,2012/10/1 9:00,\91å\83J\83e\83S\83\8a,2009/10/1 9:00,,,,,,,,,,2009/12/8 19:01,2009/12/8 19:01\r
-,\8cö\8aJ,\83X\83J\81[\83g,,\83e\83X\83g,\83e\83X\83g,,1000,70,,,69,,,,,,,,2009/10/1 9:00,2012/10/1 9:00,\91å\83J\83e\83S\83\8a,2009/10/1 9:00,,,,,,,,,,2009/12/8 19:01,2009/12/8 19:01\r
+18,\8cö\8aJ,\83X\83J\81[\83g,,\83e\83X\83g,\83e\83X\83g,,1000,70,,,69,,,,,,,,2009/10/1 9:00,2012/10/1 9:00,\91å\83J\83e\83S\83\8a,2009/10/1 9:00,,,,,,,,,,,2009/12/8 19:01,2009/12/8 19:01\r
+,\8cö\8aJ,\83X\83J\81[\83g,,\83e\83X\83g,\83e\83X\83g,,1000,70,,,69,,,,,,,,2009/10/1 9:00,2012/10/1 9:00,\91å\83J\83e\83S\83\8a,2009/10/1 9:00,,,,,,,,,,,2009/12/8 19:01,2009/12/8 19:01\r
diff --git a/test/fixtures/retailers.yml b/test/fixtures/retailers.yml
new file mode 100644 (file)
index 0000000..5bf0293
--- /dev/null
@@ -0,0 +1,7 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# one:
+#   column: value
+#
+# two:
+#   column: value
diff --git a/test/unit/retailer_test.rb b/test/unit/retailer_test.rb
new file mode 100644 (file)
index 0000000..593ccbd
--- /dev/null
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class RetailerTest < ActiveSupport::TestCase
+  # Replace this with your real tests.
+  test "the truth" do
+    assert true
+  end
+end