Renaming Enterprise.active to Enterprise.visible

This commit is contained in:
Will Marshall
2014-04-30 12:09:22 +10:00
parent 4ca148ee93
commit f68a637609
5 changed files with 12 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ class Enterprise < ActiveRecord::Base
after_validation :geocode_address
scope :by_name, order('name')
scope :active, where(:active => true)
scope :visible, where(:visible => true)
scope :is_primary_producer, where(:is_primary_producer => true)
scope :is_distributor, where(:is_distributor => true)
scope :supplying_variant_in, lambda { |variants| joins(:supplied_products => :variants_including_master).where('spree_variants.id IN (?)', variants).select('DISTINCT enterprises.*') }

View File

@@ -32,8 +32,8 @@
= f.check_box :is_distributor
= f.label :is_distributor, 'Hub'
&nbsp;
= f.check_box :active
= f.label :active, 'Active?'
= f.check_box :visible
= f.label :visible, 'Visible in search?'
.with-tip{'data-powertip' => "Select 'Producer' if you are a primary producer of food. Select 'Hub' if you want a shop-front. You can choose either or both."}
%a What's this?

View File

@@ -0,0 +1,5 @@
class RenameActiveToVisibleOnEnterprises < ActiveRecord::Migration
def change
rename_column :enterprises, :active, :visible
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140425055718) do
ActiveRecord::Schema.define(:version => 20140430020639) do
create_table "adjustment_metadata", :force => true do |t|
t.integer "adjustment_id"
@@ -230,7 +230,7 @@ ActiveRecord::Schema.define(:version => 20140425055718) do
t.string "promo_image_content_type"
t.integer "promo_image_file_size"
t.datetime "promo_image_updated_at"
t.boolean "active", :default => true
t.boolean "visible", :default => true
end
add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id"

View File

@@ -50,9 +50,9 @@ describe Enterprise do
describe 'active' do
it 'find active enterprises' do
d1 = create(:distributor_enterprise, active: false)
d1 = create(:distributor_enterprise, visible: false)
s1 = create(:supplier_enterprise)
Enterprise.active.should == [s1]
Enterprise.visible.should == [s1]
end
end