diff --git a/app/models/environment.rb b/app/models/environment.rb index 66a8e5c..078c29a 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -337,20 +337,22 @@ class Environment < ActiveRecord::Base features.delete_if{ |k, v| !self.enabled?(k) } end + DEFAULT_FEATURES = %w( + disable_asset_products + disable_gender_icon + products_for_enterprises + disable_select_city_for_contact + enterprise_registration + media_panel + organizations_are_moderated_by_default + show_balloon_with_profile_links_when_clicked + show_zoom_button_on_article_images + use_portal_community + ) + before_create :enable_default_features def enable_default_features - %w( - disable_asset_products - disable_gender_icon - products_for_enterprises - disable_select_city_for_contact - enterprise_registration - media_panel - organizations_are_moderated_by_default - show_balloon_with_profile_links_when_clicked - show_zoom_button_on_article_images - use_portal_community - ).each do |feature| + DEFAULT_FEATURES.each do |feature| enable(feature, false) end end diff --git a/db/migrate/20140408172149_enable_show_zoom_button_on_article_images.rb b/db/migrate/20140408172149_enable_show_zoom_button_on_article_images.rb new file mode 100644 index 0000000..0aef413 --- /dev/null +++ b/db/migrate/20140408172149_enable_show_zoom_button_on_article_images.rb @@ -0,0 +1,11 @@ +class EnableShowZoomButtonOnArticleImages < ActiveRecord::Migration + def self.up + Environment.find_each do |environment| + environment.enable(:show_zoom_button_on_article_images) + end + end + + def self.down + say("This migration is irreversible.") + end +end diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index f942e69..76981df 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -53,6 +53,13 @@ class EnvironmentTest < ActiveSupport::TestCase assert !v.enabled?('feature1') && !v.enabled?('feature2') && !v.enabled?('feature3') end + def test_default_enabled_features_are_enabled + environment = Environment.create(:name => 'Testing') + Environment::DEFAULT_FEATURES.each do |features| + assert environment.enabled?(features) + end + end + def test_name_is_mandatory v = Environment.new v.valid? -- libgit2 0.21.2