Commit 855b73d26280584eacb1e9dae555dce0bafd8718
1 parent
15c1cf5c
Exists in
master
and in
28 other branches
Fixing crashes on sample-profiles
Showing
1 changed file
with
23 additions
and
11 deletions
Show diff stats
script/sample-profiles
@@ -55,8 +55,12 @@ for name in NAMES | @@ -55,8 +55,12 @@ for name in NAMES | ||
55 | user.person.lat = place[:lat] + (rand/100)-0.005 | 55 | user.person.lat = place[:lat] + (rand/100)-0.005 |
56 | user.person.lng = place[:lng] + (rand/100)-0.005 | 56 | user.person.lng = place[:lng] + (rand/100)-0.005 |
57 | user.person.save! | 57 | user.person.save! |
58 | - categories.rand.people << user.person | ||
59 | - categories.rand.people << user.person | 58 | + if categories.present? |
59 | + 2.times do | ||
60 | + category = categories.rand | ||
61 | + category.people << user.person unless category.people.include?(user.person) | ||
62 | + end | ||
63 | + end | ||
60 | end | 64 | end |
61 | end | 65 | end |
62 | end | 66 | end |
@@ -89,12 +93,8 @@ guest = User.new({ | @@ -89,12 +93,8 @@ guest = User.new({ | ||
89 | :password_confirmation => 'test', | 93 | :password_confirmation => 'test', |
90 | :environment => $environment, | 94 | :environment => $environment, |
91 | }) | 95 | }) |
92 | -save guest do | ||
93 | - 5.times do | ||
94 | - communities.rand.add_admin(guest.person) | ||
95 | - communities.rand.add_member(guest.person) | ||
96 | - end | ||
97 | -end | 96 | +save guest |
97 | + | ||
98 | done | 98 | done |
99 | 99 | ||
100 | print "Activating users: " | 100 | print "Activating users: " |
@@ -131,11 +131,23 @@ for verb in VERBS | @@ -131,11 +131,23 @@ for verb in VERBS | ||
131 | save community do | 131 | save community do |
132 | communities << community | 132 | communities << community |
133 | rand(10).times do | 133 | rand(10).times do |
134 | - community.add_member(people.rand) | 134 | + person = people.rand |
135 | + community.add_member(person) unless community.members.include?(person) | ||
136 | + end | ||
137 | + if categories.present? | ||
138 | + 2.times do | ||
139 | + category = categories.rand | ||
140 | + category.communities << community unless category.communities.include?(community) | ||
141 | + end | ||
135 | end | 142 | end |
136 | - categories.rand.communities << community | ||
137 | - categories.rand.communities << community | ||
138 | end | 143 | end |
139 | end | 144 | end |
140 | end | 145 | end |
146 | + | ||
147 | +5.times do | ||
148 | + community = communities.rand | ||
149 | + community.add_member(guest.person) unless community.members.include?(guest.person) | ||
150 | + community.add_admin(guest.person) unless community.admins.include?(guest.person) | ||
151 | +end | ||
152 | + | ||
141 | done | 153 | done |