From 3dfc48f7188644bb3a3a00014bf0d70fa7843081 Mon Sep 17 00:00:00 2001 From: DanielRussell Date: Tue, 7 Feb 2017 17:30:49 -0500 Subject: [PATCH 01/60] Add Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..16d518d --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1 @@ +rubyBuild { } \ No newline at end of file From 3fa9c6c840c74cd17b7f1695131eef11ba233b9a Mon Sep 17 00:00:00 2001 From: Nathan Sullivan Date: Wed, 8 Mar 2017 07:48:21 +1000 Subject: [PATCH 02/60] remove Jenkinsfile cc @DanielRussell --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 16d518d..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1 +0,0 @@ -rubyBuild { } \ No newline at end of file From 15ec8e02a24092495a24853935ee2c2e6271bade Mon Sep 17 00:00:00 2001 From: Nathan Selikoff Date: Tue, 7 Mar 2017 20:50:44 -0500 Subject: [PATCH 03/60] update README --- README.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8c74d7c..755b4c9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Climate](https://codeclimate.com/github/tedconf/front_end_builds/badges/gpa.svg) # FrontEndBuilds -Front-End Builds lets you easily serve remotely-hosted static (JS) applications from your Rails apps. +Front-End Builds (FEB) lets you easily serve remotely-hosted static (JS) applications from your Rails apps. For example, you can host a Rails backend on Heroku, an Ember.js frontend on S3, and use FEB to connect the two. ![](https://camo.githubusercontent.com/175c23176da269c03c5d3f51a8feef3bdb50fc8a/687474703a2f2f63762d73637265656e73686f74732e73332e616d617a6f6e6177732e636f6d2f41646d696e5f323031352d30332d31305f30302d35312d32352e706e67) @@ -38,6 +38,7 @@ Front-End Builds brings some migrations along with it. To run, execute ``` rake front_end_builds:install:migrations +rake db:migrate ``` ## Usage @@ -66,7 +67,7 @@ end mount protected_app, at: '/frontends' ``` -This will use basic HTTP auth to secure access to your admin ui. Just set the ENV variable, and use it to gain access. +This will use basic HTTP auth to secure access to your admin ui. Just set the ENV variable in production, and use it to gain access. If you're deploying to Heroku, use [Config Vars](https://devcenter.heroku.com/articles/config-vars). Now, to create a new app, first add a `front_end` route pointing to your app in `routes.rb`: @@ -83,9 +84,7 @@ new app named `app-name`, and you'll receive instructions on how to start pushing builds. Note: -If you're using this engine to serve an ember app at the Root, be sure -to put all other Rails routes above the `front_end` route - as this take priority -over all routes below it! +If you're using this engine to serve an ember app at the Root, be sure to put all other Rails routes above the `front_end` route - as this takes priority over all routes below it! ```rb Rails.application.routes.draw do @@ -95,6 +94,23 @@ Rails.application.routes.draw do end ``` +At this point you should be able to test the setup in dev by running + +``` +bin/rails server +``` + +Visit `/frontends` to access the Admin interface, and visit the `front_end` route, which will initially return 404 Not found since you haven't configured and deployed any front-end builds yet. + +### Example Next Steps with Heroku and Ember.js + +A common configuration is to deploy your FEB-enabled Rails app to Heroku, and deploy your Ember.js frontend to S3: + +1. Deploy your Rails app to Heroku +2. Configure your frontend app with [ember-cli-deploy-front-end-builds-pack](https://github.com/tedconf/ember-cli-deploy-front-end-builds-pack) +3. Access your Rails app's FEB Admin interface, add an app, and configure a public SSH key that corresponds to the private key you plan on using to sign your Ember.js builds +4. Deploy your frontend app. If all goes well, it should build the Ember app, push the static assets to S3, then POST to your Rails app. You'll see the build in the Admin interface, and should be able to access your frontend at the `front_end` route you specified. + ## Development From 1ec223f09506147b25488c9dfd8065978f776ea5 Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Tue, 31 Oct 2017 08:07:52 -0700 Subject: [PATCH 04/60] alias method rails 5 version of params methods --- app/controllers/front_end_builds/apps_controller.rb | 2 ++ app/controllers/front_end_builds/bests_controller.rb | 2 ++ app/controllers/front_end_builds/builds_controller.rb | 2 ++ app/controllers/front_end_builds/pubkeys_controller.rb | 2 ++ 4 files changed, 8 insertions(+) diff --git a/app/controllers/front_end_builds/apps_controller.rb b/app/controllers/front_end_builds/apps_controller.rb index 49ecad6..a3ea162 100644 --- a/app/controllers/front_end_builds/apps_controller.rb +++ b/app/controllers/front_end_builds/apps_controller.rb @@ -82,6 +82,7 @@ def app_create_params_rails_4 :name ) end + alias_method :app_create_params_rails_5, :app_create_params_rails_4 def app_update_params_rails_3 params[:app].slice( @@ -98,6 +99,7 @@ def app_update_params_rails_4 :live_build_id ) end + alias_method :app_update_params_rails_5, :app_update_params_rails_4 end end diff --git a/app/controllers/front_end_builds/bests_controller.rb b/app/controllers/front_end_builds/bests_controller.rb index aeaf544..6117be8 100644 --- a/app/controllers/front_end_builds/bests_controller.rb +++ b/app/controllers/front_end_builds/bests_controller.rb @@ -58,5 +58,7 @@ def build_search_params_rails_3 def build_search_params_rails_4 params.permit(:app_name, :id, :branch, :sha, :job) end + alias_method :build_search_params_rails_5, :build_search_params_rails_4 + end end diff --git a/app/controllers/front_end_builds/builds_controller.rb b/app/controllers/front_end_builds/builds_controller.rb index 4a4d365..d26bf86 100644 --- a/app/controllers/front_end_builds/builds_controller.rb +++ b/app/controllers/front_end_builds/builds_controller.rb @@ -71,5 +71,7 @@ def build_create_params_rails_3 def build_create_params_rails_4 params.permit(*_create_params) end + alias_method :build_create_params_rails_5, :build_create_params_rails_4 + end end diff --git a/app/controllers/front_end_builds/pubkeys_controller.rb b/app/controllers/front_end_builds/pubkeys_controller.rb index 8047289..a6ea647 100644 --- a/app/controllers/front_end_builds/pubkeys_controller.rb +++ b/app/controllers/front_end_builds/pubkeys_controller.rb @@ -46,5 +46,7 @@ def pubkey_create_params_rails_4 :pubkey ) end + alias_method :pubkey_create_params_rails_5, :pubkey_create_params_rails_4 + end end From 1a78a95e189d43342e6253bb672a6495fb98298e Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Tue, 13 Mar 2018 09:00:38 -0700 Subject: [PATCH 05/60] gem updates --- Gemfile.lock | 124 +++++++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 59 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 63381f3..36f84ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,49 +6,50 @@ PATH GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.4) - actionpack (= 4.2.4) - actionview (= 4.2.4) - activejob (= 4.2.4) + actionmailer (4.2.10) + actionpack (= 4.2.10) + actionview (= 4.2.10) + activejob (= 4.2.10) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.4) - actionview (= 4.2.4) - activesupport (= 4.2.4) + actionpack (4.2.10) + actionview (= 4.2.10) + activesupport (= 4.2.10) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.4) - activesupport (= 4.2.4) + actionview (4.2.10) + activesupport (= 4.2.10) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.4) - activesupport (= 4.2.4) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (4.2.10) + activesupport (= 4.2.10) globalid (>= 0.3.0) - activemodel (4.2.4) - activesupport (= 4.2.4) + activemodel (4.2.10) + activesupport (= 4.2.10) builder (~> 3.1) - activerecord (4.2.4) - activemodel (= 4.2.4) - activesupport (= 4.2.4) + activerecord (4.2.10) + activemodel (= 4.2.10) + activesupport (= 4.2.10) arel (~> 6.0) - activesupport (4.2.4) + activesupport (4.2.10) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.6) - arel (6.0.3) + arel (6.0.4) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - builder (3.2.2) + builder (3.2.3) coderay (1.1.0) + concurrent-ruby (1.0.5) crack (0.4.2) safe_yaml (~> 1.0.0) + crass (1.0.3) debug_inspector (0.0.2) diff-lcs (1.2.5) erubis (2.7.0) @@ -57,20 +58,21 @@ GEM factory_girl_rails (4.5.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) - globalid (0.3.6) - activesupport (>= 4.1.0) - i18n (0.7.0) - json (1.8.3) - loofah (2.0.3) + globalid (0.4.1) + activesupport (>= 4.2.0) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + loofah (2.2.0) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) + mail (2.7.0) + mini_mime (>= 0.1.1) method_source (0.8.2) - mime-types (2.6.2) - mini_portile (0.6.2) - minitest (5.8.2) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) + mini_mime (1.0.0) + mini_portile2 (2.3.0) + minitest (5.11.3) + nokogiri (1.8.2) + mini_portile2 (~> 2.3.0) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -78,34 +80,34 @@ GEM pry-stack_explorer (0.4.9.1) binding_of_caller (>= 0.7) pry (>= 0.9.11) - rack (1.6.4) + rack (1.6.9) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.4) - actionmailer (= 4.2.4) - actionpack (= 4.2.4) - actionview (= 4.2.4) - activejob (= 4.2.4) - activemodel (= 4.2.4) - activerecord (= 4.2.4) - activesupport (= 4.2.4) + rails (4.2.10) + actionmailer (= 4.2.10) + actionpack (= 4.2.10) + actionview (= 4.2.10) + activejob (= 4.2.10) + activemodel (= 4.2.10) + activerecord (= 4.2.10) + activesupport (= 4.2.10) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.4) + railties (= 4.2.10) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) + nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.4) - actionpack (= 4.2.4) - activesupport (= 4.2.4) + railties (4.2.10) + actionpack (= 4.2.10) + activesupport (= 4.2.10) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) + rake (12.3.0) rspec-core (3.1.7) rspec-support (~> 3.1.0) rspec-expectations (3.1.2) @@ -129,16 +131,17 @@ GEM shoulda-matchers (2.7.0) activesupport (>= 3.0.0) slop (3.6.0) - sprockets (3.4.0) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) sqlite3 (1.3.10) - thor (0.19.1) - thread_safe (0.3.5) - tzinfo (1.2.2) + thor (0.20.0) + thread_safe (0.3.6) + tzinfo (1.2.5) thread_safe (~> 0.1) webmock (1.20.3) addressable (>= 2.3.6) @@ -158,3 +161,6 @@ DEPENDENCIES shoulda-matchers (= 2.7.0) sqlite3 webmock + +BUNDLED WITH + 1.15.4 From a3efbbdb8e92fded0b4b98a7c15b617d16dadbd1 Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Tue, 13 Mar 2018 09:49:05 -0700 Subject: [PATCH 06/60] version bump from 0.2.1 to 0.2.2 --- lib/front_end_builds/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/front_end_builds/version.rb b/lib/front_end_builds/version.rb index 9d3d19b..aa039c0 100644 --- a/lib/front_end_builds/version.rb +++ b/lib/front_end_builds/version.rb @@ -1,3 +1,3 @@ module FrontEndBuilds - VERSION = "0.2.1" + VERSION = "0.2.2" end From 58bd40d8830acf352180a73c5c66a58da44a8f15 Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Tue, 13 Mar 2018 11:17:20 -0700 Subject: [PATCH 07/60] update rspec-rails, clarify raise error spec --- Gemfile.lock | 33 +++++++++++---------- front_end_builds.gemspec | 2 +- spec/models/front_end_builds/pubkey_spec.rb | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 36f84ef..1ce0e58 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - front_end_builds (0.2.1) + front_end_builds (0.2.2) GEM remote: https://rubygems.org/ @@ -51,7 +51,7 @@ GEM safe_yaml (~> 1.0.0) crass (1.0.3) debug_inspector (0.0.2) - diff-lcs (1.2.5) + diff-lcs (1.3) erubis (2.7.0) factory_girl (4.5.0) activesupport (>= 3.0.0) @@ -108,25 +108,26 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (12.3.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + rspec-core (3.7.1) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) + rspec-support (~> 3.7.0) rspec-its (1.0.1) rspec-core (>= 2.99.0.beta1) rspec-expectations (>= 2.99.0.beta1) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-rails (3.1.0) + rspec-mocks (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-rails (3.7.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-support (~> 3.1.0) - rspec-support (3.1.2) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-support (~> 3.7.0) + rspec-support (3.7.1) safe_yaml (1.0.4) shoulda-matchers (2.7.0) activesupport (>= 3.0.0) @@ -157,10 +158,10 @@ DEPENDENCIES pry-stack_explorer rails (~> 4.2.0) rspec-its - rspec-rails (= 3.1.0) + rspec-rails shoulda-matchers (= 2.7.0) sqlite3 webmock BUNDLED WITH - 1.15.4 + 1.16.1 diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index fe0ce19..e8c2073 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.test_files = Dir["test/**/*"] s.add_development_dependency "sqlite3" - s.add_development_dependency 'rspec-rails', '3.1.0' + s.add_development_dependency 'rspec-rails' s.add_development_dependency 'rspec-its' s.add_development_dependency 'factory_girl_rails' s.add_development_dependency 'pry' diff --git a/spec/models/front_end_builds/pubkey_spec.rb b/spec/models/front_end_builds/pubkey_spec.rb index 63a5e55..e76ab9b 100644 --- a/spec/models/front_end_builds/pubkey_spec.rb +++ b/spec/models/front_end_builds/pubkey_spec.rb @@ -75,7 +75,7 @@ module FrontEndBuilds pubkey: 'badkey' }) - expect { pubkey.to_rsa_pkey }.to raise_error + expect { pubkey.to_rsa_pkey }.to raise_error( ArgumentError, "Invalid SSH public key 'badkey'" ) end end From 21d09819fbf9bd18e32b5875671032845cb9ecd8 Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Wed, 21 Mar 2018 06:54:58 -0700 Subject: [PATCH 08/60] update loofah from 2.2.0 to 2.2.1, fixes CVE-2018-8048 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1ce0e58..c19f4d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,7 +62,7 @@ GEM activesupport (>= 4.2.0) i18n (0.9.5) concurrent-ruby (~> 1.0) - loofah (2.2.0) + loofah (2.2.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.0) From 3eb3982b1edf7f93c93caf496ab58dd68f5c4aec Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Fri, 23 Mar 2018 12:27:49 -0700 Subject: [PATCH 09/60] add bundler-audit --- front_end_builds.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index e8c2073..8cdcdc0 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -25,4 +25,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry-stack_explorer' s.add_development_dependency 'shoulda-matchers', '2.7.0' s.add_development_dependency 'webmock' + s.add_development_dependency 'bundler-audit' + end From d547853b81c3bf9c5af2b62229713f0603a06cd2 Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Fri, 23 Mar 2018 12:28:07 -0700 Subject: [PATCH 10/60] update rails-html-sanitizer from 1.0.3 to 1.0.4 and loofah from 2.2.1 to 2.2.2 --- Gemfile.lock | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c19f4d5..f0ab2cc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,6 +45,9 @@ GEM binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.3) + bundler-audit (0.6.0) + bundler (~> 1.2) + thor (~> 0.18) coderay (1.1.0) concurrent-ruby (1.0.5) crack (0.4.2) @@ -62,7 +65,7 @@ GEM activesupport (>= 4.2.0) i18n (0.9.5) concurrent-ruby (~> 1.0) - loofah (2.2.1) + loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.0) @@ -100,8 +103,8 @@ GEM activesupport (>= 4.2.0, < 5.0) nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) railties (4.2.10) actionpack (= 4.2.10) activesupport (= 4.2.10) @@ -152,6 +155,7 @@ PLATFORMS ruby DEPENDENCIES + bundler-audit factory_girl_rails front_end_builds! pry From 500b48d4bc630eadc4078fc15f461f92279c502a Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 21 Jun 2018 11:34:59 -0400 Subject: [PATCH 11/60] Removing Gemfile.lock This is only needed for local development. It does not impact what version of gems are installed in apps that use this gem. --- Gemfile.lock | 171 --------------------------------------------------- 1 file changed, 171 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index f0ab2cc..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,171 +0,0 @@ -PATH - remote: . - specs: - front_end_builds (0.2.2) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.2.10) - actionpack (= 4.2.10) - actionview (= 4.2.10) - activejob (= 4.2.10) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.10) - actionview (= 4.2.10) - activesupport (= 4.2.10) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.10) - activesupport (= 4.2.10) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.10) - activesupport (= 4.2.10) - globalid (>= 0.3.0) - activemodel (4.2.10) - activesupport (= 4.2.10) - builder (~> 3.1) - activerecord (4.2.10) - activemodel (= 4.2.10) - activesupport (= 4.2.10) - arel (~> 6.0) - activesupport (4.2.10) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.3.6) - arel (6.0.4) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - builder (3.2.3) - bundler-audit (0.6.0) - bundler (~> 1.2) - thor (~> 0.18) - coderay (1.1.0) - concurrent-ruby (1.0.5) - crack (0.4.2) - safe_yaml (~> 1.0.0) - crass (1.0.3) - debug_inspector (0.0.2) - diff-lcs (1.3) - erubis (2.7.0) - factory_girl (4.5.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) - factory_girl (~> 4.5.0) - railties (>= 3.0.0) - globalid (0.4.1) - activesupport (>= 4.2.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - loofah (2.2.2) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.0) - mini_mime (>= 0.1.1) - method_source (0.8.2) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - pry (0.10.1) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-stack_explorer (0.4.9.1) - binding_of_caller (>= 0.7) - pry (>= 0.9.11) - rack (1.6.9) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.10) - actionmailer (= 4.2.10) - actionpack (= 4.2.10) - actionview (= 4.2.10) - activejob (= 4.2.10) - activemodel (= 4.2.10) - activerecord (= 4.2.10) - activesupport (= 4.2.10) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.10) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - railties (4.2.10) - actionpack (= 4.2.10) - activesupport (= 4.2.10) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (12.3.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-its (1.0.1) - rspec-core (>= 2.99.0.beta1) - rspec-expectations (>= 2.99.0.beta1) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-rails (3.7.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - safe_yaml (1.0.4) - shoulda-matchers (2.7.0) - activesupport (>= 3.0.0) - slop (3.6.0) - sprockets (3.7.1) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - sqlite3 (1.3.10) - thor (0.20.0) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) - webmock (1.20.3) - addressable (>= 2.3.6) - crack (>= 0.3.2) - -PLATFORMS - ruby - -DEPENDENCIES - bundler-audit - factory_girl_rails - front_end_builds! - pry - pry-stack_explorer - rails (~> 4.2.0) - rspec-its - rspec-rails - shoulda-matchers (= 2.7.0) - sqlite3 - webmock - -BUNDLED WITH - 1.16.1 From 422246619b7c11170967fa2e5ddf0a3828dd47c8 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 21 Jun 2018 11:36:15 -0400 Subject: [PATCH 12/60] ignore Gemfile.lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 45bcfb1..c64a6ec 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ spec/dummy/log/*.log spec/dummy/public/assets/* spec/dummy/tmp/ spec/dummy/.sass-cache +Gemfile.lock From 6eb2ccebae970a58931382a9c7ec4ba5290bb4f2 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 21 Jun 2018 14:11:04 -0400 Subject: [PATCH 13/60] Gemfile.lock is no longer in the repo --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e983b8a..788c51e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ language: ruby -# Reset lockfile for different rails versions -before_install: "rm Gemfile.lock" install: bundle install script: - bundle exec rake db:create From ab96ca0f69630a4f9baf3c725671bc35a6a21cbd Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 21 Jul 2016 12:36:12 +1200 Subject: [PATCH 14/60] Simplify handling of params Replace the version specific params methods with something that will probably require less maintenance. And works for Rails 5. * Also update for Rails 5 compatibility, and adds Rails 5 to the Travis build matrix. --- .travis.yml | 3 ++ .../application_controller.rb | 10 ++-- .../front_end_builds/apps_controller.rb | 51 +++++++++---------- .../front_end_builds/bests_controller.rb | 22 ++++---- .../front_end_builds/builds_controller.rb | 16 +++--- .../front_end_builds/pubkeys_controller.rb | 22 ++++---- 6 files changed, 59 insertions(+), 65 deletions(-) diff --git a/.travis.yml b/.travis.yml index 788c51e..53f857c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,3 +22,6 @@ matrix: env: "RAILS_VERSION=4.2.0" - rvm: 2.2.0 env: "RAILS_VERSION=3.2.0" + include: + - rvm: 2.2.2 + env: "RAILS_VERSION=5.0.0" diff --git a/app/controllers/front_end_builds/application_controller.rb b/app/controllers/front_end_builds/application_controller.rb index 12e9290..6027b46 100644 --- a/app/controllers/front_end_builds/application_controller.rb +++ b/app/controllers/front_end_builds/application_controller.rb @@ -1,11 +1,6 @@ module FrontEndBuilds class ApplicationController < ActionController::Base - def use_params(param_method) - v = Rails::VERSION::MAJOR - send("#{param_method}_rails_#{v}") - end - # Public: A quick helper to create a respond_to block for # returning json to the client. Used because `respond_with` # is no longer included in Rails. @@ -21,5 +16,10 @@ def error!(errors, status = :unprocessable_entity) respond_with_json({ errors: errors }, status: status) end + private + + def supports_strong_params? + Rails::VERSION::MAJOR >= 4 + end end end diff --git a/app/controllers/front_end_builds/apps_controller.rb b/app/controllers/front_end_builds/apps_controller.rb index a3ea162..706a3ef 100644 --- a/app/controllers/front_end_builds/apps_controller.rb +++ b/app/controllers/front_end_builds/apps_controller.rb @@ -23,7 +23,7 @@ def show end def create - @app = FrontEndBuilds::App.new( use_params(:app_create_params) ) + @app = FrontEndBuilds::App.new( app_create_params ) if @app.save respond_with_json( @@ -39,7 +39,7 @@ def create end def update - if @app.update_attributes( use_params(:app_update_params) ) + if @app.update_attributes( app_update_params ) respond_with_json( { app: @app.serialize }, @@ -73,33 +73,30 @@ def set_app @app = FrontEndBuilds::App.find(params[:id]) end - def app_create_params_rails_3 - params[:app].slice(:name) - end - - def app_create_params_rails_4 - params.require(:app).permit( - :name - ) - end - alias_method :app_create_params_rails_5, :app_create_params_rails_4 - - def app_update_params_rails_3 - params[:app].slice( - :name, - :require_manual_activation, - :live_build_id - ) + def app_create_params + if supports_strong_params? + params.require(:app).permit( + :name + ) + else + params[:app].slice(:name) + end end - def app_update_params_rails_4 - params.require(:app).permit( - :name, - :require_manual_activation, - :live_build_id - ) + def app_update_params + if supports_strong_params? + params.require(:app).permit( + :name, + :require_manual_activation, + :live_build_id + ) + else + params[:app].slice( + :name, + :require_manual_activation, + :live_build_id + ) + end end - alias_method :app_update_params_rails_5, :app_update_params_rails_4 - end end diff --git a/app/controllers/front_end_builds/bests_controller.rb b/app/controllers/front_end_builds/bests_controller.rb index 6117be8..c13e51b 100644 --- a/app/controllers/front_end_builds/bests_controller.rb +++ b/app/controllers/front_end_builds/bests_controller.rb @@ -33,10 +33,10 @@ def meta_tags csrf_param: request_forgery_protection_token, csrf_token: form_authenticity_token, front_end_build_version: @front_end.id, - front_end_build_params: use_params(:build_search_params).to_query, + front_end_build_params: build_search_params.to_h.to_query, front_end_build_url: front_end_builds_best_path( - use_params(:build_search_params).merge(format: :json) - ) + build_search_params.merge(format: :json) + ) } tags @@ -48,17 +48,15 @@ def meta_tags end def find_front_end - @front_end = FrontEndBuilds::Build.find_best(use_params(:build_search_params)) + @front_end = FrontEndBuilds::Build.find_best(build_search_params) end - def build_search_params_rails_3 - params.slice(:app_name, :id, :branch, :sha, :job) - end - - def build_search_params_rails_4 - params.permit(:app_name, :id, :branch, :sha, :job) + def build_search_params + if supports_strong_params? + params.permit(:app_name, :id, :branch, :sha, :job) + else + params.slice(:app_name, :id, :branch, :sha, :job) + end end - alias_method :build_search_params_rails_5, :build_search_params_rails_4 - end end diff --git a/app/controllers/front_end_builds/builds_controller.rb b/app/controllers/front_end_builds/builds_controller.rb index d26bf86..6c3b1ff 100644 --- a/app/controllers/front_end_builds/builds_controller.rb +++ b/app/controllers/front_end_builds/builds_controller.rb @@ -12,7 +12,7 @@ def index end def create - build = @app.builds.new(use_params(:build_create_params)) + build = @app.builds.new(build_create_params) if build.verify && build.save build.setup! @@ -64,14 +64,12 @@ def _create_params ] end - def build_create_params_rails_3 - params.slice(*_create_params) - end - - def build_create_params_rails_4 - params.permit(*_create_params) + def build_create_params + if supports_strong_params? + params.permit(*_create_params) + else + params.slice(*_create_params) + end end - alias_method :build_create_params_rails_5, :build_create_params_rails_4 - end end diff --git a/app/controllers/front_end_builds/pubkeys_controller.rb b/app/controllers/front_end_builds/pubkeys_controller.rb index a6ea647..7ec7151 100644 --- a/app/controllers/front_end_builds/pubkeys_controller.rb +++ b/app/controllers/front_end_builds/pubkeys_controller.rb @@ -9,7 +9,7 @@ def index def create pubkey = FrontEndBuilds::Pubkey - .new( use_params(:pubkey_create_params) ) + .new( pubkey_create_params ) if pubkey.save respond_with_json( @@ -36,17 +36,15 @@ def destroy private - def pubkey_create_params_rails_3 - params[:pubkey].slice(:name, :pubkey) - end - - def pubkey_create_params_rails_4 - params.require(:pubkey).permit( - :name, - :pubkey - ) + def pubkey_create_params + if supports_strong_params? + params.require(:pubkey).permit( + :name, + :pubkey + ) + else + params[:pubkey].slice(:name, :pubkey) + end end - alias_method :pubkey_create_params_rails_5, :pubkey_create_params_rails_4 - end end From a25e641161aaffc8d5dc7cd34d85079fef26b2e5 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Oct 2016 05:54:07 +1300 Subject: [PATCH 15/60] Update before_filter deprecation --- app/controllers/front_end_builds/apps_controller.rb | 2 +- app/controllers/front_end_builds/bests_controller.rb | 2 +- app/controllers/front_end_builds/builds_controller.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/front_end_builds/apps_controller.rb b/app/controllers/front_end_builds/apps_controller.rb index 706a3ef..f5751cd 100644 --- a/app/controllers/front_end_builds/apps_controller.rb +++ b/app/controllers/front_end_builds/apps_controller.rb @@ -2,7 +2,7 @@ module FrontEndBuilds class AppsController < ApplicationController - before_filter :set_app , :only => [:show, :destroy, :update] + before_action :set_app , :only => [:show, :destroy, :update] def index apps = App.includes(:recent_builds) diff --git a/app/controllers/front_end_builds/bests_controller.rb b/app/controllers/front_end_builds/bests_controller.rb index c13e51b..9b65543 100644 --- a/app/controllers/front_end_builds/bests_controller.rb +++ b/app/controllers/front_end_builds/bests_controller.rb @@ -11,7 +11,7 @@ module FrontEndBuilds class BestsController < ApplicationController include Rails.application.routes.url_helpers - before_filter :find_front_end, only: [:show] + before_action :find_front_end, only: [:show] def show if @front_end diff --git a/app/controllers/front_end_builds/builds_controller.rb b/app/controllers/front_end_builds/builds_controller.rb index 6c3b1ff..78a6dea 100644 --- a/app/controllers/front_end_builds/builds_controller.rb +++ b/app/controllers/front_end_builds/builds_controller.rb @@ -2,7 +2,7 @@ module FrontEndBuilds class BuildsController < ApplicationController - before_filter :set_app!, only: [:create] + before_action :set_app!, only: [:create] def index builds = FrontEndBuilds::Build.where(app_id: params[:app_id]) From d529a1c1d8b8f6b3e145b5cb5820337ee8f57210 Mon Sep 17 00:00:00 2001 From: Nick Coyne Date: Wed, 28 Jun 2017 12:05:18 +1200 Subject: [PATCH 16/60] Update deprecated render --- app/controllers/front_end_builds/admin_controller.rb | 2 +- app/controllers/front_end_builds/bests_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/front_end_builds/admin_controller.rb b/app/controllers/front_end_builds/admin_controller.rb index 7bab2e8..5d5deb8 100644 --- a/app/controllers/front_end_builds/admin_controller.rb +++ b/app/controllers/front_end_builds/admin_controller.rb @@ -15,7 +15,7 @@ def index html = html.sub('BASEURL/', baseURL) html = html.sub("baseURL: ''", "baseURL: '#{baseURL}'") - render text: html + render plain: html end end diff --git a/app/controllers/front_end_builds/bests_controller.rb b/app/controllers/front_end_builds/bests_controller.rb index 9b65543..dace844 100644 --- a/app/controllers/front_end_builds/bests_controller.rb +++ b/app/controllers/front_end_builds/bests_controller.rb @@ -16,12 +16,12 @@ class BestsController < ApplicationController def show if @front_end respond_to do |format| - format.html { render text: @front_end.with_head_tag(meta_tags) } + format.html { render plain: @front_end.with_head_tag(meta_tags) } format.json { render json: { version: @front_end.id } } end else # TODO install instructions, user needs to push build - render text: "not found", status: 404 + render plain: "not found", status: 404 end end From 141eacc17a5c44ef3a5205fe8cc2e6356aa28fb7 Mon Sep 17 00:00:00 2001 From: Nick Coyne Date: Wed, 28 Jun 2017 12:55:03 +1200 Subject: [PATCH 17/60] Proper support for Rails > 5.0 No more support for < 5.0 --- Gemfile | 9 +----- .../application_controller.rb | 6 ---- .../front_end_builds/apps_controller.rb | 31 ++++++------------- .../front_end_builds/bests_controller.rb | 6 +--- .../front_end_builds/builds_controller.rb | 10 ++---- .../front_end_builds/pubkeys_controller.rb | 15 +++------ front_end_builds.gemspec | 1 + .../front_end_builds/apps_controller_spec.rb | 26 ++++++++++------ .../front_end_builds/bests_controller_spec.rb | 14 ++++----- .../builds_controller_spec.rb | 20 ++++++------ .../host_apps_controller_spec.rb | 2 +- .../pubkeys_controller_spec.rb | 16 ++++++---- spec/dummy/config/environments/test.rb | 9 ++---- spec/rails_helper.rb | 1 + spec/requests/build_spec.rb | 26 +++++++++------- spec/requests/new_build_version_spec.rb | 17 +++++----- spec/support/database_cleaner.rb | 14 +++++++++ 17 files changed, 107 insertions(+), 116 deletions(-) create mode 100644 spec/support/database_cleaner.rb diff --git a/Gemfile b/Gemfile index e1fd10d..e21999f 100644 --- a/Gemfile +++ b/Gemfile @@ -8,16 +8,9 @@ rails = case rails_version when 'master' { :github => 'rails/rails'} when 'default' - '~> 4.2.0' + '~> 5.0.4' else "~> #{rails_version}" end gem 'rails', rails - -# These no longer ship with ruby 2.2.0, but are needed for -# Rails 3 and 4.0.0 -if RUBY_VERSION == "2.2.0" - gem 'test-unit' - gem 'minitest' -end diff --git a/app/controllers/front_end_builds/application_controller.rb b/app/controllers/front_end_builds/application_controller.rb index 6027b46..df19446 100644 --- a/app/controllers/front_end_builds/application_controller.rb +++ b/app/controllers/front_end_builds/application_controller.rb @@ -15,11 +15,5 @@ def respond_with_json(object, options = {}) def error!(errors, status = :unprocessable_entity) respond_with_json({ errors: errors }, status: status) end - - private - - def supports_strong_params? - Rails::VERSION::MAJOR >= 4 - end end end diff --git a/app/controllers/front_end_builds/apps_controller.rb b/app/controllers/front_end_builds/apps_controller.rb index f5751cd..1032ee8 100644 --- a/app/controllers/front_end_builds/apps_controller.rb +++ b/app/controllers/front_end_builds/apps_controller.rb @@ -6,7 +6,6 @@ class AppsController < ApplicationController def index apps = App.includes(:recent_builds) - respond_with_json({ apps: apps.map(&:serialize), builds: apps.map(&:recent_builds) @@ -61,7 +60,7 @@ def destroy ) else respond_with_json( - {errors: @app.errors}, + { errors: @app.errors }, status: :unprocessable_entity ) end @@ -74,29 +73,17 @@ def set_app end def app_create_params - if supports_strong_params? - params.require(:app).permit( - :name - ) - else - params[:app].slice(:name) - end + params.require(:app).permit( + :name + ) end def app_update_params - if supports_strong_params? - params.require(:app).permit( - :name, - :require_manual_activation, - :live_build_id - ) - else - params[:app].slice( - :name, - :require_manual_activation, - :live_build_id - ) - end + params.require(:app).permit( + :name, + :require_manual_activation, + :live_build_id + ) end end end diff --git a/app/controllers/front_end_builds/bests_controller.rb b/app/controllers/front_end_builds/bests_controller.rb index dace844..95008bd 100644 --- a/app/controllers/front_end_builds/bests_controller.rb +++ b/app/controllers/front_end_builds/bests_controller.rb @@ -52,11 +52,7 @@ def find_front_end end def build_search_params - if supports_strong_params? - params.permit(:app_name, :id, :branch, :sha, :job) - else - params.slice(:app_name, :id, :branch, :sha, :job) - end + params.permit(:app_name, :id, :branch, :sha, :job) end end end diff --git a/app/controllers/front_end_builds/builds_controller.rb b/app/controllers/front_end_builds/builds_controller.rb index 78a6dea..aa1adc1 100644 --- a/app/controllers/front_end_builds/builds_controller.rb +++ b/app/controllers/front_end_builds/builds_controller.rb @@ -22,7 +22,7 @@ def create build.errors[:base] << 'No access - invalid SSH key' if !build.verify render( - text: 'Could not create the build: ' + build.errors.full_messages.to_s, + plain: 'Could not create the build: ' + build.errors.full_messages.to_s, status: :unprocessable_entity ) end @@ -45,7 +45,7 @@ def set_app! if @app.nil? render( - text: "No app named #{params[:app_name]}.", + plain: "No app named #{params[:app_name]}.", status: :unprocessable_entity ) @@ -65,11 +65,7 @@ def _create_params end def build_create_params - if supports_strong_params? - params.permit(*_create_params) - else - params.slice(*_create_params) - end + params.permit(*_create_params) end end end diff --git a/app/controllers/front_end_builds/pubkeys_controller.rb b/app/controllers/front_end_builds/pubkeys_controller.rb index 7ec7151..d622b83 100644 --- a/app/controllers/front_end_builds/pubkeys_controller.rb +++ b/app/controllers/front_end_builds/pubkeys_controller.rb @@ -8,8 +8,7 @@ def index end def create - pubkey = FrontEndBuilds::Pubkey - .new( pubkey_create_params ) + pubkey = FrontEndBuilds::Pubkey.new(pubkey_create_params) if pubkey.save respond_with_json( @@ -37,14 +36,10 @@ def destroy private def pubkey_create_params - if supports_strong_params? - params.require(:pubkey).permit( - :name, - :pubkey - ) - else - params[:pubkey].slice(:name, :pubkey) - end + params.require(:pubkey).permit( + :name, + :pubkey + ) end end end diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index 8cdcdc0..f1b342a 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -21,6 +21,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rspec-rails' s.add_development_dependency 'rspec-its' s.add_development_dependency 'factory_girl_rails' + s.add_development_dependency 'database_cleaner' s.add_development_dependency 'pry' s.add_development_dependency 'pry-stack_explorer' s.add_development_dependency 'shoulda-matchers', '2.7.0' diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index 4549d49..e450d6a 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -4,9 +4,9 @@ module FrontEndBuilds RSpec.describe AppsController, :type => :controller do routes { FrontEndBuilds::Engine.routes } - let(:app) { FactoryGirl.create :front_end_builds_app, name: 'dummy' } - let!(:builds) { FactoryGirl.create_list :front_end_builds_build, 2, app: app } - let!(:live_build) { FactoryGirl.create :front_end_builds_build, :live, :fetched, app: app } + let(:app) { FactoryGirl.create(:front_end_builds_app, name: 'dummy') } + let!(:builds) { FactoryGirl.create_list(:front_end_builds_build, 2, app: app) } + let!(:live_build) { FactoryGirl.create(:front_end_builds_build, :live, :fetched, app: app) } describe 'index' do it "should find all apps" do @@ -20,7 +20,7 @@ module FrontEndBuilds describe 'show' do it "should find the requested app" do - get :show, id: app.id, format: :json + get :show, params: { id: app.id }, format: :json expect(response).to be_success expect(json['app']['id']).to eq(app.id) @@ -31,8 +31,10 @@ module FrontEndBuilds describe 'create' do it "should create a new app" do - post :create, app: { - name: 'my-new-app' + post :create, params: { + app: { + name: 'my-new-app' + } }, format: :json @@ -50,9 +52,11 @@ module FrontEndBuilds it "should edit an existing app" do post :update, - id: app.id, - app: { - live_build_id: new_build.id + params: { + id: app.id, + app: { + live_build_id: new_build.id + } }, format: :json @@ -71,7 +75,9 @@ module FrontEndBuilds context 'a valid app' do before(:each) do post :destroy, - id: deletable_app.id, + params: { + id: deletable_app.id + }, format: :json end diff --git a/spec/controllers/front_end_builds/bests_controller_spec.rb b/spec/controllers/front_end_builds/bests_controller_spec.rb index b2d433f..67ea2a8 100644 --- a/spec/controllers/front_end_builds/bests_controller_spec.rb +++ b/spec/controllers/front_end_builds/bests_controller_spec.rb @@ -39,32 +39,32 @@ module FrontEndBuilds end it "should find the live build" do - get :show, app_name: app.name + get :show, params: { app_name: app.name } expect(response).to be_success expect(response.body).to match(live.html) end it "should find the build by job" do - get :show, app_name: app.name, job: 'number3' + get :show, params: { app_name: app.name, job: 'number3' } expect(response).to be_success expect(response.body).to match(older.html) end it "should find the build by build_id" do - get :show, id: older.id + get :show, params: { id: older.id } expect(response).to be_success expect(response.body).to match(older.html) end it "should find the build by branch" do - get :show, app_name: app.name, branch: 'master' + get :show, params: { app_name: app.name, branch: 'master' } expect(response).to be_success expect(response.body).to match(latest.html) end context "meta tags" do before(:each) do - get :show, app_name: app.name, branch: 'master' + get :show, params: { app_name: app.name, branch: 'master' } expect(response).to be_success end @@ -77,13 +77,13 @@ module FrontEndBuilds end it "should be 404 when nothing is found" do - get :show, app_name: 'does-not-exist', branch: 'master' + get :show, params: { app_name: 'does-not-exist', branch: 'master' } expect(response).to_not be_success expect(response.status).to eq(404) end it "should be able to get the version of the best build" do - get :show, app_name: app.name, branch: 'master', format: :json + get :show, params: { app_name: app.name, branch: 'master', format: :json } expect(json['version']).to eq(latest.id) end diff --git a/spec/controllers/front_end_builds/builds_controller_spec.rb b/spec/controllers/front_end_builds/builds_controller_spec.rb index 042ec37..42eb12a 100644 --- a/spec/controllers/front_end_builds/builds_controller_spec.rb +++ b/spec/controllers/front_end_builds/builds_controller_spec.rb @@ -10,7 +10,7 @@ module FrontEndBuilds it "should list all the builds for an app" do FactoryGirl.create_list(:front_end_builds_build, 3, app: app) - get :index, app_id: app.id, format: :json + get :index, params: { app_id: app.id }, format: :json expect(response).to be_success expect(json['builds'].length).to eq(3) end @@ -19,7 +19,7 @@ module FrontEndBuilds build1 = FactoryGirl.create(:front_end_builds_build, app: app) FactoryGirl.create(:front_end_builds_build) - get :index, app_id: app.id, format: :json + get :index, params: { app_id: app.id }, format: :json expect(response).to be_success expect(json['builds'].length).to eq(1) expect(json['builds'].first['id']).to eq(build1.id) @@ -40,7 +40,7 @@ module FrontEndBuilds let(:build) { FactoryGirl.create :front_end_builds_build } it "should load the app" do - get :show, id: build.id, format: :json + get :show, params: { id: build.id }, format: :json expect(response).to be_success expect(json['build']['id']).to eq(build.id) end @@ -66,7 +66,7 @@ module FrontEndBuilds it "should create the new build, and make it live" do expect(app.live_build.html).to eq('the old build') - post :create, { + post :create, params: { app_name: app.name, branch: 'master', sha: 'some-sha', @@ -82,7 +82,7 @@ module FrontEndBuilds it "should not make a new build live if it's non-master" do expect(app.live_build.html).to eq('the old build') - post :create, { + post :create, params: { app_name: app.name, branch: 'some-feature', sha: 'some-sha', @@ -98,7 +98,7 @@ module FrontEndBuilds it "should not active a build if the app requires manual activiation" do app.update_attributes(require_manual_activation: true) - post :create, { + post :create, params: { app_name: app.name, branch: 'master', sha: 'some-sha', @@ -114,7 +114,7 @@ module FrontEndBuilds it 'should error if the app cannot be found' do app.update_attributes(require_manual_activation: true) - post :create, { + post :create, params: { app_name: 'this-does-not-exist', branch: 'master', sha: 'some-sha', @@ -132,7 +132,7 @@ module FrontEndBuilds digest = OpenSSL::Digest::SHA256.new signature = pkey.sign(digest, "#{app.name}-#{endpoint}") - post :create, { + post :create, params: { app_name: app.name, branch: 'master', sha: 'some-sha', @@ -146,7 +146,7 @@ module FrontEndBuilds end it "should error if not all fields are present" do - post :create, { + post :create, params: { app_name: app.name, endpoint: endpoint, signature: create_signature("#{app.name}-#{endpoint}") @@ -156,7 +156,7 @@ module FrontEndBuilds end it 'should let the html be submitted' do - post :create, { + post :create, params: { app_name: app.name, branch: 'master', sha: 'some-sha', diff --git a/spec/controllers/front_end_builds/host_apps_controller_spec.rb b/spec/controllers/front_end_builds/host_apps_controller_spec.rb index 9df01c5..35d4b4f 100644 --- a/spec/controllers/front_end_builds/host_apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/host_apps_controller_spec.rb @@ -6,7 +6,7 @@ module FrontEndBuilds describe 'show' do it 'should fetch info about the host application (rails)' do - get :show, id: 'current', format: :json + get :show, params: { id: 'current' }, format: :json expect(response).to be_success expect(json['host_app']['id']).to eq('current') diff --git a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb index 395a744..b577d4f 100644 --- a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb +++ b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb @@ -18,9 +18,11 @@ module FrontEndBuilds describe 'create' do it 'should create a new pubkey' do post :create, - pubkey: { - name: 'my-new-key', - pubkey: 'asdfasdf' + params: { + pubkey: { + name: 'my-new-key', + pubkey: 'asdfasdf' + } }, format: :json @@ -36,8 +38,10 @@ module FrontEndBuilds it 'should not create a new pubkey without a pubkey' do post :create, - pubkey: { - name: 'my-new-key' + params: { + pubkey: { + name: 'my-new-key' + } }, format: :json @@ -50,7 +54,7 @@ module FrontEndBuilds let(:pubkey) { FactoryGirl.create(:front_end_builds_pubkey) } it 'should remove a pubkey' do - delete :destroy, id: pubkey.id, format: :json + delete :destroy, params: { id: pubkey.id }, format: :json expect(response).to be_success diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index 363ab3e..4d0f642 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -14,12 +14,9 @@ config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. - if Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR > 1 - config.serve_static_files = true - else - config.serve_static_assets = true - end - config.static_cache_control = 'public, max-age=3600' + config.public_file_server.enabled = true + + config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # Show full error reports and disable caching. config.consider_all_requests_local = true diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5e91200..6d1c403 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,6 +7,7 @@ require 'factory_girl_rails' require 'shoulda/matchers' require 'webmock/rspec' +require 'database_cleaner' Rails.backtrace_cleaner.remove_silencers! diff --git a/spec/requests/build_spec.rb b/spec/requests/build_spec.rb index 9db4fee..c2a5f0c 100644 --- a/spec/requests/build_spec.rb +++ b/spec/requests/build_spec.rb @@ -13,11 +13,13 @@ it "creates a new build and then uses it" do post "/dummy", - branch: "master", - sha: "a1b2c3", - job: "jenkins-build-1", - endpoint: endpoint, - signature: create_signature("dummy-#{endpoint}") + params: { + branch: "master", + sha: "a1b2c3", + job: "jenkins-build-1", + endpoint: endpoint, + signature: create_signature("dummy-#{endpoint}") + } expect(response).to be_success @@ -34,12 +36,14 @@ it "should be able to create a build from a generic endpoint" do post "/front_end_builds/builds", - app_name: 'dummy', - branch: "master", - sha: "a1b2c3", - job: "jenkins-build-1", - endpoint: endpoint, - signature: create_signature("dummy-#{endpoint}") + params: { + app_name: 'dummy', + branch: "master", + sha: "a1b2c3", + job: "jenkins-build-1", + endpoint: endpoint, + signature: create_signature("dummy-#{endpoint}") + } expect(response).to be_success expect(front_end_app.builds.length).to eq(1) diff --git a/spec/requests/new_build_version_spec.rb b/spec/requests/new_build_version_spec.rb index 4f186f0..9b9eb8d 100644 --- a/spec/requests/new_build_version_spec.rb +++ b/spec/requests/new_build_version_spec.rb @@ -4,6 +4,7 @@ let(:front_end_app) { FactoryGirl.create :front_end_builds_app, name: "dummy" } let(:version_url) { "/front_end_builds/best?app_name=dummy&branch=master" } let(:endpoint) { "http://www.ted.com/builds/1" } + let(:headers) { { 'ACCEPT' => 'application/json' } } before(:each) do FactoryGirl.create( @@ -20,23 +21,25 @@ it "gets a different version when a new build is created" do # get the current version - get version_url, format: :json + get version_url, headers: headers expect(response).to be_success expect(json['version']).to_not be_nil original_version = json['version'] post "/dummy", - branch: "master", - sha: "a1b2c3", - job: "jenkins-build-1", - endpoint: endpoint, - signature: create_signature("dummy-#{endpoint}") + params: { + branch: "master", + sha: "a1b2c3", + job: "jenkins-build-1", + endpoint: endpoint, + signature: create_signature("dummy-#{endpoint}") + } expect(response).to be_success # now we should get a new version - get version_url, format: :json + get version_url, headers: headers expect(response).to be_success expect(json['version']).to_not be_nil diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb new file mode 100644 index 0000000..32f1a29 --- /dev/null +++ b/spec/support/database_cleaner.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +RSpec.configure do |config| + config.before(:suite) do + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean_with(:truncation) + end + + config.around(:each) do |example| + DatabaseCleaner.cleaning do + example.run + end + end +end From 05c3d866abd673b8db0b3e88510575f6f283f10f Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 31 Jan 2019 16:59:38 -0500 Subject: [PATCH 18/60] bump version --- CHANGELOG.md | 4 ++++ lib/front_end_builds/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b2fe59..d5a7540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # What's new +### 1.0.0 (January 31, 2019) +* Support for Rails 5 +* Dropping support for < Rails 5 + ## Upgrading To upgrade ``front_end_builds`` just set the appropriate version in your diff --git a/lib/front_end_builds/version.rb b/lib/front_end_builds/version.rb index aa039c0..fe2b515 100644 --- a/lib/front_end_builds/version.rb +++ b/lib/front_end_builds/version.rb @@ -1,3 +1,3 @@ module FrontEndBuilds - VERSION = "0.2.2" + VERSION = "1.0.0" end From 6fc969072a98f808e9254f850c07569ad2750daa Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 31 Jan 2019 17:04:39 -0500 Subject: [PATCH 19/60] update factory_girl to factory_bot --- front_end_builds.gemspec | 2 +- lib/front_end_builds/engine.rb | 2 +- .../front_end_builds/apps_controller_spec.rb | 14 +++--- .../front_end_builds/bests_controller_spec.rb | 8 +-- .../builds_controller_spec.rb | 16 +++--- .../pubkeys_controller_spec.rb | 4 +- spec/factories/front_end_builds_apps.rb | 4 +- spec/factories/front_end_builds_builds.rb | 4 +- spec/factories/front_end_builds_pubkeys.rb | 2 +- spec/models/front_end_builds/app_spec.rb | 10 ++-- spec/models/front_end_builds/build_spec.rb | 50 +++++++++---------- spec/models/front_end_builds/pubkey_spec.rb | 24 ++++----- spec/rails_helper.rb | 2 +- spec/requests/api_requests_spec.rb | 4 +- spec/requests/build_spec.rb | 4 +- spec/requests/new_build_version_spec.rb | 6 +-- 16 files changed, 78 insertions(+), 78 deletions(-) diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index f1b342a..4e9ace9 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.add_development_dependency "sqlite3" s.add_development_dependency 'rspec-rails' s.add_development_dependency 'rspec-its' - s.add_development_dependency 'factory_girl_rails' + s.add_development_dependency 'factory_bot_rails' s.add_development_dependency 'database_cleaner' s.add_development_dependency 'pry' s.add_development_dependency 'pry-stack_explorer' diff --git a/lib/front_end_builds/engine.rb b/lib/front_end_builds/engine.rb index fd6a686..ed4b0e2 100644 --- a/lib/front_end_builds/engine.rb +++ b/lib/front_end_builds/engine.rb @@ -6,7 +6,7 @@ class Engine < ::Rails::Engine config.generators do |g| g.test_framework :rspec, fixture: false - g.fixture_replacement :factory_girl, dir: 'spec/factories' + g.fixture_replacement :factory_bot, dir: 'spec/factories' g.assets false g.helper false end diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index e450d6a..c6b67f2 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -4,9 +4,9 @@ module FrontEndBuilds RSpec.describe AppsController, :type => :controller do routes { FrontEndBuilds::Engine.routes } - let(:app) { FactoryGirl.create(:front_end_builds_app, name: 'dummy') } - let!(:builds) { FactoryGirl.create_list(:front_end_builds_build, 2, app: app) } - let!(:live_build) { FactoryGirl.create(:front_end_builds_build, :live, :fetched, app: app) } + let(:app) { FactoryBot.create(:front_end_builds_app, name: 'dummy') } + let!(:builds) { FactoryBot.create_list(:front_end_builds_build, 2, app: app) } + let!(:live_build) { FactoryBot.create(:front_end_builds_build, :live, :fetched, app: app) } describe 'index' do it "should find all apps" do @@ -46,9 +46,9 @@ module FrontEndBuilds end describe 'update' do - let(:app) { FactoryGirl.create :front_end_builds_app, name: 'forsaken' } - let!(:live_build) { FactoryGirl.create :front_end_builds_build, :live, :fetched, app: app } - let!(:new_build) { FactoryGirl.create :front_end_builds_build, :fetched, app: app } + let(:app) { FactoryBot.create :front_end_builds_app, name: 'forsaken' } + let!(:live_build) { FactoryBot.create :front_end_builds_build, :live, :fetched, app: app } + let!(:new_build) { FactoryBot.create :front_end_builds_build, :fetched, app: app } it "should edit an existing app" do post :update, @@ -70,7 +70,7 @@ module FrontEndBuilds end describe 'destroy' do - let(:deletable_app) { FactoryGirl.create :front_end_builds_app, name: 'forsaken' } + let(:deletable_app) { FactoryBot.create :front_end_builds_app, name: 'forsaken' } context 'a valid app' do before(:each) do diff --git a/spec/controllers/front_end_builds/bests_controller_spec.rb b/spec/controllers/front_end_builds/bests_controller_spec.rb index 67ea2a8..288957d 100644 --- a/spec/controllers/front_end_builds/bests_controller_spec.rb +++ b/spec/controllers/front_end_builds/bests_controller_spec.rb @@ -2,11 +2,11 @@ module FrontEndBuilds RSpec.describe BestsController, :type => :controller do - let(:app) { FactoryGirl.create :front_end_builds_app, name: 'dummy' } + let(:app) { FactoryBot.create :front_end_builds_app, name: 'dummy' } describe "show" do let!(:latest) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha1', job: 'number1', @@ -17,7 +17,7 @@ module FrontEndBuilds end let!(:live) do - FactoryGirl.create :front_end_builds_build, :live, + FactoryBot.create :front_end_builds_build, :live, app: app, sha: 'sha2', job: 'number2', @@ -28,7 +28,7 @@ module FrontEndBuilds end let!(:older) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha3', job: 'number3', diff --git a/spec/controllers/front_end_builds/builds_controller_spec.rb b/spec/controllers/front_end_builds/builds_controller_spec.rb index 42eb12a..13e3d90 100644 --- a/spec/controllers/front_end_builds/builds_controller_spec.rb +++ b/spec/controllers/front_end_builds/builds_controller_spec.rb @@ -2,13 +2,13 @@ module FrontEndBuilds RSpec.describe BuildsController, :type => :controller do - let(:app) { FactoryGirl.create :front_end_builds_app, name: 'dummy' } + let(:app) { FactoryBot.create :front_end_builds_app, name: 'dummy' } describe "index" do routes { FrontEndBuilds::Engine.routes } it "should list all the builds for an app" do - FactoryGirl.create_list(:front_end_builds_build, 3, app: app) + FactoryBot.create_list(:front_end_builds_build, 3, app: app) get :index, params: { app_id: app.id }, format: :json expect(response).to be_success @@ -16,8 +16,8 @@ module FrontEndBuilds end it 'should be scoped to the requested app' do - build1 = FactoryGirl.create(:front_end_builds_build, app: app) - FactoryGirl.create(:front_end_builds_build) + build1 = FactoryBot.create(:front_end_builds_build, app: app) + FactoryBot.create(:front_end_builds_build) get :index, params: { app_id: app.id }, format: :json expect(response).to be_success @@ -26,7 +26,7 @@ module FrontEndBuilds end it "should not list any builds if the app is not present" do - FactoryGirl.create_list(:front_end_builds_build, 3) + FactoryBot.create_list(:front_end_builds_build, 3) get :index, format: :json expect(response).to be_success @@ -37,7 +37,7 @@ module FrontEndBuilds describe "show" do routes { FrontEndBuilds::Engine.routes } - let(:build) { FactoryGirl.create :front_end_builds_build } + let(:build) { FactoryBot.create :front_end_builds_build } it "should load the app" do get :show, params: { id: build.id }, format: :json @@ -50,14 +50,14 @@ module FrontEndBuilds let(:endpoint) { 'http://www.ted.com/testing/build' } before(:each) do - FactoryGirl.create :front_end_builds_build, :live, + FactoryBot.create :front_end_builds_build, :live, app: app, endpoint: 'http://www.ted.com/testing/build', created_at: 1.day.ago, fetched: true, html: 'the old build' - FactoryGirl.create(:front_end_builds_pubkey, :fixture_pubkey) + FactoryBot.create(:front_end_builds_pubkey, :fixture_pubkey) stub_request(:get, endpoint) .to_return(body: 'fetched html') diff --git a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb index b577d4f..cffc492 100644 --- a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb +++ b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb @@ -5,7 +5,7 @@ module FrontEndBuilds routes { FrontEndBuilds::Engine.routes } describe 'index' do - let!(:keys) { FactoryGirl.create_list(:front_end_builds_pubkey, 3) } + let!(:keys) { FactoryBot.create_list(:front_end_builds_pubkey, 3) } it 'should list all pubkeys' do get :index, format: :json @@ -51,7 +51,7 @@ module FrontEndBuilds end describe 'destroy' do - let(:pubkey) { FactoryGirl.create(:front_end_builds_pubkey) } + let(:pubkey) { FactoryBot.create(:front_end_builds_pubkey) } it 'should remove a pubkey' do delete :destroy, params: { id: pubkey.id }, format: :json diff --git a/spec/factories/front_end_builds_apps.rb b/spec/factories/front_end_builds_apps.rb index c2756b3..c94ba35 100644 --- a/spec/factories/front_end_builds_apps.rb +++ b/spec/factories/front_end_builds_apps.rb @@ -1,6 +1,6 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl +# Read about factories at https://github.com/thoughtbot/factory_bot -FactoryGirl.define do +FactoryBot.define do factory :front_end_builds_app, :class => 'FrontEndBuilds::App' do sequence(:name) { |n| "application-#{n}" } end diff --git a/spec/factories/front_end_builds_builds.rb b/spec/factories/front_end_builds_builds.rb index c440108..40e830d 100644 --- a/spec/factories/front_end_builds_builds.rb +++ b/spec/factories/front_end_builds_builds.rb @@ -1,6 +1,6 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl +# Read about factories at https://github.com/thoughtbot/factory_bot -FactoryGirl.define do +FactoryBot.define do factory :front_end_builds_build, :class => 'FrontEndBuilds::Build' do sequence(:sha) { |n| "sha#{n}" } sequence(:job) { |n| n } diff --git a/spec/factories/front_end_builds_pubkeys.rb b/spec/factories/front_end_builds_pubkeys.rb index 9437243..11f1e70 100644 --- a/spec/factories/front_end_builds_pubkeys.rb +++ b/spec/factories/front_end_builds_pubkeys.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :front_end_builds_pubkey, :class => 'FrontEndBuilds::Pubkey' do name 'ryan' sequence(:pubkey) { |i| "ssh-rsa pubkey#{i}#{i}#{i} test@ted.com" } diff --git a/spec/models/front_end_builds/app_spec.rb b/spec/models/front_end_builds/app_spec.rb index 087dfc7..1afdbce 100644 --- a/spec/models/front_end_builds/app_spec.rb +++ b/spec/models/front_end_builds/app_spec.rb @@ -2,7 +2,7 @@ module FrontEndBuilds describe App, :type => :model do - let(:app) { FactoryGirl.create(:front_end_builds_app) } + let(:app) { FactoryBot.create(:front_end_builds_app) } it { should have_many(:builds) } it { should belong_to(:live_build) } @@ -10,7 +10,7 @@ module FrontEndBuilds describe '#recent_builds' do it 'should only show the 10 most recent builds' do - FactoryGirl.create_list(:front_end_builds_build, 11, { + FactoryBot.create_list(:front_end_builds_build, 11, { app: app }) @@ -18,12 +18,12 @@ module FrontEndBuilds end it 'should order the builds with the most recent at top' do - older = FactoryGirl.create(:front_end_builds_build, { + older = FactoryBot.create(:front_end_builds_build, { app: app, created_at: 2.days.ago }) - recent = FactoryGirl.create(:front_end_builds_build, { + recent = FactoryBot.create(:front_end_builds_build, { app: app, created_at: 1.day.ago }) @@ -47,7 +47,7 @@ module FrontEndBuilds describe '#get_url' do it 'should lookup the url in the Apps url hash' do App.register_url('testing', '/testing') - app = FactoryGirl.create(:front_end_builds_app, name: 'testing') + app = FactoryBot.create(:front_end_builds_app, name: 'testing') expect(app.get_url).to eq('/testing') end end diff --git a/spec/models/front_end_builds/build_spec.rb b/spec/models/front_end_builds/build_spec.rb index 27e761d..a15a9f0 100644 --- a/spec/models/front_end_builds/build_spec.rb +++ b/spec/models/front_end_builds/build_spec.rb @@ -11,10 +11,10 @@ module FrontEndBuilds it { should validate_presence_of(:branch) } describe :find_best do - let(:app) { FactoryGirl.create :front_end_builds_app } + let(:app) { FactoryBot.create :front_end_builds_app } let!(:latest) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha1', job: 'number1', @@ -24,7 +24,7 @@ module FrontEndBuilds end let!(:live_build) do - FactoryGirl.create :front_end_builds_build, :live, + FactoryBot.create :front_end_builds_build, :live, app: app, sha: 'sha2', job: 'number2', @@ -34,7 +34,7 @@ module FrontEndBuilds end let!(:older) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha3', job: 'number3', @@ -45,7 +45,7 @@ module FrontEndBuilds context "with no query" do before(:each) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha4', branch: 'nonmaster', @@ -64,7 +64,7 @@ module FrontEndBuilds context "when finding the branch" do before(:each) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha3', branch: 'master', @@ -88,7 +88,7 @@ module FrontEndBuilds context "when finding unfetched build" do before(:each) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha3', branch: 'master', @@ -102,7 +102,7 @@ module FrontEndBuilds context "when finding another app" do before(:each) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, sha: 'sha4', branch: 'master', fetched: true, @@ -120,11 +120,11 @@ module FrontEndBuilds end describe '#verify' do - let(:app) { FactoryGirl.create(:front_end_builds_app, name: 'app') } + let(:app) { FactoryBot.create(:front_end_builds_app, name: 'app') } let(:endpoint) { 'http://some.external.url.ted.com/index.html' } let(:build) do - FactoryGirl.build(:front_end_builds_build, { + FactoryBot.build(:front_end_builds_build, { app: app, endpoint: endpoint, signature: create_signature("#{app.name}-#{endpoint}") @@ -136,7 +136,7 @@ module FrontEndBuilds end it 'should be true if the signature can be verifed by a pubkey' do - FactoryGirl.create(:front_end_builds_pubkey, { + FactoryBot.create(:front_end_builds_pubkey, { pubkey: ssh_pubkey }) @@ -149,11 +149,11 @@ module FrontEndBuilds end describe '#matching_pubkey' do - let(:app) { FactoryGirl.create(:front_end_builds_app, name: 'app') } + let(:app) { FactoryBot.create(:front_end_builds_app, name: 'app') } let(:endpoint) { 'http://some.external.url.ted.com/index.html' } let(:build) do - FactoryGirl.build(:front_end_builds_build, { + FactoryBot.build(:front_end_builds_build, { app: app, endpoint: endpoint, signature: create_signature("#{app.name}-#{endpoint}") @@ -165,7 +165,7 @@ module FrontEndBuilds end it 'should have a pubkey if the signature can be verifed by a pubkey' do - pubkey = FactoryGirl.create(:front_end_builds_pubkey, { + pubkey = FactoryBot.create(:front_end_builds_pubkey, { pubkey: ssh_pubkey }) @@ -178,9 +178,9 @@ module FrontEndBuilds end describe :live? do - let(:app) { FactoryGirl.create(:front_end_builds_app) } + let(:app) { FactoryBot.create(:front_end_builds_app) } let!(:latest) do - FactoryGirl.create :front_end_builds_build, :live, + FactoryBot.create :front_end_builds_build, :live, app: app, sha: 'sha1', job: 'number1', @@ -190,7 +190,7 @@ module FrontEndBuilds end let!(:older) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, sha: 'sha2', job: 'number2', @@ -209,14 +209,14 @@ module FrontEndBuilds end describe :master? do - let(:app) { FactoryGirl.create(:front_end_builds_app) } + let(:app) { FactoryBot.create(:front_end_builds_app) } let(:build1) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, branch: 'master' end let(:build2) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, app: app, branch: 'feature' end @@ -232,7 +232,7 @@ module FrontEndBuilds describe '#setup!' do let(:build) do - FactoryGirl.create(:front_end_builds_build) + FactoryBot.create(:front_end_builds_build) end before(:each) do @@ -282,7 +282,7 @@ module FrontEndBuilds describe :fetch! do let(:app) do - FactoryGirl.create(:front_end_builds_app) + FactoryBot.create(:front_end_builds_app) end before(:each) do @@ -295,7 +295,7 @@ module FrontEndBuilds end it "should fetch and load the html" do - build = FactoryGirl.create(:front_end_builds_build, + build = FactoryBot.create(:front_end_builds_build, app: app, job: 'job1', sha: 'sha1', @@ -310,7 +310,7 @@ module FrontEndBuilds end it "should not fetch if it has already been fetched" do - build = FactoryGirl.create :front_end_builds_build, + build = FactoryBot.create :front_end_builds_build, html: 'unchanged', fetched: true @@ -323,7 +323,7 @@ module FrontEndBuilds describe :with_head_tag do let(:build) do - FactoryGirl.create :front_end_builds_build, + FactoryBot.create :front_end_builds_build, html: '' end diff --git a/spec/models/front_end_builds/pubkey_spec.rb b/spec/models/front_end_builds/pubkey_spec.rb index e76ab9b..133ddf0 100644 --- a/spec/models/front_end_builds/pubkey_spec.rb +++ b/spec/models/front_end_builds/pubkey_spec.rb @@ -9,7 +9,7 @@ module FrontEndBuilds end let(:pubkey) do - FactoryGirl.create(:front_end_builds_pubkey, { + FactoryBot.create(:front_end_builds_pubkey, { pubkey: ssh_public_key }) end @@ -24,7 +24,7 @@ module FrontEndBuilds end it 'should be unknown if it cannot figure out the pubkey' do - pubkey = FactoryGirl.create(:front_end_builds_pubkey, { + pubkey = FactoryBot.create(:front_end_builds_pubkey, { pubkey: 'badinfo' }) @@ -45,7 +45,7 @@ module FrontEndBuilds end it 'should be false if the type of unknown' do - pubkey = FactoryGirl.create(:front_end_builds_pubkey, { + pubkey = FactoryBot.create(:front_end_builds_pubkey, { pubkey: 'ssh-UNKNOWN badkeybutwhocares' }) @@ -53,7 +53,7 @@ module FrontEndBuilds end it 'should be false if the key has no base64 encoded part' do - pubkey = FactoryGirl.create(:front_end_builds_pubkey, { + pubkey = FactoryBot.create(:front_end_builds_pubkey, { pubkey: 'someotherkeyformat' }) @@ -71,7 +71,7 @@ module FrontEndBuilds end it 'should raise an error if it cannot convert' do - pubkey = FactoryGirl.create(:front_end_builds_pubkey, { + pubkey = FactoryBot.create(:front_end_builds_pubkey, { pubkey: 'badkey' }) @@ -81,13 +81,13 @@ module FrontEndBuilds describe '#verify' do let(:app) do - FactoryGirl.create(:front_end_builds_app, name: 'app') + FactoryBot.create(:front_end_builds_app, name: 'app') end let(:endpoint) { 'http://some.external.url.ted.com/index.html' } let(:build) do - FactoryGirl.build(:front_end_builds_build, { + FactoryBot.build(:front_end_builds_build, { app: app, endpoint: endpoint }) @@ -99,7 +99,7 @@ module FrontEndBuilds end it 'should verify the signature + html for a build without an endpoint' do - build = FactoryGirl.create(:front_end_builds_build, { + build = FactoryBot.create(:front_end_builds_build, { app: app, html: 'some html', endpoint: nil, @@ -115,7 +115,7 @@ module FrontEndBuilds end it 'should not verify a bad html signature for a build' do - build = FactoryGirl.create(:front_end_builds_build, { + build = FactoryBot.create(:front_end_builds_build, { app: app, html: 'some html', endpoint: nil, @@ -127,19 +127,19 @@ module FrontEndBuilds end describe '#last_build' do - let(:pubkey) { FactoryGirl.create(:front_end_builds_pubkey) } + let(:pubkey) { FactoryBot.create(:front_end_builds_pubkey) } it 'should be nil if this pubkey was never used in a build' do expect(pubkey.last_build).to be_nil end it 'should be the most recently created build' do - build = FactoryGirl.create(:front_end_builds_build, { + build = FactoryBot.create(:front_end_builds_build, { pubkey: pubkey, created_at: 2.hours.ago }) - FactoryGirl.create(:front_end_builds_build, { + FactoryBot.create(:front_end_builds_build, { pubkey: pubkey, created_at: 3.hours.ago }) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6d1c403..f34fa1b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -4,7 +4,7 @@ require 'rspec/rails' require 'rspec/its' -require 'factory_girl_rails' +require 'factory_bot_rails' require 'shoulda/matchers' require 'webmock/rspec' require 'database_cleaner' diff --git a/spec/requests/api_requests_spec.rb b/spec/requests/api_requests_spec.rb index cf3a896..d02cb77 100644 --- a/spec/requests/api_requests_spec.rb +++ b/spec/requests/api_requests_spec.rb @@ -1,8 +1,8 @@ describe 'It should not intercept API requests', type: :request do - let(:front_end_app) { FactoryGirl.create :front_end_builds_app, name: "dummy" } + let(:front_end_app) { FactoryBot.create :front_end_builds_app, name: "dummy" } let!(:build) do - FactoryGirl.create(:front_end_builds_build, :live, + FactoryBot.create(:front_end_builds_build, :live, app: front_end_app, fetched: true, active: true diff --git a/spec/requests/build_spec.rb b/spec/requests/build_spec.rb index c2a5f0c..57271f1 100644 --- a/spec/requests/build_spec.rb +++ b/spec/requests/build_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' describe "Front end builds API", type: :request do - let!(:front_end_app) { FactoryGirl.create :front_end_builds_app, name: "dummy" } + let!(:front_end_app) { FactoryBot.create :front_end_builds_app, name: "dummy" } let(:endpoint) { "http://www.ted.com/builds/1" } before(:each) do stub_request(:get, endpoint) .to_return(body: 'your app!') - FactoryGirl.create(:front_end_builds_pubkey, :fixture_pubkey) + FactoryBot.create(:front_end_builds_pubkey, :fixture_pubkey) end it "creates a new build and then uses it" do diff --git a/spec/requests/new_build_version_spec.rb b/spec/requests/new_build_version_spec.rb index 9b9eb8d..927c2a0 100644 --- a/spec/requests/new_build_version_spec.rb +++ b/spec/requests/new_build_version_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe "Front end builds new version", type: :request do - let(:front_end_app) { FactoryGirl.create :front_end_builds_app, name: "dummy" } + let(:front_end_app) { FactoryBot.create :front_end_builds_app, name: "dummy" } let(:version_url) { "/front_end_builds/best?app_name=dummy&branch=master" } let(:endpoint) { "http://www.ted.com/builds/1" } let(:headers) { { 'ACCEPT' => 'application/json' } } before(:each) do - FactoryGirl.create( + FactoryBot.create( :front_end_builds_build, :fetched, app: front_end_app, ) - FactoryGirl.create(:front_end_builds_pubkey, :fixture_pubkey) + FactoryBot.create(:front_end_builds_pubkey, :fixture_pubkey) stub_request(:get, endpoint) .to_return(body: 'your app!') From ecbf9f418bd9ebe8a7114844232af924a83170cb Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 31 Jan 2019 17:13:43 -0500 Subject: [PATCH 20/60] update factorys to comply with new version of factoryBot Also add rubocop as a dev dep --- front_end_builds.gemspec | 2 ++ spec/factories/front_end_builds_builds.rb | 8 ++++---- spec/factories/front_end_builds_pubkeys.rb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index 4e9ace9..204f4ba 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -27,5 +27,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'shoulda-matchers', '2.7.0' s.add_development_dependency 'webmock' s.add_development_dependency 'bundler-audit' + s.add_development_dependency 'rubocop' + s.add_development_dependency 'rubocop-rspec' end diff --git a/spec/factories/front_end_builds_builds.rb b/spec/factories/front_end_builds_builds.rb index 40e830d..c8e5520 100644 --- a/spec/factories/front_end_builds_builds.rb +++ b/spec/factories/front_end_builds_builds.rb @@ -5,13 +5,13 @@ sequence(:sha) { |n| "sha#{n}" } sequence(:job) { |n| n } sequence(:endpoint) { |n| "http://ted.bucket.ted.com/#{n}/index.html" } - branch "master" - signature "some signature" - html "hello world" + branch { "master" } + signature { "some signature" } + html { "hello world" } association :app, factory: :front_end_builds_app trait :fetched do - fetched true + fetched { true } end trait :live do diff --git a/spec/factories/front_end_builds_pubkeys.rb b/spec/factories/front_end_builds_pubkeys.rb index 11f1e70..ebd932e 100644 --- a/spec/factories/front_end_builds_pubkeys.rb +++ b/spec/factories/front_end_builds_pubkeys.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :front_end_builds_pubkey, :class => 'FrontEndBuilds::Pubkey' do - name 'ryan' + name { 'ryan' } sequence(:pubkey) { |i| "ssh-rsa pubkey#{i}#{i}#{i} test@ted.com" } trait :fixture_pubkey do From 1c19e8ed999c6eeb19633b8a5263892306c8a18c Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 31 Jan 2019 17:18:57 -0500 Subject: [PATCH 21/60] use FactoryBot::Syntax::Methods --- .../front_end_builds/apps_controller_spec.rb | 14 +++--- .../front_end_builds/bests_controller_spec.rb | 8 ++-- .../builds_controller_spec.rb | 16 +++---- .../pubkeys_controller_spec.rb | 4 +- spec/models/front_end_builds/app_spec.rb | 10 ++-- spec/models/front_end_builds/build_spec.rb | 46 +++++++++---------- spec/models/front_end_builds/pubkey_spec.rb | 22 ++++----- spec/rails_helper.rb | 4 ++ spec/requests/api_requests_spec.rb | 4 +- spec/requests/build_spec.rb | 4 +- spec/requests/new_build_version_spec.rb | 6 +-- 11 files changed, 71 insertions(+), 67 deletions(-) diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index c6b67f2..6d6f223 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -4,9 +4,9 @@ module FrontEndBuilds RSpec.describe AppsController, :type => :controller do routes { FrontEndBuilds::Engine.routes } - let(:app) { FactoryBot.create(:front_end_builds_app, name: 'dummy') } - let!(:builds) { FactoryBot.create_list(:front_end_builds_build, 2, app: app) } - let!(:live_build) { FactoryBot.create(:front_end_builds_build, :live, :fetched, app: app) } + let(:app) { create(:front_end_builds_app, name: 'dummy') } + let!(:builds) { create_list(:front_end_builds_build, 2, app: app) } + let!(:live_build) { create(:front_end_builds_build, :live, :fetched, app: app) } describe 'index' do it "should find all apps" do @@ -46,9 +46,9 @@ module FrontEndBuilds end describe 'update' do - let(:app) { FactoryBot.create :front_end_builds_app, name: 'forsaken' } - let!(:live_build) { FactoryBot.create :front_end_builds_build, :live, :fetched, app: app } - let!(:new_build) { FactoryBot.create :front_end_builds_build, :fetched, app: app } + let(:app) { create :front_end_builds_app, name: 'forsaken' } + let!(:live_build) { create :front_end_builds_build, :live, :fetched, app: app } + let!(:new_build) { create :front_end_builds_build, :fetched, app: app } it "should edit an existing app" do post :update, @@ -70,7 +70,7 @@ module FrontEndBuilds end describe 'destroy' do - let(:deletable_app) { FactoryBot.create :front_end_builds_app, name: 'forsaken' } + let(:deletable_app) { create :front_end_builds_app, name: 'forsaken' } context 'a valid app' do before(:each) do diff --git a/spec/controllers/front_end_builds/bests_controller_spec.rb b/spec/controllers/front_end_builds/bests_controller_spec.rb index 288957d..a2adf51 100644 --- a/spec/controllers/front_end_builds/bests_controller_spec.rb +++ b/spec/controllers/front_end_builds/bests_controller_spec.rb @@ -2,11 +2,11 @@ module FrontEndBuilds RSpec.describe BestsController, :type => :controller do - let(:app) { FactoryBot.create :front_end_builds_app, name: 'dummy' } + let(:app) { create :front_end_builds_app, name: 'dummy' } describe "show" do let!(:latest) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha1', job: 'number1', @@ -17,7 +17,7 @@ module FrontEndBuilds end let!(:live) do - FactoryBot.create :front_end_builds_build, :live, + create :front_end_builds_build, :live, app: app, sha: 'sha2', job: 'number2', @@ -28,7 +28,7 @@ module FrontEndBuilds end let!(:older) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha3', job: 'number3', diff --git a/spec/controllers/front_end_builds/builds_controller_spec.rb b/spec/controllers/front_end_builds/builds_controller_spec.rb index 13e3d90..b4cf6c3 100644 --- a/spec/controllers/front_end_builds/builds_controller_spec.rb +++ b/spec/controllers/front_end_builds/builds_controller_spec.rb @@ -2,13 +2,13 @@ module FrontEndBuilds RSpec.describe BuildsController, :type => :controller do - let(:app) { FactoryBot.create :front_end_builds_app, name: 'dummy' } + let(:app) { create :front_end_builds_app, name: 'dummy' } describe "index" do routes { FrontEndBuilds::Engine.routes } it "should list all the builds for an app" do - FactoryBot.create_list(:front_end_builds_build, 3, app: app) + create_list(:front_end_builds_build, 3, app: app) get :index, params: { app_id: app.id }, format: :json expect(response).to be_success @@ -16,8 +16,8 @@ module FrontEndBuilds end it 'should be scoped to the requested app' do - build1 = FactoryBot.create(:front_end_builds_build, app: app) - FactoryBot.create(:front_end_builds_build) + build1 = create(:front_end_builds_build, app: app) + create(:front_end_builds_build) get :index, params: { app_id: app.id }, format: :json expect(response).to be_success @@ -26,7 +26,7 @@ module FrontEndBuilds end it "should not list any builds if the app is not present" do - FactoryBot.create_list(:front_end_builds_build, 3) + create_list(:front_end_builds_build, 3) get :index, format: :json expect(response).to be_success @@ -37,7 +37,7 @@ module FrontEndBuilds describe "show" do routes { FrontEndBuilds::Engine.routes } - let(:build) { FactoryBot.create :front_end_builds_build } + let(:build) { create :front_end_builds_build } it "should load the app" do get :show, params: { id: build.id }, format: :json @@ -50,14 +50,14 @@ module FrontEndBuilds let(:endpoint) { 'http://www.ted.com/testing/build' } before(:each) do - FactoryBot.create :front_end_builds_build, :live, + create :front_end_builds_build, :live, app: app, endpoint: 'http://www.ted.com/testing/build', created_at: 1.day.ago, fetched: true, html: 'the old build' - FactoryBot.create(:front_end_builds_pubkey, :fixture_pubkey) + create(:front_end_builds_pubkey, :fixture_pubkey) stub_request(:get, endpoint) .to_return(body: 'fetched html') diff --git a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb index cffc492..bc0fc61 100644 --- a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb +++ b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb @@ -5,7 +5,7 @@ module FrontEndBuilds routes { FrontEndBuilds::Engine.routes } describe 'index' do - let!(:keys) { FactoryBot.create_list(:front_end_builds_pubkey, 3) } + let!(:keys) { create_list(:front_end_builds_pubkey, 3) } it 'should list all pubkeys' do get :index, format: :json @@ -51,7 +51,7 @@ module FrontEndBuilds end describe 'destroy' do - let(:pubkey) { FactoryBot.create(:front_end_builds_pubkey) } + let(:pubkey) { create(:front_end_builds_pubkey) } it 'should remove a pubkey' do delete :destroy, params: { id: pubkey.id }, format: :json diff --git a/spec/models/front_end_builds/app_spec.rb b/spec/models/front_end_builds/app_spec.rb index 1afdbce..f57c321 100644 --- a/spec/models/front_end_builds/app_spec.rb +++ b/spec/models/front_end_builds/app_spec.rb @@ -2,7 +2,7 @@ module FrontEndBuilds describe App, :type => :model do - let(:app) { FactoryBot.create(:front_end_builds_app) } + let(:app) { create(:front_end_builds_app) } it { should have_many(:builds) } it { should belong_to(:live_build) } @@ -10,7 +10,7 @@ module FrontEndBuilds describe '#recent_builds' do it 'should only show the 10 most recent builds' do - FactoryBot.create_list(:front_end_builds_build, 11, { + create_list(:front_end_builds_build, 11, { app: app }) @@ -18,12 +18,12 @@ module FrontEndBuilds end it 'should order the builds with the most recent at top' do - older = FactoryBot.create(:front_end_builds_build, { + older = create(:front_end_builds_build, { app: app, created_at: 2.days.ago }) - recent = FactoryBot.create(:front_end_builds_build, { + recent = create(:front_end_builds_build, { app: app, created_at: 1.day.ago }) @@ -47,7 +47,7 @@ module FrontEndBuilds describe '#get_url' do it 'should lookup the url in the Apps url hash' do App.register_url('testing', '/testing') - app = FactoryBot.create(:front_end_builds_app, name: 'testing') + app = create(:front_end_builds_app, name: 'testing') expect(app.get_url).to eq('/testing') end end diff --git a/spec/models/front_end_builds/build_spec.rb b/spec/models/front_end_builds/build_spec.rb index a15a9f0..ae92139 100644 --- a/spec/models/front_end_builds/build_spec.rb +++ b/spec/models/front_end_builds/build_spec.rb @@ -11,10 +11,10 @@ module FrontEndBuilds it { should validate_presence_of(:branch) } describe :find_best do - let(:app) { FactoryBot.create :front_end_builds_app } + let(:app) { create :front_end_builds_app } let!(:latest) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha1', job: 'number1', @@ -24,7 +24,7 @@ module FrontEndBuilds end let!(:live_build) do - FactoryBot.create :front_end_builds_build, :live, + create :front_end_builds_build, :live, app: app, sha: 'sha2', job: 'number2', @@ -34,7 +34,7 @@ module FrontEndBuilds end let!(:older) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha3', job: 'number3', @@ -45,7 +45,7 @@ module FrontEndBuilds context "with no query" do before(:each) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha4', branch: 'nonmaster', @@ -64,7 +64,7 @@ module FrontEndBuilds context "when finding the branch" do before(:each) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha3', branch: 'master', @@ -88,7 +88,7 @@ module FrontEndBuilds context "when finding unfetched build" do before(:each) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha3', branch: 'master', @@ -102,7 +102,7 @@ module FrontEndBuilds context "when finding another app" do before(:each) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, sha: 'sha4', branch: 'master', fetched: true, @@ -120,7 +120,7 @@ module FrontEndBuilds end describe '#verify' do - let(:app) { FactoryBot.create(:front_end_builds_app, name: 'app') } + let(:app) { create(:front_end_builds_app, name: 'app') } let(:endpoint) { 'http://some.external.url.ted.com/index.html' } let(:build) do @@ -136,7 +136,7 @@ module FrontEndBuilds end it 'should be true if the signature can be verifed by a pubkey' do - FactoryBot.create(:front_end_builds_pubkey, { + create(:front_end_builds_pubkey, { pubkey: ssh_pubkey }) @@ -149,7 +149,7 @@ module FrontEndBuilds end describe '#matching_pubkey' do - let(:app) { FactoryBot.create(:front_end_builds_app, name: 'app') } + let(:app) { create(:front_end_builds_app, name: 'app') } let(:endpoint) { 'http://some.external.url.ted.com/index.html' } let(:build) do @@ -165,7 +165,7 @@ module FrontEndBuilds end it 'should have a pubkey if the signature can be verifed by a pubkey' do - pubkey = FactoryBot.create(:front_end_builds_pubkey, { + pubkey = create(:front_end_builds_pubkey, { pubkey: ssh_pubkey }) @@ -178,9 +178,9 @@ module FrontEndBuilds end describe :live? do - let(:app) { FactoryBot.create(:front_end_builds_app) } + let(:app) { create(:front_end_builds_app) } let!(:latest) do - FactoryBot.create :front_end_builds_build, :live, + create :front_end_builds_build, :live, app: app, sha: 'sha1', job: 'number1', @@ -190,7 +190,7 @@ module FrontEndBuilds end let!(:older) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, sha: 'sha2', job: 'number2', @@ -209,14 +209,14 @@ module FrontEndBuilds end describe :master? do - let(:app) { FactoryBot.create(:front_end_builds_app) } + let(:app) { create(:front_end_builds_app) } let(:build1) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, branch: 'master' end let(:build2) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, app: app, branch: 'feature' end @@ -232,7 +232,7 @@ module FrontEndBuilds describe '#setup!' do let(:build) do - FactoryBot.create(:front_end_builds_build) + create(:front_end_builds_build) end before(:each) do @@ -282,7 +282,7 @@ module FrontEndBuilds describe :fetch! do let(:app) do - FactoryBot.create(:front_end_builds_app) + create(:front_end_builds_app) end before(:each) do @@ -295,7 +295,7 @@ module FrontEndBuilds end it "should fetch and load the html" do - build = FactoryBot.create(:front_end_builds_build, + build = create(:front_end_builds_build, app: app, job: 'job1', sha: 'sha1', @@ -310,7 +310,7 @@ module FrontEndBuilds end it "should not fetch if it has already been fetched" do - build = FactoryBot.create :front_end_builds_build, + build = create :front_end_builds_build, html: 'unchanged', fetched: true @@ -323,7 +323,7 @@ module FrontEndBuilds describe :with_head_tag do let(:build) do - FactoryBot.create :front_end_builds_build, + create :front_end_builds_build, html: '' end diff --git a/spec/models/front_end_builds/pubkey_spec.rb b/spec/models/front_end_builds/pubkey_spec.rb index 133ddf0..9712db3 100644 --- a/spec/models/front_end_builds/pubkey_spec.rb +++ b/spec/models/front_end_builds/pubkey_spec.rb @@ -9,7 +9,7 @@ module FrontEndBuilds end let(:pubkey) do - FactoryBot.create(:front_end_builds_pubkey, { + create(:front_end_builds_pubkey, { pubkey: ssh_public_key }) end @@ -24,7 +24,7 @@ module FrontEndBuilds end it 'should be unknown if it cannot figure out the pubkey' do - pubkey = FactoryBot.create(:front_end_builds_pubkey, { + pubkey = create(:front_end_builds_pubkey, { pubkey: 'badinfo' }) @@ -45,7 +45,7 @@ module FrontEndBuilds end it 'should be false if the type of unknown' do - pubkey = FactoryBot.create(:front_end_builds_pubkey, { + pubkey = create(:front_end_builds_pubkey, { pubkey: 'ssh-UNKNOWN badkeybutwhocares' }) @@ -53,7 +53,7 @@ module FrontEndBuilds end it 'should be false if the key has no base64 encoded part' do - pubkey = FactoryBot.create(:front_end_builds_pubkey, { + pubkey = create(:front_end_builds_pubkey, { pubkey: 'someotherkeyformat' }) @@ -71,7 +71,7 @@ module FrontEndBuilds end it 'should raise an error if it cannot convert' do - pubkey = FactoryBot.create(:front_end_builds_pubkey, { + pubkey = create(:front_end_builds_pubkey, { pubkey: 'badkey' }) @@ -81,7 +81,7 @@ module FrontEndBuilds describe '#verify' do let(:app) do - FactoryBot.create(:front_end_builds_app, name: 'app') + create(:front_end_builds_app, name: 'app') end let(:endpoint) { 'http://some.external.url.ted.com/index.html' } @@ -99,7 +99,7 @@ module FrontEndBuilds end it 'should verify the signature + html for a build without an endpoint' do - build = FactoryBot.create(:front_end_builds_build, { + build = create(:front_end_builds_build, { app: app, html: 'some html', endpoint: nil, @@ -115,7 +115,7 @@ module FrontEndBuilds end it 'should not verify a bad html signature for a build' do - build = FactoryBot.create(:front_end_builds_build, { + build = create(:front_end_builds_build, { app: app, html: 'some html', endpoint: nil, @@ -127,19 +127,19 @@ module FrontEndBuilds end describe '#last_build' do - let(:pubkey) { FactoryBot.create(:front_end_builds_pubkey) } + let(:pubkey) { create(:front_end_builds_pubkey) } it 'should be nil if this pubkey was never used in a build' do expect(pubkey.last_build).to be_nil end it 'should be the most recently created build' do - build = FactoryBot.create(:front_end_builds_build, { + build = create(:front_end_builds_build, { pubkey: pubkey, created_at: 2.hours.ago }) - FactoryBot.create(:front_end_builds_build, { + create(:front_end_builds_build, { pubkey: pubkey, created_at: 3.hours.ago }) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f34fa1b..0bee98f 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -25,4 +25,8 @@ config.include JsonParser, type: :controller config.include JsonParser, type: :request config.include CreateSignature + + # make create & build available directly. + # FactoryBot.create(:foo) -> create(:foo) + config.include FactoryBot::Syntax::Methods end diff --git a/spec/requests/api_requests_spec.rb b/spec/requests/api_requests_spec.rb index d02cb77..343c702 100644 --- a/spec/requests/api_requests_spec.rb +++ b/spec/requests/api_requests_spec.rb @@ -1,8 +1,8 @@ describe 'It should not intercept API requests', type: :request do - let(:front_end_app) { FactoryBot.create :front_end_builds_app, name: "dummy" } + let(:front_end_app) { create :front_end_builds_app, name: "dummy" } let!(:build) do - FactoryBot.create(:front_end_builds_build, :live, + create(:front_end_builds_build, :live, app: front_end_app, fetched: true, active: true diff --git a/spec/requests/build_spec.rb b/spec/requests/build_spec.rb index 57271f1..0bcbe3b 100644 --- a/spec/requests/build_spec.rb +++ b/spec/requests/build_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' describe "Front end builds API", type: :request do - let!(:front_end_app) { FactoryBot.create :front_end_builds_app, name: "dummy" } + let!(:front_end_app) { create :front_end_builds_app, name: "dummy" } let(:endpoint) { "http://www.ted.com/builds/1" } before(:each) do stub_request(:get, endpoint) .to_return(body: 'your app!') - FactoryBot.create(:front_end_builds_pubkey, :fixture_pubkey) + create(:front_end_builds_pubkey, :fixture_pubkey) end it "creates a new build and then uses it" do diff --git a/spec/requests/new_build_version_spec.rb b/spec/requests/new_build_version_spec.rb index 927c2a0..d28a5a7 100644 --- a/spec/requests/new_build_version_spec.rb +++ b/spec/requests/new_build_version_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' describe "Front end builds new version", type: :request do - let(:front_end_app) { FactoryBot.create :front_end_builds_app, name: "dummy" } + let(:front_end_app) { create :front_end_builds_app, name: "dummy" } let(:version_url) { "/front_end_builds/best?app_name=dummy&branch=master" } let(:endpoint) { "http://www.ted.com/builds/1" } let(:headers) { { 'ACCEPT' => 'application/json' } } before(:each) do - FactoryBot.create( + create( :front_end_builds_build, :fetched, app: front_end_app, ) - FactoryBot.create(:front_end_builds_pubkey, :fixture_pubkey) + create(:front_end_builds_pubkey, :fixture_pubkey) stub_request(:get, endpoint) .to_return(body: 'your app!') From 640f506dfcbc0aa5d4efd1be96c712cab4535574 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 10:56:39 -0500 Subject: [PATCH 22/60] add rvm setup files to ease local dev --- .ruby-gemset | 1 + .ruby-version | 1 + 2 files changed, 2 insertions(+) create mode 100644 .ruby-gemset create mode 100644 .ruby-version diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000..71fe5c6 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +front_end_builds diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..0bee604 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.3.3 From 2449a32a2424639fd2d1695ffc8cc17b8561842b Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 11:03:50 -0500 Subject: [PATCH 23/60] from rspec run --- spec/dummy/config/database.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/dummy/config/database.yml b/spec/dummy/config/database.yml index 1c1a37c..60fb357 100644 --- a/spec/dummy/config/database.yml +++ b/spec/dummy/config/database.yml @@ -1,4 +1,4 @@ -# SQLite version 3.x +#talkstar SQLite version 3.x # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile From c8d3af6d2024ddbfba5ad326d98f6fbbb29985e1 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 11:09:59 -0500 Subject: [PATCH 24/60] update travis build matrix for rails 5+ --- .travis.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53f857c..a88785f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,14 @@ script: - bundle exec rake db:schema:load - bundle exec rake spec rvm: - - 1.9.3 - - 2.0.0 - - 2.1.0 - - 2.2.0 + - 2.2.2 + - 2.3.0 + - 2.4.0 + - 2.5.0 env: - - "RAILS_VERSION=3.2.0" - - "RAILS_VERSION=4.0.0" - - "RAILS_VERSION=4.1.0" - - "RAILS_VERSION=4.2.0" + - "RAILS_VERSION=5.0.0" + - "RAILS_VERSION=5.1.0" + - "RAILS_VERSION=5.2.0" matrix: exclude: - rvm: 1.9.3 From dd8b84c0ba26477a4d17ae6446fb1c33d91c60be Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 15:16:17 -0500 Subject: [PATCH 25/60] Add my name to authors and sort gems --- front_end_builds.gemspec | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index 204f4ba..9d65c11 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -7,8 +7,8 @@ require "front_end_builds/version" Gem::Specification.new do |s| s.name = "front_end_builds" s.version = FrontEndBuilds::VERSION - s.authors = ["Ryan Toronto", "Sam Selikoff"] - s.email = ["rt@ted.com", "sam@ted.com"] + s.authors = ["Ryan Toronto", "Sam Selikoff", "John Hirbour"] + s.email = ["rt@ted.com", "sam@ted.com", "gohn@ted.com"] s.homepage = "http://github.com/tedconf/front_end_builds" s.summary = "Summary of FrontEndBuilds." s.description = "Rails engine to manage front end builds and deployments" @@ -17,17 +17,25 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib,public}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] - s.add_development_dependency "sqlite3" - s.add_development_dependency 'rspec-rails' - s.add_development_dependency 'rspec-its' - s.add_development_dependency 'factory_bot_rails' + # min supported version + s.add_dependency 'rails', '~> 5.0' + + # Ideally we'd use this https://github.com/bensie/sshkey + # for ssh key bits, but it doesn't support OpenSSL v2.x + + # sort this by alpha + s.add_development_dependency 'bundler-audit' + s.add_development_dependency 'byebug' s.add_development_dependency 'database_cleaner' + s.add_development_dependency 'factory_bot_rails' s.add_development_dependency 'pry' s.add_development_dependency 'pry-stack_explorer' - s.add_development_dependency 'shoulda-matchers', '2.7.0' - s.add_development_dependency 'webmock' - s.add_development_dependency 'bundler-audit' + s.add_development_dependency 'rb-readline' + s.add_development_dependency 'rspec-rails' + s.add_development_dependency 'rspec-its' s.add_development_dependency 'rubocop' s.add_development_dependency 'rubocop-rspec' - + s.add_development_dependency 'shoulda-matchers', '2.7.0' + s.add_development_dependency "sqlite3" + s.add_development_dependency 'webmock' end From c8a0c5e35d715e50f28f5ae1ca76f7e52096c6f2 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 15:37:10 -0500 Subject: [PATCH 26/60] add byebug history --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c64a6ec..a6c563b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ spec/dummy/public/assets/* spec/dummy/tmp/ spec/dummy/.sass-cache Gemfile.lock +.byebug_history From 06619c7846b1a06c9da4a3a478fce07057301da0 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 15:43:56 -0500 Subject: [PATCH 27/60] Add specs to cover ssh key to pkey conversion This commit will not work with dsa open ssl keys yet --- .../utils/ssh_pubkey_convert.rb | 37 ++++++++++++--- spec/fixtures/README.md | 5 ++ spec/fixtures/id_dsa | 12 +++++ spec/fixtures/id_dsa.pub | 1 + spec/fixtures/id_dsa_as_open_ssl_pkey | 12 +++++ spec/fixtures/id_ecdsa | 5 ++ spec/fixtures/id_ecdsa.pub | 1 + spec/fixtures/id_rsa_as_open_ssl_pkey | 9 ++++ .../utils/ssh_pubkey_convert_spec.rb | 47 +++++++++++++++++++ 9 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 spec/fixtures/README.md create mode 100644 spec/fixtures/id_dsa create mode 100644 spec/fixtures/id_dsa.pub create mode 100644 spec/fixtures/id_dsa_as_open_ssl_pkey create mode 100644 spec/fixtures/id_ecdsa create mode 100644 spec/fixtures/id_ecdsa.pub create mode 100644 spec/fixtures/id_rsa_as_open_ssl_pkey create mode 100644 spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb diff --git a/lib/front_end_builds/utils/ssh_pubkey_convert.rb b/lib/front_end_builds/utils/ssh_pubkey_convert.rb index c9ab5e0..ca3c2ae 100644 --- a/lib/front_end_builds/utils/ssh_pubkey_convert.rb +++ b/lib/front_end_builds/utils/ssh_pubkey_convert.rb @@ -66,8 +66,16 @@ def self.convert(keystring) (nstr, bytes) = unpack_string(bytes, n) key = OpenSSL::PKey::RSA.new - key.n = OpenSSL::BN.new(nstr, 2) - key.e = OpenSSL::BN.new(estr, 2) + + # support SSL 2 + if Gem::Version.new(OpenSSL::VERSION) < Gem::Version.new('2.0.0') + key.n = OpenSSL::BN.new(nstr, 2) + key.e = OpenSSL::BN.new(estr, 2) + else + # params are n, e, d + key.set_key(OpenSSL::BN.new(nstr, 2), OpenSSL::BN.new(estr, 2), nil) + end + key elsif keytype == 'ssh-dss' (n, bytes) = unpack_u32(bytes) @@ -80,13 +88,28 @@ def self.convert(keystring) (pkstr, bytes) = unpack_string(bytes, n) key = OpenSSL::PKey::DSA.new - key.p = OpenSSL::BN.new(pstr, 2) - key.q = OpenSSL::BN.new(qstr, 2) - key.g = OpenSSL::BN.new(gstr, 2) - key.pub_key = OpenSSL::BN.new(pkstr, 2) + + # support SSL 2 + if Gem::Version.new(OpenSSL::VERSION) < Gem::Version.new('2.0.0') + # TODO make this work for DSA w/ open SSL 2 + key.p = OpenSSL::BN.new(pstr, 2) + key.q = OpenSSL::BN.new(qstr, 2) + key.g = OpenSSL::BN.new(gstr, 2) + key.pub_key = OpenSSL::BN.new(pkstr, 2) + else + # TODO make this work for DSA w/ open SSL 2 + key.p = OpenSSL::BN.new(pstr, 2) + key.q = OpenSSL::BN.new(qstr, 2) + key.g = OpenSSL::BN.new(gstr, 2) + key.pub_key = OpenSSL::BN.new(pkstr, 2) + # params are n, e, d + #key.set_key(OpenSSL::BN.new(nstr, 2), OpenSSL::BN.new(estr, 2), nil) + end + key else - nil + # waiting for the sshkey gem to support other key types + raise "Unsupported key type: #{keytype}" end end end diff --git a/spec/fixtures/README.md b/spec/fixtures/README.md new file mode 100644 index 0000000..be9c9be --- /dev/null +++ b/spec/fixtures/README.md @@ -0,0 +1,5 @@ +the keys in this dir are used for testing ssh key to open ssl pkey conversions. + +ecdsa keys are not supported at this time, the key in this dir is for testing error raising. + +Ideally we'd use something like the sshkey gem, but it doesn't currently support OpenSSL 2 diff --git a/spec/fixtures/id_dsa b/spec/fixtures/id_dsa new file mode 100644 index 0000000..a4cd5ae --- /dev/null +++ b/spec/fixtures/id_dsa @@ -0,0 +1,12 @@ +-----BEGIN DSA PRIVATE KEY----- +MIIBugIBAAKBgQCKMPZ4FvbvJosU1OtQ+TOptTrr+KE58jbZtWjcqXokSyVLDeHx +UqgGTOJMsfBkf1baJ4XzxixdSxYLgmWQLIdldl4p/W/DU+dAGRKr+uN2X1d1lx37 +ZBofJZsfl2BNtvlMlgH+VUhyefUpn/XNDr6yEfKDaWHamIWwgc3qZr6bYwIVALAe +RZEeFQKDxAtcoAMsXcEOHLsdAoGAV6EXR/2RqlUYpjk/ZB+lkPCjFVLCrQfKJ8pi +M+yGYIfrCKQ/xusMgRkLSLqhGuQlWljhCJIHbz3PTTP67kFBz2svWekSP7g5q48Z +nl/BzrojBmZljf+k+nuqKF2ZkitilU8l4nlPjZGeXDK6xVVzR3KZml883OsvPiIA +H9W/YX8CgYAPxU0kAZKbBGGo2p+T9KjOK27dXJG5fh+3nOZBzk91GRBK+2QR1jSd ++ovliKChyH1CFWGbEEcjKrJ3emD3NdBUaAmy0+Am1ET9Rxn6uhVoit9woBOFfALt +zeLewsjxPOo2+S/nHP1Pjom1hR4Uqx8VEfm8jwltOQNPa5zwCwuWgQIUO6jwfKlA +N8v2vgs82zH2MxY/7MA= +-----END DSA PRIVATE KEY----- diff --git a/spec/fixtures/id_dsa.pub b/spec/fixtures/id_dsa.pub new file mode 100644 index 0000000..55a7f1d --- /dev/null +++ b/spec/fixtures/id_dsa.pub @@ -0,0 +1 @@ +ssh-dss AAAAB3NzaC1kc3MAAACBAIow9ngW9u8mixTU61D5M6m1Ouv4oTnyNtm1aNypeiRLJUsN4fFSqAZM4kyx8GR/VtonhfPGLF1LFguCZZAsh2V2Xin9b8NT50AZEqv643ZfV3WXHftkGh8lmx+XYE22+UyWAf5VSHJ59Smf9c0OvrIR8oNpYdqYhbCBzepmvptjAAAAFQCwHkWRHhUCg8QLXKADLF3BDhy7HQAAAIBXoRdH/ZGqVRimOT9kH6WQ8KMVUsKtB8onymIz7IZgh+sIpD/G6wyBGQtIuqEa5CVaWOEIkgdvPc9NM/ruQUHPay9Z6RI/uDmrjxmeX8HOuiMGZmWN/6T6e6ooXZmSK2KVTyXieU+NkZ5cMrrFVXNHcpmaXzzc6y8+IgAf1b9hfwAAAIAPxU0kAZKbBGGo2p+T9KjOK27dXJG5fh+3nOZBzk91GRBK+2QR1jSd+ovliKChyH1CFWGbEEcjKrJ3emD3NdBUaAmy0+Am1ET9Rxn6uhVoit9woBOFfALtzeLewsjxPOo2+S/nHP1Pjom1hR4Uqx8VEfm8jwltOQNPa5zwCwuWgQ== test key diff --git a/spec/fixtures/id_dsa_as_open_ssl_pkey b/spec/fixtures/id_dsa_as_open_ssl_pkey new file mode 100644 index 0000000..8fb46df --- /dev/null +++ b/spec/fixtures/id_dsa_as_open_ssl_pkey @@ -0,0 +1,12 @@ +-----BEGIN PUBLIC KEY----- +MIIBtjCCASsGByqGSM44BAEwggEeAoGBAIow9ngW9u8mixTU61D5M6m1Ouv4oTny +Ntm1aNypeiRLJUsN4fFSqAZM4kyx8GR/VtonhfPGLF1LFguCZZAsh2V2Xin9b8NT +50AZEqv643ZfV3WXHftkGh8lmx+XYE22+UyWAf5VSHJ59Smf9c0OvrIR8oNpYdqY +hbCBzepmvptjAhUAsB5FkR4VAoPEC1ygAyxdwQ4cux0CgYBXoRdH/ZGqVRimOT9k +H6WQ8KMVUsKtB8onymIz7IZgh+sIpD/G6wyBGQtIuqEa5CVaWOEIkgdvPc9NM/ru +QUHPay9Z6RI/uDmrjxmeX8HOuiMGZmWN/6T6e6ooXZmSK2KVTyXieU+NkZ5cMrrF +VXNHcpmaXzzc6y8+IgAf1b9hfwOBhAACgYAPxU0kAZKbBGGo2p+T9KjOK27dXJG5 +fh+3nOZBzk91GRBK+2QR1jSd+ovliKChyH1CFWGbEEcjKrJ3emD3NdBUaAmy0+Am +1ET9Rxn6uhVoit9woBOFfALtzeLewsjxPOo2+S/nHP1Pjom1hR4Uqx8VEfm8jwlt +OQNPa5zwCwuWgQ== +-----END PUBLIC KEY----- diff --git a/spec/fixtures/id_ecdsa b/spec/fixtures/id_ecdsa new file mode 100644 index 0000000..bc348f5 --- /dev/null +++ b/spec/fixtures/id_ecdsa @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIBKpqV9kSisBTT15Ln8rExnQSaCGLvfU95iqZLR+KHmpoAoGCCqGSM49 +AwEHoUQDQgAEbZm3tQoVqG1ADReN+0/AEYlwGxT8juJ0azJwvmFAZquIrybjIfId +6c3qqHFYc2Ldsz0GZQlIqhsJFcuWhsyd3w== +-----END EC PRIVATE KEY----- diff --git a/spec/fixtures/id_ecdsa.pub b/spec/fixtures/id_ecdsa.pub new file mode 100644 index 0000000..efcc877 --- /dev/null +++ b/spec/fixtures/id_ecdsa.pub @@ -0,0 +1 @@ +ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBG2Zt7UKFahtQA0XjftPwBGJcBsU/I7idGsycL5hQGariK8m4yHyHenN6qhxWHNi3bM9BmUJSKobCRXLlobMnd8= test key diff --git a/spec/fixtures/id_rsa_as_open_ssl_pkey b/spec/fixtures/id_rsa_as_open_ssl_pkey new file mode 100644 index 0000000..6addd0f --- /dev/null +++ b/spec/fixtures/id_rsa_as_open_ssl_pkey @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4c7SGwMHroke/tg3BCd3 +iSxJpGXd6UZiq5D8XMbwogxrkLQV1+SNLsGSszwCf17ISRZaVzOQ7OB15p4Dy3f0 +V/XDOK6wT0aFnuiBqwdnsO0davI63WuAnGb7DEWQBlBz2V/GZ+L5HiBaykWxQ0WI +e6dpbIE6ozSgjGQ+Xs3iR1XazhytBf7O3bYRUI4qndWfSXgeIlOX+RjCXxSWExgG +0pu1YwMj17h6SPeqWT9NpS6tS7luxlCx9sr6QXpHKlKT9fQ44m07J8mfriG86SkG +XEUVogKCEkd1G8FhqfArbZwJydLnXUpZ3hWQ8crA5q9DwZGh2Mp+ANH8X/UxTkrl +gwIDAQAB +-----END PUBLIC KEY----- diff --git a/spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb b/spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb new file mode 100644 index 0000000..2145dd7 --- /dev/null +++ b/spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb @@ -0,0 +1,47 @@ +require 'rails_helper' +require 'front_end_builds/utils/ssh_pubkey_convert' + +require'byebug' +module FrontEndBuilds + module Utils + RSpec.describe SSHPubKeyConvert do + describe '.convert' do + context "RSA Key" do + let(:public_key) { "spec/fixtures/id_rsa.pub" } + let(:output_pkey) { "spec/fixtures/id_rsa_as_open_ssl_pkey" } + + it "converts a RSA keys to a pkey as expected" do + key_contents = File.read(public_key) + expected_output = File.read(output_pkey).chomp + conversion_output = FrontEndBuilds::Utils::SSHPubKeyConvert.convert(key_contents).to_s.chomp + expect(conversion_output).to eq(expected_output) + end + end + + context "DSA Key" do + let(:public_key) { "spec/fixtures/id_dsa.pub" } + let(:output_pkey) { "spec/fixtures/id_dsa_as_open_ssl_pkey" } + + it "converts a DSA key to a pkey as expected" do + key_contents = File.read(public_key) + expected_output = File.read(output_pkey).chomp + conversion_output = FrontEndBuilds::Utils::SSHPubKeyConvert.convert(key_contents).to_s.chomp + expect(conversion_output).to eq(expected_output) + end + end + + # this is not support ATT + context "ECDSA Key" do + let(:public_key) { "spec/fixtures/id_ecdsa.pub" } + + it "throws an error if passed an id_ecdsa key" do + key_contents = File.read(public_key) + expect { + FrontEndBuilds::Utils::SSHPubKeyConvert.convert(key_contents).to_s.chomp + }.to raise_error('Unsupported key type: ecdsa-sha2-nistp256') + end + end + end + end + end +end From 4b3a2429824832bcf6cb087f1c7d8df9420f5ece Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 16:32:53 -0500 Subject: [PATCH 28/60] fix DSA for Open SSL >1 --- lib/front_end_builds/utils/ssh_pubkey_convert.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/front_end_builds/utils/ssh_pubkey_convert.rb b/lib/front_end_builds/utils/ssh_pubkey_convert.rb index ca3c2ae..85d73f0 100644 --- a/lib/front_end_builds/utils/ssh_pubkey_convert.rb +++ b/lib/front_end_builds/utils/ssh_pubkey_convert.rb @@ -97,13 +97,13 @@ def self.convert(keystring) key.g = OpenSSL::BN.new(gstr, 2) key.pub_key = OpenSSL::BN.new(pkstr, 2) else - # TODO make this work for DSA w/ open SSL 2 - key.p = OpenSSL::BN.new(pstr, 2) - key.q = OpenSSL::BN.new(qstr, 2) - key.g = OpenSSL::BN.new(gstr, 2) - key.pub_key = OpenSSL::BN.new(pkstr, 2) - # params are n, e, d - #key.set_key(OpenSSL::BN.new(nstr, 2), OpenSSL::BN.new(estr, 2), nil) + # params are set_pqg(p, q, g) → self + key.set_pqg( + OpenSSL::BN.new(pstr, 2), + OpenSSL::BN.new(qstr, 2), + OpenSSL::BN.new(gstr, 2) + ) + key.set_key(OpenSSL::BN.new(pkstr, 2), nil) end key From 3aa49a3bb1f908e542d1970337e62fbbfb45085f Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 16:37:33 -0500 Subject: [PATCH 29/60] add ruby 2.5.3 for local dev --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 0bee604..aedc15b 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.3 +2.5.3 From f25adc508df32d3ef735f49efa249307e0ba8089 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 16:41:47 -0500 Subject: [PATCH 30/60] add notes about supported keys --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 755b4c9..5056e16 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,9 @@ bin/rails server Visit `/frontends` to access the Admin interface, and visit the `front_end` route, which will initially return 404 Not found since you haven't configured and deployed any front-end builds yet. +## A note on SSH Keys +At this time only RSA and DSA keys are supported for authentication. + ### Example Next Steps with Heroku and Ember.js A common configuration is to deploy your FEB-enabled Rails app to Heroku, and deploy your Ember.js frontend to S3: From 05ddf4a2cbe068c62cdd847dfae39467c42351d1 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 16:43:18 -0500 Subject: [PATCH 31/60] Add notes about SSL and exceptions --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5a7540..cb72a33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ### 1.0.0 (January 31, 2019) * Support for Rails 5 * Dropping support for < Rails 5 +* Support for OpenSSL Ver 2 +* If a user uses a key that is not RSA/DSA an exception will now be raised ## Upgrading From 1606fb384f1fc63a7c5b6443ff69baf5fcb627ac Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 17:05:05 -0500 Subject: [PATCH 32/60] fixed factory for new-ish after create syntax --- spec/factories/front_end_builds_builds.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/factories/front_end_builds_builds.rb b/spec/factories/front_end_builds_builds.rb index c8e5520..cc5b155 100644 --- a/spec/factories/front_end_builds_builds.rb +++ b/spec/factories/front_end_builds_builds.rb @@ -15,7 +15,9 @@ end trait :live do - after :create, &:activate! + after(:create) do |p| + p.activate! + end end trait :signed do From d3d942e06fe66e8c0add8ffbe29fd5e2fb7bc216 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Fri, 1 Feb 2019 17:24:30 -0500 Subject: [PATCH 33/60] cleanup travis matrix --- .travis.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a88785f..543634c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,28 @@ matrix: env: "RAILS_VERSION=4.2.0" - rvm: 2.2.0 env: "RAILS_VERSION=3.2.0" - include: - rvm: 2.2.2 env: "RAILS_VERSION=5.0.0" + - rvm: 2.2.2 + env: "RAILS_VERSION=5.1.0" + - rvm: 2.2.2 + env: "RAILS_VERSION=5.2.0" + include: + - rvm: 2.3.0 + env: "RAILS_VERSION=5.0.0" + - rvm: 2.3.0 + env: "RAILS_VERSION=5.1.0" + - rvm: 2.3.0 + env: "RAILS_VERSION=5.2.0" + - rvm: 2.4.0 + env: "RAILS_VERSION=5.0.0" + - rvm: 2.4.0 + env: "RAILS_VERSION=5.1.0" + - rvm: 2.4.0 + env: "RAILS_VERSION=5.2.0" + - rvm: 2.5.0 + env: "RAILS_VERSION=5.0.0" + - rvm: 2.5.0 + env: "RAILS_VERSION=5.1.0" + - rvm: 2.5.0 + env: "RAILS_VERSION=5.2.0" From c1bb4890bd1ac77ce495281ec7af6b5c06c56aa1 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Mon, 4 Feb 2019 14:04:54 -0500 Subject: [PATCH 34/60] change admin:build ember syntax for newer versions of ember-cli --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 0c56eb8..d879ad3 100644 --- a/Rakefile +++ b/Rakefile @@ -25,7 +25,7 @@ end namespace :admin do task :build do Dir.chdir('admin') do - sh 'ember build --environment=production' + sh 'ember build production' end # Copy the dist to public From 43497122bd6f430a7cfa97bdfc10e6b2bb1811ce Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Mon, 4 Feb 2019 20:03:45 -0500 Subject: [PATCH 35/60] Remove all mentions of DSA keys as they don't work. So here's the thing... This commits removes DSA bits from FrontEndBuilds::Utils::SSHPubKeyConvert as this app doesn't support DSA keys. If we wanted to in the future we would have to modify the PubKey#verify method. I looked all around the internet for a gem or ruby code to convert an SSH RSA key to a x509 and couldn't find any code but the snippet already in this codebase. I've removed the extra DSA code and modfied the README and specs to match --- README.md | 2 +- .../utils/ssh_pubkey_convert.rb | 36 +++---------------- .../utils/ssh_pubkey_convert_spec.rb | 10 +++--- 3 files changed, 10 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 5056e16..10b1e89 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ bin/rails server Visit `/frontends` to access the Admin interface, and visit the `front_end` route, which will initially return 404 Not found since you haven't configured and deployed any front-end builds yet. ## A note on SSH Keys -At this time only RSA and DSA keys are supported for authentication. +At this time only RSA keys are supported for authentication. ### Example Next Steps with Heroku and Ember.js diff --git a/lib/front_end_builds/utils/ssh_pubkey_convert.rb b/lib/front_end_builds/utils/ssh_pubkey_convert.rb index 85d73f0..a35aada 100644 --- a/lib/front_end_builds/utils/ssh_pubkey_convert.rb +++ b/lib/front_end_builds/utils/ssh_pubkey_convert.rb @@ -3,6 +3,9 @@ # # https://github.com/mytestbed/omf/blob/master/omf_common/lib/omf_common/auth/ssh_pub_key_convert.rb # +# Support for DSA keys was removed from this code as the FEB app doesn't support DSA keys +# See PubKey#verify +# module FrontEndBuilds module Utils @@ -76,39 +79,10 @@ def self.convert(keystring) key.set_key(OpenSSL::BN.new(nstr, 2), OpenSSL::BN.new(estr, 2), nil) end - key - elsif keytype == 'ssh-dss' - (n, bytes) = unpack_u32(bytes) - (pstr, bytes) = unpack_string(bytes, n) - (n, bytes) = unpack_u32(bytes) - (qstr, bytes) = unpack_string(bytes, n) - (n, bytes) = unpack_u32(bytes) - (gstr, bytes) = unpack_string(bytes, n) - (n, bytes) = unpack_u32(bytes) - (pkstr, bytes) = unpack_string(bytes, n) - - key = OpenSSL::PKey::DSA.new - - # support SSL 2 - if Gem::Version.new(OpenSSL::VERSION) < Gem::Version.new('2.0.0') - # TODO make this work for DSA w/ open SSL 2 - key.p = OpenSSL::BN.new(pstr, 2) - key.q = OpenSSL::BN.new(qstr, 2) - key.g = OpenSSL::BN.new(gstr, 2) - key.pub_key = OpenSSL::BN.new(pkstr, 2) - else - # params are set_pqg(p, q, g) → self - key.set_pqg( - OpenSSL::BN.new(pstr, 2), - OpenSSL::BN.new(qstr, 2), - OpenSSL::BN.new(gstr, 2) - ) - key.set_key(OpenSSL::BN.new(pkstr, 2), nil) - end - key else - # waiting for the sshkey gem to support other key types + # anything non-RSA is not supported + # this part edited by TED raise "Unsupported key type: #{keytype}" end end diff --git a/spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb b/spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb index 2145dd7..b404ea8 100644 --- a/spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb +++ b/spec/lib/front_end_builds/utils/ssh_pubkey_convert_spec.rb @@ -20,17 +20,15 @@ module Utils context "DSA Key" do let(:public_key) { "spec/fixtures/id_dsa.pub" } - let(:output_pkey) { "spec/fixtures/id_dsa_as_open_ssl_pkey" } - it "converts a DSA key to a pkey as expected" do + it "throws an error if passed an id_ecdsa key" do key_contents = File.read(public_key) - expected_output = File.read(output_pkey).chomp - conversion_output = FrontEndBuilds::Utils::SSHPubKeyConvert.convert(key_contents).to_s.chomp - expect(conversion_output).to eq(expected_output) + expect { + FrontEndBuilds::Utils::SSHPubKeyConvert.convert(key_contents).to_s.chomp + }.to raise_error('Unsupported key type: ssh-dss') end end - # this is not support ATT context "ECDSA Key" do let(:public_key) { "spec/fixtures/id_ecdsa.pub" } From bc131e53b98f49ca80a6e1aa2e380290c216bb0b Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Tue, 5 Feb 2019 10:44:50 -0500 Subject: [PATCH 36/60] Change Gemfile and gemspec file to get sqlite3 working. The people that maintain sqlite3 dropped v1.4 last night. Everything in this gem and rails expects 1.3. Adding sqllite3 to the Gemfile is strictly to make travis pass. For some reasons the travis CI env always try to load 1.4 --- Gemfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Gemfile b/Gemfile index e21999f..d5aeeaa 100644 --- a/Gemfile +++ b/Gemfile @@ -14,3 +14,9 @@ else end gem 'rails', rails + + + # there are here for travis +group :test, :development do + gem 'sqlite3', '< 1.4' +end From a4d226055abf7b74319b3c500b1a79470daebcd8 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Tue, 5 Feb 2019 15:36:15 -0500 Subject: [PATCH 37/60] correct english in comments --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d5aeeaa..d4a3dba 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ end gem 'rails', rails - # there are here for travis + # these are here so travis will work group :test, :development do gem 'sqlite3', '< 1.4' end From 98c4ec80b3641fc7c7248e5955ee6b0c3f6c19b6 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Tue, 5 Feb 2019 16:34:55 -0500 Subject: [PATCH 38/60] update README and Changelog to reflect latest changes --- CHANGELOG.md | 2 +- README.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb72a33..27d460e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * Support for Rails 5 * Dropping support for < Rails 5 * Support for OpenSSL Ver 2 -* If a user uses a key that is not RSA/DSA an exception will now be raised +* If a user uses a key that is not RSA an exception will now be raised ## Upgrading diff --git a/README.md b/README.md index 10b1e89..6140940 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,11 @@ rspec ember test ``` +## Build status +This gem is built on Travis-CI. + +![](https://travis-ci.org/tedconf/front_end_builds.svg?branch=master) + ## TODO * Create docs site From 12be8e6b1a0cda04ab5b2dfa28f2531e0d3156b0 Mon Sep 17 00:00:00 2001 From: Christian Omania Date: Mon, 6 May 2019 13:04:16 -0700 Subject: [PATCH 39/60] Allow `app.live_build` to be optional. --- CHANGELOG.md | 6 +++--- app/models/front_end_builds/app.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27d460e..10adcda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # What's new +### Unreleased +* `FrontEndBuilds::App.live_build` is now optional. This resolves issues with Rails 5 clients that have `Rails.application.config.active_record.belongs_to_required_by_default` enabled. + ### 1.0.0 (January 31, 2019) * Support for Rails 5 * Dropping support for < Rails 5 @@ -29,6 +32,3 @@ Check the log below to see all the new features. to verify the build. To set this up login to your admin area and add a public key, for example your SSH pubkey. Make sure you update your ``ember-cli-front-end-builds`` to use version `0.1.0` as well. - - - diff --git a/app/models/front_end_builds/app.rb b/app/models/front_end_builds/app.rb index ec4798b..b211933 100644 --- a/app/models/front_end_builds/app.rb +++ b/app/models/front_end_builds/app.rb @@ -6,7 +6,7 @@ class App < ActiveRecord::Base :live_build_id end - belongs_to :live_build, class_name: 'FrontEndBuilds::Build' + belongs_to :live_build, class_name: 'FrontEndBuilds::Build', optional: true has_many :builds, class_name: 'FrontEndBuilds::Build' if ActiveRecord::VERSION::MAJOR < 4 From 309383ca17123e2c4be040b9d01401af4ab302c3 Mon Sep 17 00:00:00 2001 From: Christian Omania Date: Mon, 6 May 2019 14:47:24 -0700 Subject: [PATCH 40/60] Release `v1.0.1` `FrontEndBuilds::App.live_build` is now optional. This resolves issues with Rails 5 clients that have `Rails.application.config.active_record.belongs_to_required_by_default` enabled. --- CHANGELOG.md | 2 +- lib/front_end_builds/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10adcda..36b422d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # What's new -### Unreleased +### 1.0.1 (May 6th, 2019) * `FrontEndBuilds::App.live_build` is now optional. This resolves issues with Rails 5 clients that have `Rails.application.config.active_record.belongs_to_required_by_default` enabled. ### 1.0.0 (January 31, 2019) diff --git a/lib/front_end_builds/version.rb b/lib/front_end_builds/version.rb index fe2b515..138fc45 100644 --- a/lib/front_end_builds/version.rb +++ b/lib/front_end_builds/version.rb @@ -1,3 +1,3 @@ module FrontEndBuilds - VERSION = "1.0.0" + VERSION = "1.0.1" end From 7ed30e270f3c2e7ff7b6f972599556c3d0c748fe Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 9 Jan 2020 15:53:15 -0500 Subject: [PATCH 41/60] Bugfix: serve the correct 10 builds for EVERY app on the admin screen --- .../front_end_builds/apps_controller.rb | 8 ++++- .../front_end_builds/apps_controller_spec.rb | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/controllers/front_end_builds/apps_controller.rb b/app/controllers/front_end_builds/apps_controller.rb index 1032ee8..56d1133 100644 --- a/app/controllers/front_end_builds/apps_controller.rb +++ b/app/controllers/front_end_builds/apps_controller.rb @@ -5,7 +5,13 @@ class AppsController < ApplicationController before_action :set_app , :only => [:show, :destroy, :update] def index - apps = App.includes(:recent_builds) + # this should be the most recent 10 builds for each app + + # DO NOT use `App.includes(:recent_builds)` + # b/c it mucks up the grouping logic and only gives the most + # recent 10 for ALL apps not 10 per app + apps = App.all + respond_with_json({ apps: apps.map(&:serialize), builds: apps.map(&:recent_builds) diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index 6d6f223..3c9e0f7 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -16,6 +16,36 @@ module FrontEndBuilds expect(json['apps'].length).to eq(1) expect(json['builds'].length).to eq(3) end + + # This specs query composition b/c it changed slightled between rails 4 and rails 5 + # in regards to includes + describe "testing query composition", focus: true do + # getting rid of the ones from the outer describe + before(:each) do + App.delete_all + Build.delete_all + end + + let(:app1) { create(:front_end_builds_app, name: 'dummy') } + let(:app2) { create(:front_end_builds_app, name: 'dummy2') } + let!(:app1_builds) { create_list(:front_end_builds_build, 1, app: app1) } + let!(:app2_builds) { create_list(:front_end_builds_build, 10, app: app2) } + + it "Finds the correct builds_ids for EACH app" do + get :index, format: :json + + expect(response).to be_success + expect(json['apps'].length).to eq(2) + app1_json = json['apps'].select{|x| x['id'] == app1.id}.first + app2_json = json['apps'].select{|x| x['id'] == app2.id}.first + + # make sure the oldest app (by created_by) shows up + # this rows ends up missing if include(:recent_builds) is in the Arel + expect(app1_json['build_ids']).to match(app1_builds.map(&:id)) + + expect(app2_json['build_ids']).to match( app2.recent_builds.map(&:id)) + end + end end describe 'show' do From 86354b10f58aa19cdbfbcd8663e495b6f6287731 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 9 Jan 2020 16:09:30 -0500 Subject: [PATCH 42/60] add dev deps --- front_end_builds.gemspec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index 9d65c11..d879d0d 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -36,6 +36,10 @@ Gem::Specification.new do |s| s.add_development_dependency 'rubocop' s.add_development_dependency 'rubocop-rspec' s.add_development_dependency 'shoulda-matchers', '2.7.0' + # These 2 are needed so that the rails app version matches + # otherwise bundle gives you sprockets 4 + s.add_development_dependency 'sprockets', '3.7.2' + s.add_development_dependency 'sprockets-rails', '3.2.1' s.add_development_dependency "sqlite3" s.add_development_dependency 'webmock' end From b72a56df9e59c28c3b5f2a982f8c9681eaaa2d77 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 9 Jan 2020 16:21:20 -0500 Subject: [PATCH 43/60] fix my english --- spec/controllers/front_end_builds/apps_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index 3c9e0f7..0f13bbd 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -17,7 +17,7 @@ module FrontEndBuilds expect(json['builds'].length).to eq(3) end - # This specs query composition b/c it changed slightled between rails 4 and rails 5 + # This specs query composition b/c it changed slightly between rails 4 and rails 5 # in regards to includes describe "testing query composition", focus: true do # getting rid of the ones from the outer describe From 035828028a74fe9d6b09517d8ae3bfe85bcb85f0 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 9 Jan 2020 16:25:34 -0500 Subject: [PATCH 44/60] bump version and add Changelog entry --- CHANGELOG.md | 7 +++++++ lib/front_end_builds/version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36b422d..d552fe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # What's new +### 1.0.2 (January 9th, 2020) +* This version fixes a bug with FrontEndBuilds::AppsController#index where it would not show the `/frontends`. + - This bug was introduced in 1.0.0 (rails 5 updates). + - The controller should return "10 builds for each app", instead it was + returning "10 builds for all apps". This and issue when one of your apps has + a really old "live build" that is older than your 10 most recent (for any app) + ### 1.0.1 (May 6th, 2019) * `FrontEndBuilds::App.live_build` is now optional. This resolves issues with Rails 5 clients that have `Rails.application.config.active_record.belongs_to_required_by_default` enabled. diff --git a/lib/front_end_builds/version.rb b/lib/front_end_builds/version.rb index 138fc45..3eb5733 100644 --- a/lib/front_end_builds/version.rb +++ b/lib/front_end_builds/version.rb @@ -1,3 +1,3 @@ module FrontEndBuilds - VERSION = "1.0.1" + VERSION = "1.0.2" end From 45c6a725d54692881d484b979b4fa3509002851f Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 9 Jan 2020 17:24:05 -0500 Subject: [PATCH 45/60] add link to CI --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6140940..93adba1 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ ember test ``` ## Build status -This gem is built on Travis-CI. +[This gem is built on Travis-CI.](https://travis-ci.org/tedconf/front_end_builds) ![](https://travis-ci.org/tedconf/front_end_builds.svg?branch=master) From 6ea7c612d42061e0e030795e410414bb3c3da215 Mon Sep 17 00:00:00 2001 From: Christian Omania Date: Thu, 19 Nov 2020 10:06:02 -0800 Subject: [PATCH 46/60] Remove crossdomania.xml per https://www.flowdock.com/app/ted/dev/threads/oJCdUXA1lTrOJn7fU9OZnT5EiVJ Regarding https://www.openbugbounty.org/reports/1519953/ --- admin/public/crossdomain.xml | 15 --------------- public/front_end_builds/crossdomain.xml | 15 --------------- 2 files changed, 30 deletions(-) delete mode 100644 admin/public/crossdomain.xml delete mode 100644 public/front_end_builds/crossdomain.xml diff --git a/admin/public/crossdomain.xml b/admin/public/crossdomain.xml deleted file mode 100644 index 29a035d..0000000 --- a/admin/public/crossdomain.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/public/front_end_builds/crossdomain.xml b/public/front_end_builds/crossdomain.xml deleted file mode 100644 index 29a035d..0000000 --- a/public/front_end_builds/crossdomain.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - From 3614161fe38acf63c08d1d990e14ff8eb8980a92 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Thu, 19 Nov 2020 17:06:26 -0500 Subject: [PATCH 47/60] bump version. This was missed in 6ea7c612d42061e0e030795e410414bb3c3da215 --- CHANGELOG.md | 3 +++ lib/front_end_builds/version.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d552fe1..745c593 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # What's new +### 1.0.3 (November 19th, 2020) +* remove crossdomain.xml see https://www.openbugbounty.org/reports/1519953/ + ### 1.0.2 (January 9th, 2020) * This version fixes a bug with FrontEndBuilds::AppsController#index where it would not show the `/frontends`. - This bug was introduced in 1.0.0 (rails 5 updates). diff --git a/lib/front_end_builds/version.rb b/lib/front_end_builds/version.rb index 3eb5733..2993f6b 100644 --- a/lib/front_end_builds/version.rb +++ b/lib/front_end_builds/version.rb @@ -1,3 +1,3 @@ module FrontEndBuilds - VERSION = "1.0.2" + VERSION = '1.0.3' end From a0d02c7510fc8fe513d39e85d8fc6d28a79cc9d5 Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Tue, 11 May 2021 08:29:36 -0700 Subject: [PATCH 48/60] gemspec rails >= 5.0 --- front_end_builds.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index d879d0d..575620c 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.test_files = Dir["test/**/*"] # min supported version - s.add_dependency 'rails', '~> 5.0' + s.add_dependency 'rails', '>= 5.0' # Ideally we'd use this https://github.com/bensie/sshkey # for ssh key bits, but it doesn't support OpenSSL v2.x From 56c9db18cb125f89e8f8e71c3e244db0043fdc80 Mon Sep 17 00:00:00 2001 From: Chris Herbert Date: Tue, 11 May 2021 11:41:29 -0700 Subject: [PATCH 49/60] changelog and version for gemspec rails >= 5.0 --- CHANGELOG.md | 3 +++ lib/front_end_builds/version.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 745c593..dd7bdc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # What's new +### 1.0.4 (May 11, 2021) +* changed rails dependency to '>= 5.0' + ### 1.0.3 (November 19th, 2020) * remove crossdomain.xml see https://www.openbugbounty.org/reports/1519953/ diff --git a/lib/front_end_builds/version.rb b/lib/front_end_builds/version.rb index 2993f6b..f22dee1 100644 --- a/lib/front_end_builds/version.rb +++ b/lib/front_end_builds/version.rb @@ -1,3 +1,3 @@ module FrontEndBuilds - VERSION = '1.0.3' + VERSION = '1.0.4' end From 315ca383e2029c12b368531ebdbb945f5db81752 Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Tue, 1 Feb 2022 11:56:21 -0500 Subject: [PATCH 50/60] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 93adba1..2f5567d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# Deprecation Notice + +TED has shifted to React and will no longer maintain this application/library. If you wish to continue using this application/library, please create a pull request and repo ownership can be transferred. This repository will be archived at the end of 2022. + [![Build Status](https://travis-ci.org/tedconf/front_end_builds.svg)](https://travis-ci.org/tedconf/front_end_builds) [![Code Climate](https://codeclimate.com/github/tedconf/front_end_builds/badges/gpa.svg)](https://codeclimate.com/github/tedconf/front_end_builds) [![Gem Version](https://badge.fury.io/rb/front_end_builds.svg)](http://badge.fury.io/rb/front_end_builds) From e5822d76d9590efd3b8dc864df9cfabb80930015 Mon Sep 17 00:00:00 2001 From: mark hilkert Date: Thu, 24 Mar 2022 11:58:19 -0500 Subject: [PATCH 51/60] update for Rails 6 compatibility --- .ruby-version | 2 +- Gemfile | 4 +- .../front_end_builds/apps_controller.rb | 2 +- .../front_end_builds/host_apps_controller.rb | 2 +- ...10162405_create_front_end_builds_builds.rb | 2 +- ...1010165726_create_front_end_builds_apps.rb | 2 +- ..._add_endpoint_to_front_end_builds_build.rb | 2 +- ...0150114202950_require_manual_activation.rb | 2 +- ...4215337_create_front_end_builds_pubkeys.rb | 2 +- .../20150124221024_add_pubkey_to_build.rb | 2 +- .../20150126123348_add_build_ref_to_apps.rb | 2 +- ...20150224040537_remove_api_key_from_apps.rb | 2 +- front_end_builds.gemspec | 4 +- lib/front_end_builds/version.rb | 2 +- .../front_end_builds/apps_controller_spec.rb | 15 ++--- .../front_end_builds/bests_controller_spec.rb | 12 ++-- .../builds_controller_spec.rb | 26 ++++---- .../host_apps_controller_spec.rb | 4 +- .../pubkeys_controller_spec.rb | 8 +-- spec/dummy/db/schema.rb | 63 +++++++++---------- spec/models/front_end_builds/build_spec.rb | 2 +- spec/requests/admin_api_requests_spec.rb | 8 ++- spec/requests/admin_assets_spec.rb | 2 +- spec/requests/api_requests_spec.rb | 4 +- spec/requests/build_spec.rb | 8 +-- spec/requests/new_build_version_spec.rb | 10 +-- 26 files changed, 97 insertions(+), 97 deletions(-) diff --git a/.ruby-version b/.ruby-version index aedc15b..30f69e8 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.3 +2.5.9 diff --git a/Gemfile b/Gemfile index d4a3dba..a6b8260 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ rails = case rails_version when 'master' { :github => 'rails/rails'} when 'default' - '~> 5.0.4' + '~> 6' else "~> #{rails_version}" end @@ -18,5 +18,5 @@ gem 'rails', rails # these are here so travis will work group :test, :development do - gem 'sqlite3', '< 1.4' + gem 'sqlite3' end diff --git a/app/controllers/front_end_builds/apps_controller.rb b/app/controllers/front_end_builds/apps_controller.rb index 56d1133..fe7d971 100644 --- a/app/controllers/front_end_builds/apps_controller.rb +++ b/app/controllers/front_end_builds/apps_controller.rb @@ -44,7 +44,7 @@ def create end def update - if @app.update_attributes( app_update_params ) + if @app.update( app_update_params ) respond_with_json( { app: @app.serialize }, diff --git a/app/controllers/front_end_builds/host_apps_controller.rb b/app/controllers/front_end_builds/host_apps_controller.rb index 4ed3ad7..5c8509f 100644 --- a/app/controllers/front_end_builds/host_apps_controller.rb +++ b/app/controllers/front_end_builds/host_apps_controller.rb @@ -6,7 +6,7 @@ def show respond_with_json({ host_app: { id: params[:id], - name: Rails.application.class.parent_name + name: Rails.application.class.module_parent_name.underscore } }) end diff --git a/db/migrate/20141010162405_create_front_end_builds_builds.rb b/db/migrate/20141010162405_create_front_end_builds_builds.rb index 552e2ed..1dc405f 100644 --- a/db/migrate/20141010162405_create_front_end_builds_builds.rb +++ b/db/migrate/20141010162405_create_front_end_builds_builds.rb @@ -1,4 +1,4 @@ -class CreateFrontEndBuildsBuilds < ActiveRecord::Migration +class CreateFrontEndBuildsBuilds < ActiveRecord::Migration[4.2] def change create_table :front_end_builds_builds do |t| t.references :app diff --git a/db/migrate/20141010165726_create_front_end_builds_apps.rb b/db/migrate/20141010165726_create_front_end_builds_apps.rb index ee7e204..a7c91e9 100644 --- a/db/migrate/20141010165726_create_front_end_builds_apps.rb +++ b/db/migrate/20141010165726_create_front_end_builds_apps.rb @@ -1,4 +1,4 @@ -class CreateFrontEndBuildsApps < ActiveRecord::Migration +class CreateFrontEndBuildsApps < ActiveRecord::Migration[4.2] def change create_table :front_end_builds_apps do |t| t.string :name, limit: 191 diff --git a/db/migrate/20141105222855_add_endpoint_to_front_end_builds_build.rb b/db/migrate/20141105222855_add_endpoint_to_front_end_builds_build.rb index d560bb9..c1e0f4a 100644 --- a/db/migrate/20141105222855_add_endpoint_to_front_end_builds_build.rb +++ b/db/migrate/20141105222855_add_endpoint_to_front_end_builds_build.rb @@ -1,4 +1,4 @@ -class AddEndpointToFrontEndBuildsBuild < ActiveRecord::Migration +class AddEndpointToFrontEndBuildsBuild < ActiveRecord::Migration[4.2] def change add_column :front_end_builds_builds, :endpoint, :string, limit: 2038 end diff --git a/db/migrate/20150114202950_require_manual_activation.rb b/db/migrate/20150114202950_require_manual_activation.rb index fd626e2..74f1f58 100644 --- a/db/migrate/20150114202950_require_manual_activation.rb +++ b/db/migrate/20150114202950_require_manual_activation.rb @@ -1,4 +1,4 @@ -class RequireManualActivation < ActiveRecord::Migration +class RequireManualActivation < ActiveRecord::Migration[4.2] def change add_column :front_end_builds_apps, :require_manual_activation, diff --git a/db/migrate/20150124215337_create_front_end_builds_pubkeys.rb b/db/migrate/20150124215337_create_front_end_builds_pubkeys.rb index 40d2ed3..1ff6f21 100644 --- a/db/migrate/20150124215337_create_front_end_builds_pubkeys.rb +++ b/db/migrate/20150124215337_create_front_end_builds_pubkeys.rb @@ -1,4 +1,4 @@ -class CreateFrontEndBuildsPubkeys < ActiveRecord::Migration +class CreateFrontEndBuildsPubkeys < ActiveRecord::Migration[4.2] def change create_table :front_end_builds_pubkeys do |t| t.string :name, null: false, limit: 191 diff --git a/db/migrate/20150124221024_add_pubkey_to_build.rb b/db/migrate/20150124221024_add_pubkey_to_build.rb index e71fc9d..06f3742 100644 --- a/db/migrate/20150124221024_add_pubkey_to_build.rb +++ b/db/migrate/20150124221024_add_pubkey_to_build.rb @@ -1,4 +1,4 @@ -class AddPubkeyToBuild < ActiveRecord::Migration +class AddPubkeyToBuild < ActiveRecord::Migration[4.2] def change # Track what public deployed each build add_column :front_end_builds_builds, :pubkey_id, :integer diff --git a/db/migrate/20150126123348_add_build_ref_to_apps.rb b/db/migrate/20150126123348_add_build_ref_to_apps.rb index 499c3c7..ff064a9 100644 --- a/db/migrate/20150126123348_add_build_ref_to_apps.rb +++ b/db/migrate/20150126123348_add_build_ref_to_apps.rb @@ -1,4 +1,4 @@ -class AddBuildRefToApps < ActiveRecord::Migration +class AddBuildRefToApps < ActiveRecord::Migration[4.2] def change add_column :front_end_builds_apps, :live_build_id, :integer end diff --git a/db/migrate/20150224040537_remove_api_key_from_apps.rb b/db/migrate/20150224040537_remove_api_key_from_apps.rb index 39e19d1..48402b1 100644 --- a/db/migrate/20150224040537_remove_api_key_from_apps.rb +++ b/db/migrate/20150224040537_remove_api_key_from_apps.rb @@ -1,4 +1,4 @@ -class RemoveApiKeyFromApps < ActiveRecord::Migration +class RemoveApiKeyFromApps < ActiveRecord::Migration[4.2] def change remove_column :front_end_builds_apps, :api_key end diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index 575620c..880f578 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -17,8 +17,8 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib,public}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] - # min supported version - s.add_dependency 'rails', '>= 5.0' + # Use Rails 6 + s.add_dependency 'rails', '> 5', '< 7' # Ideally we'd use this https://github.com/bensie/sshkey # for ssh key bits, but it doesn't support OpenSSL v2.x diff --git a/lib/front_end_builds/version.rb b/lib/front_end_builds/version.rb index f22dee1..447b90a 100644 --- a/lib/front_end_builds/version.rb +++ b/lib/front_end_builds/version.rb @@ -1,3 +1,3 @@ module FrontEndBuilds - VERSION = '1.0.4' + VERSION = '1.0.5' end diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index 0f13bbd..fd946b1 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -12,7 +12,7 @@ module FrontEndBuilds it "should find all apps" do get :index, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['apps'].length).to eq(1) expect(json['builds'].length).to eq(3) end @@ -34,7 +34,7 @@ module FrontEndBuilds it "Finds the correct builds_ids for EACH app" do get :index, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['apps'].length).to eq(2) app1_json = json['apps'].select{|x| x['id'] == app1.id}.first app2_json = json['apps'].select{|x| x['id'] == app2.id}.first @@ -52,7 +52,7 @@ module FrontEndBuilds it "should find the requested app" do get :show, params: { id: app.id }, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['app']['id']).to eq(app.id) expect(json['builds'].length).to eq(3) expect(json['app']['live_build_id']).to eq(app.live_build.id) @@ -68,7 +68,7 @@ module FrontEndBuilds }, format: :json - expect(response).to be_success + expect(response.successful?).to be true app = FrontEndBuilds::App.where(name: 'my-new-app').limit(1).first expect(json['app']['id']).to eq(app.id) @@ -90,7 +90,7 @@ module FrontEndBuilds }, format: :json - expect(response).to be_success + expect(response.successful?).to be true app.reload @@ -104,6 +104,7 @@ module FrontEndBuilds context 'a valid app' do before(:each) do + # binding.pry post :destroy, params: { id: deletable_app.id @@ -113,12 +114,12 @@ module FrontEndBuilds context 'the response' do subject { response } - it { should be_success } + it { expect(subject.successful?).to be true } end context 'the data' do subject { json['app']['id'] } - it { should_not be_nil } + it { expect(subject).not_to be nil } end context 'the record' do diff --git a/spec/controllers/front_end_builds/bests_controller_spec.rb b/spec/controllers/front_end_builds/bests_controller_spec.rb index a2adf51..0e0f7a5 100644 --- a/spec/controllers/front_end_builds/bests_controller_spec.rb +++ b/spec/controllers/front_end_builds/bests_controller_spec.rb @@ -40,32 +40,32 @@ module FrontEndBuilds it "should find the live build" do get :show, params: { app_name: app.name } - expect(response).to be_success + expect(response.successful?).to be true expect(response.body).to match(live.html) end it "should find the build by job" do get :show, params: { app_name: app.name, job: 'number3' } - expect(response).to be_success + expect(response.successful?).to be true expect(response.body).to match(older.html) end it "should find the build by build_id" do get :show, params: { id: older.id } - expect(response).to be_success + expect(response.successful?).to be true expect(response.body).to match(older.html) end it "should find the build by branch" do get :show, params: { app_name: app.name, branch: 'master' } - expect(response).to be_success + expect(response.successful?).to be true expect(response.body).to match(latest.html) end context "meta tags" do before(:each) do get :show, params: { app_name: app.name, branch: 'master' } - expect(response).to be_success + expect(response.successful?).to be true end subject { response.body } @@ -78,7 +78,7 @@ module FrontEndBuilds it "should be 404 when nothing is found" do get :show, params: { app_name: 'does-not-exist', branch: 'master' } - expect(response).to_not be_success + expect(response.successful?).to_not be true expect(response.status).to eq(404) end diff --git a/spec/controllers/front_end_builds/builds_controller_spec.rb b/spec/controllers/front_end_builds/builds_controller_spec.rb index b4cf6c3..7bb54db 100644 --- a/spec/controllers/front_end_builds/builds_controller_spec.rb +++ b/spec/controllers/front_end_builds/builds_controller_spec.rb @@ -11,7 +11,7 @@ module FrontEndBuilds create_list(:front_end_builds_build, 3, app: app) get :index, params: { app_id: app.id }, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['builds'].length).to eq(3) end @@ -20,7 +20,7 @@ module FrontEndBuilds create(:front_end_builds_build) get :index, params: { app_id: app.id }, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['builds'].length).to eq(1) expect(json['builds'].first['id']).to eq(build1.id) end @@ -29,7 +29,7 @@ module FrontEndBuilds create_list(:front_end_builds_build, 3) get :index, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['builds'].length).to eq(0) end end @@ -41,7 +41,7 @@ module FrontEndBuilds it "should load the app" do get :show, params: { id: build.id }, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['build']['id']).to eq(build.id) end end @@ -75,7 +75,7 @@ module FrontEndBuilds signature: create_signature("#{app.name}-#{endpoint}") } - expect(response).to be_success + expect(response.successful?).to be true expect(app.reload.live_build.html).to eq('fetched html') end @@ -91,12 +91,12 @@ module FrontEndBuilds signature: create_signature("#{app.name}-#{endpoint}") } - expect(response).to be_success + expect(response.successful?).to be true expect(app.reload.live_build.html).to eq('the old build') end it "should not active a build if the app requires manual activiation" do - app.update_attributes(require_manual_activation: true) + app.update(require_manual_activation: true) post :create, params: { app_name: app.name, @@ -107,12 +107,12 @@ module FrontEndBuilds signature: create_signature("#{app.name}-#{endpoint}") } - expect(response).to be_success + expect(response.successful?).to be true expect(app.live_build.html).to eq('the old build') end it 'should error if the app cannot be found' do - app.update_attributes(require_manual_activation: true) + app.update(require_manual_activation: true) post :create, params: { app_name: 'this-does-not-exist', @@ -123,7 +123,7 @@ module FrontEndBuilds signature: create_signature("unknown-#{endpoint}") } - expect(response).to_not be_success + expect(response.successful?).to_not be true expect(response.body).to eq('No app named this-does-not-exist.') end @@ -141,7 +141,7 @@ module FrontEndBuilds signature: Base64.encode64(signature) } - expect(response).to_not be_success + expect(response.successful?).to_not be true expect(response.body).to match("No access - invalid SSH key") end @@ -151,7 +151,7 @@ module FrontEndBuilds endpoint: endpoint, signature: create_signature("#{app.name}-#{endpoint}") } - expect(response).to_not be_success + expect(response.successful?).to_not be true expect(response.body).to match("Sha can't be blank") end @@ -165,7 +165,7 @@ module FrontEndBuilds signature: create_signature('hello world') } - expect(response).to be_success + expect(response.successful?).to be true expect(app.live_build.html).to eq('the old build') end end diff --git a/spec/controllers/front_end_builds/host_apps_controller_spec.rb b/spec/controllers/front_end_builds/host_apps_controller_spec.rb index 35d4b4f..3a3b017 100644 --- a/spec/controllers/front_end_builds/host_apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/host_apps_controller_spec.rb @@ -8,9 +8,9 @@ module FrontEndBuilds it 'should fetch info about the host application (rails)' do get :show, params: { id: 'current' }, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['host_app']['id']).to eq('current') - expect(json['host_app']['name']).to eq('Dummy') + expect(json['host_app']['name']).to eq('dummy') end end diff --git a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb index bc0fc61..a4e5d8d 100644 --- a/spec/controllers/front_end_builds/pubkeys_controller_spec.rb +++ b/spec/controllers/front_end_builds/pubkeys_controller_spec.rb @@ -10,7 +10,7 @@ module FrontEndBuilds it 'should list all pubkeys' do get :index, format: :json - expect(response).to be_success + expect(response.successful?).to be true expect(json['pubkeys'].size).to eq(3) end end @@ -26,7 +26,7 @@ module FrontEndBuilds }, format: :json - expect(response).to be_success + expect(response.successful?).to be true key = FrontEndBuilds::Pubkey .where(name: 'my-new-key') @@ -45,7 +45,7 @@ module FrontEndBuilds }, format: :json - expect(response).to_not be_success + expect(response.successful?).to_not be true expect(json['errors']['pubkey'].size).to eq(1) end end @@ -56,7 +56,7 @@ module FrontEndBuilds it 'should remove a pubkey' do delete :destroy, params: { id: pubkey.id }, format: :json - expect(response).to be_success + expect(response.successful?).to be true lookup_pubkey = FrontEndBuilds::Pubkey .where(id: pubkey.id) diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 3df7fa9..df7afc3 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -1,55 +1,52 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150224040537) do +ActiveRecord::Schema.define(version: 2015_02_24_040537) do create_table "front_end_builds_apps", force: :cascade do |t| - t.string "name" + t.string "name", limit: 191 t.datetime "created_at" t.datetime "updated_at" - t.boolean "require_manual_activation", default: false - t.integer "live_build_id" + t.boolean "require_manual_activation", default: false + t.integer "live_build_id" + t.index ["name"], name: "index_front_end_builds_apps_on_name" end - add_index "front_end_builds_apps", ["name"], name: "index_front_end_builds_apps_on_name" - create_table "front_end_builds_builds", force: :cascade do |t| - t.integer "app_id" - t.string "sha" - t.string "job" - t.string "branch" - t.text "html" - t.boolean "fetched", default: false - t.boolean "active", default: false + t.integer "app_id" + t.string "sha", limit: 191 + t.string "job", limit: 191 + t.string "branch", limit: 191 + t.text "html" + t.boolean "fetched", default: false + t.boolean "active", default: false t.datetime "created_at" t.datetime "updated_at" - t.string "endpoint", limit: 2038 - t.integer "pubkey_id" - t.text "signature" + t.string "endpoint", limit: 2038 + t.integer "pubkey_id" + t.text "signature" + t.index ["active"], name: "index_front_end_builds_builds_on_active" + t.index ["app_id", "branch"], name: "index_front_end_builds_builds_on_app_id_and_branch" + t.index ["app_id", "job"], name: "index_front_end_builds_builds_on_app_id_and_job" + t.index ["app_id", "sha"], name: "index_front_end_builds_builds_on_app_id_and_sha" + t.index ["created_at"], name: "index_front_end_builds_builds_on_created_at" + t.index ["fetched"], name: "index_front_end_builds_builds_on_fetched" end - add_index "front_end_builds_builds", ["active"], name: "index_front_end_builds_builds_on_active" - add_index "front_end_builds_builds", ["app_id", "branch"], name: "index_front_end_builds_builds_on_app_id_and_branch" - add_index "front_end_builds_builds", ["app_id", "job"], name: "index_front_end_builds_builds_on_app_id_and_job" - add_index "front_end_builds_builds", ["app_id", "sha"], name: "index_front_end_builds_builds_on_app_id_and_sha" - add_index "front_end_builds_builds", ["created_at"], name: "index_front_end_builds_builds_on_created_at" - add_index "front_end_builds_builds", ["fetched"], name: "index_front_end_builds_builds_on_fetched" - create_table "front_end_builds_pubkeys", force: :cascade do |t| - t.string "name", limit: 191, null: false - t.text "pubkey", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "name", limit: 191, null: false + t.text "pubkey", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end end diff --git a/spec/models/front_end_builds/build_spec.rb b/spec/models/front_end_builds/build_spec.rb index ae92139..406a7ba 100644 --- a/spec/models/front_end_builds/build_spec.rb +++ b/spec/models/front_end_builds/build_spec.rb @@ -252,7 +252,7 @@ module FrontEndBuilds it 'should not fetch if the build already has html' do expect(build).to_not receive(:fetch!) - build.update_attributes(html: 'got it') + build.update(html: 'got it') build.setup! end diff --git a/spec/requests/admin_api_requests_spec.rb b/spec/requests/admin_api_requests_spec.rb index c8b67b0..12021c6 100644 --- a/spec/requests/admin_api_requests_spec.rb +++ b/spec/requests/admin_api_requests_spec.rb @@ -1,13 +1,15 @@ +require 'rails_helper' + describe 'The API for the admin section should work', type: :request do it 'should load the admin' do get '/frontend-config' - expect(response).to be_success + expect(response.successful?).to be true expect(response.body).to match('Admin') end it "should respond to the admin's API requests" do get '/frontend-config/api/host_apps/current.json' - expect(response).to be_success - expect(json['host_app']['name']).to eq('Dummy') + expect(response.successful?).to be true + expect(json['host_app']['name']).to eq('dummy') end end diff --git a/spec/requests/admin_assets_spec.rb b/spec/requests/admin_assets_spec.rb index 14df71b..d075761 100644 --- a/spec/requests/admin_assets_spec.rb +++ b/spec/requests/admin_assets_spec.rb @@ -14,7 +14,7 @@ it 'should return the js file' do get admin_javascript_url - expect(response).to be_success + expect(response.successful?).to be true expect(response.body[0..1000]).to eq(admin_javascript_content[0..1000]) end end diff --git a/spec/requests/api_requests_spec.rb b/spec/requests/api_requests_spec.rb index 343c702..ef8179a 100644 --- a/spec/requests/api_requests_spec.rb +++ b/spec/requests/api_requests_spec.rb @@ -11,12 +11,12 @@ it "should get the build" do get "/dummy" - expect(response).to be_success + expect(response.successful?).to be true end it "should allow api requests to come through" do get "/items/1.json" - expect(response).to be_success + expect(response.successful?).to be true expect(JSON.parse(response.body)['it']).to eq('worked') end end diff --git a/spec/requests/build_spec.rb b/spec/requests/build_spec.rb index 0bcbe3b..f1bf46a 100644 --- a/spec/requests/build_spec.rb +++ b/spec/requests/build_spec.rb @@ -21,16 +21,16 @@ signature: create_signature("dummy-#{endpoint}") } - expect(response).to be_success + expect(response.successful?).to be true # Index loads get "/dummy" - expect(response).to be_success + expect(response.successful?).to be true expect(response.body).to match(/your app!$/) # Deep routes load get "/dummy/posts/1" - expect(response).to be_success + expect(response.successful?).to be true expect(response.body).to match(/your app!$/) end @@ -45,7 +45,7 @@ signature: create_signature("dummy-#{endpoint}") } - expect(response).to be_success + expect(response.successful?).to be true expect(front_end_app.builds.length).to eq(1) expect(front_end_app.builds.first.html).to eq('your app!') end diff --git a/spec/requests/new_build_version_spec.rb b/spec/requests/new_build_version_spec.rb index d28a5a7..4c2dfa4 100644 --- a/spec/requests/new_build_version_spec.rb +++ b/spec/requests/new_build_version_spec.rb @@ -22,8 +22,8 @@ it "gets a different version when a new build is created" do # get the current version get version_url, headers: headers - expect(response).to be_success - expect(json['version']).to_not be_nil + expect(response.successful?).to be true + expect(json['version']).to_not be nil original_version = json['version'] @@ -36,12 +36,12 @@ signature: create_signature("dummy-#{endpoint}") } - expect(response).to be_success + expect(response.successful?).to be true # now we should get a new version get version_url, headers: headers - expect(response).to be_success - expect(json['version']).to_not be_nil + expect(response.successful?).to be true + expect(json['version']).to_not be nil new_version = json['version'] From ad04e7609448a3b45125ae03ec77505fbc4ffbf8 Mon Sep 17 00:00:00 2001 From: mark hilkert Date: Thu, 24 Mar 2022 13:43:53 -0500 Subject: [PATCH 52/60] bump ruby version to 2.7.5 --- .ruby-version | 2 +- CHANGELOG.md | 5 +++++ Gemfile | 1 + spec/controllers/front_end_builds/apps_controller_spec.rb | 1 - 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.ruby-version b/.ruby-version index 30f69e8..a603bb5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.9 +2.7.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index dd7bdc8..7f45462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # What's new +### 1.0.5 (May 11, 2020) +* Version 1.0.5 may be used with Rails version 6 only. +* Update rspec syntax to work with more modern versions +* Bump Ruby version to 2.7.5 + ### 1.0.4 (May 11, 2021) * changed rails dependency to '>= 5.0' diff --git a/Gemfile b/Gemfile index a6b8260..6bdd6de 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,7 @@ end gem 'rails', rails +gem 'bigdecimal', '1.4.2' # these are here so travis will work group :test, :development do diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index fd946b1..958c938 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -104,7 +104,6 @@ module FrontEndBuilds context 'a valid app' do before(:each) do - # binding.pry post :destroy, params: { id: deletable_app.id From 35f0a43bfa5a7773393363d99ec7fe60dd7b89e9 Mon Sep 17 00:00:00 2001 From: mark hilkert Date: Thu, 24 Mar 2022 15:34:38 -0500 Subject: [PATCH 53/60] clean up rspec syntax --- spec/controllers/front_end_builds/apps_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index 958c938..6bca71c 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -118,7 +118,7 @@ module FrontEndBuilds context 'the data' do subject { json['app']['id'] } - it { expect(subject).not_to be nil } + it { expect(subject).to be_truthy } end context 'the record' do From 77bec9b270d6fa71a96f3ab82e267b0db7e51b31 Mon Sep 17 00:00:00 2001 From: mark hilkert Date: Fri, 25 Mar 2022 09:24:22 -0500 Subject: [PATCH 54/60] push TED-specific updates to our private server --- .bundle/config | 2 ++ .gitignore | 1 - front_end_builds.gemspec | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .bundle/config diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000..48a8a58 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_GEM__PUSH_KEY: "rubygems_ted_com" \ No newline at end of file diff --git a/.gitignore b/.gitignore index a6c563b..736f232 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.bundle/ log/*.log pkg/ spec/dummy/db/*.sqlite3 diff --git a/front_end_builds.gemspec b/front_end_builds.gemspec index 575620c..f4bcf3a 100644 --- a/front_end_builds.gemspec +++ b/front_end_builds.gemspec @@ -5,6 +5,15 @@ require "front_end_builds/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| + # Prevent pushing this gem to RubyGems.org. + # allow pushing only to our private gem server. + if s.respond_to?(:metadata) + s.metadata['allowed_push_host'] = 'https://rubygems.ted.com/private' + else + raise 'RubyGems 2.0 or newer is required to protect against ' \ + 'public gem pushes.' + end + s.name = "front_end_builds" s.version = FrontEndBuilds::VERSION s.authors = ["Ryan Toronto", "Sam Selikoff", "John Hirbour"] @@ -24,6 +33,7 @@ Gem::Specification.new do |s| # for ssh key bits, but it doesn't support OpenSSL v2.x # sort this by alpha + s.add_development_dependency 'bundler', '>=1.15.0' s.add_development_dependency 'bundler-audit' s.add_development_dependency 'byebug' s.add_development_dependency 'database_cleaner' From 9902b3bf093ec60a447caa2f987ddd7837614777 Mon Sep 17 00:00:00 2001 From: mark hilkert Date: Fri, 25 Mar 2022 09:35:39 -0500 Subject: [PATCH 55/60] add Gemfile.lock --- .gitignore | 1 - Gemfile.lock | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index a6c563b..227de05 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,4 @@ spec/dummy/log/*.log spec/dummy/public/assets/* spec/dummy/tmp/ spec/dummy/.sass-cache -Gemfile.lock .byebug_history diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..08a44a0 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,248 @@ +PATH + remote: . + specs: + front_end_builds (1.0.5) + rails (> 5, < 7) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (6.1.5) + actionpack (= 6.1.5) + activesupport (= 6.1.5) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.5) + actionpack (= 6.1.5) + activejob (= 6.1.5) + activerecord (= 6.1.5) + activestorage (= 6.1.5) + activesupport (= 6.1.5) + mail (>= 2.7.1) + actionmailer (6.1.5) + actionpack (= 6.1.5) + actionview (= 6.1.5) + activejob (= 6.1.5) + activesupport (= 6.1.5) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.5) + actionview (= 6.1.5) + activesupport (= 6.1.5) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.5) + actionpack (= 6.1.5) + activerecord (= 6.1.5) + activestorage (= 6.1.5) + activesupport (= 6.1.5) + nokogiri (>= 1.8.5) + actionview (6.1.5) + activesupport (= 6.1.5) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.5) + activesupport (= 6.1.5) + globalid (>= 0.3.6) + activemodel (6.1.5) + activesupport (= 6.1.5) + activerecord (6.1.5) + activemodel (= 6.1.5) + activesupport (= 6.1.5) + activestorage (6.1.5) + actionpack (= 6.1.5) + activejob (= 6.1.5) + activerecord (= 6.1.5) + activesupport (= 6.1.5) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.5) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + ast (2.4.2) + bigdecimal (1.4.2) + binding_of_caller (0.8.0) + debug_inspector (>= 0.0.1) + builder (3.2.4) + bundler-audit (0.9.0.1) + bundler (>= 1.2.0, < 3) + thor (~> 1.0) + byebug (11.1.3) + coderay (1.1.3) + concurrent-ruby (1.1.10) + crack (0.4.5) + rexml + crass (1.0.6) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.1) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + debug_inspector (1.1.0) + diff-lcs (1.5.0) + erubi (1.10.0) + factory_bot (6.2.1) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) + globalid (1.0.0) + activesupport (>= 5.0) + hashdiff (1.0.1) + i18n (1.10.0) + concurrent-ruby (~> 1.0) + loofah (2.15.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.2) + mini_portile2 (2.6.1) + minitest (5.15.0) + nio4r (2.5.8) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) + racc (~> 1.4) + nokogiri (1.12.5-x86_64-darwin) + racc (~> 1.4) + parallel (1.22.0) + parser (3.1.1.0) + ast (~> 2.4.1) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-stack_explorer (0.4.13) + binding_of_caller (~> 0.7) + pry (~> 0.13) + public_suffix (4.0.6) + racc (1.6.0) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.1.5) + actioncable (= 6.1.5) + actionmailbox (= 6.1.5) + actionmailer (= 6.1.5) + actionpack (= 6.1.5) + actiontext (= 6.1.5) + actionview (= 6.1.5) + activejob (= 6.1.5) + activemodel (= 6.1.5) + activerecord (= 6.1.5) + activestorage (= 6.1.5) + activesupport (= 6.1.5) + bundler (>= 1.15.0) + railties (= 6.1.5) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.4.2) + loofah (~> 2.3) + railties (6.1.5) + actionpack (= 6.1.5) + activesupport (= 6.1.5) + method_source + rake (>= 12.2) + thor (~> 1.0) + rainbow (3.1.1) + rake (13.0.6) + rb-readline (0.5.5) + regexp_parser (2.2.1) + rexml (3.2.5) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-its (1.3.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.11.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-rails (5.1.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.11.0) + rubocop (1.26.1) + parallel (~> 1.10) + parser (>= 3.1.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.16.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) + rubocop-rspec (2.9.0) + rubocop (~> 1.19) + ruby-progressbar (1.11.0) + shoulda-matchers (2.7.0) + activesupport (>= 3.0.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.2.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + unicode-display_width (2.1.0) + webmock (3.14.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.5.4) + +PLATFORMS + ruby + x86_64-darwin-21 + +DEPENDENCIES + bigdecimal (= 1.4.2) + bundler-audit + byebug + database_cleaner + factory_bot_rails + front_end_builds! + pry + pry-stack_explorer + rails (~> 6) + rb-readline + rspec-its + rspec-rails + rubocop + rubocop-rspec + shoulda-matchers (= 2.7.0) + sprockets (= 3.7.2) + sprockets-rails (= 3.2.1) + sqlite3 + webmock + +BUNDLED WITH + 2.3.8 From 69db1d98f853926fe583d8cf3025eb3b425bdd9a Mon Sep 17 00:00:00 2001 From: mark hilkert Date: Mon, 28 Mar 2022 14:18:38 -0500 Subject: [PATCH 56/60] add bundler dependency --- Gemfile.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile.lock b/Gemfile.lock index 08a44a0..f8e5007 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -225,6 +225,7 @@ PLATFORMS DEPENDENCIES bigdecimal (= 1.4.2) + bundler (>= 1.15.0) bundler-audit byebug database_cleaner From 4a9abcdafcc1b6469fe1e5c56e9d00daed4f2e5d Mon Sep 17 00:00:00 2001 From: John Hirbour Date: Wed, 13 Apr 2022 18:17:09 -0400 Subject: [PATCH 57/60] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f5567d..f74b849 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ bin/rails server Visit `/frontends` to access the Admin interface, and visit the `front_end` route, which will initially return 404 Not found since you haven't configured and deployed any front-end builds yet. ## A note on SSH Keys -At this time only RSA keys are supported for authentication. +At this time only RSA keys are supported for authentication. You can't generate the keys using ssh-add you'll need the use [something like this](https://www.scottbrady91.com/openssl/creating-rsa-keys-using-openssl) ### Example Next Steps with Heroku and Ember.js From 0ed26ef9edaa460f3fd9d1335594d42767b6710c Mon Sep 17 00:00:00 2001 From: Martin Feckie Date: Tue, 27 Sep 2016 14:43:48 +0800 Subject: [PATCH 58/60] Allow restricting deploys to a specific branch --- app/models/front_end_builds/app.rb | 22 +++++++++++++++++++ app/models/front_end_builds/build.rb | 7 +++++- .../front_end_builds/apps_controller_spec.rb | 17 ++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/app/models/front_end_builds/app.rb b/app/models/front_end_builds/app.rb index b211933..a14cf59 100644 --- a/app/models/front_end_builds/app.rb +++ b/app/models/front_end_builds/app.rb @@ -23,6 +23,28 @@ class App < ActiveRecord::Base validates :name, presence: true + validate do |app| + live_build_validator(app) + end + + def live_build_validator(app) + return unless deploy_restrictions? + return if app.new_record? + ensure_acceptable_branch(app) + end + + def ensure_acceptable_branch(app) + build = FrontEndBuilds::Build.find(app.live_build_id) + production_branch = ENV["FRONT_END_BUILDS_PRODUCTION_BRANCH"] + if production_branch != build.branch + app.errors[:validations] << "Cannot activate build - build is from branch: #{build.branch}, but deploys are restricted to branch: #{production_branch}" + end + end + + def deploy_restrictions? + ENV["FRONT_END_BUILDS_RESTRICT_DEPLOYS"] == "TRUE" + end + def self.register_url(name, url) @_url ||= {} @_url[name.to_sym] = url diff --git a/app/models/front_end_builds/build.rb b/app/models/front_end_builds/build.rb index 99b72cc..c67677c 100644 --- a/app/models/front_end_builds/build.rb +++ b/app/models/front_end_builds/build.rb @@ -98,7 +98,7 @@ def live? end def master? - branch == 'master' + branch == (ENV["FRONT_END_BUILDS_PRODUCTION_BRANCH"] || 'master') end def fetch! @@ -111,10 +111,15 @@ def fetch! end def activate! + return if deploy_restrictions? && !master? app.live_build = self app.save end + def deploy_restrictions? + ENV["FRONT_END_BUILDS_RESTRICT_DEPLOYS"] == "TRUE" + end + def automatic_activation? !app.require_manual_activation? end diff --git a/spec/controllers/front_end_builds/apps_controller_spec.rb b/spec/controllers/front_end_builds/apps_controller_spec.rb index 6bca71c..6adb2ee 100644 --- a/spec/controllers/front_end_builds/apps_controller_spec.rb +++ b/spec/controllers/front_end_builds/apps_controller_spec.rb @@ -79,6 +79,7 @@ module FrontEndBuilds let(:app) { create :front_end_builds_app, name: 'forsaken' } let!(:live_build) { create :front_end_builds_build, :live, :fetched, app: app } let!(:new_build) { create :front_end_builds_build, :fetched, app: app } + let(:prohibited_build) { create :front_end_builds_build, :fetched, app: app, branch: 'experimental' } it "should edit an existing app" do post :update, @@ -97,6 +98,22 @@ module FrontEndBuilds expect(app.live_build).to eq(new_build) expect(json['app']['id']).to eq(app.id) end + + it 'should fail when branch restrictions are triggered' do + allow(ENV).to receive(:[]).with("FRONT_END_BUILDS_RESTRICT_DEPLOYS").and_return("TRUE") + allow(ENV).to receive(:[]).with("FRONT_END_BUILDS_PRODUCTION_BRANCH").and_return("production") + + post :update, + id: app.id, + app: { + live_build_id: prohibited_build.id + }, + format: :json + + body = JSON.parse(response.body) + expect(response.status).to be(422) + expect(body["errors"]["validations"].first).to eq("Cannot activate build - build is from branch: experimental, but deploys are restricted to branch: production") + end end describe 'destroy' do From 4781e0da0d582bf8aa240cd99c8a5ad5278ca223 Mon Sep 17 00:00:00 2001 From: Martin Feckie Date: Wed, 28 Sep 2016 13:48:34 +0800 Subject: [PATCH 59/60] Document new configuration options --- README.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f74b849..1da7c9a 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,16 @@ Front-End Builds (FEB) lets you easily serve remotely-hosted static (JS) applica ![](https://camo.githubusercontent.com/979b56c0651251f4cf428ff354990ee167aeaf63/687474703a2f2f63762d73637265656e73686f74732e73332e616d617a6f6e6177732e636f6d2f41646d696e5f323031352d30332d31305f30302d35302d35382e706e67) Benefits: - - JS app can be deployed without redeploying your Rails app - - Easily smoke test SHAs, branches and releases in your production environment with query params: - http://your-app.com/my-ember-app?branch=new-feature + +- JS app can be deployed without redeploying your Rails app +- Easily smoke test SHAs, branches and releases in your production environment with query params: + http://your-app.com/my-ember-app?branch=new-feature Features: - - Admin interface lets you easily view, rollback and activate different app versions -The motivation for this gem came from [Luke Melia's RailsConf2014 talk](http://www.confreaks.com/videos/3324-railsconf-lightning-fast-deployment-of-your-rails-backed-javascript-app). +- Admin interface lets you easily view, rollback and activate different app versions +The motivation for this gem came from [Luke Melia's RailsConf2014 talk](http://www.confreaks.com/videos/3324-railsconf-lightning-fast-deployment-of-your-rails-backed-javascript-app). ## Installation @@ -84,7 +85,7 @@ end ``` Visit the admin (at whatever URL you mounted the engine above), create a -new app named `app-name`, and you'll receive instructions on how to +new app named `app-name`, and you'll receive instructions on how to start pushing builds. Note: @@ -107,6 +108,7 @@ bin/rails server Visit `/frontends` to access the Admin interface, and visit the `front_end` route, which will initially return 404 Not found since you haven't configured and deployed any front-end builds yet. ## A note on SSH Keys + At this time only RSA keys are supported for authentication. You can't generate the keys using ssh-add you'll need the use [something like this](https://www.scottbrady91.com/openssl/creating-rsa-keys-using-openssl) ### Example Next Steps with Heroku and Ember.js @@ -118,6 +120,11 @@ A common configuration is to deploy your FEB-enabled Rails app to Heroku, and de 3. Access your Rails app's FEB Admin interface, add an app, and configure a public SSH key that corresponds to the private key you plan on using to sign your Ember.js builds 4. Deploy your frontend app. If all goes well, it should build the Ember app, push the static assets to S3, then POST to your Rails app. You'll see the build in the Admin interface, and should be able to access your frontend at the `front_end` route you specified. +## Configurations Options + +Should you wish to allow deploys from an approved branch only, you may set the following environment variables + +`FRONT_END_BUILDS_RESTRICT_DEPLOYS=TRUE` and set the approved branch `FRONT_END_BUILDS_PRODUCTION_BRANCH=the_name_of_your_approved_branch` ## Development @@ -145,13 +152,14 @@ ember test ``` ## Build status + [This gem is built on Travis-CI.](https://travis-ci.org/tedconf/front_end_builds) ![](https://travis-ci.org/tedconf/front_end_builds.svg?branch=master) ## TODO -* Create docs site -* Auto live setting -* make posts idempotent (i think they are), but dont insert a new row if +- Create docs site +- Auto live setting +- make posts idempotent (i think they are), but dont insert a new row if it already exists. From b0ccad7f443d43c2ba8e7b12ca9c58621039e38d Mon Sep 17 00:00:00 2001 From: Martin Feckie Date: Wed, 29 May 2019 18:19:40 +0800 Subject: [PATCH 60/60] Increase limit to 50 for builds --- app/models/front_end_builds/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/front_end_builds/build.rb b/app/models/front_end_builds/build.rb index c67677c..6c45f47 100644 --- a/app/models/front_end_builds/build.rb +++ b/app/models/front_end_builds/build.rb @@ -18,7 +18,7 @@ class Build < ActiveRecord::Base validates :branch, presence: true validates :signature, presence: true - scope :recent, -> { limit(10).order('created_at desc') } + scope :recent, -> { limit(50).order('created_at desc') } def self.find_best(params = {}) scope = self