diff --git a/app/models/environment.rb b/app/models/environment.rb index e7f593d..7f561ac 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -19,6 +19,8 @@ class Environment < ActiveRecord::Base filename end + NUMBER_OF_BOXES = 4 + PERMISSIONS['Environment'] = { 'view_environment_admin_panel' => N_('View environment admin panel'), 'edit_environment_features' => N_('Edit environment features'), @@ -172,7 +174,7 @@ class Environment < ActiveRecord::Base acts_as_having_boxes after_create do |env| - 4.times do + NUMBER_OF_BOXES.times do env.boxes << Box.new end diff --git a/app/models/profile.rb b/app/models/profile.rb index 419553f..9319918 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -22,6 +22,8 @@ class Profile < ActiveRecord::Base :display => %w[compact] } + NUMBER_OF_BOXES = 4 + def self.default_search_display 'compact' end @@ -362,7 +364,7 @@ class Profile < ActiveRecord::Base if template apply_template(template, :copy_articles => false) else - 4.times do + NUMBER_OF_BOXES.times do self.boxes << Box.new end diff --git a/db/migrate/20150423144533_add_block_to_environment_and_profile.rb b/db/migrate/20150423144533_add_block_to_environment_and_profile.rb deleted file mode 100644 index 5c8ca0b..0000000 --- a/db/migrate/20150423144533_add_block_to_environment_and_profile.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddBlockToEnvironmentAndProfile < ActiveRecord::Migration - def up - Environment.all.each do |env| - env.boxes << Box.new if env.boxes.count < 4 - end - - Profile.all.each do |profile| - profile.boxes << Box.new if profile.boxes.count < 4 - end - end - - def down - say "this migration can't be reverted" - end -end diff --git a/db/migrate/20150423144533_add_new_box_to_every_environment_and_profile.rb b/db/migrate/20150423144533_add_new_box_to_every_environment_and_profile.rb new file mode 100644 index 0000000..e0950c8 --- /dev/null +++ b/db/migrate/20150423144533_add_new_box_to_every_environment_and_profile.rb @@ -0,0 +1,15 @@ +class AddNewBoxToEveryEnvironmentAndProfile < ActiveRecord::Migration + def up + Environment.find_each do |env| + env.boxes << Box.new if env.boxes.count < 4 + end + + Profile.find_each do |profile| + profile.boxes << Box.new if profile.boxes.count < 4 + end + end + + def down + say "this migration can't be reverted" + end +end diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index 2f2460d..434b7bc 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -94,7 +94,7 @@ Given /^the following blocks$/ do |table| owner.boxes<< Box.new owner.boxes.first.blocks << MainBlock.new end - box_id = owner.boxes[-2].id + box_id = owner.boxes.where(:position => [3]) klass.constantize.create!(item.merge(:box_id => box_id)) end end -- libgit2 0.21.2