Commit ea7f2e14b23d20b6e38fe3cea4b5cb81f7f3a213
1 parent
19f6ff42
Exists in
colab
and in
4 other branches
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