diff --git a/Gemfile b/Gemfile index 11cf566d..8d225e27 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 1112f9ee..2e62257d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -568,6 +570,7 @@ DEPENDENCIES rubocop-rails-omakase russian sass-rails (~> 6.0) + seedbank (~> 0.5) shoulda-callback-matchers shoulda-matchers simplecov diff --git a/db/seeds.rb b/db/seeds.rb index 46445b8c..e36e270f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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: 'user@it61.info.local', 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")) - } - ]) diff --git a/db/seeds/development/events.seeds.rb b/db/seeds/development/events.seeds.rb new file mode 100644 index 00000000..00d7791b --- /dev/null +++ b/db/seeds/development/events.seeds.rb @@ -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 diff --git a/db/seeds/development/places.seeds.rb b/db/seeds/development/places.seeds.rb new file mode 100644 index 00000000..cd6c2f35 --- /dev/null +++ b/db/seeds/development/places.seeds.rb @@ -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 diff --git a/db/seeds/development/users.seeds.rb b/db/seeds/development/users.seeds.rb new file mode 100644 index 00000000..f1394dc5 --- /dev/null +++ b/db/seeds/development/users.seeds.rb @@ -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