diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..1d953f4bd --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 46581a5c6..c33f66d0a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1000 --no-auto-gen-timestamp` -# using RuboCop version 1.6.1. +# using RuboCop version 1.13.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -188,7 +188,7 @@ RSpec/DescribeClass: - 'spec/models/factory_spec.rb' # Offense count: 172 -# Configuration parameters: Max. +# Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: - 'spec/controllers/admin_pages_controller_spec.rb' @@ -425,6 +425,7 @@ Rake/MethodDefinitionInTask: - 'lib/tasks/db.rake' # Offense count: 138 +# Configuration parameters: AllowedConstants. Style/Documentation: Exclude: - 'app/controllers/admin_pages_controller.rb' diff --git a/.ruby-version b/.ruby-version index 37c2961c2..860487ca1 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +2.7.1 diff --git a/.travis.yml b/.travis.yml index aaecfdc05..0467ace6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby rvm: - - 2.7.2 + - 2.7.1 cache: bundler: true yarn: true @@ -17,17 +17,17 @@ env: matrix: include: - - env: FORCE_POSTGRES=true - services: - - postgresql - - env: DO_NOT_FORCE_POSTGRES=true + - env: FORCE_POSTGRES=true + services: + - postgresql + - env: DO_NOT_FORCE_POSTGRES=true before_install: - env - nvm install 12 - yarn install - google-chrome-stable --version - - 'echo ''gem: --no-document'' > ~/.gemrc' + - "echo 'gem: --no-document' > ~/.gemrc" - gem update --system - gem install bundler - bundle config set --local deployment 'true' diff --git a/Gemfile b/Gemfile index 7815d897b..c77eecbe0 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -ruby '2.7.2' +ruby '2.7.1' gem 'active_hash' # OPTIMIZE: and cache expensive computations for faster boot times. It's @@ -32,7 +32,7 @@ gem 'pundit' gem 'rack-canonical-host' gem 'rack-cors' gem 'rack-mini-profiler', require: ['prepend_net_http_patch'] -gem 'rails', '~> 5.2.4.3' +gem 'rails', '~> 5.2.5' gem 'sanitize' gem 'sassc-rails' gem 'simple_form' diff --git a/Gemfile.lock b/Gemfile.lock index b501eda1a..9974aa701 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,45 +1,45 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.4.4) - actionpack (= 5.2.4.4) + actioncable (5.2.5) + actionpack (= 5.2.5) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.4) - actionpack (= 5.2.4.4) - actionview (= 5.2.4.4) - activejob (= 5.2.4.4) + actionmailer (5.2.5) + actionpack (= 5.2.5) + actionview (= 5.2.5) + activejob (= 5.2.5) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.4) - actionview (= 5.2.4.4) - activesupport (= 5.2.4.4) + actionpack (5.2.5) + actionview (= 5.2.5) + activesupport (= 5.2.5) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4.4) - activesupport (= 5.2.4.4) + actionview (5.2.5) + activesupport (= 5.2.5) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) active_hash (3.1.0) activesupport (>= 5.0.0) - activejob (5.2.4.4) - activesupport (= 5.2.4.4) + activejob (5.2.5) + activesupport (= 5.2.5) globalid (>= 0.3.6) - activemodel (5.2.4.4) - activesupport (= 5.2.4.4) - activerecord (5.2.4.4) - activemodel (= 5.2.4.4) - activesupport (= 5.2.4.4) + activemodel (5.2.5) + activesupport (= 5.2.5) + activerecord (5.2.5) + activemodel (= 5.2.5) + activesupport (= 5.2.5) arel (>= 9.0) - activestorage (5.2.4.4) - actionpack (= 5.2.4.4) - activerecord (= 5.2.4.4) - marcel (~> 0.3.1) - activesupport (5.2.4.4) + activestorage (5.2.5) + actionpack (= 5.2.5) + activerecord (= 5.2.5) + marcel (~> 1.0.0) + activesupport (5.2.5) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -51,10 +51,10 @@ GEM capybara (~> 3.13, < 4) websocket-driver (>= 0.6.5) arel (9.0.0) - ast (2.4.1) + ast (2.4.2) autoprefixer-rails (10.1.0.0) execjs - awesome_print (1.8.0) + awesome_print (1.9.2) backbone-on-rails (1.2.0.0) eco ejs @@ -65,7 +65,7 @@ GEM coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - binding_of_caller (0.8.0) + binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) bootsnap (1.5.1) msgpack (~> 1.0) @@ -73,26 +73,25 @@ GEM autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) builder (3.2.4) - bullet (6.1.2) + bullet (6.1.4) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) - capybara (3.34.0) + capybara (3.35.3) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.5) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) capybara-screenshot (1.0.25) capybara (>= 1.0, < 4) launchy chrome_remote (0.3.0) websocket-driver (~> 0.6) - codecov (0.2.12) - json - simplecov + codecov (0.5.2) + simplecov (>= 0.15, < 0.22) coderay (1.1.3) coffee-rails (5.0.0) coffee-script (>= 2.2.0) @@ -101,11 +100,17 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.7) - crack (0.4.4) + concurrent-ruby (1.1.8) + crack (0.4.5) + rexml crass (1.0.6) - database_cleaner (1.8.5) - debug_inspector (0.0.3) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.0) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + debug_inspector (1.1.0) devise (4.7.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -113,7 +118,7 @@ GEM responders warden (~> 1.2.3) diff-lcs (1.4.4) - docile (1.3.2) + docile (1.3.5) dotenv (2.7.6) dotenv-rails (2.7.6) dotenv (= 2.7.6) @@ -131,12 +136,12 @@ GEM factory_bot_rails (6.1.0) factory_bot (~> 6.1.0) railties (>= 5.0.0) - faker (2.15.1) + faker (2.17.0) i18n (>= 1.6, < 2) faraday (1.1.0) multipart-post (>= 1.2, < 3) ruby2_keywords - ffi (1.13.1) + ffi (1.15.0) font-awesome-rails (4.7.0.5) railties (>= 3.2, < 6.1) geocoder (1.6.4) @@ -149,17 +154,17 @@ GEM tilt (>= 1.2) hashdiff (1.0.1) hashie (4.1.0) - i18n (1.8.5) + i18n (1.8.10) concurrent-ruby (~> 1.0) icalendar (2.7.0) ice_cube (~> 0.16) ice_cube (0.16.3) - jasmine (3.6.0) - jasmine-core (~> 3.6.0) + jasmine (3.7.0) + jasmine-core (~> 3.7.0) phantomjs rack (>= 1.2.1) rake - jasmine-core (3.6.0) + jasmine-core (3.7.1) jasmine-jquery-rails (2.0.3) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) @@ -167,26 +172,23 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (2.3.1) jwt (2.2.2) kdtree (0.4) launchy (2.5.0) addressable (~> 2.7) - listen (3.3.3) + listen (3.5.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.8.0) + loofah (2.9.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.1) method_source (1.0.0) - mimemagic (0.3.5) - mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.14.2) + mini_mime (1.1.0) + mini_portile2 (2.5.1) + minitest (5.14.4) msgpack (1.3.3) multi_json (1.15.0) multi_xml (0.6.0) @@ -197,12 +199,13 @@ GEM require_all nested_form (0.3.2) newrelic_rpm (6.14.0) - nio4r (2.5.4) - nokogiri (1.10.10) - mini_portile2 (~> 2.4.0) + nio4r (2.5.7) + nokogiri (1.11.3) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) nokogumbo (2.0.4) nokogiri (~> 1.8, >= 1.8.4) - oauth (0.5.4) + oauth (0.5.6) oauth2 (1.4.4) faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) @@ -240,13 +243,13 @@ GEM rack orm_adapter (0.5.0) parallel (1.20.1) - parallel_tests (3.4.0) + parallel_tests (3.7.0) parallel - parser (2.7.2.0) + parser (3.0.1.1) ast (~> 2.4.1) pg (1.2.3) phantomjs (2.1.1.0) - pry (0.13.1) + pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) @@ -254,6 +257,7 @@ GEM nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) + racc (1.5.2) rack (2.2.3) rack-canonical-host (1.0.0) addressable (> 0, < 3) @@ -265,18 +269,18 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) rack-timeout (0.6.0) - rails (5.2.4.4) - actioncable (= 5.2.4.4) - actionmailer (= 5.2.4.4) - actionpack (= 5.2.4.4) - actionview (= 5.2.4.4) - activejob (= 5.2.4.4) - activemodel (= 5.2.4.4) - activerecord (= 5.2.4.4) - activestorage (= 5.2.4.4) - activesupport (= 5.2.4.4) + rails (5.2.5) + actioncable (= 5.2.5) + actionmailer (= 5.2.5) + actionpack (= 5.2.5) + actionview (= 5.2.5) + activejob (= 5.2.5) + activemodel (= 5.2.5) + activerecord (= 5.2.5) + activestorage (= 5.2.5) + activesupport (= 5.2.5) bundler (>= 1.3.0) - railties (= 5.2.4.4) + railties (= 5.2.5) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -287,55 +291,55 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (5.2.4.4) - actionpack (= 5.2.4.4) - activesupport (= 5.2.4.4) + railties (5.2.5) + actionpack (= 5.2.5) + activesupport (= 5.2.5) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - rake (13.0.1) + rake (13.0.3) rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (1.8.2) + regexp_parser (2.1.1) require_all (3.0.0) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) - rexml (3.2.4) + rexml (3.2.5) rspec-collection_matchers (1.2.0) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.10.0) + rspec-core (3.10.1) rspec-support (~> 3.10.0) - rspec-expectations (3.10.0) + rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) - rspec-mocks (3.10.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) - rspec-rails (4.0.1) - actionpack (>= 4.2) - activesupport (>= 4.2) - railties (>= 4.2) - rspec-core (~> 3.9) - rspec-expectations (~> 3.9) - rspec-mocks (~> 3.9) - rspec-support (~> 3.9) - rspec-support (3.10.0) - rubocop (1.6.1) + rspec-rails (5.0.1) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.10.2) + rubocop (1.13.0) parallel (~> 1.10) - parser (>= 2.7.1.5) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml rubocop-ast (>= 1.2.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.3.0) - parser (>= 2.7.1.5) - rubocop-performance (1.9.1) - rubocop (>= 0.90.0, < 2.0) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.5.0) + parser (>= 3.0.1.1) + rubocop-performance (1.11.1) + rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.9.1) activesupport (>= 4.2.0) @@ -343,12 +347,12 @@ GEM rubocop (>= 0.90.0, < 2.0) rubocop-rake (0.5.1) rubocop - rubocop-rspec (2.1.0) + rubocop-rspec (2.3.0) rubocop (~> 1.0) rubocop-ast (>= 1.1.0) rubocop-thread_safety (0.4.2) rubocop (>= 0.53.0) - ruby-progressbar (1.10.1) + ruby-progressbar (1.11.0) ruby2_keywords (0.0.2) sanitize (5.2.1) crass (~> 1.0.2) @@ -364,17 +368,17 @@ GEM tilt sentry-raven (3.1.1) faraday (>= 1.0) - shoulda-matchers (4.4.1) + shoulda-matchers (4.5.1) activesupport (>= 4.2.0) simple_form (5.0.3) actionpack (>= 5.0) activemodel (>= 5.0) - simplecov (0.20.0) + simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.2) + simplecov_json_formatter (0.1.3) spring (2.1.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) @@ -386,18 +390,18 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.4.2) - thor (1.0.1) + thor (1.1.0) thread_safe (0.3.6) tilt (2.0.10) - tzinfo (1.2.8) + tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.7.0) - uniform_notifier (1.13.0) + unicode-display_width (2.0.0) + uniform_notifier (1.14.2) warden (1.2.9) rack (>= 2.0.9) - webmock (3.11.0) + webmock (3.12.2) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -461,7 +465,7 @@ DEPENDENCIES rack-cors rack-mini-profiler rack-timeout - rails (~> 5.2.4.3) + rails (~> 5.2.5) rails-controller-testing rake rb-fsevent @@ -487,7 +491,7 @@ DEPENDENCIES webmock RUBY VERSION - ruby 2.7.2p137 + ruby 2.7.1p83 BUNDLED WITH 2.1.4 diff --git a/README.markdown b/README.markdown index 91cdd42e1..7fa4ecde0 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,5 @@ # Bridge Troll -  + [![Build Status](https://travis-ci.com/railsbridge/bridge_troll.svg?branch=master)](https://travis-ci.com/railsbridge/bridge_troll) [![codecov](https://codecov.io/gh/railsbridge/bridge_troll/branch/master/graph/badge.svg)](https://codecov.io/gh/railsbridge/bridge_troll) @@ -14,20 +14,23 @@ Prospective organizers and attendees can sign up right now at [www.bridgetroll.o New? Keep reading this, and then read the [contributor guidelines](CONTRIBUTING.md). ### Where is it? -* The real live production application lives at [bridgetroll.herokuapp.com](http://bridgetroll.herokuapp.com/) or [www.bridgetroll.org](http://www.bridgetroll.org/) -* The staging server lives at [bridgetroll-staging.herokuapp.com](http://bridgetroll-staging.herokuapp.com/) -* The continuous integration server is at [travis-ci.org/railsbridge/bridge_troll](http://travis-ci.org/railsbridge/bridge_troll) + +- The real live production application lives at [bridgetroll.herokuapp.com](http://bridgetroll.herokuapp.com/) or [www.bridgetroll.org](http://www.bridgetroll.org/) +- The staging server lives at [bridgetroll-staging.herokuapp.com](http://bridgetroll-staging.herokuapp.com/) +- The continuous integration server is at [travis-ci.org/railsbridge/bridge_troll](http://travis-ci.org/railsbridge/bridge_troll) For details on how production and staging are setup, see the [deployment docs](doc/deploy.md). ### Features & Bugs -* We use [GitHub Issues](https://github.com/railsbridge/bridge_troll/issues?state=open) for tracking bugs and features. - * Issues marked as [Help Wanted](https://github.com/railsbridge/bridge_troll/issues?q=is%3Aissue+is%3Aopen+label%3A%22Help+Wanted%22) are ready to go, so pick one up! - * Bugs are, naturally, [marked as bugs](https://github.com/railsbridge/bridge_troll/labels/bug). - * Issues marked with the [Discussion label](https://github.com/railsbridge/bridge_troll/labels/Discussion) are currently being refined. If you're interested in working on one, comment and ask what needs to be finalized before it's ready to be worked on. - * We also mark issues as [beginner friendly](https://github.com/railsbridge/bridge_troll/labels/Beginner%20Friendly), so if you're new to Rails, check those out. + +- We use [GitHub Issues](https://github.com/railsbridge/bridge_troll/issues?state=open) for tracking bugs and features. +- Issues marked as [Help Wanted](https://github.com/railsbridge/bridge_troll/issues?q=is%3Aissue+is%3Aopen+label%3A%22Help+Wanted%22) are ready to go, so pick one up! +- Bugs are, naturally, [marked as bugs](https://github.com/railsbridge/bridge_troll/labels/bug). +- Issues marked with the [Discussion label](https://github.com/railsbridge/bridge_troll/labels/Discussion) are currently being refined. If you're interested in working on one, comment and ask what needs to be finalized before it's ready to be worked on. +- We also mark issues as [beginner friendly](https://github.com/railsbridge/bridge_troll/labels/Beginner%20Friendly), so if you're new to Rails, check those out. ### Want to help out? + Join the [google group](https://groups.google.com/forum/?fromgroups#!forum/bridge-troll) and send a quick note introducing yourself. Then, have a look at our [GitHub Issues](https://github.com/railsbridge/bridge_troll/issues?state=open). Pick a feature to work on, fork the project, code some code, and send a [really good pull request](http://railsbridge.github.com/bridge_troll/). Not sure what to do? Ask the [google group](https://groups.google.com/forum/?fromgroups#!forum/bridge-troll) for advice! @@ -36,25 +39,28 @@ Curious about the longer-term? We have something of a roadmap [here](https://git ## Setting up for your local development environment -You'll need a version manager for Ruby. A version manager is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments. We recommend [rvm](http://rvm.io), but [rbenv](https://github.com/sstephenson/rbenv) will work. +You'll need a version manager for Ruby. A version manager is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments. We recommend [rvm](http://rvm.io), but [rbenv](https://github.com/sstephenson/rbenv) will work. ### Quickstart -We're using a fork & pull model (see [Fork A Repo](https://help.github.com/articles/fork-a-repo) for an example), so fork this repo then clone the *forked* repo. -(Note: change *username* below to be *your* repo.) +We're using a fork & pull model (see [Fork A Repo](https://help.github.com/articles/fork-a-repo) for an example), so fork this repo then clone the _forked_ repo. +(Note: change _username_ below to be _your_ repo.) + ``` git clone https://github.com/username/bridge_troll.git cd bridge_troll ``` -Make sure you have the correct version of ruby before installing the gems for this repo. If you are using rvm, run: `rvm install 2.7.2`. For rbenv, run: `rbenv install 2.7.2`. +Make sure you have the correct version of ruby before installing the gems for this repo. If you are using rvm, run: `rvm install 2.7.1`. For rbenv, run: `rbenv install 2.7.1`. Finish setting up your environment + ``` bin/setup ``` To verify your environment is set up correctly, run the server + ``` rails s ``` @@ -62,8 +68,9 @@ rails s Go to http://localhost:3000/ and verify your success! You can play with the app locally to become more familiar with it. Pro-tip: Confirming Users Locally -* outgoing emails are logged, so if you scroll back in your terminal window, you can see the contents of the confirmation email and copy/paste the confirmation link into your browser -* or create a valid user for most recent signup, run `rails console`: `User.last.confirm!` + +- outgoing emails are logged, so if you scroll back in your terminal window, you can see the contents of the confirmation email and copy/paste the confirmation link into your browser +- or create a valid user for most recent signup, run `rails console`: `User.last.confirm!` ### Running tests @@ -98,18 +105,21 @@ All the created users have easyish-to-remember logins, so a great way to test ou Doing `rake db:seed` again will destroy all those sample persons and create the event again. The exact details of what is created can be found in `seed_event.rb`. #### Anonymizing Data + You can replace sensitive personal information about events and participants from the data with a Rake task. Note that it will not run if your Rails environment is set to `production`. -```` + +``` rake db:anonymize -```` +``` Restore the original data to your database with -```` -rake db:restore -```` +``` +rake db:restore +``` ### Styling Guidelines + We have created a living style guide to keep track of HTML components and their styling across the site. See it at http://localhost:3000/style_guide. We're still working on adding every element to the page, so if you see missing components, add it to the erb template ([style_guide.html.erb](app/views/static_pages/style_guide.html.erb)) @@ -126,15 +136,15 @@ You can see rendered versions of all emails the application can send at http://l #### Mailcatcher - To receive/develop emails locally, install the MailCatcher gem at http://mailcatcher.me. The process is as follows: +To receive/develop emails locally, install the MailCatcher gem at http://mailcatcher.me. The process is as follows: - 1. `gem install mailcatcher` -- installs MailCatcher in your current gemset - 1. `mailcatcher` -- start the MailCatcher server if it isn't running already - 1. Visit http://localhost:1080/ in your web browser. This is your MailCatcher mailbox, where mails will appear. - 1. Do something in your local Bridge Troll app that would send a mail, like signing up for a new account. - 1. You should see the mail that Rails sent in the MailCatcher window. Woo! +1. `gem install mailcatcher` -- installs MailCatcher in your current gemset +1. `mailcatcher` -- start the MailCatcher server if it isn't running already +1. Visit http://localhost:1080/ in your web browser. This is your MailCatcher mailbox, where mails will appear. +1. Do something in your local Bridge Troll app that would send a mail, like signing up for a new account. +1. You should see the mail that Rails sent in the MailCatcher window. Woo! - Note that MailCatcher just makes it easy to see the HTML output of your mails: it doesn't guarantee that the way the mail looks like in MailCatcher is how it will look in Gmail or Outlook. Beware! +Note that MailCatcher just makes it easy to see the HTML output of your mails: it doesn't guarantee that the way the mail looks like in MailCatcher is how it will look in Gmail or Outlook. Beware! ### Working with external services @@ -158,12 +168,12 @@ With the `.env` file in place, the environment variables will be set every time Bridge Troll uses [Omniauth](https://github.com/intridea/omniauth) to allow external authentication to a number of services. -* Twitter through [omniauth-twitter](https://github.com/arunagw/omniauth-twitter) - [set up a consumer here](https://apps.twitter.com/) -* Facebook through [omniauth-facebook](https://github.com/mkdynamic/omniauth-facebook) - [set up a consumer here](https://developers.facebook.com/apps/) -* GitHub through [omniauth-github](https://github.com/intridea/omniauth-github) - [set up a consumer here](https://github.com/settings/applications) -* Meetup through [omniauth-meetup](https://github.com/tapster/omniauth-meetup) - [set up a consumer here](http://www.meetup.com/meetup_api/oauth_consumers/) +- Twitter through [omniauth-twitter](https://github.com/arunagw/omniauth-twitter) - [set up a consumer here](https://apps.twitter.com/) +- Facebook through [omniauth-facebook](https://github.com/mkdynamic/omniauth-facebook) - [set up a consumer here](https://developers.facebook.com/apps/) +- GitHub through [omniauth-github](https://github.com/intridea/omniauth-github) - [set up a consumer here](https://github.com/settings/applications) +- Meetup through [omniauth-meetup](https://github.com/tapster/omniauth-meetup) - [set up a consumer here](http://www.meetup.com/meetup_api/oauth_consumers/) -To set up external authentication, create an oauth consumer on the site you want to authenticate with, then add [PROVIDER]_OAUTH_KEY and [PROVIDER]_OAUTH_SECRET value to the app environment. +To set up external authentication, create an oauth consumer on the site you want to authenticate with, then add [PROVIDER]\_OAUTH_KEY and [PROVIDER]\_OAUTH_SECRET value to the app environment. When developing locally, it is often helpful to set up **local.bridgetroll.org** to point at your localhost server via your [hosts file](https://en.wikipedia.org/wiki/Hosts_%28file%29). You can then tell the OAuth provider to use the url local.bridgetroll.org. Often, a separate OAuth consumer needs to be set up for each environment (localhost/staging/production), but some providers (like Facebook) allow a consumer set up as "www.bridgetroll.org" to function for any subdomain (like "local.bridgetroll.org"). @@ -176,7 +186,9 @@ When you add a new OAuth consumer, set the _Website_ as `http://www.bridgetroll. The values for _key_ and _secret_ on the OAuth consumers page should be added to your local environment as MEETUP_OAUTH_KEY and MEETUP_OAUTH_SECRET, respectively. ## Contributors + One billion thanks to our [super awesome contributors](https://github.com/railsbridge/bridge_troll/contributors). ## License + The code is licensed under an [MIT license](https://github.com/railsbridge/bridge_troll/blob/master/LICENSE.md). Copyright (c) 2016 by RailsBridge. diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 6aab37c36..331dc0938 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -12,7 +12,7 @@ def index format.html do @events = Event.upcoming.published_or_visible_to(current_user) .includes(:location, :region, :chapter, :organization, event_sessions: :location) - @event_regions = @events.map(&:region).compact.uniq + @event_regions = @events.filter_map(&:region).uniq end format.json do render json: EventList.new(params[:type], diff --git a/app/models/event.rb b/app/models/event.rb index f2a96e32e..80d0961e1 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -334,7 +334,7 @@ def checked_in_attendees_other_dietary_restrictions end def other_dietary_restrictions_for(rsvps) - rsvps.map { |rsvp| rsvp.dietary_info.presence }.compact + rsvps.filter_map { |rsvp| rsvp.dietary_info.presence } end def organizer_names diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 000000000..82cff1b0b --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,26 @@ +{ + "niv": { + "branch": "master", + "description": "Easy dependency management for Nix projects", + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e", + "sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n", + "type": "tarball", + "url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "release-20.03", + "description": "Nix Packages collection", + "homepage": "", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", + "sha256": "05k9y9ki6jhaqdhycnidnk5zrdzsdammbk5lsmsbz249hjhhgcgh", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/1db42b7fe3878f3f5f7a4f2dc210772fd080e205.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 000000000..1938409dd --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,174 @@ +# This file has been generated by Niv. + +let + + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; name = name'; } + else + pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + + fetch_tarball = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + else + pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + + fetch_git = name: spec: + let + ref = + if spec ? ref then spec.ref else + if spec ? branch then "refs/heads/${spec.branch}" else + if spec ? tag then "refs/tags/${spec.tag}" else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + in + builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; + + fetch_local = spec: spec.path; + + fetch_builtin-tarball = name: throw + ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; + + fetch_builtin-url = name: throw + ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; + + # + # Various helpers + # + + # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 + sanitizeName = name: + ( + concatMapStrings (s: if builtins.isList s then "-" else s) + ( + builtins.split "[^[:alnum:]+._?=-]+" + ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + ) + ); + + # The set of packages used when specs are fetched using non-builtins. + mkPkgs = sources: system: + let + sourcesNixpkgs = + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; + hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; + hasThisAsNixpkgsPath = == ./.; + in + if builtins.hasAttr "nixpkgs" sources + then sourcesNixpkgs + else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + import {} + else + abort + '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + # The actual fetching function. + fetch = pkgs: name: spec: + + if ! builtins.hasAttr "type" spec then + abort "ERROR: niv spec ${name} does not have a 'type' attribute" + else if spec.type == "file" then fetch_file pkgs name spec + else if spec.type == "tarball" then fetch_tarball pkgs name spec + else if spec.type == "git" then fetch_git name spec + else if spec.type == "local" then fetch_local spec + else if spec.type == "builtin-tarball" then fetch_builtin-tarball name + else if spec.type == "builtin-url" then fetch_builtin-url name + else + abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + + # If the environment variable NIV_OVERRIDE_${name} is set, then use + # the path directly as opposed to the fetched source. + replace = name: drv: + let + saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; + ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; + in + if ersatz == "" then drv else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + + # Ports of functions for older nix versions + + # a Nix version of mapAttrs if the built-in doesn't exist + mapAttrs = builtins.mapAttrs or ( + f: set: with builtins; + listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) + ); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 + range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 + stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); + concatMapStrings = f: list: concatStrings (map f list); + concatStrings = builtins.concatStringsSep ""; + + # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 + optionalAttrs = cond: as: if cond then as else {}; + + # fetchTarball version that is compatible between all the versions of Nix + builtins_fetchTarball = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchTarball; + in + if lessThan nixVersion "1.12" then + fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + else + fetchTarball attrs; + + # fetchurl version that is compatible between all the versions of Nix + builtins_fetchurl = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchurl; + in + if lessThan nixVersion "1.12" then + fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + else + fetchurl attrs; + + # Create the final "sources" from the config + mkSources = config: + mapAttrs ( + name: spec: + if builtins.hasAttr "outPath" spec + then abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) config.sources; + + # The "config" used by the fetchers + mkConfig = + { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null + , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) + , system ? builtins.currentSystem + , pkgs ? mkPkgs sources system + }: rec { + # The sources, i.e. the attribute set of spec name to spec + inherit sources; + + # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers + inherit pkgs; + }; + +in +mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..473abbc8f --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +let + sources = import ./nix/sources.nix { }; + pkgs = import sources.nixpkgs { }; +in pkgs.mkShell { + buildInputs = [ + # for nokogiri + pkgs.zlib + pkgs.libiconv + # for pg + pkgs.postgresql + # + pkgs.ruby_2_7 + ]; +} diff --git a/spec/mailers/previews/rsvp_preview.rb b/spec/mailers/previews/rsvp_preview.rb index ac4016939..dd1a5998c 100644 --- a/spec/mailers/previews/rsvp_preview.rb +++ b/spec/mailers/previews/rsvp_preview.rb @@ -10,9 +10,9 @@ def reminder end def multiple_location_event_reminder - rsvp = EventSession.where.not(location_id: nil).all.map do |event_session| + rsvp = EventSession.where.not(location_id: nil).all.filter_map do |event_session| event_session.rsvps.where(role_id: Role::VOLUNTEER.id).first - end.compact.first + end.first RsvpMailer.reminder(rsvp) end