From c05ae7583e796dc075aa6f49c4a697fd619e3d27 Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Wed, 1 Aug 2018 11:27:04 -0400 Subject: [PATCH] Make Algolia a requirement (#636) * Make algolia a requirement * Remove algolia defaults * Fix Envfile issue --- Envfile | 9 +++++---- README.md | 2 +- config/application.rb | 1 - config/initializers/0_application_config.rb | 2 ++ db/seeds.rb | 8 +++++++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Envfile b/Envfile index 161522924..17d758bba 100644 --- a/Envfile +++ b/Envfile @@ -47,10 +47,11 @@ variable :TWITTER_SECRET, :String, default: "Optional" variable :AIRBRAKE_API_KEY, :String, default: "Optional" variable :AIRBRAKE_PROJECT_ID, :integer, default: 00000 -# Algolia for search -variable :ALGOLIASEARCH_API_KEY, :String, default: "Optional" -variable :ALGOLIASEARCH_APPLICATION_ID, :String, default: "Optional" -variable :ALGOLIASEARCH_SEARCH_ONLY_KEY, :String, default: "Optional" +# Algolia for search (not optional) +only_in_test = proc { ENV['RACK_ENV'] == "test" ? "test-test" : nil} +variable :ALGOLIASEARCH_API_KEY, :String, default: only_in_test +variable :ALGOLIASEARCH_APPLICATION_ID, :String, default: only_in_test +variable :ALGOLIASEARCH_SEARCH_ONLY_KEY, :String, default: only_in_test # AWS for images storages variable :AWS_ID, :String, default: "Optional" diff --git a/README.md b/README.md index 13dd364b6..b8ccec490 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ We are all humans trying to work together to improve things for the community. A 2. `bundle install` 3. `bin/yarn` 4. Set up your environment variables/secrets - * Take a look at `Envfile`. This file lists all the `ENV` variables we use and provides a fake default for any missing keys. You'll need to get your own free API keys for a few services in order to get your development environment running. [**Follow this wiki to get them.**](https://github.com/thepracticaldev/dev.to_core/wiki/Getting-API-Keys-for-Basic-Development) + * Take a look at `Envfile`. This file lists all the `ENV` variables we use and provides a fake default for any missing keys. You'll need to get your own free API keys for a few services in order to get your development environment running. Check this [wiki](https://github.com/thepracticaldev/dev.to_core/wiki/Getting-API-Keys-for-Basic-Development) on how to get them. For minimum requirement, you should obtain valid [Algolia](https://github.com/thepracticaldev/dev.to_core/wiki/Getting-API-Keys-for-Basic-Development#algolia-choose-oauth-or-email-sign-up) credentials. * For any key that you wish to enter/replace: 1. Create `config/application.yml` by copying from the provided template (`cp config/sample_application.yml config/application.yml`). This is a personal file that is ignored in git. 2. Obtain the development variable and apply the key you wish to enter/replace. ie: diff --git a/config/application.rb b/config/application.rb index a40d658c7..beb6da219 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,6 @@ require 'sprockets/es6' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -ENVied.require(*ENV['ENVIED_GROUPS'] || Rails.groups) module PracticalDeveloper class Application < Rails::Application diff --git a/config/initializers/0_application_config.rb b/config/initializers/0_application_config.rb index 114532ac2..2a9ac7a82 100644 --- a/config/initializers/0_application_config.rb +++ b/config/initializers/0_application_config.rb @@ -1,3 +1,5 @@ +ENVied.require(*ENV['ENVIED_GROUPS'] || Rails.groups) + class ApplicationConfig def self.[](key) ENVied.send(key) diff --git a/db/seeds.rb b/db/seeds.rb index 9c8f44ffc..4d51cfabd 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -23,7 +23,7 @@ p "2/8 Creating Users" roles = %i(level_1_member level_2_member level_3_member level_4_member workshop_pass) - +User.clear_index! 40.times do |i| user = User.create!( name: name = Faker::Name.unique.name, @@ -46,6 +46,7 @@ roles = %i(level_1_member level_2_member level_3_member level_4_member token: i.to_s, secret: i.to_s, user: user, + auth_data_dump: { "extra" => { "raw_info" => { "lang" => "en" } } }, ) end @@ -69,6 +70,7 @@ end p "4/8 Creating Articles" +Article.clear_index! 80.times do |i| tags = [] tags << "discuss" if (i % 3).zero? @@ -98,6 +100,8 @@ end ############################################################################## p "5/8 Creating Comments" + +Comment.clear_index! 120.times do attributes = { body_markdown: Faker::Hipster.paragraph(1), @@ -138,6 +142,7 @@ Broadcast.create!( p "8/8 Creating chat_channel" +ChatChannel.clear_index! ChatChannel.without_auto_index do ["Workshop", "Meta", "General"].each do |chan| ChatChannel.create!( @@ -147,5 +152,6 @@ ChatChannel.without_auto_index do ) end end +ChatChannel.reindex! ##############################################################################