Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dev seeds #269

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ end
group :development do
gem "active_record_query_trace", require: false
gem "listen"
gem "seedbank", "~> 0.5"
end

group :development, :test do
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
seedbank (0.5.0)
rake (>= 10.0)
shoulda-callback-matchers (1.1.4)
activesupport (>= 3)
shoulda-matchers (6.2.0)
Expand Down Expand Up @@ -568,6 +570,7 @@ DEPENDENCIES
rubocop-rails-omakase
russian
sass-rails (~> 6.0)
seedbank (~> 0.5)
shoulda-callback-matchers
shoulda-matchers
simplecov
Expand Down
46 changes: 0 additions & 46 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,51 +1,5 @@
Place.create!([
{ title: 'Рабочее пространство "MESTO"', address: 'улица Максима Горького, 151', latitude: 47.226894, longitude: 39.714285, created_at: '2016-08-25 12:11:41.806837', updated_at: '2016-08-25 12:11:41.806837' },
{ title: 'Креативное пространство CreativeSpace.pro', address: 'улица Суворова, 52А', latitude: 47.225193, longitude: 39.728838, created_at: '2016-08-26 09:04:34.626668', updated_at: '2016-08-26 09:04:34.626668' },
{ title: 'Южный IT-парк', address: 'улица Суворова, 91', latitude: 47.226796, longitude: 39.732746, created_at: '2016-08-26 09:05:08.291215', updated_at: '2016-08-26 09:05:08.291215' },
{ title: 'Учебный Центр «Эксперт»', address: 'улица Станиславского, 167/25', latitude: 47.222415, longitude: 39.735054, created_at: '2016-08-26 09:05:57.700912', updated_at: '2016-08-26 09:05:57.700912' },
{ title: 'Отель «Атташе»', address: 'проспект Соколова, 19', latitude: 47.223883, longitude: 39.72069, created_at: '2016-08-26 09:06:23.073808', updated_at: '2016-08-26 09:06:23.073808' },
{ title: 'Конгресс-отель «Амакс»', address: 'проспект Михаила Нагибина, 19', latitude: 47.248779, longitude: 39.711851, created_at: '2016-08-26 09:07:06.816933', updated_at: '2016-08-26 09:07:06.816933' },
{ title: 'ИФЖиМКК ЮФУ', address: 'Университетский переулок, 93', latitude: 47.226766, longitude: 39.726808, created_at: '2016-08-26 09:07:56.474912', updated_at: '2016-08-26 09:07:56.474912' },
{ title: 'База отдыха «Казачок»', address: 'Очаковская коса', latitude: 47.031146, longitude: 39.099065, created_at: '2016-08-26 09:09:26.087182', updated_at: '2016-08-26 09:09:26.087182' },
{ title: 'Конгресс-отель «Дон-Плаза»', address: 'Большая Садовая улица, 115', latitude: 47.226117, longitude: 39.734327, created_at: '2016-08-26 09:09:40.030728', updated_at: '2016-08-26 09:09:40.030728' },
{ title: 'Офис «Game Insight»', address: 'Таганрог, Петровская улица, 26', latitude: 47.207964, longitude: 38.941527, created_at: '2016-08-26 09:10:05.032555', updated_at: '2016-08-26 09:10:05.032555' },
{ title: 'ДГТУ, 7 корпус', address: 'площадь Гагарина, 1', latitude: 47.237412, longitude: 39.712632, created_at: '2016-08-26 09:12:13.254869', updated_at: '2016-08-26 09:12:13.254869' },
{ title: 'Бизнс-центр «Оптима Ленд»', address: 'Таганрог, улица Москатова, 31/2', latitude: 47.257317, longitude: 38.911308, created_at: '2016-08-26 09:13:02.004318', updated_at: '2016-08-26 09:13:02.004318' },
{ title: 'Свободное пространство «Циферблат»', address: 'проспект Соколова, 46', latitude: 47.225872, longitude: 39.720466, created_at: '2016-08-26 09:13:41.476870', updated_at: '2016-08-26 09:13:41.476870' },
{ title: 'DobroCowork University', address: 'улица 16-я Линия, 7В', latitude: 47.231355, longitude: 39.759354, created_at: '2016-08-26 09:14:22.045622', updated_at: '2016-08-26 09:14:22.045622' },
{ title: 'AZIMUT Hotel Sochi 3*', address: 'Сочи, Континентальный проспект, 6', latitude: 43.402584, longitude: 39.973099, created_at: '2016-08-26 09:14:48.345412', updated_at: '2016-08-26 09:14:48.345412' },
{ title: 'ДГТУ, Академия строительства и архитектуры', address: 'Социалистическая улица, 162/32', latitude: 47.223736, longitude: 39.732278, created_at: '2016-08-26 09:16:23.618108', updated_at: '2016-08-26 09:16:23.618108' }
])

# Groups
Group.create!([
{ name: "Разработчик IT61", kind: 1 },
{ name: "Команда IT61", kind: 2 }
])

User.create!(email: '[email protected]', first_name: 'Река', last_name: 'Дон', role: User.roles[:member])

Event.create!([
{
description: 'Описание тестового события в прошлом',
place: Place.first,
title: 'Прошедшее событие',
organizer: User.first,
started_at: 1.week.ago,
published: true,
published_at: 2.weeks.ago,
# TODO(vitallium): Move to fixtures?
cover: Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "files", "event_title_image.jpg"))
},
{
description: 'Описание тестового события в будущем',
place: Place.last,
title: 'Будущее событие',
organizer: User.first,
started_at: 1.week.from_now,
published: true,
published_at: 1.day.ago,
# TODO(vitallium): Move to fixtures?
cover: Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "files", "event_title_image.jpg"))
}
])
36 changes: 36 additions & 0 deletions db/seeds/development/events.seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
after "development:places" do
(1..5).each do
# Unpublished events
Event.create!(
title: Faker::Esport.event,
description: Faker::Markdown.sandwich(sentences: 6, repeat: 3),
organizer: User.order("RANDOM()").first,
started_at: Faker::Time.forward(days: 30),
published: false,
place: Place.order("RANDOM()").first
)

# Upcoming events
Event.create!(
title: Faker::Esport.event,
description: Faker::Markdown.sandwich(sentences: 6, repeat: 3),
organizer: User.order("RANDOM()").first,
started_at: Faker::Time.forward(days: 30),
published: true,
published_at: Date.current,
place: Place.order("RANDOM()").first

)

# Past events
Event.create!(
title: Faker::Esport.event,
description: Faker::Markdown.sandwich(sentences: 6, repeat: 3),
organizer: User.order("RANDOM()").first,
started_at: Faker::Time.backward(days: 30),
published: true,
published_at: Faker::Time.backward(days: 10),
place: Place.order("RANDOM()").first
)
end
end
20 changes: 20 additions & 0 deletions db/seeds/development/places.seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
after "development:users" do
Place.create!([
{ title: 'Рабочее пространство "MESTO"', address: 'улица Максима Горького, 151', latitude: 47.226894, longitude: 39.714285, created_at: '2016-08-25 12:11:41.806837', updated_at: '2016-08-25 12:11:41.806837' },
{ title: 'Креативное пространство CreativeSpace.pro', address: 'улица Суворова, 52А', latitude: 47.225193, longitude: 39.728838, created_at: '2016-08-26 09:04:34.626668', updated_at: '2016-08-26 09:04:34.626668' },
{ title: 'Южный IT-парк', address: 'улица Суворова, 91', latitude: 47.226796, longitude: 39.732746, created_at: '2016-08-26 09:05:08.291215', updated_at: '2016-08-26 09:05:08.291215' },
{ title: 'Учебный Центр «Эксперт»', address: 'улица Станиславского, 167/25', latitude: 47.222415, longitude: 39.735054, created_at: '2016-08-26 09:05:57.700912', updated_at: '2016-08-26 09:05:57.700912' },
{ title: 'Отель «Атташе»', address: 'проспект Соколова, 19', latitude: 47.223883, longitude: 39.72069, created_at: '2016-08-26 09:06:23.073808', updated_at: '2016-08-26 09:06:23.073808' },
{ title: 'Конгресс-отель «Амакс»', address: 'проспект Михаила Нагибина, 19', latitude: 47.248779, longitude: 39.711851, created_at: '2016-08-26 09:07:06.816933', updated_at: '2016-08-26 09:07:06.816933' },
{ title: 'ИФЖиМКК ЮФУ', address: 'Университетский переулок, 93', latitude: 47.226766, longitude: 39.726808, created_at: '2016-08-26 09:07:56.474912', updated_at: '2016-08-26 09:07:56.474912' },
{ title: 'База отдыха «Казачок»', address: 'Очаковская коса', latitude: 47.031146, longitude: 39.099065, created_at: '2016-08-26 09:09:26.087182', updated_at: '2016-08-26 09:09:26.087182' },
{ title: 'Конгресс-отель «Дон-Плаза»', address: 'Большая Садовая улица, 115', latitude: 47.226117, longitude: 39.734327, created_at: '2016-08-26 09:09:40.030728', updated_at: '2016-08-26 09:09:40.030728' },
{ title: 'Офис «Game Insight»', address: 'Таганрог, Петровская улица, 26', latitude: 47.207964, longitude: 38.941527, created_at: '2016-08-26 09:10:05.032555', updated_at: '2016-08-26 09:10:05.032555' },
{ title: 'ДГТУ, 7 корпус', address: 'площадь Гагарина, 1', latitude: 47.237412, longitude: 39.712632, created_at: '2016-08-26 09:12:13.254869', updated_at: '2016-08-26 09:12:13.254869' },
{ title: 'Бизнс-центр «Оптима Ленд»', address: 'Таганрог, улица Москатова, 31/2', latitude: 47.257317, longitude: 38.911308, created_at: '2016-08-26 09:13:02.004318', updated_at: '2016-08-26 09:13:02.004318' },
{ title: 'Свободное пространство «Циферблат»', address: 'проспект Соколова, 46', latitude: 47.225872, longitude: 39.720466, created_at: '2016-08-26 09:13:41.476870', updated_at: '2016-08-26 09:13:41.476870' },
{ title: 'DobroCowork University', address: 'улица 16-я Линия, 7В', latitude: 47.231355, longitude: 39.759354, created_at: '2016-08-26 09:14:22.045622', updated_at: '2016-08-26 09:14:22.045622' },
{ title: 'AZIMUT Hotel Sochi 3*', address: 'Сочи, Континентальный проспект, 6', latitude: 43.402584, longitude: 39.973099, created_at: '2016-08-26 09:14:48.345412', updated_at: '2016-08-26 09:14:48.345412' },
{ title: 'ДГТУ, Академия строительства и архитектуры', address: 'Социалистическая улица, 162/32', latitude: 47.223736, longitude: 39.732278, created_at: '2016-08-26 09:16:23.618108', updated_at: '2016-08-26 09:16:23.618108' }
])
end
8 changes: 8 additions & 0 deletions db/seeds/development/users.seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(1..10).each do
User.create!(
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
bio: Faker::Lorem.paragraph,
email: Faker::Internet.email,
)
end