Commit ea7f2e14b23d20b6e38fe3cea4b5cb81f7f3a213

Authored by Heitor
1 parent 19f6ff42

Added seeds script to set the default configurations to public

The script will make a request to the kalibro configurations server and
receive all the stored configurations, setting each one of them to
public, belonging to a default Mezuro User

Signed-off-by: Eduardo Silva <duduktamg@hotmail.com>
Showing 2 changed files with 20 additions and 0 deletions   Show diff stats
db/seeds.rb
... ... @@ -5,3 +5,18 @@
5 5 #
6 6 # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 7 # Mayor.create(name: 'Emanuel', city: cities.first)
  8 +
  9 +# Default mezuro user, the owner of the public kalibro configurations
  10 +default_user = FactoryGirl.create(:mezuro_user, password: Devise.friendly_token.first(10))
  11 +default_user.save
  12 +
  13 +# The database should have only the default public
  14 +# configurations when this file is executed
  15 +kalibro_configurations = KalibroConfiguration.all
  16 +kalibro_configurations.each do |configuration|
  17 + attributes = KalibroConfigurationAttributes.new
  18 + attributes.kalibro_configuration_id = configuration.id
  19 + attributes.public = true
  20 + attributes.user_id = default_user.id
  21 + attributes.save
  22 +end
... ...
spec/factories/users.rb
... ... @@ -13,5 +13,10 @@ FactoryGirl.define do
13 13 email "hr@email.com"
14 14 password "password"
15 15 end
  16 +
  17 + factory :mezuro_user do
  18 + name "Mezuro Default user"
  19 + email "mezuro@librelist.com"
  20 + end
16 21 end
17 22 end
... ...