From d76e789fc2d872a56289f7cb114c34b7449a4716 Mon Sep 17 00:00:00 2001 From: Michael Stock Date: Thu, 21 Dec 2017 18:43:01 -0800 Subject: [PATCH 001/779] Update to Feedjira 2.1.3 --- Gemfile | 2 +- Gemfile.lock | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index db9447538..a8d60ed70 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem "bcrypt", "~> 3.1" gem "delayed_job", "~> 4.1" gem "delayed_job_active_record", "~> 4.1" gem "feedbag", "~> 0.9.5" -gem "feedjira", "~> 2.1.0" +gem "feedjira", "~> 2.1.3" gem "i18n" gem "loofah", "~> 2.0" gem "nokogiri", "~> 1.6", ">= 1.6.7.2" diff --git a/Gemfile.lock b/Gemfile.lock index fe40a9405..8b3bcf184 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,6 +39,7 @@ GEM term-ansicolor (~> 1.3) thor (~> 0.19.1) tins (~> 1.6.0) + crass (1.0.3) debugger-linecache (1.2.0) delayed_job (4.1.1) activesupport (>= 3.0, < 5.0) @@ -50,13 +51,13 @@ GEM execjs (2.7.0) faker (1.6.3) i18n (~> 0.5) - faraday (0.11.0) + faraday (0.13.1) multipart-post (>= 1.2, < 3) - faraday_middleware (0.11.0.1) + faraday_middleware (0.12.2) faraday (>= 0.7.4, < 1.0) feedbag (0.9.5) nokogiri (~> 1.0) - feedjira (2.1.0) + feedjira (2.1.3) faraday (>= 0.9) faraday_middleware (>= 0.9) loofah (>= 2.0) @@ -64,18 +65,19 @@ GEM i18n (0.7.0) json (1.8.3) kgio (2.10.0) - loofah (2.0.3) + loofah (2.1.1) + crass (~> 1.0.2) nokogiri (>= 1.5.9) method_source (0.8.2) mime-types (3.0) mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) - mini_portile2 (2.0.0) + mini_portile2 (2.3.0) minitest (5.8.4) multi_json (1.12.1) multipart-post (2.0.0) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) parser (2.3.0.6) ast (~> 2.2) pg (0.18.4) @@ -188,7 +190,7 @@ DEPENDENCIES delayed_job_active_record (~> 4.1) faker (~> 1.2) feedbag (~> 0.9.5) - feedjira (~> 2.1.0) + feedjira (~> 2.1.3) i18n loofah (~> 2.0) nokogiri (~> 1.6, >= 1.6.7.2) @@ -221,4 +223,4 @@ RUBY VERSION ruby 2.3.3p222 BUNDLED WITH - 1.14.6 + 1.16.1 From c812ca7822d08686859a773b45a2155d016b3114 Mon Sep 17 00:00:00 2001 From: Lv Yangpeng Date: Fri, 29 Dec 2017 16:20:20 +0800 Subject: [PATCH 002/779] normalize_url strip the url before parse it --- app/helpers/url_helpers.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/url_helpers.rb b/app/helpers/url_helpers.rb index 9d4c6fc7e..6c3a97bef 100644 --- a/app/helpers/url_helpers.rb +++ b/app/helpers/url_helpers.rb @@ -25,11 +25,11 @@ def expand_absolute_urls(content, base_url) end def normalize_url(url, base_url) - uri = URI.parse(url) + uri = URI.parse(url.strip) # resolve (protocol) relative URIs if uri.relative? - base_uri = URI.parse(base_url) + base_uri = URI.parse(base_url.strip) scheme = base_uri.scheme || "http" uri = URI.join("#{scheme}://#{base_uri.host}", uri) end From ca455344b8f47dbb60067581d602079032e19f5c Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Tue, 20 Mar 2018 21:30:40 +0100 Subject: [PATCH 003/779] Bump activerecord to address CVE-2016-6317 As reported by `bundler-audit`: > Name: activerecord > Version: 4.2.6 > Advisory: CVE-2016-6317 > Criticality: Unknown > URL: https://groups.google.com/forum/#!topic/rubyonrails-security/rgO20zYW33s > Title: Unsafe Query Generation Risk in Active Record > Solution: upgrade to >= 4.2.7.1 Ref: Ref: Ref: --- Gemfile.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8b3bcf184..178e4b476 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,25 +1,24 @@ GEM remote: https://rubygems.org/ specs: - activemodel (4.2.6) - activesupport (= 4.2.6) + activemodel (4.2.10) + activesupport (= 4.2.10) builder (~> 3.1) - activerecord (4.2.6) - activemodel (= 4.2.6) - activesupport (= 4.2.6) + activerecord (4.2.10) + activemodel (= 4.2.10) + activesupport (= 4.2.10) arel (~> 6.0) - activesupport (4.2.6) + 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.4.0) - arel (6.0.3) + arel (6.0.4) ast (2.2.0) backports (3.6.8) bcrypt (3.1.11) - builder (3.2.2) + builder (3.2.3) byebug (2.7.0) columnize (~> 0.3) debugger-linecache (~> 1.2) @@ -62,8 +61,9 @@ GEM faraday_middleware (>= 0.9) loofah (>= 2.0) sax-machine (>= 1.0) - i18n (0.7.0) - json (1.8.3) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + json (1.8.6) kgio (2.10.0) loofah (2.1.1) crass (~> 1.0.2) @@ -73,7 +73,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) mini_portile2 (2.3.0) - minitest (5.8.4) + minitest (5.11.3) multi_json (1.12.1) multipart-post (2.0.0) nokogiri (1.8.1) @@ -161,11 +161,11 @@ GEM tins (~> 1.0) thor (0.19.1) thread (0.2.2) - thread_safe (0.3.5) + thread_safe (0.3.6) tilt (1.4.1) timecop (0.8.0) tins (1.6.0) - tzinfo (1.2.2) + tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (3.0.2) execjs (>= 0.3.0, < 3) From d070412168102955e822ba25846056a33f2c5368 Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Tue, 20 Mar 2018 21:40:52 +0100 Subject: [PATCH 004/779] Bump nokogiri to address CVE-2017-15412 As reported by `bundler-audit`: > Name: nokogiri > Version: 1.8.1 > Advisory: CVE-2017-15412 > Criticality: Unknown > URL: https://github.com/sparklemotion/nokogiri/issues/1714 > Title: Nokogiri gem, via libxml, is affected by DoS vulnerabilities > Solution: upgrade to >= 1.8.2 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8b3bcf184..840f1b430 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,7 +76,7 @@ GEM minitest (5.8.4) multi_json (1.12.1) multipart-post (2.0.0) - nokogiri (1.8.1) + nokogiri (1.8.2) mini_portile2 (~> 2.3.0) parser (2.3.0.6) ast (~> 2.2) From b88363c992c527cb1ef5e4252f0646c79b934af4 Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Tue, 20 Mar 2018 21:43:39 +0100 Subject: [PATCH 005/779] Bump loofah to address CVE-2018-8048 As reported by `bundler-audit`: > Name: loofah > Version: 2.1.1 > Advisory: CVE-2018-8048 > Criticality: Unknown > URL: https://github.com/flavorjones/loofah/issues/144 > Title: Loofah XSS Vulnerability > Solution: upgrade to >= 2.2.1 Ref: --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8b3bcf184..cb989ecf0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,7 +65,7 @@ GEM i18n (0.7.0) json (1.8.3) kgio (2.10.0) - loofah (2.1.1) + loofah (2.2.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) method_source (0.8.2) From c84d7b8a6e7befa346d77050b845c011350f7bcd Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Thu, 29 Mar 2018 10:45:10 +0100 Subject: [PATCH 006/779] Prevents crash when both url and enclosure_url dont exist --- app/repositories/story_repository.rb | 2 +- spec/repositories/story_repository_spec.rb | 7 +++++++ spec/spec_helper.rb | 3 --- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 4967d77ac..94f5666d8 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -82,7 +82,7 @@ def self.read_count end def self.extract_url(entry, feed) - return entry.enclosure_url if entry.url.nil? && entry.enclosure_url.present? + return entry.enclosure_url if entry.url.nil? && entry.respond_to?(:enclosure_url) normalize_url(entry.url, feed.url) unless entry.url.nil? end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index b7eed53bf..75a73dbe0 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -40,6 +40,13 @@ expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/swanson/stringer" end + + it "does not crash if url is nil but enclosure_url does not exist" do + feed = double(url: "http://github.com") + entry = double(url: nil) + + expect(StoryRepository.extract_url(entry, feed)).to eq nil + end end describe ".extract_title" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f2799081b..96039db07 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,9 +8,6 @@ require "ostruct" require "date" -require "coveralls" -Coveralls.wear! - require "factories/feed_factory" require "factories/story_factory" require "factories/user_factory" From 727eaf7432f67c9a46cca31d6bf35b21fe960a03 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Fri, 30 Mar 2018 10:04:46 +0100 Subject: [PATCH 007/779] Fixes entry parse if there is no URL --- app/repositories/story_repository.rb | 6 +++++- spec/repositories/story_repository_spec.rb | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 94f5666d8..59fb5cf6b 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -96,7 +96,11 @@ def self.extract_content(entry) sanitized_content = sanitize(entry.summary) end - expand_absolute_urls(sanitized_content, entry.url) + if entry.url.present? + expand_absolute_urls(sanitized_content, entry.url) + else + sanitized_content + end end def self.extract_title(entry) diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 75a73dbe0..fa392abdd 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -85,6 +85,22 @@ it "falls back to summary if there is no content" do expect(StoryRepository.extract_content(summary_only)).to eq "Dumb publisher" end + + it "expands urls" do + entry = double(url: "http://mdswanson.com", + content: nil, + summary: "Page") + + expect(StoryRepository.extract_content(entry)).to eq "Page" + end + + it "ignores URL expansion if entry url is nil" do + entry = double(url: nil, + content: nil, + summary: "Page") + + expect(StoryRepository.extract_content(entry)).to eq "Page" + end end describe ".sanitize" do From d73a7d7381f5bb1ece51819db41caa05a0831cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Po=C3=A7a?= Date: Fri, 2 Mar 2018 13:13:26 +0000 Subject: [PATCH 008/779] Upgrade Unicorn In this change I'm upgrading unicorn in order to get the call back `after_worker_exit`. I need this in development to kill ghost workers that are pilling up on my computer every time I restart the app. --- config/unicorn.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/unicorn.rb b/config/unicorn.rb index 0171aba70..7f1487bc8 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -21,3 +21,7 @@ ActiveRecord::Base.establish_connection(config) end end + +after_worker_exit do |_server, _worker, _status| + Process.kill("QUIT", @delayed_job_pid) if !ENV["RACK_ENV"] || ENV["RACK_ENV"] == "development" +end From bd47ef62ce0e43e49fba1ac63e255eedb5aeab61 Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Mon, 30 Apr 2018 09:37:36 +0200 Subject: [PATCH 009/779] Bugfix: bump unicorn for after_worker_exit feature NoMethodError: undefined method `after_worker_exit' for # Did you mean? after_fork ./config/unicorn.rb:25:in `reload' This was probably meant to be a part of d73a7d7381f5bb1ece51819db41caa05a0831cbf (#475). Fixes #483. Ref: --- Gemfile | 2 +- Gemfile.lock | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index a8d60ed70..95557cd8d 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" group :production do gem "pg", "~> 0.18.4" - gem "unicorn", "~> 4.7" + gem "unicorn", "~> 5.3" end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 925779844..2da311c96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,7 +64,7 @@ GEM i18n (0.9.5) concurrent-ruby (~> 1.0) json (1.8.6) - kgio (2.10.0) + kgio (2.11.2) loofah (2.2.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -89,7 +89,7 @@ GEM pry-byebug (1.3.3) byebug (~> 2.7) pry (~> 0.10) - rack (1.6.5) + rack (1.6.10) rack-protection (1.5.3) rack rack-ssl (1.4.1) @@ -100,7 +100,7 @@ GEM rack (>= 1.0) rack-test (>= 0.5) rainbow (2.1.0) - raindrops (0.16.0) + raindrops (0.19.0) rake (10.5.0) rspec (3.4.0) rspec-core (~> 3.4.0) @@ -170,9 +170,8 @@ GEM uglifier (3.0.2) execjs (>= 0.3.0, < 3) unicode-display_width (1.0.2) - unicorn (4.9.0) + unicorn (5.4.0) kgio (~> 2.6) - rack raindrops (~> 0.7) will_paginate (3.1.0) xpath (2.0.0) @@ -216,7 +215,7 @@ DEPENDENCIES thread (~> 0.2) timecop (~> 0.8) uglifier - unicorn (~> 4.7) + unicorn (~> 5.3) will_paginate (~> 3.1) RUBY VERSION From d832dcc1556be06109aa99a7459a554b09b34ec5 Mon Sep 17 00:00:00 2001 From: Hagen Tasche Date: Tue, 28 Aug 2018 13:19:36 +0200 Subject: [PATCH 010/779] Gemnasium is migratet to Gitlab and closed What happened to my badge? To avoid broken 404 images, all badges pointing to Gemnasium.com will be a placeholder, inviting you to migrate to GitLab (and pointing to this page). https://docs.gitlab.com/ee/user/project/import/gemnasium.html --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f7e0806c2..12a675803 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![Build Status](https://api.travis-ci.org/swanson/stringer.svg?style=flat)](https://travis-ci.org/swanson/stringer) [![Code Climate](https://codeclimate.com/github/swanson/stringer.svg?style=flat)](https://codeclimate.com/github/swanson/stringer) [![Coverage Status](https://coveralls.io/repos/swanson/stringer/badge.svg?style=flat)](https://coveralls.io/r/swanson/stringer) -[![Dependency Status](https://gemnasium.com/swanson/stringer.svg)](https://gemnasium.com/swanson/stringer) ### A self-hosted, anti-social RSS reader. From 5358146b2e321f4f8a47201c21f155e268433e2f Mon Sep 17 00:00:00 2001 From: Ryan Whitworth Date: Tue, 30 Oct 2018 20:31:20 -0400 Subject: [PATCH 011/779] minor readme update --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 12a675803..bf68e7230 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ You can access the keyboard shortcuts when using the app by hitting `?`. ![](screenshots/keyboard_shortcuts.png) -### Using you own domain with Heroku +### Using your own domain with Heroku You can run Stringer at `http://reader.yourdomain.com` using a CNAME. @@ -112,7 +112,7 @@ The application will be running on port `5000`. You can launch an interactive console (a la `rails c`) using `racksh`. -## Acknowledgements +## Acknowledgments Most of the heavy-lifting is done by [`feedjira`](https://github.com/feedjira/feedjira) and [`feedbag`](https://github.com/dwillis/feedbag). @@ -124,7 +124,7 @@ Lato Font Copyright © 2010-2011 by tyPoland Lukasz Dziedzic (team@latofonts ## Contact -If you have a question, feature idea, or are running into problems, our preferred method of contact is to open an issue on GitHub. This allows multiple people to weigh in and we can keep everything in one place. Thanks! +If you have a question, feature idea, or are running into problems, our preferred method of contact is to open an issue on GitHub. This allows multiple people to weigh in, and we can keep everything in one place. Thanks! ## Maintainers From 209d58d82ec4a790bf47ecf2d5cdda80e2284e6c Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Thu, 1 Nov 2018 20:37:18 +0100 Subject: [PATCH 012/779] Add a StoryRepository test for title-based XSS --- spec/repositories/story_repository_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index fa392abdd..0cb547a8d 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -16,7 +16,7 @@ StoryRepository.add(entry, feed) end - it "sanitizes titles" do + it "deletes line and paragraph separator characters from titles" do entry = double(title: "n\u2028\u2029", content: "").as_null_object allow(StoryRepository).to receive(:normalize_url) @@ -24,6 +24,15 @@ StoryRepository.add(entry, feed) end + + it "deletes script tags from titles" do + entry = double(title: "n", content: "").as_null_object + allow(StoryRepository).to receive(:normalize_url) + + expect(Story).to receive(:create).with(hash_including(title: "n")) + + StoryRepository.add(entry, feed) + end end describe ".extract_url" do From 35b9183c52f559d57b96c8c7a49f25758cf57f51 Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Thu, 1 Nov 2018 21:34:26 +0100 Subject: [PATCH 013/779] Sanitize feed titles Attempt to fix a recently reported XSS vulnerability. We reuse the same sanitization strategy as for _story_ titles. Fixes #490. --- app/commands/feeds/add_new_feed.rb | 3 ++- app/repositories/story_repository.rb | 16 ++++-------- app/utils/content_sanitizer.rb | 8 ++++++ spec/commands/feeds/add_new_feed_spec.rb | 12 +++++++++ spec/repositories/story_repository_spec.rb | 24 ------------------ spec/utils/content_sanitizer_spec.rb | 29 ++++++++++++++++++++++ 6 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 app/utils/content_sanitizer.rb create mode 100644 spec/utils/content_sanitizer_spec.rb diff --git a/app/commands/feeds/add_new_feed.rb b/app/commands/feeds/add_new_feed.rb index 1334e1aed..2d7502e29 100644 --- a/app/commands/feeds/add_new_feed.rb +++ b/app/commands/feeds/add_new_feed.rb @@ -1,4 +1,5 @@ require_relative "../../models/feed" +require_relative "../../utils/content_sanitizer" require_relative "../../utils/feed_discovery" class AddNewFeed @@ -8,7 +9,7 @@ def self.add(url, discoverer = FeedDiscovery.new, repo = Feed) result = discoverer.discover(url) return false unless result - repo.create(name: result.title, + repo.create(name: ContentSanitizer.sanitize(result.title), url: result.feed_url, last_fetched: Time.now - ONE_DAY) end diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 59fb5cf6b..d6037972b 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -1,5 +1,6 @@ require_relative "../helpers/url_helpers" require_relative "../models/story" +require_relative "../utils/content_sanitizer" require_relative "../utils/sample_story" class StoryRepository @@ -91,9 +92,9 @@ def self.extract_content(entry) sanitized_content = "" if entry.content - sanitized_content = sanitize(entry.content) + sanitized_content = ContentSanitizer.sanitize(entry.content) elsif entry.summary - sanitized_content = sanitize(entry.summary) + sanitized_content = ContentSanitizer.sanitize(entry.summary) end if entry.url.present? @@ -104,18 +105,11 @@ def self.extract_content(entry) end def self.extract_title(entry) - return sanitize(entry.title) if entry.title.present? - return sanitize(entry.summary) if entry.summary.present? + return ContentSanitizer.sanitize(entry.title) if entry.title.present? + return ContentSanitizer.sanitize(entry.summary) if entry.summary.present? "There isn't a title for this story" end - def self.sanitize(content) - Loofah.fragment(content.gsub(//i, "")) - .scrub!(:prune) - .scrub!(:unprintable) - .to_s - end - def self.samples [ SampleStory.new("Darin' Fireballs", "Why you should trade your firstborn for a Retina iPad"), diff --git a/app/utils/content_sanitizer.rb b/app/utils/content_sanitizer.rb new file mode 100644 index 000000000..87886c688 --- /dev/null +++ b/app/utils/content_sanitizer.rb @@ -0,0 +1,8 @@ +class ContentSanitizer + def self.sanitize(content) + Loofah.fragment(content.gsub(//i, "")) + .scrub!(:prune) + .scrub!(:unprintable) + .to_s + end +end diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 3e113a6c8..38451e2e4 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -27,6 +27,18 @@ expect(result).to be feed end + + context "title includes a script tag" do + let(:feed_result) { double(title: "foobar", feed_url: feed.url) } + + it "deletes the script tag from the title" do + allow(repo).to receive(:create) + + AddNewFeed.add("http://feed.com", discoverer, repo) + + expect(repo).to have_received(:create).with(include(name: "foobar")) + end + end end end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 0cb547a8d..e7f1035a8 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -111,28 +111,4 @@ expect(StoryRepository.extract_content(entry)).to eq "Page" end end - - describe ".sanitize" do - context "regressions" do - it "handles tag properly" do - result = StoryRepository.sanitize("WM_ERROR asdf") - expect(result).to eq "WM_ERROR asdf" - end - - it "handles
tag properly" do - result = StoryRepository.sanitize("
some code
") - expect(result).to eq "
some code
" - end - - it "handles unprintable characters" do - result = StoryRepository.sanitize("n\u2028\u2029") - expect(result).to eq "n" - end - - it "preserves line endings" do - result = StoryRepository.sanitize("test\r\ncase") - expect(result).to eq "test\r\ncase" - end - end - end end diff --git a/spec/utils/content_sanitizer_spec.rb b/spec/utils/content_sanitizer_spec.rb new file mode 100644 index 000000000..9fd3e18a7 --- /dev/null +++ b/spec/utils/content_sanitizer_spec.rb @@ -0,0 +1,29 @@ +require "spec_helper" + +app_require "utils/content_sanitizer" + +describe ContentSanitizer do + describe ".sanitize" do + context "regressions" do + it "handles tag properly" do + result = described_class.sanitize("WM_ERROR asdf") + expect(result).to eq "WM_ERROR asdf" + end + + it "handles
tag properly" do + result = described_class.sanitize("
some code
") + expect(result).to eq "
some code
" + end + + it "handles unprintable characters" do + result = described_class.sanitize("n\u2028\u2029") + expect(result).to eq "n" + end + + it "preserves line endings" do + result = described_class.sanitize("test\r\ncase") + expect(result).to eq "test\r\ncase" + end + end + end +end From a430644a768a41ee1d06145b6dfa765a00c1f875 Mon Sep 17 00:00:00 2001 From: tsayen Date: Thu, 17 Oct 2019 23:41:55 +0200 Subject: [PATCH 014/779] upgrade ruby version --- .ruby-version | 2 +- .travis.yml | 2 +- Gemfile.lock | 12 ++++++------ db/schema.rb | 26 +++++++++++++------------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.ruby-version b/.ruby-version index 0bee604df..57cf282eb 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.3 +2.6.5 diff --git a/.travis.yml b/.travis.yml index 501560eae..a819d6f5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ before_script: cache: bundler language: ruby rvm: - - 2.3.3 + - 2.6.5 - ruby-head matrix: allow_failures: diff --git a/Gemfile.lock b/Gemfile.lock index 2da311c96..1105a17ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,7 +31,7 @@ GEM xpath (~> 2.0) coderay (1.1.1) columnize (0.9.0) - concurrent-ruby (1.0.2) + concurrent-ruby (1.1.5) coveralls (0.8.13) json (~> 1.8) simplecov (~> 0.11.0) @@ -40,8 +40,8 @@ GEM tins (~> 1.6.0) crass (1.0.3) debugger-linecache (1.2.0) - delayed_job (4.1.1) - activesupport (>= 3.0, < 5.0) + delayed_job (4.1.8) + activesupport (>= 3.0, < 6.1) delayed_job_active_record (4.1.0) activerecord (>= 3.0, < 5) delayed_job (>= 3.0, < 5) @@ -73,7 +73,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) mini_portile2 (2.3.0) - minitest (5.11.3) + minitest (5.12.2) multi_json (1.12.1) multipart-post (2.0.0) nokogiri (1.8.2) @@ -219,7 +219,7 @@ DEPENDENCIES will_paginate (~> 3.1) RUBY VERSION - ruby 2.3.3p222 + ruby 2.6.5p114 BUNDLED WITH - 1.16.1 + 1.17.2 diff --git a/db/schema.rb b/db/schema.rb index 3f7ef303d..3f33b80fe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -15,7 +15,7 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "delayed_jobs", force: true do |t| + create_table "delayed_jobs", force: :cascade do |t| t.integer "priority", default: 0 t.integer "attempts", default: 0 t.text "handler" @@ -25,37 +25,37 @@ t.datetime "failed_at" t.string "locked_by" t.string "queue" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree - create_table "feeds", force: true do |t| + create_table "feeds", force: :cascade do |t| t.string "name" t.text "url" t.datetime "last_fetched" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "status" t.integer "group_id" end add_index "feeds", ["url"], name: "index_feeds_on_url", unique: true, using: :btree - create_table "groups", force: true do |t| + create_table "groups", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "stories", force: true do |t| + create_table "stories", force: :cascade do |t| t.text "title" t.text "permalink" t.text "body" t.integer "feed_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.datetime "published" t.boolean "is_read" t.boolean "keep_unread", default: false @@ -65,10 +65,10 @@ add_index "stories", ["entry_id", "feed_id"], name: "index_stories_on_entry_id_and_feed_id", unique: true, using: :btree - create_table "users", force: true do |t| + create_table "users", force: :cascade do |t| t.string "password_digest" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "setup_complete" t.string "api_key" end From 573e0e7e6e5222430bd32d3ae7f60ae645d97bcd Mon Sep 17 00:00:00 2001 From: tsayen Date: Fri, 18 Oct 2019 08:51:04 +0200 Subject: [PATCH 015/779] stabilize mocha tests (see https://github.com/nathanboktae/mocha-phantomjs-core/blob/master/README.md#usage) --- spec/javascript/spec/spec_helper.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/javascript/spec/spec_helper.js b/spec/javascript/spec/spec_helper.js index a35e11d48..e18c11a27 100644 --- a/spec/javascript/spec/spec_helper.js +++ b/spec/javascript/spec/spec_helper.js @@ -1,3 +1,7 @@ +if (typeof initMochaPhantomJS === 'function') { + initMochaPhantomJS() +} + mocha.ui('bdd'); chai.should(); From 5e7702be7cd4afbc08b4b0b395563c8a710fa535 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2019 14:17:38 +0000 Subject: [PATCH 016/779] Bump nokogiri from 1.8.2 to 1.10.4 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.8.2 to 1.10.4. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.8.2...v1.10.4) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 95557cd8d..a0e23c230 100644 --- a/Gemfile +++ b/Gemfile @@ -32,7 +32,7 @@ gem "feedbag", "~> 0.9.5" gem "feedjira", "~> 2.1.3" gem "i18n" gem "loofah", "~> 2.0" -gem "nokogiri", "~> 1.6", ">= 1.6.7.2" +gem "nokogiri", "~> 1.10" gem "rack-protection", "~> 1.5" gem "rack-ssl", "~> 1.4" gem "racksh", "~> 1.0" diff --git a/Gemfile.lock b/Gemfile.lock index 1105a17ea..6dd7e1092 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,12 +72,12 @@ GEM mime-types (3.0) mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) - mini_portile2 (2.3.0) + mini_portile2 (2.4.0) minitest (5.12.2) multi_json (1.12.1) multipart-post (2.0.0) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) + nokogiri (1.10.4) + mini_portile2 (~> 2.4.0) parser (2.3.0.6) ast (~> 2.2) pg (0.18.4) @@ -192,7 +192,7 @@ DEPENDENCIES feedjira (~> 2.1.3) i18n loofah (~> 2.0) - nokogiri (~> 1.6, >= 1.6.7.2) + nokogiri (~> 1.10) pg (~> 0.18.4) pry-byebug (~> 1.2) rack-protection (~> 1.5) From 5e902e5ba87a00158ae15131fd7ab32cc17d9972 Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Sun, 3 Nov 2019 10:24:35 +0100 Subject: [PATCH 017/779] Remove .tool-versions This file fell out of sync with `.ruby-version` in a430644a768a41ee1d06145b6dfa765a00c1f875. Instead of trying to remember to keep this file in sync moving forward, I suggest removing it and recommending asdf-vm users to use the `legacy_version_file` option reading the Ruby version from `.ruby-version`. Ref: --- .tool-versions | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index 69ed28bbf..000000000 --- a/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -ruby 2.3.3 From 34e1ba44bedc5bbd5cff84b415a5422fb5856350 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2019 11:44:10 +0000 Subject: [PATCH 018/779] Bump loofah from 2.2.1 to 2.3.1 Bumps [loofah](https://github.com/flavorjones/loofah) from 2.2.1 to 2.3.1. - [Release notes](https://github.com/flavorjones/loofah/releases) - [Changelog](https://github.com/flavorjones/loofah/blob/master/CHANGELOG.md) - [Commits](https://github.com/flavorjones/loofah/compare/v2.2.1...v2.3.1) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index a0e23c230..156c2d79c 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem "delayed_job_active_record", "~> 4.1" gem "feedbag", "~> 0.9.5" gem "feedjira", "~> 2.1.3" gem "i18n" -gem "loofah", "~> 2.0" +gem "loofah", "~> 2.3" gem "nokogiri", "~> 1.10" gem "rack-protection", "~> 1.5" gem "rack-ssl", "~> 1.4" diff --git a/Gemfile.lock b/Gemfile.lock index 6dd7e1092..3979a0b53 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,7 +38,7 @@ GEM term-ansicolor (~> 1.3) thor (~> 0.19.1) tins (~> 1.6.0) - crass (1.0.3) + crass (1.0.5) debugger-linecache (1.2.0) delayed_job (4.1.8) activesupport (>= 3.0, < 6.1) @@ -65,7 +65,7 @@ GEM concurrent-ruby (~> 1.0) json (1.8.6) kgio (2.11.2) - loofah (2.2.1) + loofah (2.3.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) method_source (0.8.2) @@ -191,7 +191,7 @@ DEPENDENCIES feedbag (~> 0.9.5) feedjira (~> 2.1.3) i18n - loofah (~> 2.0) + loofah (~> 2.3) nokogiri (~> 1.10) pg (~> 0.18.4) pry-byebug (~> 1.2) From 17d2dac0596dc28559b5552ecb526d04e59cc1b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2019 11:44:13 +0000 Subject: [PATCH 019/779] Bump rack from 1.6.10 to 1.6.11 Bumps [rack](https://github.com/rack/rack) from 1.6.10 to 1.6.11. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/master/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/1.6.10...1.6.11) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6dd7e1092..84f7c41b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,7 +89,7 @@ GEM pry-byebug (1.3.3) byebug (~> 2.7) pry (~> 0.10) - rack (1.6.10) + rack (1.6.11) rack-protection (1.5.3) rack rack-ssl (1.4.1) From 2da7e16e9de818033ff11ad246f006bc77493ff0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2019 11:44:12 +0000 Subject: [PATCH 020/779] Bump rubocop from 0.38.0 to 0.48.1 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.38.0 to 0.48.1. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.38.0...v0.48.1) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index a0e23c230..9eccfd283 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ group :development, :test do gem "rack-test", "~> 0.6" gem "rspec", "~> 3.4" gem "rspec-html-matchers", "~> 0.7" - gem "rubocop", "~> 0.38", require: false + gem "rubocop", "~> 0.48", require: false gem "shotgun", "~> 0.9" gem "timecop", "~> 0.8" end diff --git a/Gemfile.lock b/Gemfile.lock index 6dd7e1092..5fec1e9db 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,7 +15,7 @@ GEM tzinfo (~> 1.1) addressable (2.4.0) arel (6.0.4) - ast (2.2.0) + ast (2.4.0) backports (3.6.8) bcrypt (3.1.11) builder (3.2.3) @@ -78,10 +78,10 @@ GEM multipart-post (2.0.0) nokogiri (1.10.4) mini_portile2 (~> 2.4.0) - parser (2.3.0.6) - ast (~> 2.2) + parser (2.6.5.0) + ast (~> 2.4.0) pg (0.18.4) - powerpack (0.1.1) + powerpack (0.1.2) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -99,7 +99,8 @@ GEM racksh (1.0.0) rack (>= 1.0) rack-test (>= 0.5) - rainbow (2.1.0) + rainbow (2.2.2) + rake raindrops (0.19.0) rake (10.5.0) rspec (3.4.0) @@ -118,13 +119,13 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.38.0) - parser (>= 2.3.0.6, < 3.0) + rubocop (0.48.1) + parser (>= 2.3.3.1, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.7.5) + ruby-progressbar (1.10.1) sass (3.4.22) sax-machine (1.3.2) shotgun (0.9.1) @@ -169,7 +170,7 @@ GEM thread_safe (~> 0.1) uglifier (3.0.2) execjs (>= 0.3.0, < 3) - unicode-display_width (1.0.2) + unicode-display_width (1.6.0) unicorn (5.4.0) kgio (~> 2.6) raindrops (~> 0.7) @@ -202,7 +203,7 @@ DEPENDENCIES rake (~> 10.1, >= 10.1.1) rspec (~> 3.4) rspec-html-matchers (~> 0.7) - rubocop (~> 0.38) + rubocop (~> 0.48) sass shotgun (~> 0.9) sinatra (~> 1.4.8, >= 1.4.8) From fcc68ccbe2cd4d92c3333316b86edaa031ef7dbd Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Sat, 16 Nov 2019 18:31:22 +0100 Subject: [PATCH 021/779] Bump rubocop from 0.48.1 to 0.76.0 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.48.1 to 0.76.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.48.1...v0.76.0) To support Ruby v2.6. We got the following error when using version 0.48.1. $ bundle exec rubocop Error: Unknown Ruby version 2.6 found in `.ruby-version`. Known versions: 1.9, 2.0, 2.1, 2.2, 2.3, 2.4 Ref: --- .rubocop.yml | 6 ------ Gemfile | 2 +- Gemfile.lock | 21 +++++++++++---------- app/utils/sample_story.rb | 4 ++-- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a7403fc37..cb259fecf 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,14 +18,8 @@ Style/Documentation: Style/DoubleNegation: Enabled: false -Style/IfUnlessModifier: - MaxLineLength: 120 - Style/NumericLiterals: Enabled: false Style/StringLiterals: EnforcedStyle: double_quotes - -Style/WhileUntilModifier: - MaxLineLength: 120 diff --git a/Gemfile b/Gemfile index 9eccfd283..df6766cd5 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ group :production do end group :development do + gem "rubocop", ">= 0.61.1", require: false gem "sqlite3", "~> 1.3", ">= 1.3.8" end @@ -19,7 +20,6 @@ group :development, :test do gem "rack-test", "~> 0.6" gem "rspec", "~> 3.4" gem "rspec-html-matchers", "~> 0.7" - gem "rubocop", "~> 0.48", require: false gem "shotgun", "~> 0.9" gem "timecop", "~> 0.8" end diff --git a/Gemfile.lock b/Gemfile.lock index 5fec1e9db..bb6cf4ed9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,6 +63,7 @@ GEM sax-machine (>= 1.0) i18n (0.9.5) concurrent-ruby (~> 1.0) + jaro_winkler (1.5.4) json (1.8.6) kgio (2.11.2) loofah (2.2.1) @@ -78,10 +79,10 @@ GEM multipart-post (2.0.0) nokogiri (1.10.4) mini_portile2 (~> 2.4.0) + parallel (1.19.0) parser (2.6.5.0) ast (~> 2.4.0) pg (0.18.4) - powerpack (0.1.2) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -99,8 +100,7 @@ GEM racksh (1.0.0) rack (>= 1.0) rack-test (>= 0.5) - rainbow (2.2.2) - rake + rainbow (3.0.0) raindrops (0.19.0) rake (10.5.0) rspec (3.4.0) @@ -119,12 +119,13 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.48.1) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rubocop (0.76.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.6) + rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) + unicode-display_width (>= 1.4.0, < 1.7) ruby-progressbar (1.10.1) sass (3.4.22) sax-machine (1.3.2) @@ -203,7 +204,7 @@ DEPENDENCIES rake (~> 10.1, >= 10.1.1) rspec (~> 3.4) rspec-html-matchers (~> 0.7) - rubocop (~> 0.48) + rubocop (>= 0.61.1) sass shotgun (~> 0.9) sinatra (~> 1.4.8, >= 1.4.8) @@ -223,4 +224,4 @@ RUBY VERSION ruby 2.6.5p114 BUNDLED WITH - 1.17.2 + 1.17.3 diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 9fa5ae58e..921369ef4 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -40,7 +40,7 @@ def body BODY end - def is_read # rubocop:disable Style/PredicateName + def is_read # rubocop:disable Naming/PredicateName false end @@ -48,7 +48,7 @@ def keep_unread false end - def is_starred # rubocop:disable Style/PredicateName + def is_starred # rubocop:disable Naming/PredicateName false end From 48ef2a9ceaba3307a209006e2a0318393dec10e7 Mon Sep 17 00:00:00 2001 From: Victor Koronen Date: Sat, 16 Nov 2019 20:22:09 +0100 Subject: [PATCH 022/779] Make RuboCop pass again after upgrading * Remove `TargetRubyVersion` This is an application, not a library. We specify an explicit Ruby version in `Gemfile`. RuboCop can read this Ruby version from `Gemfile.lock` since v0.54.0. * Fix some minor complaints This includes: * whitespace issues * `rescue` without specifying an error * `YAML.load` -> `YAML.safe_load` * variable naming Thank you `--auto-correct`! * Replace custom enum implementation with `ActiveRecord::Enum` Instead of just fixing the complaint about an uncommunicative parameter name. Ref: * Update `.rubocop_todo.yml` Postpone addressing some of the new-found issues in order to keep the diff size down. --- .rubocop.yml | 1 - .rubocop_todo.yml | 61 +++++++++++++++++-- Gemfile | 2 +- app/commands/feeds/find_new_stories.rb | 1 + app/fever_api/read_items.rb | 2 +- app/fever_api/response.rb | 2 +- app/fever_api/write_mark_item.rb | 4 +- app/helpers/authentication_helpers.rb | 1 + app/models/feed.rb | 11 +--- app/repositories/feed_repository.rb | 8 +-- app/repositories/story_repository.rb | 1 + app/tasks/fetch_feed.rb | 4 +- app/utils/feed_discovery.rb | 2 +- app/utils/opml_parser.rb | 2 +- app/utils/sample_story.rb | 42 ++++++------- config/unicorn.rb | 2 +- fever_api.rb | 1 + spec/commands/feeds/import_from_opml_spec.rb | 2 +- .../stories/mark_group_as_read_spec.rb | 2 +- spec/factories/group_factory.rb | 3 +- spec/factories/user_factory.rb | 3 +- ...url_helers_spec.rb => url_helpers_spec.rb} | 50 +++++++-------- spec/integration/feed_importing_spec.rb | 6 +- spec/support/active_record.rb | 2 +- spec/tasks/change_password_spec.rb | 4 +- spec/utils/opml_parser_spec.rb | 16 ++--- 26 files changed, 143 insertions(+), 92 deletions(-) rename spec/helpers/{url_helers_spec.rb => url_helpers_spec.rb} (77%) diff --git a/.rubocop.yml b/.rubocop.yml index cb259fecf..a06bb3b3e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,6 @@ AllCops: Exclude: - 'db/schema.rb' - 'vendor/**/*' - TargetRubyVersion: 2.3 Metrics/LineLength: Max: 120 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0e4ee7524..6ff5e7cac 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,14 +1,67 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2016-03-22 20:52:58 +0100 using RuboCop version 0.38.0. +# on 2019-11-16 20:15:02 +0100 using RuboCop version 0.76.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 163 +# Offense count: 41 +# Configuration parameters: CountComments, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Exclude: + - 'spec/**/*' + +# Offense count: 9 +# Configuration parameters: Blacklist. +# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Exclude: + - 'app/utils/sample_story.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/utils/opml_parser_spec.rb' + +# Offense count: 139 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: when_needed, always +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, never Style/FrozenStringLiteralComment: Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'app/commands/stories/mark_group_as_read.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'app/helpers/authentication_helpers.rb' + - 'app/helpers/url_helpers.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/javascript/test_controller.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. +# Whitelist: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'app/controllers/feeds_controller.rb' + - 'app/tasks/fetch_feed.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets diff --git a/Gemfile b/Gemfile index df6766cd5..ca9df1338 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -ruby_version_file = File.join(File.expand_path("..", __FILE__), ".ruby-version") +ruby_version_file = File.expand_path(".ruby-version", __dir__) ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file) source "https://rubygems.org" diff --git a/app/commands/feeds/find_new_stories.rb b/app/commands/feeds/find_new_stories.rb index e8bd10678..609198562 100644 --- a/app/commands/feeds/find_new_stories.rb +++ b/app/commands/feeds/find_new_stories.rb @@ -16,6 +16,7 @@ def new_stories @raw_feed.entries.each do |story| break if @latest_entry_id && story.id == @latest_entry_id next if story_age_exceeds_threshold?(story) || StoryRepository.exists?(story.id, @feed_id) + stories << story end diff --git a/app/fever_api/read_items.rb b/app/fever_api/read_items.rb index 0ae45ffbd..845e18f92 100644 --- a/app/fever_api/read_items.rb +++ b/app/fever_api/read_items.rb @@ -10,7 +10,7 @@ def call(params = {}) if params.keys.include?("items") item_ids = begin params[:with_ids].split(",") - rescue + rescue StandardError nil end diff --git a/app/fever_api/response.rb b/app/fever_api/response.rb index 1c9521060..31336b5f4 100644 --- a/app/fever_api/response.rb +++ b/app/fever_api/response.rb @@ -40,7 +40,7 @@ def initialize(params) @params = params end - def to_json + def to_json(*_args) base_response = { api_version: API_VERSION } ACTIONS .inject(base_response) { |a, e| a.merge!(e.new.call(@params)) } diff --git a/app/fever_api/write_mark_item.rb b/app/fever_api/write_mark_item.rb index a2752e013..28346bc08 100644 --- a/app/fever_api/write_mark_item.rb +++ b/app/fever_api/write_mark_item.rb @@ -20,8 +20,8 @@ def call(params = {}) private - def mark_item_as(id, as) - case as + def mark_item_as(id, mark_as) + case mark_as when "read" @read_marker_class.new(id).mark_as_read when "unread" diff --git a/app/helpers/authentication_helpers.rb b/app/helpers/authentication_helpers.rb index 9239b5d63..d9f564aae 100644 --- a/app/helpers/authentication_helpers.rb +++ b/app/helpers/authentication_helpers.rb @@ -13,6 +13,7 @@ def needs_authentication?(path) return false unless UserRepository.setup_complete? return false if %w(/login /logout /heroku).include?(path) return false if path =~ /css|js|img/ + true end diff --git a/app/models/feed.rb b/app/models/feed.rb index 08b66523b..ff0efea9a 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -4,18 +4,11 @@ class Feed < ActiveRecord::Base validates_uniqueness_of :url - STATUS = { green: 0, yellow: 1, red: 2 }.freeze - - def status - STATUS.key(read_attribute(:status)) - end - - def status=(s) - write_attribute(:status, STATUS[s]) - end + enum status: { green: 0, yellow: 1, red: 2 } def status_bubble return :yellow if status == :red && stories.any? + status end diff --git a/app/repositories/feed_repository.rb b/app/repositories/feed_repository.rb index 6a8bec620..dcce4fcdd 100644 --- a/app/repositories/feed_repository.rb +++ b/app/repositories/feed_repository.rb @@ -19,10 +19,10 @@ def self.update_feed(feed, name, url, group_id = nil) end def self.update_last_fetched(feed, timestamp) - if valid_timestamp?(timestamp, feed.last_fetched) - feed.last_fetched = timestamp - feed.save - end + return unless valid_timestamp?(timestamp, feed.last_fetched) + + feed.last_fetched = timestamp + feed.save end def self.delete(feed_id) diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index d6037972b..73a65d904 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -107,6 +107,7 @@ def self.extract_content(entry) def self.extract_title(entry) return ContentSanitizer.sanitize(entry.title) if entry.title.present? return ContentSanitizer.sanitize(entry.summary) if entry.summary.present? + "There isn't a title for this story" end diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index 2482391cc..941a9005c 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -21,10 +21,10 @@ def fetch end FeedRepository.set_status(:green, @feed) - rescue => ex + rescue StandardError => e FeedRepository.set_status(:red, @feed) - @logger.error "Something went wrong when parsing #{@feed.url}: #{ex}" if @logger + @logger.error "Something went wrong when parsing #{@feed.url}: #{e}" if @logger end private diff --git a/app/utils/feed_discovery.rb b/app/utils/feed_discovery.rb index 8c8be46d9..f0fb64697 100644 --- a/app/utils/feed_discovery.rb +++ b/app/utils/feed_discovery.rb @@ -17,7 +17,7 @@ def get_feed_for_url(url, parser) feed = parser.fetch_and_parse(url) feed.feed_url ||= url feed - rescue + rescue StandardError yield if block_given? end end diff --git a/app/utils/opml_parser.rb b/app/utils/opml_parser.rb index e1643f68c..e99d45938 100644 --- a/app/utils/opml_parser.rb +++ b/app/utils/opml_parser.rb @@ -38,7 +38,7 @@ def extract_name(attributes) def feed_to_hash(feed) { name: extract_name(feed.attributes).value, - url: feed.attributes["xmlUrl"].value + url: feed.attributes["xmlUrl"].value } end end diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 921369ef4..03c2f69a9 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -1,24 +1,24 @@ -SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do - BODY = <<-eos.freeze -

Tofu shoreditch intelligentsia umami, fashion axe photo booth -try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic -salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee -street art gentrify. Quinoa PBR readymade 90's. Chambray Austin aesthetic -meggings, carles vinyl intelligentsia tattooed. Keffiyeh mumblecore -fingerstache, sartorial sriracha disrupt biodiesel cred. Skateboard yr cosby -sweater, narwhal beard ethnic jean shorts aesthetic. Post-ironic flannel mlkshk, -pickled VHS wolf banjo forage portland wayfarers.

- -

Selfies mumblecore odd future irony DIY messenger bag. -Authentic neutra next level selvage squid. Four loko freegan occupy, tousled -vinyl leggings selvage messenger bag. Four loko wayfarers kale chips, next level -banksy banh mi umami flannel hella. Street art odd future scenester, -intelligentsia brunch fingerstache YOLO narwhal single-origin coffee tousled -tumblr pop-up four loko you probably haven't heard of them dreamcatcher. -Single-origin coffee direct trade retro biodiesel, truffaut fanny pack portland -blue bottle scenester bushwick. Skateboard squid fanny pack bushwick, photo -booth vice literally.

- eos +SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do # rubocop:disable Metrics/BlockLength + BODY = <<~EOS.freeze +

Tofu shoreditch intelligentsia umami, fashion axe photo booth + try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic + salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee + street art gentrify. Quinoa PBR readymade 90's. Chambray Austin aesthetic + meggings, carles vinyl intelligentsia tattooed. Keffiyeh mumblecore + fingerstache, sartorial sriracha disrupt biodiesel cred. Skateboard yr cosby + sweater, narwhal beard ethnic jean shorts aesthetic. Post-ironic flannel mlkshk, + pickled VHS wolf banjo forage portland wayfarers.

+ +

Selfies mumblecore odd future irony DIY messenger bag. + Authentic neutra next level selvage squid. Four loko freegan occupy, tousled + vinyl leggings selvage messenger bag. Four loko wayfarers kale chips, next level + banksy banh mi umami flannel hella. Street art odd future scenester, + intelligentsia brunch fingerstache YOLO narwhal single-origin coffee tousled + tumblr pop-up four loko you probably haven't heard of them dreamcatcher. + Single-origin coffee direct trade retro biodiesel, truffaut fanny pack portland + blue bottle scenester bushwick. Skateboard squid fanny pack bushwick, photo + booth vice literally.

+ EOS def id -1 * rand(100) diff --git a/config/unicorn.rb b/config/unicorn.rb index 7f1487bc8..5b139c6bd 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -17,7 +17,7 @@ after_fork do |_server, _worker| if defined?(ActiveRecord::Base) env = ENV["RACK_ENV"] || "development" - config = YAML.load(ERB.new(File.read("config/database.yml")).result)[env] + config = YAML.safe_load(ERB.new(File.read("config/database.yml")).result)[env] ActiveRecord::Base.establish_connection(config) end end diff --git a/fever_api.rb b/fever_api.rb index 6de858ee3..e3d7f7cf4 100644 --- a/fever_api.rb +++ b/fever_api.rb @@ -20,6 +20,7 @@ class Endpoint < Sinatra::Base def authenticated?(api_key) return unless api_key + user = User.first user.api_key && api_key.casecmp(user.api_key).zero? end diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 2f691e9d2..8fd7b3f25 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -3,7 +3,7 @@ app_require "commands/feeds/import_from_opml" describe ImportFromOpml do - let(:subscriptions) { File.open(File.expand_path("../../../support/files/subscriptions.xml", __FILE__)) } + let(:subscriptions) { File.open(File.expand_path("../../support/files/subscriptions.xml", __dir__)) } def import described_class.import(subscriptions) diff --git a/spec/commands/stories/mark_group_as_read_spec.rb b/spec/commands/stories/mark_group_as_read_spec.rb index fcbbfc702..84d68b81a 100644 --- a/spec/commands/stories/mark_group_as_read_spec.rb +++ b/spec/commands/stories/mark_group_as_read_spec.rb @@ -3,7 +3,7 @@ app_require "commands/stories/mark_group_as_read" describe MarkGroupAsRead do - describe '#mark_group_as_read' do + describe "#mark_group_as_read" do let(:stories) { double } let(:repo) { double } let(:timestamp) { Time.now.to_i } diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rb index de9d16c2f..d761a5820 100644 --- a/spec/factories/group_factory.rb +++ b/spec/factories/group_factory.rb @@ -11,6 +11,7 @@ def as_fever_json def self.build(params = {}) FakeGroup.new( id: rand(100), - name: params[:name] || Faker::Name.name + " group") + name: params[:name] || Faker::Name.name + " group" + ) end end diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index da91ad011..ced5ad345 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -6,6 +6,7 @@ class FakeUser < OpenStruct; end def self.build FakeUser.new( id: rand(100), - setup_complete: false) + setup_complete: false + ) end end diff --git a/spec/helpers/url_helers_spec.rb b/spec/helpers/url_helpers_spec.rb similarity index 77% rename from spec/helpers/url_helers_spec.rb rename to spec/helpers/url_helpers_spec.rb index 6ed0288bf..9fd259c83 100644 --- a/spec/helpers/url_helers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -17,22 +17,22 @@ class Helper end it "replaces relative urls in a, img and video tags" do - content = <<-EOS -
- -tee - -
+ content = <<~EOS +
+ + tee + +
EOS result = helper.expand_absolute_urls(content, "http://oodl.io/d/") - expect(result.delete("\n")).to eq <<-EOS.delete("\n") -
- -tee - - -
+ expect(result.delete("\n")).to eq <<~EOS.delete("\n") +
+ + tee + + +
EOS end @@ -41,21 +41,21 @@ class Helper end it "doesn't modify tags that do not have url attributes" do - content = <<-EOS -
- - - -
+ content = <<~EOS +
+ + + +
EOS result = helper.expand_absolute_urls(content, "http://oodl.io/d/") - expect(result.delete("\n")).to eq <<-EOS.delete("\n") -
- - - -
+ expect(result.delete("\n")).to eq <<~EOS.delete("\n") +
+ + + +
EOS end diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index 699a9e696..e67568234 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -31,7 +31,7 @@ describe "Importing for the first time" do it "imports all entries" do @server.response = sample_data("feeds/feed01_valid_feed/feed.xml") - expect { fetch_feed(feed) }.to change { feed.stories.count }.to(5) + expect { fetch_feed(feed) }.to change(feed.stories, :count).to(5) end end @@ -44,14 +44,14 @@ context "no new entries" do it "does not create new stories" do @server.response = sample_data("feeds/feed01_valid_feed/feed.xml") - expect { fetch_feed(feed) }.to_not change { feed.stories.count } + expect { fetch_feed(feed) }.to_not change(feed.stories, :count) end end context "new entries" do it "creates new stories" do @server.response = sample_data("feeds/feed01_valid_feed/feed_updated.xml") - expect { fetch_feed(feed) }.to change { feed.stories.count }.by(1) + expect { fetch_feed(feed) }.to change(feed.stories, :count).by(1) end end end diff --git a/spec/support/active_record.rb b/spec/support/active_record.rb index 6e13deec9..0d28984b3 100644 --- a/spec/support/active_record.rb +++ b/spec/support/active_record.rb @@ -1,6 +1,6 @@ require "active_record" -db_config = YAML.load(File.read("config/database.yml")) +db_config = YAML.safe_load(File.read("config/database.yml")) ActiveRecord::Base.establish_connection(db_config["test"]) ActiveRecord::Base.logger = Logger.new("log/test.log") diff --git a/spec/tasks/change_password_spec.rb b/spec/tasks/change_password_spec.rb index f39dfcc11..e35b17e1e 100644 --- a/spec/tasks/change_password_spec.rb +++ b/spec/tasks/change_password_spec.rb @@ -11,7 +11,7 @@ describe "#change_password" do it "invokes command with confirmed password" do expect(task).to receive(:ask_hidden).twice - .and_return(new_password, new_password) + .and_return(new_password, new_password) expect(command) .to receive(:change_user_password) @@ -22,7 +22,7 @@ it "repeats until a matching confirmation" do expect(task).to receive(:ask_hidden).exactly(2).times - .and_return(new_password, "", new_password, new_password) + .and_return(new_password, "", new_password, new_password) expect(command) .to receive(:change_user_password) diff --git a/spec/utils/opml_parser_spec.rb b/spec/utils/opml_parser_spec.rb index e007dc195..ea844b3e8 100644 --- a/spec/utils/opml_parser_spec.rb +++ b/spec/utils/opml_parser_spec.rb @@ -7,7 +7,7 @@ describe "#parse_feeds" do it "it returns a hash of feed details from an OPML file" do - result = parser.parse_feeds(<<-eos) + result = parser.parse_feeds(<<-EOS) @@ -20,7 +20,7 @@ xmlUrl="http://mdswanson.com/atom.xml" htmlUrl="http://mdswanson.com/"/> - eos + EOS resulted_values = result.values.flatten expect(resulted_values.size).to eq 2 @@ -33,7 +33,7 @@ end it "handles nested groups of feeds" do - result = parser.parse_feeds(<<-eos) + result = parser.parse_feeds(<<-EOS) @@ -46,7 +46,7 @@ - eos + EOS resulted_values = result.values.flatten expect(resulted_values.count).to eq 1 @@ -56,7 +56,7 @@ end it "doesn't explode when there are no feeds" do - result = parser.parse_feeds(<<-eos) + result = parser.parse_feeds(<<-EOS) @@ -65,13 +65,13 @@ - eos + EOS expect(result).to be_empty end it "handles Feedly's exported OPML (missing :title)" do - result = parser.parse_feeds(<<-eos) + result = parser.parse_feeds(<<-EOS) @@ -82,7 +82,7 @@ xmlUrl="http://feeds.feedburner.com/foobar" htmlUrl="http://www.example.org/"/> - eos + EOS resulted_values = result.values.flatten expect(resulted_values.count).to eq 1 From 8729d7e53102c4b69d972af2d4d5dc93ee8e4b18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2019 13:34:01 +0000 Subject: [PATCH 023/779] Bump rack-protection from 1.5.3 to 1.5.5 Bumps [rack-protection](https://github.com/sinatra/sinatra) from 1.5.3 to 1.5.5. - [Release notes](https://github.com/sinatra/sinatra/releases) - [Changelog](https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md) - [Commits](https://github.com/sinatra/sinatra/commits) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 84f7c41b2..a084db708 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,7 +90,7 @@ GEM byebug (~> 2.7) pry (~> 0.10) rack (1.6.11) - rack-protection (1.5.3) + rack-protection (1.5.5) rack rack-ssl (1.4.1) rack From 7e5bdbce63a83a6ed171caa3dce6666411cf1d7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2019 15:01:53 +0000 Subject: [PATCH 024/779] Bump sprockets from 3.7.0 to 3.7.2 Bumps [sprockets](https://github.com/rails/sprockets) from 3.7.0 to 3.7.2. - [Release notes](https://github.com/rails/sprockets/releases) - [Changelog](https://github.com/rails/sprockets/blob/v3.7.2/CHANGELOG.md) - [Commits](https://github.com/rails/sprockets/compare/v3.7.0...v3.7.2) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index a0e23c230..b2f898adb 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ gem "sinatra", "~> 1.4.8", ">= 1.4.8" gem "sinatra-activerecord", "~> 1.2", ">= 1.2.3" gem "sinatra-contrib", "~> 1.4.7" gem "sinatra-flash", "~> 0.3" -gem "sprockets", "~> 3.0" +gem "sprockets", "~> 3.7" gem "sprockets-helpers" gem "thread", "~> 0.2" gem "uglifier" diff --git a/Gemfile.lock b/Gemfile.lock index a084db708..884634442 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -151,7 +151,7 @@ GEM sinatra-flash (0.3.0) sinatra (>= 1.0.0) slop (3.6.0) - sprockets (3.7.0) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-helpers (1.2.1) @@ -209,7 +209,7 @@ DEPENDENCIES sinatra-activerecord (~> 1.2, >= 1.2.3) sinatra-contrib (~> 1.4.7) sinatra-flash (~> 0.3) - sprockets (~> 3.0) + sprockets (~> 3.7) sprockets-helpers sqlite3 (~> 1.3, >= 1.3.8) thread (~> 0.2) From a1a231b3eafe32140fdcae5b6d6a14ceb1fbff9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2019 02:21:14 +0000 Subject: [PATCH 025/779] Bump rack from 1.6.11 to 1.6.12 Bumps [rack](https://github.com/rack/rack) from 1.6.11 to 1.6.12. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/master/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/1.6.11...1.6.12) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 884634442..8f0bbccc3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,7 +89,7 @@ GEM pry-byebug (1.3.3) byebug (~> 2.7) pry (~> 0.10) - rack (1.6.11) + rack (1.6.12) rack-protection (1.5.5) rack rack-ssl (1.4.1) From e8774a45f909a508034aa14515a52bb11f2019c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2020 22:31:24 +0000 Subject: [PATCH 026/779] Bump nokogiri from 1.10.4 to 1.10.8 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.4 to 1.10.8. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.10.4...v1.10.8) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1f4d22810..e48775a4b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,7 +77,7 @@ GEM minitest (5.12.2) multi_json (1.12.1) multipart-post (2.0.0) - nokogiri (1.10.4) + nokogiri (1.10.8) mini_portile2 (~> 2.4.0) parallel (1.19.0) parser (2.6.5.0) From a17f9f67469549f8ca5345ecb2b5741aeefd1b87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Feb 2020 21:28:57 +0000 Subject: [PATCH 027/779] Bump rake from 10.5.0 to 12.3.3 Bumps [rake](https://github.com/ruby/rake) from 10.5.0 to 12.3.3. - [Release notes](https://github.com/ruby/rake/releases) - [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc) - [Commits](https://github.com/ruby/rake/compare/v10.5.0...v12.3.3) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 0edbb5ff0..17618a50d 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,7 @@ gem "nokogiri", "~> 1.10" gem "rack-protection", "~> 1.5" gem "rack-ssl", "~> 1.4" gem "racksh", "~> 1.0" -gem "rake", "~> 10.1", ">= 10.1.1" +gem "rake", "~> 12.3" gem "sass" gem "sinatra", "~> 1.4.8", ">= 1.4.8" gem "sinatra-activerecord", "~> 1.2", ">= 1.2.3" diff --git a/Gemfile.lock b/Gemfile.lock index e48775a4b..38d7d998d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,7 +102,7 @@ GEM rack-test (>= 0.5) rainbow (3.0.0) raindrops (0.19.0) - rake (10.5.0) + rake (12.3.3) rspec (3.4.0) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) @@ -201,7 +201,7 @@ DEPENDENCIES rack-ssl (~> 1.4) rack-test (~> 0.6) racksh (~> 1.0) - rake (~> 10.1, >= 10.1.1) + rake (~> 12.3) rspec (~> 3.4) rspec-html-matchers (~> 0.7) rubocop (>= 0.61.1) From 4b876d5ce2dc7a272b08f28128df5c1e2686b07f Mon Sep 17 00:00:00 2001 From: Matthew Conway Date: Wed, 13 May 2020 13:33:30 -0700 Subject: [PATCH 028/779] Update command for setting APP_URL on Heroku * `web-url` in the `heroku apps:info` output is now `web_url` * Command was returning an empty string and setting that as the value of `APP_URL` --- docs/Heroku.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Heroku.md b/docs/Heroku.md index 4a113e20e..0e75c49b0 100644 --- a/docs/Heroku.md +++ b/docs/Heroku.md @@ -4,7 +4,7 @@ cd stringer heroku create git push heroku master -heroku config:set APP_URL=`heroku apps:info --shell | grep web-url | cut -d= -f2` +heroku config:set APP_URL=`heroku apps:info --shell | grep web_url | cut -d= -f2` heroku config:set SECRET_TOKEN=`openssl rand -hex 20` heroku run rake db:migrate From b510764ad06364972e648c100abe554a5b4cb226 Mon Sep 17 00:00:00 2001 From: bossi Date: Sun, 9 Aug 2020 20:22:47 +1000 Subject: [PATCH 029/779] Docs: Bring version-number for localized Ruby up to date --- docs/VPS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/VPS.md b/docs/VPS.md index 752f91550..6f70a0faf 100644 --- a/docs/VPS.md +++ b/docs/VPS.md @@ -61,8 +61,8 @@ We are going to use Rbenv to manage the version of Ruby you use. git clone git://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build source ~/.bash_profile - rbenv install 2.3.3 - rbenv local 2.3.3 + rbenv install 2.6.5 + rbenv local 2.6.5 rbenv rehash We also need to install bundler which will handle Stringer's dependencies @@ -163,13 +163,13 @@ server { Deploy Stringer With Passenger And Apache ========================================= -You may want to run Stringer with the existing Apache server. We need to install +You may want to run Stringer with the existing Apache server. We need to install *mod_passenger* and edit few files. The installation of *mod_passenger* depends on VPS's system distribution release. Offical installation guide is available at [Passenger Library](https://www.phusionpassenger.com/library/install/apache/install/oss/) -After validating the *mod_passenger* install, we will fetch dependencies again +After validating the *mod_passenger* install, we will fetch dependencies again to meet Passenger's default GEM_HOME set. As stringer user: cd ~/stringer From 69ff97c7f33b4d38fefa6f4417ace59a0bb58fe2 Mon Sep 17 00:00:00 2001 From: Vojtech Vondra Date: Thu, 3 Sep 2020 12:31:31 +0200 Subject: [PATCH 030/779] Add web manifest to enable native app feel on mobile - by adding the meta headers and manifest, if you add the website on mobile to you home screen, the browser chrome will dissappear and more screen space will be available for the reader --- app/public/manifest.json | 7 +++++++ app/views/layout.erb | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 app/public/manifest.json diff --git a/app/public/manifest.json b/app/public/manifest.json new file mode 100644 index 000000000..e6d6c8261 --- /dev/null +++ b/app/public/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "Stringer", + "theme_color": "#F67100", + "background_color": "#FAF2E5", + "display": "standalone", + "start_url": "/" +} diff --git a/app/views/layout.erb b/app/views/layout.erb index 980aee3ae..2063cecd4 100644 --- a/app/views/layout.erb +++ b/app/views/layout.erb @@ -10,6 +10,11 @@ + + + + + <%= yield_content :head %> From edc2d856362a97990783eb10a045a7631e76f57c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Feb 2021 19:18:15 +0000 Subject: [PATCH 031/779] Bump nokogiri from 1.10.8 to 1.11.0 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.8 to 1.11.0. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.10.8...v1.11.0) Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 17618a50d..3a24d1b20 100644 --- a/Gemfile +++ b/Gemfile @@ -32,7 +32,7 @@ gem "feedbag", "~> 0.9.5" gem "feedjira", "~> 2.1.3" gem "i18n" gem "loofah", "~> 2.3" -gem "nokogiri", "~> 1.10" +gem "nokogiri", "~> 1.11" gem "rack-protection", "~> 1.5" gem "rack-ssl", "~> 1.4" gem "racksh", "~> 1.0" diff --git a/Gemfile.lock b/Gemfile.lock index 38d7d998d..fb863cca7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -73,12 +73,13 @@ GEM mime-types (3.0) mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) - mini_portile2 (2.4.0) + mini_portile2 (2.5.0) minitest (5.12.2) multi_json (1.12.1) multipart-post (2.0.0) - nokogiri (1.10.8) - mini_portile2 (~> 2.4.0) + nokogiri (1.11.0) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) parallel (1.19.0) parser (2.6.5.0) ast (~> 2.4.0) @@ -90,6 +91,7 @@ GEM pry-byebug (1.3.3) byebug (~> 2.7) pry (~> 0.10) + racc (1.5.2) rack (1.6.12) rack-protection (1.5.5) rack @@ -194,7 +196,7 @@ DEPENDENCIES feedjira (~> 2.1.3) i18n loofah (~> 2.3) - nokogiri (~> 1.10) + nokogiri (~> 1.11) pg (~> 0.18.4) pry-byebug (~> 1.2) rack-protection (~> 1.5) From b2257e85eb4f5f946b6ea6418a4de6f182481bd1 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 18 Feb 2021 18:45:47 -0800 Subject: [PATCH 032/779] fix filename for `mark_as_starred_spec` This test wasn't running because it didn't have `_spec` on the end. --- .../stories/{mark_as_starred.rb => mark_as_starred_spec.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/commands/stories/{mark_as_starred.rb => mark_as_starred_spec.rb} (100%) diff --git a/spec/commands/stories/mark_as_starred.rb b/spec/commands/stories/mark_as_starred_spec.rb similarity index 100% rename from spec/commands/stories/mark_as_starred.rb rename to spec/commands/stories/mark_as_starred_spec.rb From 51a2496dbae809eba70ee4372dd71c6d637f054f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 19 Feb 2021 14:53:36 -0800 Subject: [PATCH 033/779] Add feed specs, fix status bug This fixes an issue with `Feed#status_bubble` where it would *never* return `:yellow`. `Feed#status` comes back as a string, so `status == :red` would always be falsey. This updates it to instead do a string comparison. --- app/models/feed.rb | 2 +- spec/models/feed_spec.rb | 77 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 spec/models/feed_spec.rb diff --git a/app/models/feed.rb b/app/models/feed.rb index ff0efea9a..a752dfc89 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -7,7 +7,7 @@ class Feed < ActiveRecord::Base enum status: { green: 0, yellow: 1, red: 2 } def status_bubble - return :yellow if status == :red && stories.any? + return "yellow" if status == "red" && stories.any? status end diff --git a/spec/models/feed_spec.rb b/spec/models/feed_spec.rb new file mode 100644 index 000000000..e7e3b4c57 --- /dev/null +++ b/spec/models/feed_spec.rb @@ -0,0 +1,77 @@ +require "spec_helper" +require "support/active_record" + +app_require "models/feed" + +describe "Feed" do + describe "#status_bubble" do + it "returns 'yellow' when status == 'red' and there are stories" do + feed = Feed.new(status: :red, stories: [Story.new]) + + expect(feed.status_bubble).to eq("yellow") + end + + it "returns 'red' if status is 'red' and there are no stories" do + feed = Feed.new(status: :red) + + expect(feed.status_bubble).to eq("red") + end + + it "returns nil when no status is set" do + feed = Feed.new + + expect(feed.status_bubble).to be_nil + end + + it "returns :green when status is :green" do + feed = Feed.new(status: :green) + + expect(feed.status_bubble).to eq("green") + end + end + + describe "#unread_stories" do + it "returns stories where is_read is false" do + feed = Feed.create! + story = feed.stories.create!(is_read: false) + + expect(feed.unread_stories).to eq([story]) + end + + it "does not return stories where is_read is true" do + feed = Feed.create! + feed.stories.create!(is_read: true) + + expect(feed.unread_stories).to be_empty + end + + it "does not return stories where is_read is nil" do + feed = Feed.create! + feed.stories.create! + + expect(feed.unread_stories).to be_empty + end + end + + describe "#as_fever_json" do + it "returns a hash of the feed in fever format" do + last_fetched = 1.day.ago + feed = Feed.new( + id: 52, + name: "chicken feed", + url: "wat url", + last_fetched: last_fetched + ) + + expect(feed.as_fever_json).to eq( + id: 52, + favicon_id: 0, + title: "chicken feed", + url: "wat url", + site_url: "wat url", + is_spark: 0, + last_updated_on_time: last_fetched.to_i + ) + end + end +end From 59df9d41f1ea79816de450ea7951968961960a06 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 20 Feb 2021 11:21:33 -0800 Subject: [PATCH 034/779] Specs: restore coverage (#528) It looks like Coveralls was disabled back in c84d7b8, but it seems to have been unrelated to the code changes. This reenables it on CI, and uses just `SimpleCov` in local development. --- Gemfile | 1 + Gemfile.lock | 1 + spec/spec_helper.rb | 1 + spec/support/coverage.rb | 17 +++++++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 spec/support/coverage.rb diff --git a/Gemfile b/Gemfile index 3a24d1b20..583621c9a 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ group :development, :test do gem "rspec", "~> 3.4" gem "rspec-html-matchers", "~> 0.7" gem "shotgun", "~> 0.9" + gem "simplecov" gem "timecop", "~> 0.8" end diff --git a/Gemfile.lock b/Gemfile.lock index fb863cca7..356c5260d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -209,6 +209,7 @@ DEPENDENCIES rubocop (>= 0.61.1) sass shotgun (~> 0.9) + simplecov sinatra (~> 1.4.8, >= 1.4.8) sinatra-activerecord (~> 1.2, >= 1.2.3) sinatra-contrib (~> 1.4.7) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 96039db07..8c1dc3275 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,6 +8,7 @@ require "ostruct" require "date" +require_relative "support/coverage" require "factories/feed_factory" require "factories/story_factory" require "factories/user_factory" diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb new file mode 100644 index 000000000..905d5861d --- /dev/null +++ b/spec/support/coverage.rb @@ -0,0 +1,17 @@ +require "simplecov" + +if ENV["CI"] + require "coveralls" + SimpleCov.formatter = Coveralls::SimpleCov::Formatter +end + +SimpleCov.start("test_frameworks") do + add_group("Commands", "app/commands") + add_group("Controllers", "app/controllers") + add_group("Fever API", "app/fever_api") + add_group("Helpers", "app/helpers") + add_group("Models", "app/models") + add_group("Repositories", "app/repositories") + add_group("Tasks", "app/tasks") + add_group("Utils", "app/utils") +end From 831af297b3b05d4233aa0b9e7eb3b73ba2412ebc Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 21 Feb 2021 11:47:43 -0800 Subject: [PATCH 035/779] Specs: add tests for UserRepository (#529) Also: * Add factory helpers for `User` records * Remove method `User#setup_complete?`. ActiveRecord automatically provides predicate (`?`) methods for model attributes, so it's not necessary. --- app/models/user.rb | 4 -- spec/factories/users.rb | 9 ++++ spec/repositories/user_repository_spec.rb | 60 +++++++++++++++++++++++ spec/spec_helper.rb | 2 + 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 spec/factories/users.rb create mode 100644 spec/repositories/user_repository_spec.rb diff --git a/app/models/user.rb b/app/models/user.rb index 13422ce7f..40f070579 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,3 @@ class User < ActiveRecord::Base has_secure_password - - def setup_complete? - setup_complete - end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 000000000..923a74d7f --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,9 @@ +module Factories + def create_user(params = {}) + build_user(params).tap(&:save!) + end + + def build_user(params = {}) + User.new(password: "super-secret", **params) + end +end diff --git a/spec/repositories/user_repository_spec.rb b/spec/repositories/user_repository_spec.rb new file mode 100644 index 000000000..c6662f63d --- /dev/null +++ b/spec/repositories/user_repository_spec.rb @@ -0,0 +1,60 @@ +require "spec_helper" +require "support/active_record" + +app_require "repositories/user_repository" + +describe UserRepository do + describe ".fetch" do + it "returns nil when given id is nil" do + expect(UserRepository.fetch(nil)).to be(nil) + end + + it "returns the user for the given id" do + user = create_user + + expect(UserRepository.fetch(user.id)).to eq(user) + end + end + + describe ".setup_complete?" do + it "returns false when there are no users" do + expect(UserRepository.setup_complete?).to be(false) + end + + it "returns false when user has not completed setup" do + create_user + + expect(UserRepository.setup_complete?).to be(false) + end + + it "returns true when user has completed setup" do + create_user(setup_complete: true) + + expect(UserRepository.setup_complete?).to be(true) + end + end + + describe ".save" do + it "saves the given user" do + user = build_user + + expect { UserRepository.save(user) } + .to change(user, :persisted?).from(false).to(true) + end + + it "returns the given user" do + user = User.new + + expect(UserRepository.save(user)).to eq(user) + end + end + + describe ".first" do + it "returns the first user" do + user = create_user + create_user + + expect(UserRepository.first).to eq(user) + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8c1dc3275..63e9cdced 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,12 +13,14 @@ require "factories/story_factory" require "factories/user_factory" require "factories/group_factory" +require "factories/users" require "./app" RSpec.configure do |config| config.include Rack::Test::Methods config.include RSpecHtmlMatchers + config.include Factories end def app_require(file) From 4cd6ed6ba79bf6d54b4d6f31e372e4ddbc2bcdd4 Mon Sep 17 00:00:00 2001 From: David Personette Date: Mon, 22 Feb 2021 12:43:31 -0500 Subject: [PATCH 036/779] update rack and sinatra (#531) --- Gemfile | 10 +++++----- Gemfile.lock | 50 ++++++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Gemfile b/Gemfile index 583621c9a..0eff2936d 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ group :development, :test do gem "coveralls", "~> 0.7", require: false gem "faker", "~> 1.2" gem "pry-byebug", "~> 1.2" - gem "rack-test", "~> 0.6" + gem "rack-test", "~> 1.1" gem "rspec", "~> 3.4" gem "rspec-html-matchers", "~> 0.7" gem "shotgun", "~> 0.9" @@ -34,14 +34,14 @@ gem "feedjira", "~> 2.1.3" gem "i18n" gem "loofah", "~> 2.3" gem "nokogiri", "~> 1.11" -gem "rack-protection", "~> 1.5" +gem "rack-protection", "~> 2.0" gem "rack-ssl", "~> 1.4" gem "racksh", "~> 1.0" gem "rake", "~> 12.3" gem "sass" -gem "sinatra", "~> 1.4.8", ">= 1.4.8" -gem "sinatra-activerecord", "~> 1.2", ">= 1.2.3" -gem "sinatra-contrib", "~> 1.4.7" +gem "sinatra", "~> 2.0" +gem "sinatra-activerecord", "~> 2.0" +gem "sinatra-contrib", "~> 2.0" gem "sinatra-flash", "~> 0.3" gem "sprockets", "~> 3.7" gem "sprockets-helpers" diff --git a/Gemfile.lock b/Gemfile.lock index 356c5260d..3678324ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,8 +75,9 @@ GEM mime-types-data (3.2016.0221) mini_portile2 (2.5.0) minitest (5.12.2) - multi_json (1.12.1) + multi_json (1.14.1) multipart-post (2.0.0) + mustermann (1.0.3) nokogiri (1.11.0) mini_portile2 (~> 2.5.0) racc (~> 1.4) @@ -92,13 +93,13 @@ GEM byebug (~> 2.7) pry (~> 0.10) racc (1.5.2) - rack (1.6.12) - rack-protection (1.5.5) + rack (2.0.7) + rack-protection (2.0.7) rack rack-ssl (1.4.1) rack - rack-test (0.6.3) - rack (>= 1.0) + rack-test (1.1.0) + rack (>= 1.0, < 3) racksh (1.0.0) rack (>= 1.0) rack-test (>= 0.5) @@ -138,20 +139,21 @@ GEM json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - sinatra (1.4.8) - rack (~> 1.5) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) - sinatra-activerecord (1.7.0) - activerecord (>= 3.0) - sinatra (~> 1.0) - sinatra-contrib (1.4.7) - backports (>= 2.0) + sinatra (2.0.7) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.7) + tilt (~> 2.0) + sinatra-activerecord (2.0.14) + activerecord (>= 3.2) + sinatra (>= 1.0) + sinatra-contrib (2.0.7) + backports (>= 2.8.2) multi_json - rack-protection - rack-test - sinatra (~> 1.4.0) - tilt (>= 1.3, < 3) + mustermann (~> 1.0) + rack-protection (= 2.0.7) + sinatra (= 2.0.7) + tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) slop (3.6.0) @@ -166,7 +168,7 @@ GEM thor (0.19.1) thread (0.2.2) thread_safe (0.3.6) - tilt (1.4.1) + tilt (2.0.10) timecop (0.8.0) tins (1.6.0) tzinfo (1.2.5) @@ -199,9 +201,9 @@ DEPENDENCIES nokogiri (~> 1.11) pg (~> 0.18.4) pry-byebug (~> 1.2) - rack-protection (~> 1.5) + rack-protection (~> 2.0) rack-ssl (~> 1.4) - rack-test (~> 0.6) + rack-test (~> 1.1) racksh (~> 1.0) rake (~> 12.3) rspec (~> 3.4) @@ -210,9 +212,9 @@ DEPENDENCIES sass shotgun (~> 0.9) simplecov - sinatra (~> 1.4.8, >= 1.4.8) - sinatra-activerecord (~> 1.2, >= 1.2.3) - sinatra-contrib (~> 1.4.7) + sinatra (~> 2.0) + sinatra-activerecord (~> 2.0) + sinatra-contrib (~> 2.0) sinatra-flash (~> 0.3) sprockets (~> 3.7) sprockets-helpers From 9033f427651aff9506411fa5da79b310c6246916 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Feb 2021 10:27:42 -0800 Subject: [PATCH 037/779] Bump rack from 2.0.7 to 2.2.3 (#532) Bumps [rack](https://github.com/rack/rack) from 2.0.7 to 2.2.3. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/master/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/2.0.7...2.2.3) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3678324ee..534a6a1d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,7 +93,7 @@ GEM byebug (~> 2.7) pry (~> 0.10) racc (1.5.2) - rack (2.0.7) + rack (2.2.3) rack-protection (2.0.7) rack rack-ssl (1.4.1) From d0a7f988cfa571f6f695c8e9110c22288c5efae5 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 22 Feb 2021 12:47:43 -0800 Subject: [PATCH 038/779] Specs: add specs for Group and Story (#534) As well as factory helpers for `feeds` and `stories`. --- spec/factories/feeds.rb | 9 +++++ spec/factories/stories.rb | 9 +++++ spec/models/group_spec.rb | 12 ++++++ spec/models/story_spec.rb | 83 +++++++++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 2 + 5 files changed, 115 insertions(+) create mode 100644 spec/factories/feeds.rb create mode 100644 spec/factories/stories.rb create mode 100644 spec/models/group_spec.rb diff --git a/spec/factories/feeds.rb b/spec/factories/feeds.rb new file mode 100644 index 000000000..4047705c0 --- /dev/null +++ b/spec/factories/feeds.rb @@ -0,0 +1,9 @@ +module Factories + def create_feed(params = {}) + build_feed(params).tap(&:save!) + end + + def build_feed(params = {}) + Feed.new(**params) + end +end diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb new file mode 100644 index 000000000..17128ca0d --- /dev/null +++ b/spec/factories/stories.rb @@ -0,0 +1,9 @@ +module Factories + def create_story(params = {}) + build_story(params).tap(&:save!) + end + + def build_story(params = {}) + Story.new(feed: build_feed, **params) + end +end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb new file mode 100644 index 000000000..14b3285ca --- /dev/null +++ b/spec/models/group_spec.rb @@ -0,0 +1,12 @@ +require "spec_helper" +require "support/active_record" + +RSpec.describe Group do + describe "#as_fever_json" do + it "returns a hash of the group in fever format" do + group = Group.new(id: 5, name: "wat group") + + expect(group.as_fever_json).to eq(id: 5, title: "wat group") + end + end +end diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 3ca12d381..30ea50589 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -46,4 +46,87 @@ expect(story.source).to eq(feed.name) end end + + describe "#pretty_date" do + it "returns a formatted published date" do + published_at = Time.now + story = Story.new(published: published_at) + + expect(story.pretty_date).to eq(I18n.l(published_at)) + end + + it "raises an error when published is nil" do + story = Story.new + + expect { story.pretty_date }.to raise_error(ArgumentError) + end + end + + describe "#as_json" do + it "returns a hash of the story" do + feed = create_feed(name: "my feed") + published_at = 1.day.ago + created_at = 1.hour.ago + updated_at = 1.minute.ago + story = create_story( + body: "story body", + created_at: created_at, + entry_id: 5, + feed: feed, + is_read: true, + is_starred: false, + keep_unread: true, + permalink: "www.exampoo.com/perma", + published: published_at, + title: "the story title", + updated_at: updated_at + ) + + expect(story.as_json).to eq({ + body: "story body", + created_at: created_at, + entry_id: "5", + feed_id: feed.id, + headline: "the story title", + id: story.id, + is_read: true, + is_starred: false, + keep_unread: true, + lead: "story body", + permalink: "www.exampoo.com/perma", + pretty_date: I18n.l(published_at), + published: published_at, + source: "my feed", + title: "the story title", + updated_at: updated_at + }.stringify_keys) + end + end + + describe "#as_fever_json" do + it "returns a hash of the story in fever format" do + feed = create_feed(name: "my feed") + published_at = 1.day.ago + story = create_story( + feed: feed, + title: "the story title", + body: "story body", + permalink: "www.exampoo.com/perma", + published: published_at, + is_read: true + ) + + expect(story.as_fever_json).to eq( + id: story.id, + feed_id: feed.id, + title: "the story title", + author: "my feed", + html: "story body", + url: "www.exampoo.com/perma", + is_saved: 0, + is_read: 1, + created_on_time: published_at.to_i + ) + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 63e9cdced..72ed6bdb9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,8 @@ require "factories/story_factory" require "factories/user_factory" require "factories/group_factory" +require "factories/feeds" +require "factories/stories" require "factories/users" require "./app" From 933fd073c4cf54905bcc385d1085c086ae79ae94 Mon Sep 17 00:00:00 2001 From: David Personette Date: Mon, 22 Feb 2021 22:10:07 -0500 Subject: [PATCH 039/779] Update to activerecord 5 (#533) --- Gemfile | 2 +- Gemfile.lock | 23 +++++++++---------- app/models/application_record.rb | 3 +++ app/models/feed.rb | 4 +++- app/models/group.rb | 4 +++- app/models/story.rb | 3 ++- app/models/user.rb | 4 +++- db/migrate/20130409010818_create_feeds.rb | 2 +- db/migrate/20130409010826_create_stories.rb | 2 +- ...0130412185253_add_new_fields_to_stories.rb | 2 +- db/migrate/20130418221144_add_user_model.rb | 2 +- .../20130423001740_drop_email_from_user.rb | 2 +- ...130423180446_remove_author_from_stories.rb | 2 +- ...130425211008_add_setup_complete_to_user.rb | 2 +- db/migrate/20130425222157_add_delayed_job.rb | 2 +- .../20130429232127_add_status_to_feeds.rb | 2 +- db/migrate/20130504005816_text_url.rb | 2 +- ...504022615_change_story_permalink_column.rb | 2 +- .../20130509131045_add_unique_constraints.rb | 2 +- ...130513025939_add_keep_unread_to_stories.rb | 2 +- ...44029_add_is_starred_status_for_stories.rb | 2 +- .../20130522014405_add_api_key_to_user.rb | 2 +- .../20130730120312_add_entry_id_to_stories.rb | 2 +- ...13712_update_stories_unique_constraints.rb | 2 +- .../20130821020313_update_nil_entry_ids.rb | 2 +- ...se_text_datatype_for_title_and_entry_id.rb | 2 +- ..._groups_table_and_foreign_keys_to_feeds.rb | 2 +- .../20140421224454_fix_invalid_unicode.rb | 2 +- ...nvalid_titles_with_unicode_line_endings.rb | 2 +- spec/support/active_record.rb | 4 ++-- 30 files changed, 50 insertions(+), 41 deletions(-) create mode 100644 app/models/application_record.rb diff --git a/Gemfile b/Gemfile index 0eff2936d..02907e99b 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ group :development, :test do gem "timecop", "~> 0.8" end -gem "activerecord", "~> 4.2.6" +gem "activerecord", "~> 5.0" gem "bcrypt", "~> 3.1" gem "delayed_job", "~> 4.1" gem "delayed_job_active_record", "~> 4.1" diff --git a/Gemfile.lock b/Gemfile.lock index 534a6a1d9..a27c1c98b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,19 @@ GEM remote: https://rubygems.org/ specs: - 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) + activemodel (5.2.4.5) + activesupport (= 5.2.4.5) + activerecord (5.2.4.5) + activemodel (= 5.2.4.5) + activesupport (= 5.2.4.5) + arel (>= 9.0) + activesupport (5.2.4.5) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.4.0) - arel (6.0.4) + arel (9.0.0) ast (2.4.0) backports (3.6.8) bcrypt (3.1.11) @@ -187,7 +186,7 @@ PLATFORMS ruby DEPENDENCIES - activerecord (~> 4.2.6) + activerecord (~> 5.0) bcrypt (~> 3.1) capybara (~> 2.6) coveralls (~> 0.7) diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/feed.rb b/app/models/feed.rb index a752dfc89..1f7913c4f 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -1,4 +1,6 @@ -class Feed < ActiveRecord::Base +require_relative "./application_record" + +class Feed < ApplicationRecord has_many :stories, -> { order "published desc" }, dependent: :delete_all belongs_to :group diff --git a/app/models/group.rb b/app/models/group.rb index 7c26fcd54..e8d8ee22b 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,4 +1,6 @@ -class Group < ActiveRecord::Base +require_relative "./application_record" + +class Group < ApplicationRecord has_many :feeds def as_fever_json diff --git a/app/models/story.rb b/app/models/story.rb index 6dec0471d..ae346ef2a 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -1,6 +1,7 @@ +require_relative "./application_record" require_relative "./feed" -class Story < ActiveRecord::Base +class Story < ApplicationRecord belongs_to :feed validates_uniqueness_of :entry_id, scope: :feed_id diff --git a/app/models/user.rb b/app/models/user.rb index 40f070579..dcbec3ad5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,5 @@ -class User < ActiveRecord::Base +require_relative "./application_record" + +class User < ApplicationRecord has_secure_password end diff --git a/db/migrate/20130409010818_create_feeds.rb b/db/migrate/20130409010818_create_feeds.rb index c1eec66df..202396200 100644 --- a/db/migrate/20130409010818_create_feeds.rb +++ b/db/migrate/20130409010818_create_feeds.rb @@ -1,4 +1,4 @@ -class CreateFeeds < ActiveRecord::Migration +class CreateFeeds < ActiveRecord::Migration[4.2] def change create_table :feeds do |t| t.string :name diff --git a/db/migrate/20130409010826_create_stories.rb b/db/migrate/20130409010826_create_stories.rb index 0d9bcc91e..23dfe6ed5 100644 --- a/db/migrate/20130409010826_create_stories.rb +++ b/db/migrate/20130409010826_create_stories.rb @@ -1,4 +1,4 @@ -class CreateStories < ActiveRecord::Migration +class CreateStories < ActiveRecord::Migration[4.2] def change create_table :stories do |t| t.string :title diff --git a/db/migrate/20130412185253_add_new_fields_to_stories.rb b/db/migrate/20130412185253_add_new_fields_to_stories.rb index 58916f7f6..00beff1cc 100644 --- a/db/migrate/20130412185253_add_new_fields_to_stories.rb +++ b/db/migrate/20130412185253_add_new_fields_to_stories.rb @@ -1,4 +1,4 @@ -class AddNewFieldsToStories < ActiveRecord::Migration +class AddNewFieldsToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :published, :timestamp add_column :stories, :is_read, :boolean diff --git a/db/migrate/20130418221144_add_user_model.rb b/db/migrate/20130418221144_add_user_model.rb index f454fc12e..91240e384 100644 --- a/db/migrate/20130418221144_add_user_model.rb +++ b/db/migrate/20130418221144_add_user_model.rb @@ -1,4 +1,4 @@ -class AddUserModel < ActiveRecord::Migration +class AddUserModel < ActiveRecord::Migration[4.2] def change create_table :users do |t| t.string :email diff --git a/db/migrate/20130423001740_drop_email_from_user.rb b/db/migrate/20130423001740_drop_email_from_user.rb index e07e5eda1..f40b8a62c 100644 --- a/db/migrate/20130423001740_drop_email_from_user.rb +++ b/db/migrate/20130423001740_drop_email_from_user.rb @@ -1,4 +1,4 @@ -class DropEmailFromUser < ActiveRecord::Migration +class DropEmailFromUser < ActiveRecord::Migration[4.2] def up remove_column :users, :email end diff --git a/db/migrate/20130423180446_remove_author_from_stories.rb b/db/migrate/20130423180446_remove_author_from_stories.rb index b38517f6d..47b630d0f 100644 --- a/db/migrate/20130423180446_remove_author_from_stories.rb +++ b/db/migrate/20130423180446_remove_author_from_stories.rb @@ -1,4 +1,4 @@ -class RemoveAuthorFromStories < ActiveRecord::Migration +class RemoveAuthorFromStories < ActiveRecord::Migration[4.2] def up remove_column :stories, :author end diff --git a/db/migrate/20130425211008_add_setup_complete_to_user.rb b/db/migrate/20130425211008_add_setup_complete_to_user.rb index 1e5a57f1c..d98aa7a1c 100644 --- a/db/migrate/20130425211008_add_setup_complete_to_user.rb +++ b/db/migrate/20130425211008_add_setup_complete_to_user.rb @@ -1,4 +1,4 @@ -class AddSetupCompleteToUser < ActiveRecord::Migration +class AddSetupCompleteToUser < ActiveRecord::Migration[4.2] def change add_column :users, :setup_complete, :boolean end diff --git a/db/migrate/20130425222157_add_delayed_job.rb b/db/migrate/20130425222157_add_delayed_job.rb index 6c32be2ca..5232fead1 100644 --- a/db/migrate/20130425222157_add_delayed_job.rb +++ b/db/migrate/20130425222157_add_delayed_job.rb @@ -1,4 +1,4 @@ -class AddDelayedJob < ActiveRecord::Migration +class AddDelayedJob < ActiveRecord::Migration[4.2] def self.up create_table :delayed_jobs, force: true do |table| # Allows some jobs to jump to the front of the queue diff --git a/db/migrate/20130429232127_add_status_to_feeds.rb b/db/migrate/20130429232127_add_status_to_feeds.rb index da45f32bf..9bb84a23f 100644 --- a/db/migrate/20130429232127_add_status_to_feeds.rb +++ b/db/migrate/20130429232127_add_status_to_feeds.rb @@ -1,4 +1,4 @@ -class AddStatusToFeeds < ActiveRecord::Migration +class AddStatusToFeeds < ActiveRecord::Migration[4.2] def change add_column :feeds, :status, :int end diff --git a/db/migrate/20130504005816_text_url.rb b/db/migrate/20130504005816_text_url.rb index a62d7a10d..5f3c1ea7a 100644 --- a/db/migrate/20130504005816_text_url.rb +++ b/db/migrate/20130504005816_text_url.rb @@ -1,4 +1,4 @@ -class TextUrl < ActiveRecord::Migration +class TextUrl < ActiveRecord::Migration[4.2] def up change_column :feeds, :url, :text end diff --git a/db/migrate/20130504022615_change_story_permalink_column.rb b/db/migrate/20130504022615_change_story_permalink_column.rb index 69297bc9e..db8d8b924 100644 --- a/db/migrate/20130504022615_change_story_permalink_column.rb +++ b/db/migrate/20130504022615_change_story_permalink_column.rb @@ -1,4 +1,4 @@ -class ChangeStoryPermalinkColumn < ActiveRecord::Migration +class ChangeStoryPermalinkColumn < ActiveRecord::Migration[4.2] def up change_column :stories, :permalink, :text end diff --git a/db/migrate/20130509131045_add_unique_constraints.rb b/db/migrate/20130509131045_add_unique_constraints.rb index fad3d9f2a..f04989164 100644 --- a/db/migrate/20130509131045_add_unique_constraints.rb +++ b/db/migrate/20130509131045_add_unique_constraints.rb @@ -1,4 +1,4 @@ -class AddUniqueConstraints < ActiveRecord::Migration +class AddUniqueConstraints < ActiveRecord::Migration[4.2] def change add_index :stories, [:permalink, :feed_id], unique: true add_index :feeds, :url, unique: true diff --git a/db/migrate/20130513025939_add_keep_unread_to_stories.rb b/db/migrate/20130513025939_add_keep_unread_to_stories.rb index b3311f32c..76742a0de 100644 --- a/db/migrate/20130513025939_add_keep_unread_to_stories.rb +++ b/db/migrate/20130513025939_add_keep_unread_to_stories.rb @@ -1,4 +1,4 @@ -class AddKeepUnreadToStories < ActiveRecord::Migration +class AddKeepUnreadToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :keep_unread, :boolean, default: false end diff --git a/db/migrate/20130513044029_add_is_starred_status_for_stories.rb b/db/migrate/20130513044029_add_is_starred_status_for_stories.rb index 63423ab31..8333225a0 100644 --- a/db/migrate/20130513044029_add_is_starred_status_for_stories.rb +++ b/db/migrate/20130513044029_add_is_starred_status_for_stories.rb @@ -1,4 +1,4 @@ -class AddIsStarredStatusForStories < ActiveRecord::Migration +class AddIsStarredStatusForStories < ActiveRecord::Migration[4.2] def change add_column :stories, :is_starred, :boolean, default: false end diff --git a/db/migrate/20130522014405_add_api_key_to_user.rb b/db/migrate/20130522014405_add_api_key_to_user.rb index b76d63c02..b52aae725 100644 --- a/db/migrate/20130522014405_add_api_key_to_user.rb +++ b/db/migrate/20130522014405_add_api_key_to_user.rb @@ -1,4 +1,4 @@ -class AddApiKeyToUser < ActiveRecord::Migration +class AddApiKeyToUser < ActiveRecord::Migration[4.2] def change add_column :users, :api_key, :string end diff --git a/db/migrate/20130730120312_add_entry_id_to_stories.rb b/db/migrate/20130730120312_add_entry_id_to_stories.rb index 447e06ca1..f160a6d9d 100644 --- a/db/migrate/20130730120312_add_entry_id_to_stories.rb +++ b/db/migrate/20130730120312_add_entry_id_to_stories.rb @@ -1,4 +1,4 @@ -class AddEntryIdToStories < ActiveRecord::Migration +class AddEntryIdToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :entry_id, :string end diff --git a/db/migrate/20130805113712_update_stories_unique_constraints.rb b/db/migrate/20130805113712_update_stories_unique_constraints.rb index 0cb354727..53ec20b71 100644 --- a/db/migrate/20130805113712_update_stories_unique_constraints.rb +++ b/db/migrate/20130805113712_update_stories_unique_constraints.rb @@ -1,4 +1,4 @@ -class UpdateStoriesUniqueConstraints < ActiveRecord::Migration +class UpdateStoriesUniqueConstraints < ActiveRecord::Migration[4.2] def up remove_index :stories, [:permalink, :feed_id] add_index :stories, [:entry_id, :feed_id], unique: true, length: { permalink: 767 } diff --git a/db/migrate/20130821020313_update_nil_entry_ids.rb b/db/migrate/20130821020313_update_nil_entry_ids.rb index 57739f60d..2b5624910 100644 --- a/db/migrate/20130821020313_update_nil_entry_ids.rb +++ b/db/migrate/20130821020313_update_nil_entry_ids.rb @@ -1,4 +1,4 @@ -class UpdateNilEntryIds < ActiveRecord::Migration +class UpdateNilEntryIds < ActiveRecord::Migration[4.2] def up Story.where(entry_id: nil).each do |story| story.entry_id = story.permalink || story.id diff --git a/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb b/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb index a08210f18..0d847e58c 100644 --- a/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb +++ b/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb @@ -1,4 +1,4 @@ -class UseTextDatatypeForTitleAndEntryId < ActiveRecord::Migration +class UseTextDatatypeForTitleAndEntryId < ActiveRecord::Migration[4.2] def up change_column :stories, :title, :text change_column :stories, :entry_id, :text diff --git a/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb b/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb index 1ff359975..149e3f77b 100644 --- a/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb +++ b/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb @@ -1,4 +1,4 @@ -class AddGroupsTableAndForeignKeysToFeeds < ActiveRecord::Migration +class AddGroupsTableAndForeignKeysToFeeds < ActiveRecord::Migration[4.2] def up create_table :groups do |t| t.string :name, null: false diff --git a/db/migrate/20140421224454_fix_invalid_unicode.rb b/db/migrate/20140421224454_fix_invalid_unicode.rb index d9200cd6c..902e311d2 100644 --- a/db/migrate/20140421224454_fix_invalid_unicode.rb +++ b/db/migrate/20140421224454_fix_invalid_unicode.rb @@ -1,4 +1,4 @@ -class FixInvalidUnicode < ActiveRecord::Migration +class FixInvalidUnicode < ActiveRecord::Migration[4.2] def up Story.find_each do |story| valid_body = story.body.delete("\u2028").delete("\u2029") diff --git a/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb b/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb index 4202b0bc8..5d0fa90d4 100644 --- a/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb +++ b/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb @@ -1,4 +1,4 @@ -class FixInvalidTitlesWithUnicodeLineEndings < ActiveRecord::Migration +class FixInvalidTitlesWithUnicodeLineEndings < ActiveRecord::Migration[4.2] def up Story.find_each do |story| unless story.title.nil? diff --git a/spec/support/active_record.rb b/spec/support/active_record.rb index 0d28984b3..724b89aa0 100644 --- a/spec/support/active_record.rb +++ b/spec/support/active_record.rb @@ -5,10 +5,10 @@ ActiveRecord::Base.logger = Logger.new("log/test.log") def need_to_migrate? - ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations("db/migrate")).pending_migrations.any? + ActiveRecord::Base.connection.migration_context.needs_migration? end -ActiveRecord::Migrator.up "db/migrate" if need_to_migrate? +ActiveRecord::MigrationContext.new("db/migrate").migrate if need_to_migrate? RSpec.configure do |config| config.around do |example| From ef0e1640a92f40d7b5a116d3a967b136c95d89ba Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 23 Feb 2021 15:37:48 -0800 Subject: [PATCH 040/779] Specs: fix flaky story_spec (#536) The date seems to be coming back in UTC. --- spec/models/story_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 30ea50589..058473613 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -94,8 +94,8 @@ keep_unread: true, lead: "story body", permalink: "www.exampoo.com/perma", - pretty_date: I18n.l(published_at), - published: published_at, + pretty_date: I18n.l(published_at.utc), + published: published_at.utc, source: "my feed", title: "the story title", updated_at: updated_at From 58ea9feb119e7eee524417422202b3940af30a55 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 23 Feb 2021 16:25:33 -0800 Subject: [PATCH 041/779] Specs: add tests for GroupRepository (#537) And new groups factory. --- spec/factories/groups.rb | 9 +++++++++ spec/repositories/group_repository_spec.rb | 18 ++++++++++++++++++ spec/spec_helper.rb | 1 + 3 files changed, 28 insertions(+) create mode 100644 spec/factories/groups.rb create mode 100644 spec/repositories/group_repository_spec.rb diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb new file mode 100644 index 000000000..9d7ba4e85 --- /dev/null +++ b/spec/factories/groups.rb @@ -0,0 +1,9 @@ +module Factories + def create_group(params = {}) + build_group(params).tap(&:save!) + end + + def build_group(params = {}) + Group.new(**params) + end +end diff --git a/spec/repositories/group_repository_spec.rb b/spec/repositories/group_repository_spec.rb new file mode 100644 index 000000000..b1ab5c268 --- /dev/null +++ b/spec/repositories/group_repository_spec.rb @@ -0,0 +1,18 @@ +require "spec_helper" +require "support/active_record" + +app_require "repositories/group_repository" + +describe GroupRepository do + describe ".list" do + it "lists groups ordered by lower name" do + group1 = create_group(name: "Zabba") + group2 = create_group(name: "zlabba") + group3 = create_group(name: "blabba") + group4 = create_group(name: "Babba") + expected_groups = [group4, group3, group1, group2] + + expect(GroupRepository.list).to eq(expected_groups) + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 72ed6bdb9..974eb897c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,6 +14,7 @@ require "factories/user_factory" require "factories/group_factory" require "factories/feeds" +require "factories/groups" require "factories/stories" require "factories/users" From 8766a51c85ad00f045620c2679c087ffdc5c5f52 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Wed, 24 Feb 2021 10:30:14 -0800 Subject: [PATCH 042/779] Specs: add specs for StoryRepository (#538) Also adjust the way that factories are required and introduce a `next_id` helper. There are still some untested methods in StoryRepository which I will continue to work on in followups. --- spec/factories.rb | 15 +++++++ spec/factories/stories.rb | 2 +- spec/repositories/story_repository_spec.rb | 47 ++++++++++++++++++++++ spec/spec_helper.rb | 9 +---- 4 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 spec/factories.rb diff --git a/spec/factories.rb b/spec/factories.rb new file mode 100644 index 000000000..4b0718ff2 --- /dev/null +++ b/spec/factories.rb @@ -0,0 +1,15 @@ +require_relative "factories/feed_factory" +require_relative "factories/story_factory" +require_relative "factories/user_factory" +require_relative "factories/group_factory" +require_relative "factories/feeds" +require_relative "factories/groups" +require_relative "factories/stories" +require_relative "factories/users" + +module Factories + def next_id + @next_id ||= 0 + @next_id += 1 + end +end diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index 17128ca0d..191c74fb9 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -4,6 +4,6 @@ def create_story(params = {}) end def build_story(params = {}) - Story.new(feed: build_feed, **params) + Story.new(entry_id: next_id, feed: build_feed, **params) end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index e7f1035a8..96ae1bb2e 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -1,4 +1,5 @@ require "spec_helper" +require "support/active_record" app_require "repositories/story_repository" @@ -35,6 +36,52 @@ end end + describe ".fetch" do + it "finds the story by id" do + story = create_story + + expect(StoryRepository.fetch(story.id)).to eq(story) + end + end + + describe ".fetch_by_ids" do + it "finds all stories by id" do + story1 = create_story + story2 = create_story + expected_stories = [story1, story2] + + actual_stories = StoryRepository.fetch_by_ids(expected_stories.map(&:id)) + + expect(actual_stories).to match_array(expected_stories) + end + end + + describe ".fetch_unread_by_timestamp" do + it "returns unread stories from before the timestamp" do + story = create_story(created_at: 1.week.ago, is_read: false) + + actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) + + expect(actual_stories).to eq([story]) + end + + it "does not return unread stories from after the timestamp" do + create_story(created_at: 3.days.ago, is_read: false) + + actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) + + expect(actual_stories).to be_empty + end + + it "does not return read stories from before the timestamp" do + create_story(created_at: 1.week.ago, is_read: true) + + actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) + + expect(actual_stories).to be_empty + end + end + describe ".extract_url" do it "returns the url" do feed = double(url: "http://github.com") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 974eb897c..0afb6ad4d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,14 +9,7 @@ require "date" require_relative "support/coverage" -require "factories/feed_factory" -require "factories/story_factory" -require "factories/user_factory" -require "factories/group_factory" -require "factories/feeds" -require "factories/groups" -require "factories/stories" -require "factories/users" +require_relative "factories" require "./app" From 7b4935b6f40b112f198f6b93967b20282b0ed9b0 Mon Sep 17 00:00:00 2001 From: David Personette Date: Thu, 25 Feb 2021 00:33:52 -0500 Subject: [PATCH 043/779] update to feedjira 3 (#535) --- Gemfile | 3 ++- Gemfile.lock | 19 ++++++++--------- app/tasks/fetch_feed.rb | 7 +++++-- app/utils/feed_discovery.rb | 12 ++++++----- spec/tasks/fetch_feed_spec.rb | 35 +++++++++++++++++++++---------- spec/utils/feed_discovery_spec.rb | 33 +++++++++++++++++++---------- 6 files changed, 69 insertions(+), 40 deletions(-) diff --git a/Gemfile b/Gemfile index 02907e99b..70cf9fc9b 100644 --- a/Gemfile +++ b/Gemfile @@ -30,7 +30,8 @@ gem "bcrypt", "~> 3.1" gem "delayed_job", "~> 4.1" gem "delayed_job_active_record", "~> 4.1" gem "feedbag", "~> 0.9.5" -gem "feedjira", "~> 2.1.3" +gem "feedjira", "~> 3.0" +gem "httparty" gem "i18n" gem "loofah", "~> 2.3" gem "nokogiri", "~> 1.11" diff --git a/Gemfile.lock b/Gemfile.lock index a27c1c98b..d2c5ea6a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,17 +49,14 @@ GEM execjs (2.7.0) faker (1.6.3) i18n (~> 0.5) - faraday (0.13.1) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.12.2) - faraday (>= 0.7.4, < 1.0) feedbag (0.9.5) nokogiri (~> 1.0) - feedjira (2.1.3) - faraday (>= 0.9) - faraday_middleware (>= 0.9) - loofah (>= 2.0) + feedjira (3.1.2) + loofah (>= 2.3.1) sax-machine (>= 1.0) + httparty (0.18.1) + mime-types (~> 3.0) + multi_xml (>= 0.5.2) i18n (0.9.5) concurrent-ruby (~> 1.0) jaro_winkler (1.5.4) @@ -69,12 +66,13 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.5.9) method_source (0.8.2) - mime-types (3.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) mini_portile2 (2.5.0) minitest (5.12.2) multi_json (1.14.1) + multi_xml (0.6.0) multipart-post (2.0.0) mustermann (1.0.3) nokogiri (1.11.0) @@ -194,7 +192,8 @@ DEPENDENCIES delayed_job_active_record (~> 4.1) faker (~> 1.2) feedbag (~> 0.9.5) - feedjira (~> 2.1.3) + feedjira (~> 3.0) + httparty i18n loofah (~> 2.3) nokogiri (~> 1.11) diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index 941a9005c..c0af4efa0 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -1,13 +1,15 @@ require "feedjira" +require "httparty" require_relative "../repositories/story_repository" require_relative "../repositories/feed_repository" require_relative "../commands/feeds/find_new_stories" class FetchFeed - def initialize(feed, parser: Feedjira::Feed, logger: nil) + def initialize(feed, parser: Feedjira, client: HTTParty, logger: nil) @feed = feed @parser = parser + @client = client @logger = logger end @@ -30,7 +32,8 @@ def fetch private def fetch_raw_feed - @parser.fetch_and_parse(@feed.url) + response = @client.get(@feed.url).to_s + @parser.parse(response) end def feed_not_modified diff --git a/app/utils/feed_discovery.rb b/app/utils/feed_discovery.rb index f0fb64697..dd65d4740 100644 --- a/app/utils/feed_discovery.rb +++ b/app/utils/feed_discovery.rb @@ -1,20 +1,22 @@ require "feedbag" require "feedjira" +require "httparty" class FeedDiscovery - def discover(url, finder = Feedbag, parser = Feedjira::Feed) - get_feed_for_url(url, parser) do + def discover(url, finder = Feedbag, parser = Feedjira, client = HTTParty) + get_feed_for_url(url, parser, client) do urls = finder.find(url) return false if urls.empty? - get_feed_for_url(urls.first, parser) do + get_feed_for_url(urls.first, parser, client) do return false end end end - def get_feed_for_url(url, parser) - feed = parser.fetch_and_parse(url) + def get_feed_for_url(url, parser, client) + response = client.get(url).to_s + feed = parser.parse(response) feed.feed_url ||= url feed rescue StandardError diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 7408e854e..8448bbd12 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -18,24 +18,26 @@ context "when feed has not been modified" do it "should not try to fetch posts" do - parser = double(fetch_and_parse: 304) + client = class_spy(HTTParty) + parser = class_double(Feedjira, parse: 304) expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser: parser) + FetchFeed.new(daring_fireball, parser: parser, client: client) end end context "when no new posts have been added" do it "should not add any new posts" do fake_feed = double(last_modified: Time.new(2012, 12, 31)) - parser = double(fetch_and_parse: fake_feed) + client = class_spy(HTTParty) + parser = class_double(Feedjira, parse: fake_feed) allow_any_instance_of(FindNewStories).to receive(:new_stories).and_return([]) expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser: parser).fetch + FetchFeed.new(daring_fireball, parser: parser, client: client).fetch end end @@ -45,7 +47,8 @@ let(:old_story) { double } let(:fake_feed) { double(last_modified: now, entries: [new_story, old_story]) } - let(:fake_parser) { double(fetch_and_parse: fake_feed) } + let(:fake_client) { class_spy(HTTParty) } + let(:fake_parser) { class_double(Feedjira, parse: fake_feed) } before { allow_any_instance_of(FindNewStories).to receive(:new_stories).and_return([new_story]) } @@ -53,35 +56,45 @@ expect(StoryRepository).to receive(:add).with(new_story, daring_fireball) expect(StoryRepository).not_to receive(:add).with(old_story, daring_fireball) - FetchFeed.new(daring_fireball, parser: fake_parser).fetch + FetchFeed.new( + daring_fireball, + parser: fake_parser, + client: fake_client + ).fetch end it "should update the last fetched time for the feed" do expect(FeedRepository).to receive(:update_last_fetched) .with(daring_fireball, now) - FetchFeed.new(daring_fireball, parser: fake_parser).fetch + FetchFeed.new( + daring_fireball, + parser: fake_parser, + client: fake_client + ).fetch end end context "feed status" do it "sets the status to green if things are all good" do fake_feed = double(last_modified: Time.new(2012, 12, 31), entries: []) - parser = double(fetch_and_parse: fake_feed) + client = class_spy(HTTParty) + parser = class_double(Feedjira, parse: fake_feed) expect(FeedRepository).to receive(:set_status) .with(:green, daring_fireball) - FetchFeed.new(daring_fireball, parser: parser).fetch + FetchFeed.new(daring_fireball, parser: parser, client: client).fetch end it "sets the status to red if things go wrong" do - parser = double(fetch_and_parse: 404) + client = class_spy(HTTParty) + parser = class_double(Feedjira, parse: 404) expect(FeedRepository).to receive(:set_status) .with(:red, daring_fireball) - FetchFeed.new(daring_fireball, parser: parser).fetch + FetchFeed.new(daring_fireball, parser: parser, client: client).fetch end end end diff --git a/spec/utils/feed_discovery_spec.rb b/spec/utils/feed_discovery_spec.rb index 1c10286d9..19be6b4eb 100644 --- a/spec/utils/feed_discovery_spec.rb +++ b/spec/utils/feed_discovery_spec.rb @@ -4,7 +4,8 @@ describe FeedDiscovery do let(:finder) { double } - let(:parser) { double } + let(:client) { class_double(HTTParty) } + let(:parser) { class_double(Feedjira) } let(:feed) { double(feed_url: url) } let(:url) { "http://example.com" } @@ -13,38 +14,48 @@ describe "#discover" do it "returns false if url is not a feed and feed url cannot be discovered" do - expect(parser).to receive(:fetch_and_parse).with(url).and_raise(StandardError) + expect(client).to receive(:get).with(url) + expect(parser).to receive(:parse).and_raise(StandardError) expect(finder).to receive(:find).and_return([]) - result = FeedDiscovery.new.discover(url, finder, parser) + result = FeedDiscovery.new.discover(url, finder, parser, client) expect(result).to eq(false) end it "returns a feed if the url provided is parsable" do - expect(parser).to receive(:fetch_and_parse).with(url).and_return(feed) + expect(client).to receive(:get).with(url) + expect(parser).to receive(:parse).and_return(feed) - result = FeedDiscovery.new.discover(url, finder, parser) + result = FeedDiscovery.new.discover(url, finder, parser, client) expect(result).to eq feed end it "returns false if the discovered feed is not parsable" do - expect(parser).to receive(:fetch_and_parse).with(url).and_raise(StandardError) + expect(client).to receive(:get).with(url) + expect(parser).to receive(:parse).and_raise(StandardError) + expect(finder).to receive(:find).and_return([invalid_discovered_url]) - expect(parser).to receive(:fetch_and_parse).with(invalid_discovered_url).and_raise(StandardError) - result = FeedDiscovery.new.discover(url, finder, parser) + expect(client).to receive(:get).with(invalid_discovered_url) + expect(parser).to receive(:parse).and_raise(StandardError) + + result = FeedDiscovery.new.discover(url, finder, parser, client) expect(result).to eq(false) end it "returns the feed if the discovered feed is parsable" do - expect(parser).to receive(:fetch_and_parse).with(url).and_raise(StandardError) + expect(client).to receive(:get).with(url) + expect(parser).to receive(:parse).and_raise(StandardError) + expect(finder).to receive(:find).and_return([valid_discovered_url]) - expect(parser).to receive(:fetch_and_parse).with(valid_discovered_url).and_return(feed) - result = FeedDiscovery.new.discover(url, finder, parser) + expect(client).to receive(:get).with(valid_discovered_url) + expect(parser).to receive(:parse).and_return(feed) + + result = FeedDiscovery.new.discover(url, finder, parser, client) expect(result).to eq feed end From 07dee5b34578e664f09676574ad39b23e651584b Mon Sep 17 00:00:00 2001 From: David Personette Date: Fri, 26 Feb 2021 20:42:36 -0500 Subject: [PATCH 044/779] update dev gems (rubocop and sqlite3) and their dependencies, and fix new rubocop warnings (#541) --- .rubocop.yml | 2 +- .rubocop_todo.yml | 3 +- Gemfile | 6 +-- Gemfile.lock | 33 ++++++++------ Rakefile | 4 +- app/fever_api/read_items.rb | 8 ++-- app/helpers/url_helpers.rb | 2 +- app/tasks/change_password.rb | 2 +- app/tasks/fetch_feed.rb | 4 +- app/utils/sample_story.rb | 4 +- db/migrate/20130409010818_create_feeds.rb | 2 +- db/migrate/20130409010826_create_stories.rb | 2 +- db/migrate/20130418221144_add_user_model.rb | 2 +- db/migrate/20130425222157_add_delayed_job.rb | 2 +- spec/commands/feeds/import_from_opml_spec.rb | 46 ++++++++++---------- spec/factories/feed_factory.rb | 2 +- spec/factories/group_factory.rb | 2 +- spec/fever_api/read_groups_spec.rb | 6 +-- spec/helpers/authentications_helper_spec.rb | 2 +- spec/helpers/url_helpers_spec.rb | 2 +- spec/integration/feed_importing_spec.rb | 2 +- 21 files changed, 71 insertions(+), 67 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a06bb3b3e..cb431f7fb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ AllCops: - 'db/schema.rb' - 'vendor/**/*' -Metrics/LineLength: +Layout/LineLength: Max: 120 Metrics/MethodLength: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6ff5e7cac..ad41fdec2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -50,14 +50,13 @@ Style/PercentLiteralDelimiters: - 'spec/helpers/url_helpers_spec.rb' - 'spec/javascript/test_controller.rb' -# Offense count: 3 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. # Whitelist: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - 'app/controllers/feeds_controller.rb' - - 'app/tasks/fetch_feed.rb' # Offense count: 7 # Cop supports --auto-correct. diff --git a/Gemfile b/Gemfile index 70cf9fc9b..5e83c25d2 100644 --- a/Gemfile +++ b/Gemfile @@ -8,8 +8,8 @@ group :production do end group :development do - gem "rubocop", ">= 0.61.1", require: false - gem "sqlite3", "~> 1.3", ">= 1.3.8" + gem "rubocop", require: false + gem "sqlite3" end group :development, :test do @@ -36,8 +36,8 @@ gem "i18n" gem "loofah", "~> 2.3" gem "nokogiri", "~> 1.11" gem "rack-protection", "~> 2.0" -gem "rack-ssl", "~> 1.4" gem "racksh", "~> 1.0" +gem "rack-ssl", "~> 1.4" gem "rake", "~> 12.3" gem "sass" gem "sinatra", "~> 2.0" diff --git a/Gemfile.lock b/Gemfile.lock index d2c5ea6a7..7e40538af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ GEM tzinfo (~> 1.1) addressable (2.4.0) arel (9.0.0) - ast (2.4.0) + ast (2.4.2) backports (3.6.8) bcrypt (3.1.11) builder (3.2.3) @@ -59,7 +59,6 @@ GEM multi_xml (>= 0.5.2) i18n (0.9.5) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.4) json (1.8.6) kgio (2.11.2) loofah (2.3.1) @@ -78,9 +77,9 @@ GEM nokogiri (1.11.0) mini_portile2 (~> 2.5.0) racc (~> 1.4) - parallel (1.19.0) - parser (2.6.5.0) - ast (~> 2.4.0) + parallel (1.20.1) + parser (3.0.0.0) + ast (~> 2.4.1) pg (0.18.4) pry (0.10.3) coderay (~> 1.1.0) @@ -103,6 +102,8 @@ GEM rainbow (3.0.0) raindrops (0.19.0) rake (12.3.3) + regexp_parser (2.1.1) + rexml (3.2.4) rspec (3.4.0) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) @@ -119,14 +120,18 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.76.0) - jaro_winkler (~> 1.5.1) + rubocop (1.10.0) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.2.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - ruby-progressbar (1.10.1) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.4.1) + parser (>= 2.7.1.5) + ruby-progressbar (1.11.0) sass (3.4.22) sax-machine (1.3.2) shotgun (0.9.1) @@ -159,7 +164,7 @@ GEM rack (> 1, < 3) sprockets-helpers (1.2.1) sprockets (>= 2.2) - sqlite3 (1.3.11) + sqlite3 (1.4.2) term-ansicolor (1.3.2) tins (~> 1.0) thor (0.19.1) @@ -172,7 +177,7 @@ GEM thread_safe (~> 0.1) uglifier (3.0.2) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.0) + unicode-display_width (2.0.0) unicorn (5.4.0) kgio (~> 2.6) raindrops (~> 0.7) @@ -206,7 +211,7 @@ DEPENDENCIES rake (~> 12.3) rspec (~> 3.4) rspec-html-matchers (~> 0.7) - rubocop (>= 0.61.1) + rubocop sass shotgun (~> 0.9) simplecov @@ -216,7 +221,7 @@ DEPENDENCIES sinatra-flash (~> 0.3) sprockets (~> 3.7) sprockets-helpers - sqlite3 (~> 1.3, >= 1.3.8) + sqlite3 thread (~> 0.2) timecop (~> 0.8) uglifier diff --git a/Rakefile b/Rakefile index 65669e57e..ec14cc8fc 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ require "./app" require_relative "./app/jobs/fetch_feed_job" require_relative "./app/tasks/fetch_feeds" require_relative "./app/tasks/change_password" -require_relative "./app/tasks/remove_old_stories.rb" +require_relative "./app/tasks/remove_old_stories" desc "Fetch all feeds." task :fetch_feeds do @@ -83,6 +83,6 @@ begin RSpec::Core::RakeTask.new(:spec) task default: [:speedy_tests] -rescue LoadError # rubocop:disable Lint/HandleExceptions +rescue LoadError # allow for bundle install --without development:test end diff --git a/app/fever_api/read_items.rb b/app/fever_api/read_items.rb index 845e18f92..84c94e4ae 100644 --- a/app/fever_api/read_items.rb +++ b/app/fever_api/read_items.rb @@ -9,10 +9,10 @@ def initialize(options = {}) def call(params = {}) if params.keys.include?("items") item_ids = begin - params[:with_ids].split(",") - rescue StandardError - nil - end + params[:with_ids].split(",") + rescue StandardError + nil + end { items: items(item_ids, params[:since_id]), diff --git a/app/helpers/url_helpers.rb b/app/helpers/url_helpers.rb index 6c3a97bef..0be9dd386 100644 --- a/app/helpers/url_helpers.rb +++ b/app/helpers/url_helpers.rb @@ -14,7 +14,7 @@ def expand_absolute_urls(content, base_url) begin node.set_attribute(attr, URI.join(base_url, url).to_s) - rescue URI::InvalidURIError # rubocop:disable Lint/HandleExceptions + rescue URI::InvalidURIError # Just ignore. If we cannot parse the url, we don't want the entire # import to blow up. end diff --git a/app/tasks/change_password.rb b/app/tasks/change_password.rb index 8a3f67011..f6fbb3a26 100644 --- a/app/tasks/change_password.rb +++ b/app/tasks/change_password.rb @@ -26,7 +26,7 @@ def ask_confirmation def ask_hidden(question) print(question) - input = STDIN.noecho(&:gets).chomp + input = $stdin.noecho(&:gets).chomp puts input end diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index c0af4efa0..e52862ce9 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -26,7 +26,7 @@ def fetch rescue StandardError => e FeedRepository.set_status(:red, @feed) - @logger.error "Something went wrong when parsing #{@feed.url}: #{e}" if @logger + @logger&.error "Something went wrong when parsing #{@feed.url}: #{e}" end private @@ -37,7 +37,7 @@ def fetch_raw_feed end def feed_not_modified - @logger.info "#{@feed.url} has not been modified since last fetch" if @logger + @logger&.info "#{@feed.url} has not been modified since last fetch" end def feed_modified(raw_feed) diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 03c2f69a9..0bcc41558 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -1,5 +1,5 @@ -SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do # rubocop:disable Metrics/BlockLength - BODY = <<~EOS.freeze +SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do + BODY = <<~EOS.freeze # rubocop:disable Lint/ConstantDefinitionInBlock

Tofu shoreditch intelligentsia umami, fashion axe photo booth try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee diff --git a/db/migrate/20130409010818_create_feeds.rb b/db/migrate/20130409010818_create_feeds.rb index 202396200..628400da3 100644 --- a/db/migrate/20130409010818_create_feeds.rb +++ b/db/migrate/20130409010818_create_feeds.rb @@ -5,7 +5,7 @@ def change t.string :url t.timestamp :last_fetched - t.timestamps + t.timestamps null: false end end end diff --git a/db/migrate/20130409010826_create_stories.rb b/db/migrate/20130409010826_create_stories.rb index 23dfe6ed5..8df287917 100644 --- a/db/migrate/20130409010826_create_stories.rb +++ b/db/migrate/20130409010826_create_stories.rb @@ -7,7 +7,7 @@ def change t.references :feed - t.timestamps + t.timestamps null: false end end end diff --git a/db/migrate/20130418221144_add_user_model.rb b/db/migrate/20130418221144_add_user_model.rb index 91240e384..5adc4fc3b 100644 --- a/db/migrate/20130418221144_add_user_model.rb +++ b/db/migrate/20130418221144_add_user_model.rb @@ -4,7 +4,7 @@ def change t.string :email t.string :password_digest - t.timestamps + t.timestamps null: false end end end diff --git a/db/migrate/20130425222157_add_delayed_job.rb b/db/migrate/20130425222157_add_delayed_job.rb index 5232fead1..60736b629 100644 --- a/db/migrate/20130425222157_add_delayed_job.rb +++ b/db/migrate/20130425222157_add_delayed_job.rb @@ -30,7 +30,7 @@ def self.up # The name of the queue this job is in table.string :queue - table.timestamps + table.timestamps null: false end add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 8fd7b3f25..49661795a 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -14,14 +14,14 @@ def import Group.delete_all end - let(:group_1) { Group.find_by_name("Football News") } - let(:group_2) { Group.find_by_name("RoR") } + let(:group1) { Group.find_by_name("Football News") } + let(:group2) { Group.find_by_name("RoR") } context "adding group_id for existing feeds" do - let!(:feed_1) do + let!(:feed1) do Feed.create(name: "TMW Football Transfer News", url: "http://www.transfermarketweb.com/rss") end - let!(:feed_2) do + let!(:feed2) do Feed.create( name: "GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home", url: "http://feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots" @@ -30,26 +30,26 @@ def import before { import } it "retains exising feeds" do - expect(feed_1).to be_valid - expect(feed_2).to be_valid + expect(feed1).to be_valid + expect(feed2).to be_valid end it "creates new groups" do - expect(group_1).to be - expect(group_2).to be + expect(group1).to be + expect(group2).to be end it "sets group_id for existing feeds" do - expect(feed_1.reload.group).to eq group_1 - expect(feed_2.reload.group).to eq group_2 + expect(feed1.reload.group).to eq group1 + expect(feed2.reload.group).to eq group2 end end context "creates new feeds with groups" do - let(:feed_1) do + let(:feed1) do Feed.where(name: "TMW Football Transfer News", url: "http://www.transfermarketweb.com/rss") end - let(:feed_2) do + let(:feed2) do Feed.where( name: "GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home", url: "http://feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots" @@ -58,34 +58,34 @@ def import before { import } it "creates groups" do - expect(group_1).to be - expect(group_1).to be + expect(group1).to be + expect(group1).to be end it "creates feeds" do - expect(feed_1).to exist - expect(feed_2).to exist + expect(feed1).to exist + expect(feed2).to exist end it "sets group" do - expect(feed_1.first.group).to eq group_1 - expect(feed_2.first.group).to eq group_2 + expect(feed1.first.group).to eq group1 + expect(feed2.first.group).to eq group2 end end context "creates new feeds without group" do - let(:feed_1) { Feed.where(name: "Autoblog", url: "http://feeds.autoblog.com/weblogsinc/autoblog/").first } - let(:feed_2) { Feed.where(name: "City Guide News", url: "http://www.probki.net/news/RSS_news_feed.asp").first } + let(:feed1) { Feed.where(name: "Autoblog", url: "http://feeds.autoblog.com/weblogsinc/autoblog/").first } + let(:feed2) { Feed.where(name: "City Guide News", url: "http://www.probki.net/news/RSS_news_feed.asp").first } before { import } it "does not create any new group for feeds without group" do - expect(Group.where("id NOT IN (?)", [group_1.id, group_2.id]).count).to eq 0 + expect(Group.where("id NOT IN (?)", [group1.id, group2.id]).count).to eq 0 end it "creates feeds without group_id" do - expect(feed_1.group_id).to be_nil - expect(feed_2.group_id).to be_nil + expect(feed1.group_id).to be_nil + expect(feed2.group_id).to be_nil end end end diff --git a/spec/factories/feed_factory.rb b/spec/factories/feed_factory.rb index ccad1c46f..3c64ab1ef 100644 --- a/spec/factories/feed_factory.rb +++ b/spec/factories/feed_factory.rb @@ -17,7 +17,7 @@ def self.build(params = {}) FakeFeed.new( id: rand(100), group_id: params[:group_id] || rand(100), - name: params[:name] || Faker::Name.name + " on Software", + name: params[:name] || Faker::Name.name + " on Software", # rubocop:disable Style/StringConcatenation url: params[:url] || Faker::Internet.url, last_fetched: params[:last_fetched] || Time.now, stories: params[:stories] || [], diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rb index d761a5820..bcbcd6d00 100644 --- a/spec/factories/group_factory.rb +++ b/spec/factories/group_factory.rb @@ -11,7 +11,7 @@ def as_fever_json def self.build(params = {}) FakeGroup.new( id: rand(100), - name: params[:name] || Faker::Name.name + " group" + name: params[:name] || Faker::Name.name + " group" # rubocop:disable Style/StringConcatenation ) end end diff --git a/spec/fever_api/read_groups_spec.rb b/spec/fever_api/read_groups_spec.rb index b2c958bb6..6c5bbf33d 100644 --- a/spec/fever_api/read_groups_spec.rb +++ b/spec/fever_api/read_groups_spec.rb @@ -3,14 +3,14 @@ app_require "fever_api/read_groups" describe FeverAPI::ReadGroups do - let(:group_1) { double("group_1", as_fever_json: { id: 1, title: "IT news" }) } - let(:group_2) { double("group_2", as_fever_json: { id: 2, title: "World news" }) } + let(:group1) { double("group1", as_fever_json: { id: 1, title: "IT news" }) } + let(:group2) { double("group2", as_fever_json: { id: 2, title: "World news" }) } let(:group_repository) { double("repo") } subject { FeverAPI::ReadGroups.new(group_repository: group_repository) } it "returns a group list if requested" do - expect(group_repository).to receive(:list).and_return([group_1, group_2]) + expect(group_repository).to receive(:list).and_return([group1, group2]) expect(subject.call("groups" => nil)).to eq( groups: [ { diff --git a/spec/helpers/authentications_helper_spec.rb b/spec/helpers/authentications_helper_spec.rb index 325dce20b..5407bb13f 100644 --- a/spec/helpers/authentications_helper_spec.rb +++ b/spec/helpers/authentications_helper_spec.rb @@ -3,7 +3,7 @@ app_require "helpers/authentication_helpers" RSpec.describe Sinatra::AuthenticationHelpers do - class Helper + class Helper # rubocop:disable Lint/ConstantDefinitionInBlock include Sinatra::AuthenticationHelpers end diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index 9fd259c83..db775744e 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -3,7 +3,7 @@ app_require "helpers/url_helpers" RSpec.describe UrlHelpers do - class Helper + class Helper # rubocop:disable Lint/ConstantDefinitionInBlock include UrlHelpers end diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index e67568234..db0681f0d 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -87,7 +87,7 @@ def sample_data(path) end def fetch_feed(feed) - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.level = Logger::DEBUG FetchFeed.new(feed, logger: logger).fetch From 34cff7950126f4e70e586e0f4977fff48ae4a758 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 26 Feb 2021 18:07:00 -0800 Subject: [PATCH 045/779] clean up Gemfile.lock (#542) These gems aren't dependencies anywhere. Not sure why they are still lurking in our Gemfile.lock, but every time I run bundle it removes them, so might as well commit that. --- Gemfile.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7e40538af..8f5dbe187 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,6 @@ GEM ast (2.4.2) backports (3.6.8) bcrypt (3.1.11) - builder (3.2.3) byebug (2.7.0) columnize (~> 0.3) debugger-linecache (~> 1.2) @@ -72,7 +71,6 @@ GEM minitest (5.12.2) multi_json (1.14.1) multi_xml (0.6.0) - multipart-post (2.0.0) mustermann (1.0.3) nokogiri (1.11.0) mini_portile2 (~> 2.5.0) From 8d27b726cb60e67fc25bd6873a86be3f6cc64cb0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 27 Feb 2021 10:44:36 -0800 Subject: [PATCH 046/779] refactor specs for ChangePassword (#544) This makes it so that we can pass input and output to ChangePassword in order to test against them, and prevent them from outputting in the tests. --- app/tasks/change_password.rb | 14 ++++++++------ spec/tasks/change_password_spec.rb | 23 +++++++++-------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/app/tasks/change_password.rb b/app/tasks/change_password.rb index f6fbb3a26..585ba3f1d 100644 --- a/app/tasks/change_password.rb +++ b/app/tasks/change_password.rb @@ -3,13 +3,15 @@ require_relative "../commands/users/change_user_password" class ChangePassword - def initialize(command = ChangeUserPassword.new) + def initialize(command = ChangeUserPassword.new, output: $stdout, input: $stdin) @command = command + @output = output + @input = input end def change_password while (password = ask_password) != ask_confirmation - puts "The confirmation doesn't match the password. Please try again." + @output.puts "The confirmation doesn't match the password. Please try again." end @command.change_user_password(password) end @@ -25,9 +27,9 @@ def ask_confirmation end def ask_hidden(question) - print(question) - input = $stdin.noecho(&:gets).chomp - puts - input + @output.print(question) + user_input = $stdin.noecho { @input.gets }.chomp + @output.puts + user_input end end diff --git a/spec/tasks/change_password_spec.rb b/spec/tasks/change_password_spec.rb index e35b17e1e..168f5401a 100644 --- a/spec/tasks/change_password_spec.rb +++ b/spec/tasks/change_password_spec.rb @@ -3,30 +3,25 @@ app_require "tasks/change_password" describe ChangePassword do - let(:command) { double("command") } - let(:new_password) { "new-pw" } - - let(:task) { ChangePassword.new(command) } + let(:command) { instance_double(ChangeUserPassword) } describe "#change_password" do it "invokes command with confirmed password" do - expect(task).to receive(:ask_hidden).twice - .and_return(new_password, new_password) + output = StringIO.new + input = StringIO.new("new-pw\nnew-pw\n") + task = ChangePassword.new(command, output: output, input: input) - expect(command) - .to receive(:change_user_password) - .with(new_password) + expect(command).to receive(:change_user_password).with("new-pw") task.change_password end it "repeats until a matching confirmation" do - expect(task).to receive(:ask_hidden).exactly(2).times - .and_return(new_password, "", new_password, new_password) + output = StringIO.new + input = StringIO.new("woops\nnope\nnew-pw\nnew-pw\n") + task = ChangePassword.new(command, output: output, input: input) - expect(command) - .to receive(:change_user_password) - .with(new_password) + expect(command).to receive(:change_user_password).with("new-pw") task.change_password end From 647e80eef3ed1f98d8f8fb0f5f838203d5863499 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 27 Feb 2021 11:38:32 -0800 Subject: [PATCH 047/779] fix ActiveRecord deprecation warning (#545) ActiveRecord no longer wants us to pass SQL fragments to `order`. This instead makes use of the underlying framework Arel to generate the query. --- app/repositories/group_repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/repositories/group_repository.rb b/app/repositories/group_repository.rb index 61f30a914..b827dd199 100644 --- a/app/repositories/group_repository.rb +++ b/app/repositories/group_repository.rb @@ -2,6 +2,6 @@ class GroupRepository def self.list - Group.order("LOWER(name)") + Group.order(Group.arel_table[:name].lower) end end From 22d5233271972c074c668e7a341d4092581561eb Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 27 Feb 2021 18:09:50 -0800 Subject: [PATCH 048/779] Deps: fix delayed job dependency (#546) I'm a little surprised this was possible, but #533 introduced a version of ActiveRecord that did not match the constraints of `delayed_job_active_record`. I thought bundler was more strict, but it somehow allowed this one to slip through. This fixes the issue. --- Gemfile.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8f5dbe187..08e0f9e56 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,7 @@ GEM xpath (~> 2.0) coderay (1.1.1) columnize (0.9.0) - concurrent-ruby (1.1.5) + concurrent-ruby (1.1.8) coveralls (0.8.13) json (~> 1.8) simplecov (~> 0.11.0) @@ -38,10 +38,10 @@ GEM tins (~> 1.6.0) crass (1.0.5) debugger-linecache (1.2.0) - delayed_job (4.1.8) - activesupport (>= 3.0, < 6.1) - delayed_job_active_record (4.1.0) - activerecord (>= 3.0, < 5) + delayed_job (4.1.9) + activesupport (>= 3.0, < 6.2) + delayed_job_active_record (4.1.5) + activerecord (>= 3.0, < 6.2) delayed_job (>= 3.0, < 5) diff-lcs (1.2.5) docile (1.1.5) @@ -68,7 +68,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) mini_portile2 (2.5.0) - minitest (5.12.2) + minitest (5.14.4) multi_json (1.14.1) multi_xml (0.6.0) mustermann (1.0.3) @@ -171,7 +171,7 @@ GEM tilt (2.0.10) timecop (0.8.0) tins (1.6.0) - tzinfo (1.2.5) + tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (3.0.2) execjs (>= 0.3.0, < 3) From b0424bb583553e86a67afa4208aad75d223b5832 Mon Sep 17 00:00:00 2001 From: David Personette Date: Sun, 28 Feb 2021 13:53:14 -0500 Subject: [PATCH 049/779] update test gems and dependencies (#543) fix a rubocop alert from the newer version faker work around a capybara change --- Gemfile | 18 ++-- Gemfile.lock | 130 ++++++++++++------------ spec/integration/feed_importing_spec.rb | 2 - spec/models/story_spec.rb | 4 +- spec/spec_helper.rb | 4 + 5 files changed, 80 insertions(+), 78 deletions(-) diff --git a/Gemfile b/Gemfile index 5e83c25d2..aac112ed4 100644 --- a/Gemfile +++ b/Gemfile @@ -13,16 +13,16 @@ group :development do end group :development, :test do - gem "capybara", "~> 2.6" - gem "coveralls", "~> 0.7", require: false - gem "faker", "~> 1.2" - gem "pry-byebug", "~> 1.2" - gem "rack-test", "~> 1.1" - gem "rspec", "~> 3.4" - gem "rspec-html-matchers", "~> 0.7" - gem "shotgun", "~> 0.9" + gem "capybara" + gem "coveralls", "> 0.8", require: false + gem "faker" + gem "pry-byebug" + gem "rack-test" + gem "rspec" + gem "rspec-html-matchers" + gem "shotgun" gem "simplecov" - gem "timecop", "~> 0.8" + gem "timecop" end gem "activerecord", "~> 5.0" diff --git a/Gemfile.lock b/Gemfile.lock index 08e0f9e56..f6230e27e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,42 +12,40 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.4.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) arel (9.0.0) ast (2.4.2) backports (3.6.8) bcrypt (3.1.11) - byebug (2.7.0) - columnize (~> 0.3) - debugger-linecache (~> 1.2) - capybara (2.6.2) + byebug (11.1.3) + capybara (3.35.3) addressable - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - coderay (1.1.1) - columnize (0.9.0) + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + coderay (1.1.3) concurrent-ruby (1.1.8) - coveralls (0.8.13) - json (~> 1.8) - simplecov (~> 0.11.0) + coveralls (0.8.23) + json (>= 1.8, < 3) + simplecov (~> 0.16.1) term-ansicolor (~> 1.3) - thor (~> 0.19.1) - tins (~> 1.6.0) + thor (>= 0.19.4, < 2.0) + tins (~> 1.6) crass (1.0.5) - debugger-linecache (1.2.0) delayed_job (4.1.9) activesupport (>= 3.0, < 6.2) delayed_job_active_record (4.1.5) activerecord (>= 3.0, < 6.2) delayed_job (>= 3.0, < 5) diff-lcs (1.2.5) - docile (1.1.5) + docile (1.3.5) execjs (2.7.0) - faker (1.6.3) - i18n (~> 0.5) + faker (2.16.0) + i18n (>= 1.6, < 2) feedbag (0.9.5) nokogiri (~> 1.0) feedjira (3.1.2) @@ -56,36 +54,37 @@ GEM httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (0.9.5) + i18n (1.8.9) concurrent-ruby (~> 1.0) - json (1.8.6) + json (2.5.1) kgio (2.11.2) loofah (2.3.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - method_source (0.8.2) + method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0221) + mini_mime (1.0.2) mini_portile2 (2.5.0) minitest (5.14.4) multi_json (1.14.1) multi_xml (0.6.0) mustermann (1.0.3) - nokogiri (1.11.0) + nokogiri (1.11.1) mini_portile2 (~> 2.5.0) racc (~> 1.4) parallel (1.20.1) parser (3.0.0.0) ast (~> 2.4.1) pg (0.18.4) - pry (0.10.3) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-byebug (1.3.3) - byebug (~> 2.7) - pry (~> 0.10) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.9.0) + byebug (~> 11.0) + pry (~> 0.13.0) + public_suffix (4.0.6) racc (1.5.2) rack (2.2.3) rack-protection (2.0.7) @@ -102,22 +101,22 @@ GEM rake (12.3.3) regexp_parser (2.1.1) rexml (3.2.4) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-html-matchers (0.7.1) + rspec-support (~> 3.10.0) + rspec-html-matchers (0.9.4) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.4.1) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) + rspec-support (~> 3.10.0) + rspec-support (3.10.2) rubocop (1.10.0) parallel (~> 1.10) parser (>= 3.0.0.0) @@ -132,13 +131,13 @@ GEM ruby-progressbar (1.11.0) sass (3.4.22) sax-machine (1.3.2) - shotgun (0.9.1) + shotgun (0.9.2) rack (>= 1.0) - simplecov (0.11.2) - docile (~> 1.1.0) - json (~> 1.8) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.2) sinatra (2.0.7) mustermann (~> 1.0) rack (~> 2.0) @@ -156,21 +155,22 @@ GEM tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) - slop (3.6.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-helpers (1.2.1) sprockets (>= 2.2) sqlite3 (1.4.2) - term-ansicolor (1.3.2) + sync (0.5.0) + term-ansicolor (1.7.1) tins (~> 1.0) - thor (0.19.1) + thor (1.1.0) thread (0.2.2) thread_safe (0.3.6) tilt (2.0.10) - timecop (0.8.0) - tins (1.6.0) + timecop (0.9.4) + tins (1.28.0) + sync tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (3.0.2) @@ -180,8 +180,8 @@ GEM kgio (~> 2.6) raindrops (~> 0.7) will_paginate (3.1.0) - xpath (2.0.0) - nokogiri (~> 1.3) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS ruby @@ -189,11 +189,11 @@ PLATFORMS DEPENDENCIES activerecord (~> 5.0) bcrypt (~> 3.1) - capybara (~> 2.6) - coveralls (~> 0.7) + capybara + coveralls (> 0.8) delayed_job (~> 4.1) delayed_job_active_record (~> 4.1) - faker (~> 1.2) + faker feedbag (~> 0.9.5) feedjira (~> 3.0) httparty @@ -201,17 +201,17 @@ DEPENDENCIES loofah (~> 2.3) nokogiri (~> 1.11) pg (~> 0.18.4) - pry-byebug (~> 1.2) + pry-byebug rack-protection (~> 2.0) rack-ssl (~> 1.4) - rack-test (~> 1.1) + rack-test racksh (~> 1.0) rake (~> 12.3) - rspec (~> 3.4) - rspec-html-matchers (~> 0.7) + rspec + rspec-html-matchers rubocop sass - shotgun (~> 0.9) + shotgun simplecov sinatra (~> 2.0) sinatra-activerecord (~> 2.0) @@ -221,7 +221,7 @@ DEPENDENCIES sprockets-helpers sqlite3 thread (~> 0.2) - timecop (~> 0.8) + timecop uglifier unicorn (~> 5.3) will_paginate (~> 3.1) diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index db0681f0d..f938381cf 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -2,8 +2,6 @@ require "time" require "support/active_record" require "support/feed_server" -require "capybara" -require "capybara/server" require "timecop" app_require "tasks/fetch_feed" diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 058473613..01ce0aea7 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -6,8 +6,8 @@ describe "Story" do let(:story) do Story.new( - title: Faker::Lorem.sentence(50), - body: Faker::Lorem.sentence(50) + title: Faker::Lorem.sentence(word_count: 50), + body: Faker::Lorem.sentence(word_count: 50) ) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0afb6ad4d..b2b783241 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ ENV["RACK_ENV"] = "test" +require "capybara" +require "capybara/server" require "rspec" require "rspec-html-matchers" require "rack/test" @@ -13,6 +15,8 @@ require "./app" +Capybara.server = :webrick + RSpec.configure do |config| config.include Rack::Test::Methods config.include RSpecHtmlMatchers From 49516f47615428ba6df01884702592a9cffd1759 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 28 Feb 2021 12:16:29 -0800 Subject: [PATCH 050/779] Rubocop: enable all rubocop rules by default (#548) And auto generate the configuration --- .rubocop.yml | 5 ++ .rubocop_todo.yml | 212 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 204 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index cb431f7fb..192202fff 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,8 @@ inherit_from: .rubocop_todo.yml AllCops: + DisplayCopNames: true + EnabledByDefault: true Exclude: - 'db/schema.rb' - 'vendor/**/*' @@ -11,6 +13,9 @@ Layout/LineLength: Metrics/MethodLength: Max: 15 +Style/Copyright: + Enabled: false + Style/Documentation: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ad41fdec2..c8f055358 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,42 +1,180 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-11-16 20:15:02 +0100 using RuboCop version 0.76.0. +# on 2021-02-28 19:30:55 UTC using RuboCop version 1.10.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 41 -# Configuration parameters: CountComments, ExcludedMethods. -# ExcludedMethods: refine -Metrics/BlockLength: +# Offense count: 38 +# Configuration parameters: Include, IgnoredGems, OnlyFor. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/GemComment: Exclude: - - 'spec/**/*' + - 'Gemfile' + +# Offense count: 9 +# Cop supports --auto-correct. +Layout/FirstMethodArgumentLineBreak: + Exclude: + - 'app/commands/feeds/add_new_feed.rb' + - 'app/commands/users/create_user.rb' + - 'app/repositories/story_repository.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedTypes: block, case, class, if, kwbegin, module +# SupportedStyles: same_line, new_line +Layout/MultilineAssignmentLayout: + Exclude: + - 'app/commands/feeds/export_to_opml.rb' + - 'app/fever_api/read_items.rb' + - 'app/jobs/fetch_feed_job.rb' + - 'app/utils/sample_story.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Layout/MultilineMethodArgumentLineBreaks: + Exclude: + - 'app/controllers/debug_controller.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/javascript/test_controller.rb' + +# Offense count: 702 +# Configuration parameters: Only, Ignore. +Lint/ConstantResolution: + Enabled: false + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'spec/repositories/story_repository_spec.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods, IgnoredClasses. +# IgnoredClasses: Time, DateTime +Lint/NumberConversion: + Exclude: + - 'Rakefile' + - 'app/commands/stories/mark_feed_as_read.rb' + - 'app/commands/stories/mark_group_as_read.rb' + - 'app/fever_api/authentication.rb' + - 'app/models/feed.rb' + - 'app/models/story.rb' + - 'app/repositories/story_repository.rb' + - 'spec/factories/feed_factory.rb' + - 'spec/factories/story_factory.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/story_spec.rb' + +# Offense count: 47 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine +Metrics/BlockLength: + Max: 183 # Offense count: 9 -# Configuration parameters: Blacklist. -# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - 'app/utils/sample_story.rb' - 'spec/helpers/url_helpers_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 139 +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. +# MethodsAcceptingSymbol: inject, reduce +Style/CollectionMethods: + Exclude: + - 'app/controllers/stories_controller.rb' + - 'app/fever_api/response.rb' + +# Offense count: 10 +# Configuration parameters: IgnoreModules. +Style/ConstantVisibility: + Exclude: + - 'app/commands/feeds/add_new_feed.rb' + - 'app/commands/feeds/find_new_stories.rb' + - 'app/commands/feeds/import_from_opml.rb' + - 'app/commands/stories/mark_group_as_read.rb' + - 'app/fever_api/response.rb' + - 'app/helpers/url_helpers.rb' + - 'app/models/story.rb' + - 'app/repositories/feed_repository.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: AllowedCops. +Style/DisableCopsWithinSourceCodeDirective: + Exclude: + - 'app/commands/feeds/export_to_opml.rb' + - 'app/utils/sample_story.rb' + - 'spec/factories/feed_factory.rb' + - 'spec/factories/group_factory.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + +# Offense count: 166 +# Configuration parameters: RequireForNonPublicMethods. +Style/DocumentationMethod: + Enabled: false + +# Offense count: 150 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. -# SupportedStyles: always, never +# SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Enabled: false +# Offense count: 1 +Style/InlineComment: + Exclude: + - 'app/utils/opml_parser.rb' + +# Offense count: 652 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle. +# SupportedStyles: require_parentheses, omit_parentheses +Style/MethodCallWithArgsParentheses: + Enabled: false + +# Offense count: 8 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: if, case, both +Style/MissingElse: + Exclude: + - 'Rakefile' + - 'app.rb' + - 'app/commands/stories/mark_group_as_read.rb' + - 'app/fever_api/write_mark_item.rb' + - 'app/helpers/url_helpers.rb' + - 'app/repositories/story_repository.rb' + - 'config/unicorn.rb' + - 'spec/support/coverage.rb' + # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# Configuration parameters: EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: + - 'spec/**/*' - 'app/commands/stories/mark_group_as_read.rb' +# Offense count: 32 +# Configuration parameters: SuspiciousParamNames. +# SuspiciousParamNames: options, opts, args, params, parameters +Style/OptionHash: + Enabled: false + # Offense count: 12 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. @@ -52,12 +190,60 @@ Style/PercentLiteralDelimiters: # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. -# Whitelist: present?, blank?, presence, try, try! +# Configuration parameters: EnforcedStyle. +# SupportedStyles: return, return_nil +Style/ReturnNil: + Exclude: + - 'app/repositories/user_repository.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - 'app/controllers/feeds_controller.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Methods. +# Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]} +Style/SingleLineBlockParams: + Exclude: + - 'app/fever_api/response.rb' + +# Offense count: 10 +Style/StaticClass: + Exclude: + - 'app/commands/feeds/add_new_feed.rb' + - 'app/commands/users/complete_setup.rb' + - 'app/commands/users/sign_in_user.rb' + - 'app/repositories/feed_repository.rb' + - 'app/repositories/group_repository.rb' + - 'app/repositories/story_repository.rb' + - 'app/repositories/user_repository.rb' + - 'app/tasks/remove_old_stories.rb' + - 'app/utils/api_key.rb' + - 'app/utils/content_sanitizer.rb' + +# Offense count: 18 +# Cop supports --auto-correct. +Style/StringHashKeys: + Exclude: + - 'fever_api.rb' + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/fever_api/read_favicons_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/read_links_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/helpers/authentications_helper_spec.rb' + # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: MinSize. From e7ab9be94a25611ea01848da8d249a28aab4387e Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 28 Feb 2021 12:16:38 -0800 Subject: [PATCH 051/779] Specs: add tests for FetchFeeds (#547) This is super janky, grabbing the instance variable out of the instance, but there doesn't seem to be a great way to test for the underlying issue, which is that in some cases jobs don't work when passing the entire record. I thought also about inspecting the job more closely, but wasn't able to think of a great solution there, either. I'd like to refactor this class some down the road to not try to juggle both `@feeds_ids` and `@feeds` variables. --- app/tasks/fetch_feeds.rb | 1 + spec/factories/feeds.rb | 2 +- spec/tasks/fetch_feeds_spec.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/tasks/fetch_feeds.rb b/app/tasks/fetch_feeds.rb index 73cfc2c68..f4085abc2 100644 --- a/app/tasks/fetch_feeds.rb +++ b/app/tasks/fetch_feeds.rb @@ -1,6 +1,7 @@ require "thread/pool" require_relative "fetch_feed" +require "delayed_job_active_record" class FetchFeeds def initialize(feeds, pool = nil) diff --git a/spec/factories/feeds.rb b/spec/factories/feeds.rb index 4047705c0..e0a2f50f5 100644 --- a/spec/factories/feeds.rb +++ b/spec/factories/feeds.rb @@ -4,6 +4,6 @@ def create_feed(params = {}) end def build_feed(params = {}) - Feed.new(**params) + Feed.new(url: "https://exampoo.com/#{next_id}", **params) end end diff --git a/spec/tasks/fetch_feeds_spec.rb b/spec/tasks/fetch_feeds_spec.rb index 80ad429ac..9a7ce4ffd 100644 --- a/spec/tasks/fetch_feeds_spec.rb +++ b/spec/tasks/fetch_feeds_spec.rb @@ -1,4 +1,5 @@ require "spec_helper" +require "support/active_record" describe FetchFeeds do describe "#fetch_all" do @@ -19,4 +20,29 @@ FetchFeeds.new(feeds, pool).fetch_all end end + + describe "#prepare_to_delay" do + it "serializes the instance for backgrounding" do + feeds = [create_feed, create_feed] + feeds_ids = feeds.map(&:id) + fetch_feeds = FetchFeeds.new(feeds) + + fetch_feeds.prepare_to_delay + + expect(fetch_feeds.instance_variable_get(:@feeds)).to be_empty + expect(fetch_feeds.instance_variable_get(:@feeds_ids)).to eq(feeds_ids) + end + end + + describe ".enqueue" do + it "enqueues a fetch_all job" do + feeds = [create_feed, create_feed] + feeds_ids = feeds.map(&:id) + + expect { FetchFeeds.enqueue(feeds) }.to change(Delayed::Job, :count).by(1) + + job_object = Delayed::Job.last.payload_object.object + expect(job_object.instance_variable_get(:@feeds_ids)).to eq(feeds_ids) + end + end end From e72799214c717cb3165f12c65b41ab21fa07c9e9 Mon Sep 17 00:00:00 2001 From: David Personette Date: Sun, 28 Feb 2021 22:00:58 -0500 Subject: [PATCH 052/779] update the prod gems (#549) --- Gemfile | 40 +++++++++--------- Gemfile.lock | 112 ++++++++++++++++++++++++++++----------------------- 2 files changed, 81 insertions(+), 71 deletions(-) diff --git a/Gemfile b/Gemfile index aac112ed4..d76f6838a 100644 --- a/Gemfile +++ b/Gemfile @@ -3,8 +3,8 @@ ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file) source "https://rubygems.org" group :production do - gem "pg", "~> 0.18.4" - gem "unicorn", "~> 5.3" + gem "pg" + gem "unicorn" end group :development do @@ -26,26 +26,26 @@ group :development, :test do end gem "activerecord", "~> 5.0" -gem "bcrypt", "~> 3.1" -gem "delayed_job", "~> 4.1" -gem "delayed_job_active_record", "~> 4.1" -gem "feedbag", "~> 0.9.5" -gem "feedjira", "~> 3.0" +gem "bcrypt" +gem "delayed_job" +gem "delayed_job_active_record" +gem "feedbag" +gem "feedjira" gem "httparty" gem "i18n" -gem "loofah", "~> 2.3" -gem "nokogiri", "~> 1.11" -gem "rack-protection", "~> 2.0" -gem "racksh", "~> 1.0" -gem "rack-ssl", "~> 1.4" -gem "rake", "~> 12.3" +gem "loofah" +gem "nokogiri" +gem "rack-protection" +gem "racksh" +gem "rack-ssl" +gem "rake" gem "sass" -gem "sinatra", "~> 2.0" -gem "sinatra-activerecord", "~> 2.0" -gem "sinatra-contrib", "~> 2.0" -gem "sinatra-flash", "~> 0.3" -gem "sprockets", "~> 3.7" +gem "sinatra" +gem "sinatra-activerecord" +gem "sinatra-contrib" +gem "sinatra-flash" +gem "sprockets" gem "sprockets-helpers" -gem "thread", "~> 0.2" +gem "thread" gem "uglifier" -gem "will_paginate", "~> 3.1" +gem "will_paginate" diff --git a/Gemfile.lock b/Gemfile.lock index f6230e27e..e1739c9ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,8 +16,7 @@ GEM public_suffix (>= 2.0.2, < 5.0) arel (9.0.0) ast (2.4.2) - backports (3.6.8) - bcrypt (3.1.11) + bcrypt (3.1.16) byebug (11.1.3) capybara (3.35.3) addressable @@ -35,49 +34,53 @@ GEM term-ansicolor (~> 1.3) thor (>= 0.19.4, < 2.0) tins (~> 1.6) - crass (1.0.5) + crass (1.0.6) delayed_job (4.1.9) activesupport (>= 3.0, < 6.2) delayed_job_active_record (4.1.5) activerecord (>= 3.0, < 6.2) delayed_job (>= 3.0, < 5) - diff-lcs (1.2.5) + diff-lcs (1.4.4) docile (1.3.5) execjs (2.7.0) faker (2.16.0) i18n (>= 1.6, < 2) - feedbag (0.9.5) - nokogiri (~> 1.0) + feedbag (0.10.1) + nokogiri (~> 1.8, >= 1.8.2) + open_uri_redirections (~> 0.2) feedjira (3.1.2) loofah (>= 2.3.1) sax-machine (>= 1.0) + ffi (1.14.2) httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) i18n (1.8.9) concurrent-ruby (~> 1.0) json (2.5.1) - kgio (2.11.2) - loofah (2.3.1) + kgio (2.11.3) + loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0221) + mime-types-data (3.2021.0212) mini_mime (1.0.2) mini_portile2 (2.5.0) minitest (5.14.4) - multi_json (1.14.1) + multi_json (1.15.0) multi_xml (0.6.0) - mustermann (1.0.3) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) nokogiri (1.11.1) mini_portile2 (~> 2.5.0) racc (~> 1.4) + open_uri_redirections (0.2.1) parallel (1.20.1) parser (3.0.0.0) ast (~> 2.4.1) - pg (0.18.4) + pg (1.2.3) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -87,7 +90,7 @@ GEM public_suffix (4.0.6) racc (1.5.2) rack (2.2.3) - rack-protection (2.0.7) + rack-protection (2.1.0) rack rack-ssl (1.4.1) rack @@ -97,8 +100,11 @@ GEM rack (>= 1.0) rack-test (>= 0.5) rainbow (3.0.0) - raindrops (0.19.0) - rake (12.3.3) + raindrops (0.19.1) + rake (13.0.3) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) regexp_parser (2.1.1) rexml (3.2.4) rspec (3.10.0) @@ -129,7 +135,12 @@ GEM rubocop-ast (1.4.1) parser (>= 2.7.1.5) ruby-progressbar (1.11.0) - sass (3.4.22) + ruby2_keywords (0.0.4) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) sax-machine (1.3.2) shotgun (0.9.2) rack (>= 1.0) @@ -138,27 +149,26 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sinatra (2.0.7) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.14) - activerecord (>= 3.2) + sinatra-activerecord (2.0.22) + activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (2.0.7) - backports (>= 2.8.2) + sinatra-contrib (2.1.0) multi_json mustermann (~> 1.0) - rack-protection (= 2.0.7) - sinatra (= 2.0.7) + rack-protection (= 2.1.0) + sinatra (= 2.1.0) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) - sprockets (3.7.2) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-helpers (1.2.1) + sprockets-helpers (1.4.0) sprockets (>= 2.2) sqlite3 (1.4.2) sync (0.5.0) @@ -173,13 +183,13 @@ GEM sync tzinfo (1.2.9) thread_safe (~> 0.1) - uglifier (3.0.2) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.0.0) - unicorn (5.4.0) + unicorn (5.8.0) kgio (~> 2.6) raindrops (~> 0.7) - will_paginate (3.1.0) + will_paginate (3.3.0) xpath (3.2.0) nokogiri (~> 1.8) @@ -188,46 +198,46 @@ PLATFORMS DEPENDENCIES activerecord (~> 5.0) - bcrypt (~> 3.1) + bcrypt capybara coveralls (> 0.8) - delayed_job (~> 4.1) - delayed_job_active_record (~> 4.1) + delayed_job + delayed_job_active_record faker - feedbag (~> 0.9.5) - feedjira (~> 3.0) + feedbag + feedjira httparty i18n - loofah (~> 2.3) - nokogiri (~> 1.11) - pg (~> 0.18.4) + loofah + nokogiri + pg pry-byebug - rack-protection (~> 2.0) - rack-ssl (~> 1.4) + rack-protection + rack-ssl rack-test - racksh (~> 1.0) - rake (~> 12.3) + racksh + rake rspec rspec-html-matchers rubocop sass shotgun simplecov - sinatra (~> 2.0) - sinatra-activerecord (~> 2.0) - sinatra-contrib (~> 2.0) - sinatra-flash (~> 0.3) - sprockets (~> 3.7) + sinatra + sinatra-activerecord + sinatra-contrib + sinatra-flash + sprockets sprockets-helpers sqlite3 - thread (~> 0.2) + thread timecop uglifier - unicorn (~> 5.3) - will_paginate (~> 3.1) + unicorn + will_paginate RUBY VERSION ruby 2.6.5p114 BUNDLED WITH - 1.17.3 + 2.1.4 From 974153ecc178f9da690e9c0ac61878d66b0ec56d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 1 Mar 2021 10:28:11 -0800 Subject: [PATCH 053/779] Deps: switch to latest bundler version (#551) --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e1739c9ea..7f8d22ce7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -240,4 +240,4 @@ RUBY VERSION ruby 2.6.5p114 BUNDLED WITH - 2.1.4 + 2.2.12 From c9da11f3ad2de48145919b18e59a009861555a35 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 1 Mar 2021 10:46:47 -0800 Subject: [PATCH 054/779] Specs: add more tests for StoryRepository (#552) --- .rubocop.yml | 3 ++ spec/factories/stories.rb | 12 +++-- spec/repositories/story_repository_spec.rb | 62 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 192202fff..d5b2b46e3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,6 +13,9 @@ Layout/LineLength: Metrics/MethodLength: Max: 15 +Style/ConstantVisibility: + Enabled: false + Style/Copyright: Enabled: false diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index 191c74fb9..18aa9ca23 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -1,9 +1,15 @@ module Factories - def create_story(params = {}) - build_story(params).tap(&:save!) + STORY_TRAITS = { + unread: -> { { is_read: false } } + }.freeze + + def create_story(*traits, **params) + build_story(*traits, **params).tap(&:save!) end - def build_story(params = {}) + def build_story(*traits, **params) + traits.each { |trait| params.merge!(STORY_TRAITS.fetch(trait).call) } + Story.new(entry_id: next_id, feed: build_feed, **params) end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 96ae1bb2e..e07645496 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -82,6 +82,68 @@ end end + describe ".fetch_unread_by_timestamp_and_group" do + it "returns unread stories before timestamp for group_id" do + feed = create_feed(group_id: 52) + story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + time = Time.now + + stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + + expect(stories).to eq([story]) + end + + it "does not return read stories before timestamp for group_id" do + feed = create_feed(group_id: 52) + create_story(feed: feed, created_at: 5.minutes.ago) + time = Time.now + + stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + + expect(stories).to be_empty + end + + it "does not return unread stories after timestamp for group_id" do + feed = create_feed(group_id: 52) + create_story(:unread, feed: feed, created_at: 5.minutes.ago) + time = 6.minutes.ago + + stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + + expect(stories).to be_empty + end + + it "does not return stories before timestamp for other group_id" do + feed = create_feed(group_id: 52) + create_story(:unread, feed: feed, created_at: 5.minutes.ago) + time = Time.now + + stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 55) + + expect(stories).to be_empty + end + + it "does not return stories with no group_id before timestamp" do + feed = create_feed + create_story(:unread, feed: feed, created_at: 5.minutes.ago) + time = Time.now + + stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + + expect(stories).to be_empty + end + + it "returns unread stories before timestamp for nil group_id" do + feed = create_feed + story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + time = Time.now + + stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, nil) + + expect(stories).to eq([story]) + end + end + describe ".extract_url" do it "returns the url" do feed = double(url: "http://github.com") From 71c82e23ea3b7a97d712323e6c5ea0af5d9d7ae2 Mon Sep 17 00:00:00 2001 From: David Personette Date: Mon, 1 Mar 2021 14:58:44 -0500 Subject: [PATCH 055/779] update ruby version (#550) --- .ruby-version | 2 +- .travis.yml | 2 +- Gemfile.lock | 2 +- docs/VPS.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.ruby-version b/.ruby-version index 57cf282eb..37c2961c2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.5 +2.7.2 diff --git a/.travis.yml b/.travis.yml index a819d6f5b..95f247571 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ before_script: cache: bundler language: ruby rvm: - - 2.6.5 + - 2.7.2 - ruby-head matrix: allow_failures: diff --git a/Gemfile.lock b/Gemfile.lock index 7f8d22ce7..7ba934a21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -237,7 +237,7 @@ DEPENDENCIES will_paginate RUBY VERSION - ruby 2.6.5p114 + ruby 2.7.2 BUNDLED WITH 2.2.12 diff --git a/docs/VPS.md b/docs/VPS.md index 6f70a0faf..21308c835 100644 --- a/docs/VPS.md +++ b/docs/VPS.md @@ -61,8 +61,8 @@ We are going to use Rbenv to manage the version of Ruby you use. git clone git://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build source ~/.bash_profile - rbenv install 2.6.5 - rbenv local 2.6.5 + rbenv install 2.7.2 + rbenv local 2.7.2 rbenv rehash We also need to install bundler which will handle Stringer's dependencies From 72051449290691165b2d920985d714dd48ef99f3 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Wed, 3 Mar 2021 14:07:22 -0800 Subject: [PATCH 056/779] Specs: add test for /heroku endpoint (#553) --- spec/controllers/debug_controller_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index f4e1a1922..3c435ef9a 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -46,4 +46,12 @@ expect(page).to have_tag("li", text: /Migration C - 3/) end end + + describe "#heroku" do + it "displays Heroku instructions" do + get("/heroku") + + expect(last_response.body).to include("add an hourly task") + end + end end From bc1c3593aab575068c5d7b40591d5631d17fb1a6 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 5 Mar 2021 14:36:20 -0800 Subject: [PATCH 057/779] Specs: add tests for asset_pipeline.rb (#554) I enabled settings for test mode, which doesn't seem to noticeably impact performance, but gives us a little bit more test coverage. --- config/asset_pipeline.rb | 4 ++-- spec/config/asset_pipeline_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 spec/config/asset_pipeline_spec.rb diff --git a/config/asset_pipeline.rb b/config/asset_pipeline.rb index 73818fd89..68fc62ed1 100644 --- a/config/asset_pipeline.rb +++ b/config/asset_pipeline.rb @@ -22,13 +22,13 @@ def append_paths(app) end def configure_development(app) - app.configure :development do + app.configure :development, :test do app.sprockets.cache = Sprockets::Cache::FileStore.new("./tmp") end end def configure_production(app) - app.configure :production do + app.configure :production, :test do app.sprockets.css_compressor = :scss app.sprockets.js_compressor = :uglify end diff --git a/spec/config/asset_pipeline_spec.rb b/spec/config/asset_pipeline_spec.rb new file mode 100644 index 000000000..4eb814211 --- /dev/null +++ b/spec/config/asset_pipeline_spec.rb @@ -0,0 +1,9 @@ +require "spec_helper" + +describe "AssetPipeline" do + it "handles asset requests" do + get("/assets/stylesheets/application.css") + + expect(last_response.body).to match("#feed-title") + end +end From b491326ef66afb45f2e7ff49c74640814e22c6a6 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 6 Mar 2021 10:55:25 -0800 Subject: [PATCH 058/779] Specs: add more tests for StoryRepository (#555) --- .rubocop.yml | 4 + spec/repositories/story_repository_spec.rb | 96 ++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index d5b2b46e3..dcf06b104 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,6 +10,10 @@ AllCops: Layout/LineLength: Max: 120 +Metrics/BlockLength: + Exclude: + - 'spec/**/*_spec.rb' + Metrics/MethodLength: Max: 15 diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index e07645496..3641e5162 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -144,6 +144,102 @@ end end + describe ".fetch_unread_for_feed_by_timestamp" do + it "returns unread stories for the feed before timestamp" do + feed = create_feed + story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + time = 4.minutes.ago + + stories = + StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + + expect(stories).to eq([story]) + end + + it "returns unread stories for the feed before string timestamp" do + feed = create_feed + story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + timestamp = Integer(4.minutes.ago).to_s + + stories = + StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, timestamp) + + expect(stories).to eq([story]) + end + + it "does not return read stories for the feed before timestamp" do + feed = create_feed + create_story(feed: feed, created_at: 5.minutes.ago) + time = 4.minutes.ago + + stories = + StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + + expect(stories).to be_empty + end + + it "does not return unread stories for the feed after timestamp" do + feed = create_feed + create_story(:unread, feed: feed, created_at: 5.minutes.ago) + time = 6.minutes.ago + + stories = + StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + + expect(stories).to be_empty + end + + it "does not return unread stories for another feed before timestamp" do + feed = create_feed + create_story(:unread, created_at: 5.minutes.ago) + time = 4.minutes.ago + + stories = + StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + + expect(stories).to be_empty + end + end + + describe ".unread" do + it "returns unread stories ordered by published date descending" do + story1 = create_story(:unread, published: 5.minutes.ago) + story2 = create_story(:unread, published: 4.minutes.ago) + + expect(StoryRepository.unread).to eq([story2, story1]) + end + + it "does not return read stories" do + create_story(published: 5.minutes.ago) + create_story(published: 4.minutes.ago) + + expect(StoryRepository.unread).to be_empty + end + end + + describe ".unread_since_id" do + it "returns unread stories with id greater than given id" do + story1 = create_story(:unread) + story2 = create_story(:unread) + + expect(StoryRepository.unread_since_id(story1.id)).to eq([story2]) + end + + it "does not return read stories with id greater than given id" do + story1 = create_story(:unread) + create_story + + expect(StoryRepository.unread_since_id(story1.id)).to be_empty + end + + it "does not return unread stories with id less than given id" do + create_story(:unread) + story2 = create_story(:unread) + + expect(StoryRepository.unread_since_id(story2.id)).to be_empty + end + end + describe ".extract_url" do it "returns the url" do feed = double(url: "http://github.com") From 850a7d44dbcc36e6a5e59fb01feb45ecf1772bcc Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 13 Mar 2021 12:02:30 -0800 Subject: [PATCH 059/779] Specs: add test coverage for FeedRepository (#556) * Add tests for `.fetch_by_ids`, `.delete`, `.list`, and `.in_group` * Rearrange test file to mirror ordering of class * Fix deprecation warning for `lower(name)` * Refactor `in_group` query to use AR syntax --- app/repositories/feed_repository.rb | 4 +- spec/repositories/feed_repository_spec.rb | 91 +++++++++++++++++++---- 2 files changed, 78 insertions(+), 17 deletions(-) diff --git a/app/repositories/feed_repository.rb b/app/repositories/feed_repository.rb index dcce4fcdd..5deee8e22 100644 --- a/app/repositories/feed_repository.rb +++ b/app/repositories/feed_repository.rb @@ -35,11 +35,11 @@ def self.set_status(status, feed) end def self.list - Feed.order("lower(name)") + Feed.order(Feed.arel_table[:name].lower) end def self.in_group - Feed.where("group_id IS NOT NULL") + Feed.where.not(group_id: nil) end def self.valid_timestamp?(new_timestamp, current_timestamp) diff --git a/spec/repositories/feed_repository_spec.rb b/spec/repositories/feed_repository_spec.rb index 1951019f5..75ab32846 100644 --- a/spec/repositories/feed_repository_spec.rb +++ b/spec/repositories/feed_repository_spec.rb @@ -4,6 +4,49 @@ app_require "repositories/feed_repository" describe FeedRepository do + describe ".fetch" do + let(:feed) { Feed.new(id: 1) } + + it "finds by id" do + expect(Feed).to receive(:find).with(feed.id).and_return(feed) + FeedRepository.fetch(feed.id) + end + + it "returns found feed" do + allow(Feed).to receive(:find).with(feed.id).and_return(feed) + + result = FeedRepository.fetch(feed.id) + + expect(result).to eq feed + end + end + + describe ".fetch_by_ids" do + it "finds all feeds by id" do + feeds = [create_feed, create_feed] + + expect(FeedRepository.fetch_by_ids(feeds.map(&:id))).to match_array(feeds) + end + + it "does not find other feeds" do + feed1 = create_feed + create_feed + + expect(FeedRepository.fetch_by_ids(feed1.id)).to eq([feed1]) + end + end + + describe ".update_feed" do + it "saves the name and url" do + feed = Feed.new + + FeedRepository.update_feed(feed, "Test Feed", "example.com/feed") + + expect(feed.name).to eq "Test Feed" + expect(feed.url).to eq "example.com/feed" + end + end + describe ".update_last_fetched" do let(:timestamp) { Time.now } @@ -43,31 +86,49 @@ end end - describe ".update_feed" do - it "saves the name and url" do - feed = Feed.new + describe ".delete" do + it "deletes the feed by id" do + feed = create_feed - FeedRepository.update_feed(feed, "Test Feed", "example.com/feed") + FeedRepository.delete(feed.id) - expect(feed.name).to eq "Test Feed" - expect(feed.url).to eq "example.com/feed" + expect(Feed.unscoped.find_by(id: feed.id)).to be_nil + end + + it "does not delete other feeds" do + feed1 = create_feed + feed2 = create_feed + + FeedRepository.delete(feed1.id) + + expect(Feed.unscoped.find_by(id: feed2.id)).to eq(feed2) end end - describe "fetch" do - let(:feed) { Feed.new(id: 1) } + describe ".list" do + it "returns all feeds ordered by name, case insensitive" do + feed1 = create_feed(name: "foo") + feed2 = create_feed(name: "Fabulous") + feed3 = create_feed(name: "Zooby") + feed4 = create_feed(name: "zabby") - it "finds by id" do - expect(Feed).to receive(:find).with(feed.id).and_return(feed) - FeedRepository.fetch(feed.id) + expect(FeedRepository.list).to eq([feed2, feed1, feed4, feed3]) end + end - it "returns found feed" do - allow(Feed).to receive(:find).with(feed.id).and_return(feed) + describe ".in_group" do + it "returns feeds that are in a group" do + feed1 = create_feed(group_id: 5) + feed2 = create_feed(group_id: 6) - result = FeedRepository.fetch(feed.id) + expect(FeedRepository.in_group).to match_array([feed1, feed2]) + end - expect(result).to eq feed + it "does not return feeds that are not in a group" do + create_feed + create_feed + + expect(FeedRepository.in_group).to be_empty end end end From e7521ea2c966788e657fb1d28e38863277957abf Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 13 Mar 2021 17:31:41 -0800 Subject: [PATCH 060/779] RuboCop: add additional RuboCop plugins (#557) This adds `rubocop-rails`, `rubocop-rake`, and `rubocop-rspec`. Even though this project doesn't use Rails, a lot of the same linters will apply. Also regenerates `.rubocop_todo.yml` based on the new rules. --- .rubocop.yml | 4 + .rubocop_todo.yml | 383 +++++++++++++++++++++++++++++++++++++++++++--- Gemfile | 3 + Gemfile.lock | 12 ++ 4 files changed, 379 insertions(+), 23 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index dcf06b104..a725a457d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,8 @@ inherit_from: .rubocop_todo.yml +require: + - rubocop-rails + - rubocop-rake + - rubocop-rspec AllCops: DisplayCopNames: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c8f055358..59c231955 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-02-28 19:30:55 UTC using RuboCop version 1.10.0. +# on 2021-03-13 20:00:37 UTC using RuboCop version 1.10.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 38 +# Offense count: 41 # Configuration parameters: Include, IgnoredGems, OnlyFor. # Include: **/*.gemfile, **/Gemfile, **/gems.rb Bundler/GemComment: @@ -44,7 +44,7 @@ Layout/MultilineMethodArgumentLineBreaks: - 'spec/controllers/sessions_controller_spec.rb' - 'spec/javascript/test_controller.rb' -# Offense count: 702 +# Offense count: 725 # Configuration parameters: Only, Ignore. Lint/ConstantResolution: Enabled: false @@ -73,12 +73,6 @@ Lint/NumberConversion: - 'spec/models/feed_spec.rb' - 'spec/models/story_spec.rb' -# Offense count: 47 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. -# IgnoredMethods: refine -Metrics/BlockLength: - Max: 183 - # Offense count: 9 # Configuration parameters: ForbiddenDelimiters. # ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) @@ -88,27 +82,371 @@ Naming/HeredocDelimiterNaming: - 'spec/helpers/url_helpers_spec.rb' - 'spec/utils/opml_parser_spec.rb' +# Offense count: 39 +# Cop supports --auto-correct. +RSpec/AlignLeftLetBrace: + Enabled: false + +# Offense count: 44 +# Cop supports --auto-correct. +RSpec/AlignRightLetBrace: + Enabled: false + +# Offense count: 5 +RSpec/AnyInstance: + Exclude: + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + +# Offense count: 4 +RSpec/Be: + Exclude: + - 'spec/commands/feeds/import_from_opml_spec.rb' + +# Offense count: 3 +RSpec/BeforeAfterAll: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + +# Offense count: 18 +# Configuration parameters: Prefixes. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/import_from_opml_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/utils/content_sanitizer_spec.rb' + # Offense count: 2 +# Configuration parameters: IgnoredMetadata. +RSpec/DescribeClass: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + +# Offense count: 115 # Cop supports --auto-correct. -# Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. -# MethodsAcceptingSymbol: inject, reduce -Style/CollectionMethods: +# Configuration parameters: SkipBlocks, EnforcedStyle. +# SupportedStyles: described_class, explicit +RSpec/DescribedClass: + Enabled: false + +# Offense count: 9 +# Cop supports --auto-correct. +RSpec/EmptyLineAfterFinalLet: + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/import_from_opml_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +RSpec/EmptyLineAfterHook: + Exclude: + - 'spec/controllers/stories_controller_spec.rb' + +# Offense count: 50 +# Configuration parameters: Max. +RSpec/ExampleLength: + Enabled: false + +# Offense count: 18 +# Cop supports --auto-correct. +# Configuration parameters: CustomTransform, IgnoredWords. +RSpec/ExampleWording: + Exclude: + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + - 'spec/utils/opml_parser_spec.rb' + +# Offense count: 2 +RSpec/ExpectInHook: Exclude: + - 'spec/commands/stories/mark_group_as_read_spec.rb' + +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Exclude: + - 'spec/helpers/authentications_helper_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, each, example +RSpec/HookArgument: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + +# Offense count: 6 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +RSpec/LeadingSubject: + Exclude: + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + +# Offense count: 2 +RSpec/LeakyConstantDeclaration: + Exclude: + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +RSpec/LetBeforeExamples: + Exclude: + - 'spec/repositories/feed_repository_spec.rb' + +# Offense count: 4 +RSpec/MessageChain: + Exclude: + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api_spec.rb' + +# Offense count: 104 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: allow, expect +RSpec/MessageExpectation: + Enabled: false + +# Offense count: 109 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: have_received, receive +RSpec/MessageSpies: + Enabled: false + +# Offense count: 94 +RSpec/MultipleExpectations: + Max: 8 + +# Offense count: 7 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 9 + +# Offense count: 28 +# Configuration parameters: IgnoreSharedExamples. +RSpec/NamedSubject: + Exclude: + - 'spec/fever_api/read_favicons_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/read_links_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + +# Offense count: 9 +RSpec/NestedGroups: + Max: 4 + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: not_to, to_not +RSpec/NotToNot: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: and_return, block +RSpec/ReturnFromStub: + Exclude: + - 'spec/tasks/remove_old_stories_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +RSpec/ScatteredLet: + Exclude: + - 'spec/commands/feeds/import_from_opml_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + +# Offense count: 53 +RSpec/StubbedMock: + Enabled: false + +# Offense count: 100 +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. +RSpec/VerifiedDoubles: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Rails/ActiveRecordAliases: + Exclude: + - 'app/commands/stories/mark_as_read.rb' + - 'app/commands/stories/mark_as_starred.rb' + - 'app/commands/stories/mark_as_unread.rb' + - 'app/commands/stories/mark_as_unstarred.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. +# Whitelist: find_by_sql +# AllowedMethods: find_by_sql +# AllowedReceivers: Gem::Specification +Rails/DynamicFindBy: + Exclude: + - 'spec/commands/feeds/import_from_opml_spec.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/HasManyOrHasOneDependent: + Exclude: + - 'app/models/group.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: spec/**/*, test/**/* +Rails/HttpPositionalArguments: + Exclude: + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api_spec.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/InverseOf: + Exclude: + - 'app/models/feed.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. +Rails/Present: + Exclude: + - 'app/tasks/fetch_feeds.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/Rakefile, **/*.rake +Rails/RakeEnvironment: + Exclude: + - 'Rakefile' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: AllowImplicitReturn, AllowedReceivers. +Rails/SaveBang: + Exclude: + - 'app/commands/feeds/add_new_feed.rb' + - 'app/commands/feeds/import_from_opml.rb' + - 'app/commands/users/change_user_password.rb' + - 'app/commands/users/complete_setup.rb' + - 'app/commands/users/create_user.rb' + - 'app/controllers/first_run_controller.rb' - 'app/controllers/stories_controller.rb' - - 'app/fever_api/response.rb' + - 'app/repositories/feed_repository.rb' + - 'app/repositories/story_repository.rb' + - 'app/repositories/user_repository.rb' + - 'db/migrate/20130821020313_update_nil_entry_ids.rb' -# Offense count: 10 -# Configuration parameters: IgnoreModules. -Style/ConstantVisibility: +# Offense count: 6 +# Configuration parameters: ForbiddenMethods, AllowedMethods. +# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all +Rails/SkipsModelValidations: + Exclude: + - 'app/commands/stories/mark_all_as_read.rb' + - 'app/commands/stories/mark_feed_as_read.rb' + - 'app/commands/stories/mark_group_as_read.rb' + - 'db/migrate/20140421224454_fix_invalid_unicode.rb' + - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' + +# Offense count: 30 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: Exclude: - 'app/commands/feeds/add_new_feed.rb' - 'app/commands/feeds/find_new_stories.rb' - 'app/commands/feeds/import_from_opml.rb' - - 'app/commands/stories/mark_group_as_read.rb' - - 'app/fever_api/response.rb' - - 'app/helpers/url_helpers.rb' + - 'app/repositories/story_repository.rb' + - 'app/tasks/remove_old_stories.rb' + - 'app/utils/sample_story.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/factories/feed_factory.rb' + - 'spec/factories/story_factory.rb' + - 'spec/fever_api_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/Validation: + Exclude: + - 'app/models/feed.rb' - 'app/models/story.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Rails/WhereEquals: + Exclude: + - 'app/models/feed.rb' + - 'app/repositories/story_repository.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Rails/WhereNot: + Exclude: - 'app/repositories/feed_repository.rb' + - 'spec/commands/feeds/import_from_opml_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. +# MethodsAcceptingSymbol: inject, reduce +Style/CollectionMethods: + Exclude: + - 'app/controllers/stories_controller.rb' + - 'app/fever_api/response.rb' # Offense count: 8 # Cop supports --auto-correct. @@ -127,7 +465,7 @@ Style/DisableCopsWithinSourceCodeDirective: Style/DocumentationMethod: Enabled: false -# Offense count: 150 +# Offense count: 151 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -139,7 +477,7 @@ Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 652 +# Offense count: 670 # Cop supports --auto-correct. # Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -166,10 +504,9 @@ Style/MissingElse: # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - - 'spec/**/*' - 'app/commands/stories/mark_group_as_read.rb' -# Offense count: 32 +# Offense count: 30 # Configuration parameters: SuspiciousParamNames. # SuspiciousParamNames: options, opts, args, params, parameters Style/OptionHash: diff --git a/Gemfile b/Gemfile index d76f6838a..6357d3331 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,9 @@ end group :development do gem "rubocop", require: false + gem "rubocop-rails", require: false + gem "rubocop-rake", require: false + gem "rubocop-rspec", require: false gem "sqlite3" end diff --git a/Gemfile.lock b/Gemfile.lock index 7ba934a21..0a7e8860d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -134,6 +134,15 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.4.1) parser (>= 2.7.1.5) + rubocop-rails (2.9.1) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 0.90.0, < 2.0) + rubocop-rake (0.5.1) + rubocop + rubocop-rspec (2.2.0) + rubocop (~> 1.0) + rubocop-ast (>= 1.1.0) ruby-progressbar (1.11.0) ruby2_keywords (0.0.4) sass (3.7.4) @@ -220,6 +229,9 @@ DEPENDENCIES rspec rspec-html-matchers rubocop + rubocop-rails + rubocop-rake + rubocop-rspec sass shotgun simplecov From c6f34f047efb242eb79528b275502633586e2ba7 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 14 Mar 2021 11:32:56 -0700 Subject: [PATCH 061/779] Specs: add more tests for StoryRepository (#558) --- spec/factories/stories.rb | 1 + spec/repositories/story_repository_spec.rb | 44 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index 18aa9ca23..df8699c31 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -1,5 +1,6 @@ module Factories STORY_TRAITS = { + read: -> { { is_read: true } }, unread: -> { { is_read: false } } }.freeze diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 3641e5162..f60a6e141 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -240,6 +240,50 @@ end end + describe ".feed" do + it "returns stories for the given feed id" do + feed = create_feed + story = create_story(feed: feed) + + expect(StoryRepository.feed(feed.id)).to eq([story]) + end + + it "sorts stories by published" do + feed = create_feed + story1 = create_story(feed: feed, published: 1.day.ago) + story2 = create_story(feed: feed, published: 1.hour.ago) + + expect(StoryRepository.feed(feed.id)).to eq([story2, story1]) + end + + it "does not return stories for other feeds" do + feed1 = create_feed + feed2 = create_feed + create_story(feed: feed2) + create_story + + expect(StoryRepository.feed(feed1.id)).to be_empty + end + end + + describe ".read_count" do + it "returns the count of read stories" do + create_story(:read) + create_story(:read) + create_story(:read) + + expect(StoryRepository.read_count).to eq(3) + end + + it "does not count unread stories" do + create_story(:unread) + create_story(:unread) + create_story(:unread) + + expect(StoryRepository.read_count).to eq(0) + end + end + describe ".extract_url" do it "returns the url" do feed = double(url: "http://github.com") From 34be045ee6ffb32025acf59eee9445e5827f00f6 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 16 Mar 2021 18:07:30 -0700 Subject: [PATCH 062/779] Specs: actually execute code in fetch_feed_spec (#559) The test wasn't actually executing the method under test, so it wasn't verifying anything. --- spec/tasks/fetch_feed_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 8448bbd12..d8fb83b22 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -23,7 +23,7 @@ expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser: parser, client: client) + FetchFeed.new(daring_fireball, parser: parser, client: client).fetch end end From b15da45b7338343849b6d2798538d330c2faecea Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 20 Mar 2021 13:10:18 -0700 Subject: [PATCH 063/779] Specs: add tests for StoryRepository.read (#560) --- spec/repositories/story_repository_spec.rb | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index f60a6e141..3bc4c372e 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -257,12 +257,39 @@ end it "does not return stories for other feeds" do - feed1 = create_feed - feed2 = create_feed - create_story(feed: feed2) + feed = create_feed create_story - expect(StoryRepository.feed(feed1.id)).to be_empty + expect(StoryRepository.feed(feed.id)).to be_empty + end + end + + describe ".read" do + it "returns read stories" do + story = create_story(:read) + + expect(StoryRepository.read).to eq([story]) + end + + it "sorts stories by published" do + story1 = create_story(:read, published: 1.day.ago) + story2 = create_story(:read, published: 1.hour.ago) + + expect(StoryRepository.read).to eq([story2, story1]) + end + + it "does not return unread stories" do + create_story(:unread) + + expect(StoryRepository.read).to be_empty + end + + it "paginates results" do + stories = + 21.times.map { |num| create_story(:read, published: num.days.ago) } + + expect(StoryRepository.read).to eq(stories[0...20]) + expect(StoryRepository.read(2)).to eq([stories.last]) end end From a92e5622cf2f2dbc8de5091233867f7d0c807a4d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 27 Mar 2021 18:19:15 -0700 Subject: [PATCH 064/779] Specs: add tests for redirects in app.rb (#561) Also made it so that auth check applies in test mode as well. Needed to make a couple of other changes to tests to get them working. --- .rubocop_todo.yml | 24 ++++++------ app/helpers/authentication_helpers.rb | 1 - spec/app_spec.rb | 39 +++++++++++++++++++ spec/controllers/first_run_controller_spec.rb | 14 +++---- spec/factories/users.rb | 12 ++++-- spec/helpers/authentications_helper_spec.rb | 9 ----- 6 files changed, 68 insertions(+), 31 deletions(-) create mode 100644 spec/app_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 59c231955..e521faa0d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-03-13 20:00:37 UTC using RuboCop version 1.10.0. +# on 2021-03-28 01:11:19 UTC using RuboCop version 1.10.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -44,7 +44,7 @@ Layout/MultilineMethodArgumentLineBreaks: - 'spec/controllers/sessions_controller_spec.rb' - 'spec/javascript/test_controller.rb' -# Offense count: 725 +# Offense count: 744 # Configuration parameters: Only, Ignore. Lint/ConstantResolution: Enabled: false @@ -132,7 +132,7 @@ RSpec/DescribeClass: - 'spec/integration/feed_importing_spec.rb' - 'spec/utils/i18n_support_spec.rb' -# Offense count: 115 +# Offense count: 132 # Cop supports --auto-correct. # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit @@ -244,7 +244,7 @@ RSpec/MessageExpectation: RSpec/MessageSpies: Enabled: false -# Offense count: 94 +# Offense count: 96 RSpec/MultipleExpectations: Max: 8 @@ -331,12 +331,13 @@ Rails/HasManyOrHasOneDependent: Exclude: - 'app/models/group.rb' -# Offense count: 24 +# Offense count: 28 # Cop supports --auto-correct. # Configuration parameters: Include. # Include: spec/**/*, test/**/* Rails/HttpPositionalArguments: Exclude: + - 'spec/app_spec.rb' - 'spec/controllers/debug_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' @@ -432,11 +433,10 @@ Rails/WhereEquals: - 'app/models/feed.rb' - 'app/repositories/story_repository.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. Rails/WhereNot: Exclude: - - 'app/repositories/feed_repository.rb' - 'spec/commands/feeds/import_from_opml_spec.rb' # Offense count: 2 @@ -465,7 +465,7 @@ Style/DisableCopsWithinSourceCodeDirective: Style/DocumentationMethod: Enabled: false -# Offense count: 151 +# Offense count: 152 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -477,7 +477,7 @@ Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 670 +# Offense count: 690 # Cop supports --auto-correct. # Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -506,7 +506,7 @@ Style/NumericPredicate: Exclude: - 'app/commands/stories/mark_group_as_read.rb' -# Offense count: 30 +# Offense count: 28 # Configuration parameters: SuspiciousParamNames. # SuspiciousParamNames: options, opts, args, params, parameters Style/OptionHash: @@ -563,13 +563,15 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' -# Offense count: 18 +# Offense count: 19 # Cop supports --auto-correct. Style/StringHashKeys: Exclude: - 'fever_api.rb' + - 'spec/app_spec.rb' - 'spec/controllers/debug_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/fever_api/read_favicons_spec.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' diff --git a/app/helpers/authentication_helpers.rb b/app/helpers/authentication_helpers.rb index d9f564aae..cb70a94f5 100644 --- a/app/helpers/authentication_helpers.rb +++ b/app/helpers/authentication_helpers.rb @@ -9,7 +9,6 @@ def authenticated? end def needs_authentication?(path) - return false if ENV["RACK_ENV"] == "test" return false unless UserRepository.setup_complete? return false if %w(/login /logout /heroku).include?(path) return false if path =~ /css|js|img/ diff --git a/spec/app_spec.rb b/spec/app_spec.rb new file mode 100644 index 000000000..b8faeebf9 --- /dev/null +++ b/spec/app_spec.rb @@ -0,0 +1,39 @@ +require "spec_helper" +require "support/active_record" + +describe "App" do + context "when user is not authenticated and page requires authentication" do + it "sets the session redirect_to" do + create_user(:setup_complete) + + get("/news") + + expect(session[:redirect_to]).to eq("/news") + end + + it "redirects to /login" do + create_user(:setup_complete) + + get("/news") + + expect(last_response).to be_redirect + expect(last_response.headers["Location"]).to end_with("/login") + end + end + + it "does not redirect when page needs no authentication" do + create_user(:setup_complete) + + get("/login") + + expect(last_response).not_to be_redirect + end + + it "does not redirect when user is authenticated" do + user = create_user(:setup_complete) + + get("/news", {}, "rack.session" => { user_id: user.id }) + + expect(last_response).not_to be_redirect + end +end diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 22155e133..878cc3037 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -1,4 +1,5 @@ require "spec_helper" +require "support/active_record" app_require "controllers/first_run_controller" @@ -72,20 +73,19 @@ end context "when a user has been setup" do - before do - allow(UserRepository).to receive(:setup_complete?).and_return(true) - end - it "should redirect any requests to first run stuff" do - get "/" + user = create_user(:setup_complete) + session = { "rack.session" => { user_id: user.id } } + + get "/", {}, session expect(last_response.status).to be 302 expect(URI.parse(last_response.location).path).to eq "/news" - get "/setup/password" + get "/setup/password", {}, session expect(last_response.status).to be 302 expect(URI.parse(last_response.location).path).to eq "/news" - get "/setup/tutorial" + get "/setup/tutorial", {}, session expect(last_response.status).to be 302 expect(URI.parse(last_response.location).path).to eq "/news" end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 923a74d7f..4a76ebe07 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,9 +1,15 @@ module Factories - def create_user(params = {}) - build_user(params).tap(&:save!) + USER_TRAITS = { + setup_complete: -> { { setup_complete: true } } + }.freeze + + def create_user(*traits, **params) + build_user(*traits, **params).tap(&:save!) end - def build_user(params = {}) + def build_user(*traits, **params) + traits.each { |trait| params.merge!(USER_TRAITS.fetch(trait).call) } + User.new(password: "super-secret", **params) end end diff --git a/spec/helpers/authentications_helper_spec.rb b/spec/helpers/authentications_helper_spec.rb index 5407bb13f..eb95f0555 100644 --- a/spec/helpers/authentications_helper_spec.rb +++ b/spec/helpers/authentications_helper_spec.rb @@ -13,18 +13,9 @@ class Helper # rubocop:disable Lint/ConstantDefinitionInBlock let(:authenticated_path) { "/news" } before do - stub_const("ENV", "RACK_ENV" => "not-test") allow(UserRepository).to receive(:setup_complete?).and_return(true) end - context "when `RACK_ENV` is 'test'" do - it "returns false" do - stub_const("ENV", "RACK_ENV" => "test") - - expect(helper.needs_authentication?(authenticated_path)).to eq(false) - end - end - context "when setup in not complete" do it "returns false" do allow(UserRepository).to receive(:setup_complete?).and_return(false) From 765da7bf829127c26a36c0759a9843c90bdb0a65 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 30 Mar 2021 16:42:21 -0700 Subject: [PATCH 065/779] Specs: add more tests for StoryRepository (#562) This brings test coverage up to 100%, so I'm also enabling the `minimum_coverage` threshold to make sure it stays there. --- spec/factories/stories.rb | 1 + spec/repositories/story_repository_spec.rb | 55 ++++++++++++++++++++++ spec/support/coverage.rb | 2 + 3 files changed, 58 insertions(+) diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index df8699c31..c4c622868 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -1,6 +1,7 @@ module Factories STORY_TRAITS = { read: -> { { is_read: true } }, + starred: -> { { is_starred: true } }, unread: -> { { is_read: false } } }.freeze diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 3bc4c372e..75ac83dde 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -293,6 +293,61 @@ end end + describe ".starred" do + it "returns starred stories" do + story = create_story(:starred) + + expect(StoryRepository.starred).to eq([story]) + end + + it "sorts stories by published" do + story1 = create_story(:starred, published: 1.day.ago) + story2 = create_story(:starred, published: 1.hour.ago) + + expect(StoryRepository.starred).to eq([story2, story1]) + end + + it "does not return unstarred stories" do + create_story + + expect(StoryRepository.starred).to be_empty + end + + it "paginates results" do + stories = + 21.times.map { |num| create_story(:starred, published: num.days.ago) } + + expect(StoryRepository.starred).to eq(stories[0...20]) + expect(StoryRepository.starred(2)).to eq([stories.last]) + end + end + + describe ".unstarred_read_stories_older_than" do + it "returns unstarred read stories older than given number of days" do + story = create_story(:read, published: 6.days.ago) + + expect(StoryRepository.unstarred_read_stories_older_than(5)).to eq([story]) + end + + it "does not return starred stories older than the given number of days" do + create_story(:read, :starred, published: 6.days.ago) + + expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty + end + + it "does not return unread stories older than the given number of days" do + create_story(:unread, published: 6.days.ago) + + expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty + end + + it "does not return stories newer than given number of days" do + create_story(:read, published: 4.days.ago) + + expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty + end + end + describe ".read_count" do it "returns the count of read stories" do create_story(:read) diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb index 905d5861d..03b601a45 100644 --- a/spec/support/coverage.rb +++ b/spec/support/coverage.rb @@ -14,4 +14,6 @@ add_group("Repositories", "app/repositories") add_group("Tasks", "app/tasks") add_group("Utils", "app/utils") + add_filter("/db/migrate/") end +SimpleCov.minimum_coverage(100) From 9ef2dc0e4101ff174e2feb12fe425489b4ebaa52 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 11 Apr 2021 14:54:26 -0700 Subject: [PATCH 066/779] Deps: upgrade Unicorn to 6.0.0 (#563) There doesn't appear to be anything in [the major release][release] that should impact us. [release]: https://github.com/defunkt/unicorn/releases/tag/v6.0.0 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0a7e8860d..25185a493 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -195,7 +195,7 @@ GEM uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.0.0) - unicorn (5.8.0) + unicorn (6.0.0) kgio (~> 2.6) raindrops (~> 0.7) will_paginate (3.3.0) From 2e978fc54b512c7b9b22ca449f7a7ffadfc1576f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 11 Apr 2021 15:46:05 -0700 Subject: [PATCH 067/779] Deps: remove SQLite (#564) This blocks upgrading to ActiveRecord 6.x, as the query for `true`/`false` values is different for some reason depending on the database, and it fails tests with SQLite. The simplest solution in this case is probably to remove SQLite. The production setup uses Postgres, so better to have a consistent database setup, anyway. This also frees us up to take advantage of Postgres specific features. --- .gitignore | 1 - .travis.yml | 3 +++ Gemfile | 1 - Gemfile.lock | 2 -- config/database.yml | 6 ++++-- db/stringer_test.sqlite | Bin 0 -> 17408 bytes docker/start.sh | 3 --- docs/VPS.md | 6 +++--- docs/docker.md | 13 ------------- 9 files changed, 10 insertions(+), 25 deletions(-) create mode 100644 db/stringer_test.sqlite diff --git a/.gitignore b/.gitignore index e35bb576d..03d45aca4 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,5 @@ _yardoc doc/ bin/ -db/*.sqlite .DS_Store .localeapp diff --git a/.travis.yml b/.travis.yml index 95f247571..87774e7f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ before_install: - gem update bundler - 'echo "RUBY_VERSION: $RUBY_VERSION"' before_script: + - bundle exec rake db:create db:schema:load - npm install -g mocha-phantomjs@4.1.0 - bundle exec rake test_js &> /dev/null & - sleep 5 @@ -10,6 +11,8 @@ language: ruby rvm: - 2.7.2 - ruby-head +services: + - postgresql matrix: allow_failures: - rvm: ruby-head diff --git a/Gemfile b/Gemfile index 6357d3331..7b6e3afa4 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,6 @@ group :development do gem "rubocop-rails", require: false gem "rubocop-rake", require: false gem "rubocop-rspec", require: false - gem "sqlite3" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 25185a493..1331cc469 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,7 +179,6 @@ GEM rack (> 1, < 3) sprockets-helpers (1.4.0) sprockets (>= 2.2) - sqlite3 (1.4.2) sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) @@ -241,7 +240,6 @@ DEPENDENCIES sinatra-flash sprockets sprockets-helpers - sqlite3 thread timecop uglifier diff --git a/config/database.yml b/config/database.yml index f1c394139..f18477a44 100644 --- a/config/database.yml +++ b/config/database.yml @@ -5,8 +5,10 @@ development: pool: 5 test: - adapter: sqlite3 - database: db/stringer_test.sqlite + adapter: postgresql + database: stringer_test + encoding: unicode + pool: 5 production: url: <%= ENV["DATABASE_URL"] %> diff --git a/db/stringer_test.sqlite b/db/stringer_test.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..f1a05088d153800149c0fb3deda6556f83e4e778 GIT binary patch literal 17408 zcmeHOO>7%Q6yDu&?EE&Hw8<)pfR#&|T5ZYB+8aB)fN2dxB<>FhP$99}#FKQ1?R9t8 zp%q-5(q6fM#0`l92RMUzKwP*W4oI9hz<~o-P|E=hTzLEI-HlUKN<@=(R*5tI=FRNP z_ue<__maGJc~Q5CxNevY%@*@aieXvi1yN)eW(vN?;5)dUg+?lP13%eFd$;BkbN2q- zKIrAp-;T`@^sm?0Z2-k71C)XPfq}tcxXD2O2)s^mHiP~|zoH+|UGzEn2yLSldK)dG zbLbSBL@Dks?l{|&4@MA4Dd9POz()%5 zyqt%<75V-Uf&0r?De{>J0+dK4J{=-?T!IzN@qJxHl5nvg@u>j8C71^G!J`n7aY>Pt zJkJFPaE7IlJjb(f1eXTEkCUA0=>He=J^BiLhCW2^BOSet&Lasug$B8QxZk;-xNo^H zLH)Nm6O8Fa8F)Ab#!-%qOMNncx>}#;LV?(i`A|gdM?)x-`*;@$^gb3sUBQP?sQA$? z6iEI^401I;(uD%i4@V$h^+PepmHl7{g}NVzK)&$%W00%-Oa$_!pN>MF_WQa}ApTSY z^3{*JP#}M94CMyE9dOEd5H2~-e-?esz!$wJ1C)V7!N4nQ-|>lZnKZX_(`YtG)3%9a z%kXjPtR$b6OCm0vlcjSw{~X3e_-L|wkMsOz(R~KK=tUWz3_R`(96`qiBIkzl{Et=j z9{2sz{ZR%e10e%c{~;B$K^b`B7@+!p;#^KQOc@9naP*&M?lI^NIuEt|9Q!kKk40hk zW7p`^`ZIzcu(xJxZM9C?7BMaNW$65sN_n{=E|*_itcY0`%ZjJ6dMzvJO`B{GQ>yqmS$P+8fHzc=^Idn$%O^b8NUf!-o8)GA=iH@q zS~z{0z3Oh#x?YFB@lY*ty-k{HB=I&A+jye$R8wn^GcYpuaw;vnrLc_NtdSeOmDaWm z_r0o_szZ|5)aq)3*cxm^Q*ke}uTw=CK~dQ4=iSBivgw7TV$00-GI87$Wg+A?;jb;N z-Uj-7FYVPaxiXg)R%Ul&##*~Z8k*YBH%!geji#mI9T2*~W`x;Uw)2eVujG&&1GqRD zJNg|awji?Me&IfQvXL8MKV=Yel3`AwTihx)!MPs@lCt048q5eMPO!IU-38W2UAqZ^ z`i`+`Mcc#iWktJ^Qi>=@EUzqIT&Tj>rAigV;)@LY(lT|!)NP3CK!JgxBq!*h=-Fu5 zR`1?xTC-LsW>&Px4I8ZMnq{lRG>tA~wwp06I#$NoWF>mvlT@Tr3$TK`@e;>)DQ&9#E z83WGm|LO1l4w=*Faw!A*#DMesPca`e=u`F&_A)dM!qu4{&j?df?DmqIGP)^~<-Lx@ zlSU6rW{nS3T!`n8L81w%(Vh~(TxV)5BfK%qc9z_9&MS{uHqP+6M z{89aJW+QV&lGU&}lSs&I-L6AM?$lb6S$B)Tzn0bY=4S8iRig$4lwJdaW$!5d_?h&c z`~ Date: Sun, 11 Apr 2021 15:50:44 -0700 Subject: [PATCH 068/779] Deps: upgrade ActiveRecord to 6.1 (#566) I needed to update the format of the json being returned in the tests. I'm not sure if it actually ends up changing the result when the dates are converted to JSON strings, but it doesn't look like anything client or server relies particularly on the format, so we should be fine. Also updates the formatting in `schema.rb` by running `rake db:migrate`. All of the changes look to be cosmetic. --- Gemfile | 2 +- Gemfile.lock | 31 +++++++++---------- db/schema.rb | 65 +++++++++++++++++++-------------------- spec/models/story_spec.rb | 6 ++-- 4 files changed, 50 insertions(+), 54 deletions(-) diff --git a/Gemfile b/Gemfile index 7b6e3afa4..837970cd5 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,7 @@ group :development, :test do gem "timecop" end -gem "activerecord", "~> 5.0" +gem "activerecord" gem "bcrypt" gem "delayed_job" gem "delayed_job_active_record" diff --git a/Gemfile.lock b/Gemfile.lock index 1331cc469..295f5bf09 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,19 @@ GEM remote: https://rubygems.org/ specs: - activemodel (5.2.4.5) - activesupport (= 5.2.4.5) - activerecord (5.2.4.5) - activemodel (= 5.2.4.5) - activesupport (= 5.2.4.5) - arel (>= 9.0) - activesupport (5.2.4.5) + activemodel (6.1.3.1) + activesupport (= 6.1.3.1) + activerecord (6.1.3.1) + activemodel (= 6.1.3.1) + activesupport (= 6.1.3.1) + activesupport (6.1.3.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - arel (9.0.0) ast (2.4.2) bcrypt (3.1.16) byebug (11.1.3) @@ -55,7 +54,7 @@ GEM httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.8.9) + i18n (1.8.10) concurrent-ruby (~> 1.0) json (2.5.1) kgio (2.11.3) @@ -184,13 +183,12 @@ GEM tins (~> 1.0) thor (1.1.0) thread (0.2.2) - thread_safe (0.3.6) tilt (2.0.10) timecop (0.9.4) tins (1.28.0) sync - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.0.0) @@ -200,12 +198,13 @@ GEM will_paginate (3.3.0) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.4.2) PLATFORMS ruby DEPENDENCIES - activerecord (~> 5.0) + activerecord bcrypt capybara coveralls (> 0.8) diff --git a/db/schema.rb b/db/schema.rb index 3f33b80fe..f4d5a1075 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,75 +2,72 @@ # 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: 20141102103617) do +ActiveRecord::Schema.define(version: 2014_11_02_103617) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "delayed_jobs", force: :cascade do |t| - t.integer "priority", default: 0 - t.integer "attempts", default: 0 - t.text "handler" - t.text "last_error" + t.integer "priority", default: 0 + t.integer "attempts", default: 0 + t.text "handler" + t.text "last_error" t.datetime "run_at" t.datetime "locked_at" t.datetime "failed_at" - t.string "locked_by" - t.string "queue" + t.string "locked_by" + t.string "queue" t.datetime "created_at" t.datetime "updated_at" + t.index ["priority", "run_at"], name: "delayed_jobs_priority" end - add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree - create_table "feeds", force: :cascade do |t| - t.string "name" - t.text "url" + t.string "name" + t.text "url" t.datetime "last_fetched" t.datetime "created_at" t.datetime "updated_at" - t.integer "status" - t.integer "group_id" + t.integer "status" + t.integer "group_id" + t.index ["url"], name: "index_feeds_on_url", unique: true end - add_index "feeds", ["url"], name: "index_feeds_on_url", unique: true, using: :btree - create_table "groups", force: :cascade do |t| - t.string "name", null: false + t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "stories", force: :cascade do |t| - t.text "title" - t.text "permalink" - t.text "body" - t.integer "feed_id" + t.text "title" + t.text "permalink" + t.text "body" + t.integer "feed_id" t.datetime "created_at" t.datetime "updated_at" t.datetime "published" - t.boolean "is_read" - t.boolean "keep_unread", default: false - t.boolean "is_starred", default: false - t.text "entry_id" + t.boolean "is_read" + t.boolean "keep_unread", default: false + t.boolean "is_starred", default: false + t.text "entry_id" + t.index ["entry_id", "feed_id"], name: "index_stories_on_entry_id_and_feed_id", unique: true end - add_index "stories", ["entry_id", "feed_id"], name: "index_stories_on_entry_id_and_feed_id", unique: true, using: :btree - create_table "users", force: :cascade do |t| - t.string "password_digest" + t.string "password_digest" t.datetime "created_at" t.datetime "updated_at" - t.boolean "setup_complete" - t.string "api_key" + t.boolean "setup_complete" + t.string "api_key" end end diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 01ce0aea7..b695f5ff6 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -84,7 +84,7 @@ expect(story.as_json).to eq({ body: "story body", - created_at: created_at, + created_at: created_at.utc.as_json, entry_id: "5", feed_id: feed.id, headline: "the story title", @@ -95,10 +95,10 @@ lead: "story body", permalink: "www.exampoo.com/perma", pretty_date: I18n.l(published_at.utc), - published: published_at.utc, + published: published_at.utc.as_json, source: "my feed", title: "the story title", - updated_at: updated_at + updated_at: updated_at.utc.as_json }.stringify_keys) end end From cf66a629178d00454d9ad3b1a2ed5d76d68687cf Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 11 Apr 2021 16:07:48 -0700 Subject: [PATCH 069/779] Deps: bundle update gems (#567) This updates minor versions of gems. --- Gemfile.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 295f5bf09..6eda4bde2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,13 +36,13 @@ GEM crass (1.0.6) delayed_job (4.1.9) activesupport (>= 3.0, < 6.2) - delayed_job_active_record (4.1.5) + delayed_job_active_record (4.1.6) activerecord (>= 3.0, < 6.2) delayed_job (>= 3.0, < 5) diff-lcs (1.4.4) docile (1.3.5) execjs (2.7.0) - faker (2.16.0) + faker (2.17.0) i18n (>= 1.6, < 2) feedbag (0.10.1) nokogiri (~> 1.8, >= 1.8.2) @@ -50,7 +50,7 @@ GEM feedjira (3.1.2) loofah (>= 2.3.1) sax-machine (>= 1.0) - ffi (1.14.2) + ffi (1.15.0) httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) @@ -58,26 +58,26 @@ GEM concurrent-ruby (~> 1.0) json (2.5.1) kgio (2.11.3) - loofah (2.9.0) + loofah (2.9.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0212) - mini_mime (1.0.2) + mime-types-data (3.2021.0225) + mini_mime (1.1.0) mini_portile2 (2.5.0) minitest (5.14.4) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) - nokogiri (1.11.1) + nokogiri (1.11.3) mini_portile2 (~> 2.5.0) racc (~> 1.4) open_uri_redirections (0.2.1) parallel (1.20.1) - parser (3.0.0.0) + parser (3.0.1.0) ast (~> 2.4.1) pg (1.2.3) pry (0.13.1) @@ -105,7 +105,7 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (2.1.1) - rexml (3.2.4) + rexml (3.2.5) rspec (3.10.0) rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.10.0) + rubocop (1.12.1) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) From 72bd2a308afd623bbe2a14779e610d2a8e33a453 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 11 Apr 2021 21:39:07 -0700 Subject: [PATCH 070/779] Deps: switch to coveralls_reborn (#568) The [coveralls gem][gem] hasn't been updated in more than a year. The [reborn][reborn] is a more up to date version that doesn't lock us down on an older version of SimpleCov. We may want to consider removing Coveralls entirely and just using the CI coverage, perhaps also keeping the artifacts for easy reference. [gem]: https://github.com/lemurheavy/coveralls-ruby [reborn]: https://github.com/tagliala/coveralls-ruby-reborn --- Gemfile | 2 +- Gemfile.lock | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index 837970cd5..59402bc57 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ end group :development, :test do gem "capybara" - gem "coveralls", "> 0.8", require: false + gem "coveralls_reborn", require: false gem "faker" gem "pry-byebug" gem "rack-test" diff --git a/Gemfile.lock b/Gemfile.lock index 6eda4bde2..3885d478e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,12 +27,11 @@ GEM xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.1.8) - coveralls (0.8.23) - json (>= 1.8, < 3) - simplecov (~> 0.16.1) - term-ansicolor (~> 1.3) - thor (>= 0.19.4, < 2.0) - tins (~> 1.6) + coveralls_reborn (0.21.0) + simplecov (>= 0.18.1, < 0.22.0) + term-ansicolor (~> 1.6) + thor (>= 0.20.3, < 2.0) + tins (~> 1.16) crass (1.0.6) delayed_job (4.1.9) activesupport (>= 3.0, < 6.2) @@ -56,7 +55,6 @@ GEM multi_xml (>= 0.5.2) i18n (1.8.10) concurrent-ruby (~> 1.0) - json (2.5.1) kgio (2.11.3) loofah (2.9.1) crass (~> 1.0.2) @@ -152,11 +150,12 @@ GEM sax-machine (1.3.2) shotgun (0.9.2) rack (>= 1.0) - simplecov (0.16.1) + simplecov (0.21.2) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.2) sinatra (2.1.0) mustermann (~> 1.0) rack (~> 2.2) @@ -207,7 +206,7 @@ DEPENDENCIES activerecord bcrypt capybara - coveralls (> 0.8) + coveralls_reborn delayed_job delayed_job_active_record faker From 2a487df378358e113489f9dc49d408a46417be13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 19:21:22 -0700 Subject: [PATCH 071/779] Bump nokogiri from 1.11.3 to 1.11.4 (#572) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.11.3 to 1.11.4. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.11.3...v1.11.4) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3885d478e..a7cb87318 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,13 +64,13 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2021.0225) mini_mime (1.1.0) - mini_portile2 (2.5.0) + mini_portile2 (2.5.1) minitest (5.14.4) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) - nokogiri (1.11.3) + nokogiri (1.11.4) mini_portile2 (~> 2.5.0) racc (~> 1.4) open_uri_redirections (0.2.1) From 0b64dc083f69cea51c8ec1c3d3734951f6a62fb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jul 2021 09:47:15 -0700 Subject: [PATCH 072/779] Bump addressable from 2.7.0 to 2.8.0 (#577) Bumps [addressable](https://github.com/sporkmonger/addressable) from 2.7.0 to 2.8.0. - [Release notes](https://github.com/sporkmonger/addressable/releases) - [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md) - [Commits](https://github.com/sporkmonger/addressable/compare/addressable-2.7.0...addressable-2.8.0) --- updated-dependencies: - dependency-name: addressable dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index a7cb87318..7a1961210 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,7 +12,7 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) bcrypt (3.1.16) From 4aae9d522dbf77c67e500fa33b56ddc78ca0b7d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 09:32:02 -0700 Subject: [PATCH 073/779] Bump nokogiri from 1.11.4 to 1.12.5 (#579) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.11.4 to 1.12.5. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.11.4...v1.12.5) --- updated-dependencies: - dependency-name: nokogiri dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7a1961210..2ae75414f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,14 +64,14 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2021.0225) mini_mime (1.1.0) - mini_portile2 (2.5.1) + mini_portile2 (2.6.1) minitest (5.14.4) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) - nokogiri (1.11.4) - mini_portile2 (~> 2.5.0) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) racc (~> 1.4) open_uri_redirections (0.2.1) parallel (1.20.1) From d6430939c16c140275b9697b6e283122145949c5 Mon Sep 17 00:00:00 2001 From: David Personette Date: Fri, 24 Dec 2021 17:27:51 +0000 Subject: [PATCH 074/779] update ruby and gems (#580) --- .ruby-version | 2 +- .travis.yml | 2 +- Gemfile.lock | 97 ++++++++++++++++++++++++++------------------------- docs/VPS.md | 4 +-- 4 files changed, 53 insertions(+), 52 deletions(-) diff --git a/.ruby-version b/.ruby-version index 37c2961c2..a603bb50a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +2.7.5 diff --git a/.travis.yml b/.travis.yml index 87774e7f1..c094492b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_script: cache: bundler language: ruby rvm: - - 2.7.2 + - 2.7.5 - ruby-head services: - postgresql diff --git a/Gemfile.lock b/Gemfile.lock index 2ae75414f..8ee702421 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activemodel (6.1.3.1) - activesupport (= 6.1.3.1) - activerecord (6.1.3.1) - activemodel (= 6.1.3.1) - activesupport (= 6.1.3.1) - activesupport (6.1.3.1) + activemodel (6.1.4.4) + activesupport (= 6.1.4.4) + activerecord (6.1.4.4) + activemodel (= 6.1.4.4) + activesupport (= 6.1.4.4) + activesupport (6.1.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -17,8 +17,9 @@ GEM ast (2.4.2) bcrypt (3.1.16) byebug (11.1.3) - capybara (3.35.3) + capybara (3.36.0) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) @@ -26,8 +27,8 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) coderay (1.1.3) - concurrent-ruby (1.1.8) - coveralls_reborn (0.21.0) + concurrent-ruby (1.1.9) + coveralls_reborn (0.23.1) simplecov (>= 0.18.1, < 0.22.0) term-ansicolor (~> 1.6) thor (>= 0.20.3, < 2.0) @@ -39,33 +40,34 @@ GEM activerecord (>= 3.0, < 6.2) delayed_job (>= 3.0, < 5) diff-lcs (1.4.4) - docile (1.3.5) - execjs (2.7.0) - faker (2.17.0) + docile (1.4.0) + execjs (2.8.1) + faker (2.19.0) i18n (>= 1.6, < 2) feedbag (0.10.1) nokogiri (~> 1.8, >= 1.8.2) open_uri_redirections (~> 0.2) - feedjira (3.1.2) + feedjira (3.2.0) loofah (>= 2.3.1) sax-machine (>= 1.0) - ffi (1.15.0) - httparty (0.18.1) + ffi (1.15.4) + httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.8.10) + i18n (1.8.11) concurrent-ruby (~> 1.0) - kgio (2.11.3) - loofah (2.9.1) + kgio (2.11.4) + loofah (2.13.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) + matrix (0.4.2) method_source (1.0.0) - mime-types (3.3.1) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0225) - mini_mime (1.1.0) + mime-types-data (3.2021.1115) + mini_mime (1.1.2) mini_portile2 (2.6.1) - minitest (5.14.4) + minitest (5.15.0) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) @@ -74,8 +76,8 @@ GEM mini_portile2 (~> 2.6.1) racc (~> 1.4) open_uri_redirections (0.2.1) - parallel (1.20.1) - parser (3.0.1.0) + parallel (1.21.0) + parser (3.0.3.2) ast (~> 2.4.1) pg (1.2.3) pry (0.13.1) @@ -85,7 +87,7 @@ GEM byebug (~> 11.0) pry (~> 0.13.0) public_suffix (4.0.6) - racc (1.5.2) + racc (1.6.0) rack (2.2.3) rack-protection (2.1.0) rack @@ -97,12 +99,12 @@ GEM rack (>= 1.0) rack-test (>= 0.5) rainbow (3.0.0) - raindrops (0.19.1) - rake (13.0.3) - rb-fsevent (0.10.4) + raindrops (0.20.0) + rake (13.0.6) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.1.1) + regexp_parser (2.2.0) rexml (3.2.5) rspec (3.10.0) rspec-core (~> 3.10.0) @@ -119,29 +121,28 @@ GEM rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) - rspec-support (3.10.2) - rubocop (1.12.1) + rspec-support (3.10.3) + rubocop (1.23.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.12.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) - rubocop-rails (2.9.1) + rubocop-ast (1.15.0) + parser (>= 3.0.1.1) + rubocop-rails (2.12.4) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) - rubocop-rake (0.5.1) - rubocop - rubocop-rspec (2.2.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-ast (>= 1.1.0) + rubocop-rspec (2.6.0) + rubocop (~> 1.19) ruby-progressbar (1.11.0) - ruby2_keywords (0.0.4) + ruby2_keywords (0.0.5) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -155,13 +156,13 @@ GEM simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.2) + simplecov_json_formatter (0.1.3) sinatra (2.1.0) mustermann (~> 1.0) rack (~> 2.2) rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.22) + sinatra-activerecord (2.0.23) activerecord (>= 4.1) sinatra (>= 1.0) sinatra-contrib (2.1.0) @@ -184,20 +185,20 @@ GEM thread (0.2.2) tilt (2.0.10) timecop (0.9.4) - tins (1.28.0) + tins (1.29.1) sync tzinfo (2.0.4) concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.0.0) + unicode-display_width (2.1.0) unicorn (6.0.0) kgio (~> 2.6) raindrops (~> 0.7) - will_paginate (3.3.0) + will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.4.2) + zeitwerk (2.5.1) PLATFORMS ruby @@ -245,7 +246,7 @@ DEPENDENCIES will_paginate RUBY VERSION - ruby 2.7.2 + ruby 2.7.5 BUNDLED WITH 2.2.12 diff --git a/docs/VPS.md b/docs/VPS.md index 724ca1910..4bb635de7 100644 --- a/docs/VPS.md +++ b/docs/VPS.md @@ -61,8 +61,8 @@ We are going to use Rbenv to manage the version of Ruby you use. git clone git://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build source ~/.bash_profile - rbenv install 2.7.2 - rbenv local 2.7.2 + rbenv install 2.7.5 + rbenv local 2.7.5 rbenv rehash We also need to install bundler which will handle Stringer's dependencies From 2ee6aa6866d38110a3409f6c8f14c0d3e8f307a5 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Thu, 6 Jan 2022 01:52:39 +0800 Subject: [PATCH 075/779] Add Traditional Chinese (zh-TW) locale (#581) --- config/locales/zh-TW.yml | 157 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 config/locales/zh-TW.yml diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml new file mode 100644 index 000000000..9eef85581 --- /dev/null +++ b/config/locales/zh-TW.yml @@ -0,0 +1,157 @@ +zh-TW: + archive: + next: 下一頁 + of: 之 + previous: 上一頁 + sorry: 你現在還沒有任何已讀的文章! + date: + abbr_month_names: + - + - 一月 + - 二月 + - 三月 + - 四月 + - 五月 + - 六月 + - 七月 + - 八月 + - 九月 + - 十月 + - 十一月 + - 十二月 + feeds: + add: + description: 請填入你想要訂閱的 RSS 訊息來源 + fields: + feed_url: RSS 訊息來源 + submit: 新增 + flash: + added_successfully: 你的訂閱已經新增完畢,請稍等一段時間再回來查看 + already_subscribed_error: 你已經訂閱過這個訊息來源了 + feed_not_found_error: 我們找不到這個訊息來源,麻煩檢查並稍後後再試一次 + title: 想要新增新內容? + edit: + fields: + feed_name: 訊息來源名稱 + feed_url: 訊息來源網址 + group: 群組 + submit: 送出 + flash: + updated_successfully: 訊息來源成功更新! + index: + add: 新增 + add_some_feeds: 嘿!你應該要%{add}一些訂閱 + first_run: + password: + anti_social: 反社交化的 + description: 設定一組你的密碼,然後你就可以開始享受獨自閱讀的樂趣了 + fields: + next: 下一步 + password: 密碼 + password_confirmation: 確認密碼 + flash: + passwords_dont_match: 兩次輸入的密碼不同,麻煩你檢查並重新輸入。 + subtitle: 這裡只會有一個使用者,那就是你 + title: Stringer 是 + flash: + cookies_required: 抱歉,你的瀏覽器似乎停用了 Cookie,請啟用瀏覽器的 Cookie 功能才能正常使用。 + js_required: 抱歉,你的瀏覽器似乎停用了 JavaScript,請啟用瀏覽器的 JavaScript 功能才能正常使用。 + import: + description: '%{link}你在 Google Reader 上的訂閱列表然後再將它們匯入' + export: 匯出 + fields: + import: 匯入 + not_now: 稍後再說 + subtitle: 開始設定你的訂閱吧 + title: 歡迎使用 + layout: + back_to_work: 回去工作吧,懶鬼! + export: 匯出 + hey: 嘿! + import: 匯入 + logout: 登出 + support: 支援 + title: stringer | 你的 RSS 好夥伴 + partials: + action_bar: + add_feed: 新增訂閱 + archived_stories: 已讀文章 + mark_all: 全部標為已讀 + refresh: 重新整理 + starred_stories: 加星號標記的文章 + view_feeds: 查看訂閱列表 + feed: + last_fetched: + never: 尚未成功讀取過 + last_updated: 最後更新於 + status_bubble: + green: 成功! + red: 解析時出現錯誤(而且從來沒成功過!此訂閱可能已經失效!) + yellow: 解析時出現錯誤 (可能只是暫時的) + feed_action_bar: + add_feed: 新增訂閱 + archived_stories: 已讀文章 + feeds: 查看訂閱列表 + home: 返回未讀文章列表 + starred_stories: 加上星號標記的文章 + shortcuts: + keys: + a: 新增訂閱 + bv: 打開到原網址 + f: 到訊息來源頁面 + jk: 下一篇/上一篇文章 + left: 上一頁 + m: 將一個條目標為已讀/未讀 + np: 向上/向下移動 + oenter: 點選打開/關閉 + or: 或 + r: 重新整理 + right: 下一頁 + s: 將條目標為加上星號標記/取消星號標記 + shifta: 全部標為已讀 + title: 快捷鍵 + zen: + archive: 查看所有文章 + go_make: 去做些其它事了 + gtfo: 該停止閱讀 + rss_zero: 你已經達成了清空 RSS 的任務™ + sessions: + destroy: + flash: + logged_out_successfully: 你已經成功登出 + new: + fields: + password: 密碼 + submit: 登入 + flash: + wrong_password: 你輸入的密碼錯誤,麻煩重新輸入 + rss: RSS + subtitle: 歡迎回來,我的朋友。 + title: Stringer 說 + starred: + next: 下一頁 + of: 之 + previous: 上一頁 + sorry: 抱歉,你還沒有為任何條目加上星號標記 + stories: + keep_unread: 保持未讀狀態 + time: + formats: + default: '%b%d日 %H:%M' + tutorial: + add_feed: 新增新訂閱 + as_read: 已讀 + click_to_read: (點選閱讀) + description: 我們正在努力的載入您訂閱的內容,請稍等。 + heroku_hourly_task: 您需要一個每小時執行的工作以檢查新的文章 + heroku_one_more_thing: 還有一件事 ... + heroku_scheduler: 到 Heroku Scheduler 新增這個工作 + mark_all: 全部標為 + ready: OK,我想你已經準備好了~ + refresh: 重新整理 + simple: 簡單的 + start: 開始閱讀吧! + subtitle: 這是一份簡單的使用手冊。 + title: 'Stringer 是 ' + your_feeds: 你的訂閱列表 + your_stories: 你訂閱的內容 From bcbb5c4dbdb08f2b0065a9743db0c05e6132d87f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 14 Jan 2022 20:07:38 -0800 Subject: [PATCH 076/779] Remove sqlite test file (#583) Looks like I accidentally introduced this when [I removed SQLite as a depndency][dep]. [dep]: https://github.com/stringer-rss/stringer/pull/564/files --- db/stringer_test.sqlite | Bin 17408 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 db/stringer_test.sqlite diff --git a/db/stringer_test.sqlite b/db/stringer_test.sqlite deleted file mode 100644 index f1a05088d153800149c0fb3deda6556f83e4e778..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17408 zcmeHOO>7%Q6yDu&?EE&Hw8<)pfR#&|T5ZYB+8aB)fN2dxB<>FhP$99}#FKQ1?R9t8 zp%q-5(q6fM#0`l92RMUzKwP*W4oI9hz<~o-P|E=hTzLEI-HlUKN<@=(R*5tI=FRNP z_ue<__maGJc~Q5CxNevY%@*@aieXvi1yN)eW(vN?;5)dUg+?lP13%eFd$;BkbN2q- zKIrAp-;T`@^sm?0Z2-k71C)XPfq}tcxXD2O2)s^mHiP~|zoH+|UGzEn2yLSldK)dG zbLbSBL@Dks?l{|&4@MA4Dd9POz()%5 zyqt%<75V-Uf&0r?De{>J0+dK4J{=-?T!IzN@qJxHl5nvg@u>j8C71^G!J`n7aY>Pt zJkJFPaE7IlJjb(f1eXTEkCUA0=>He=J^BiLhCW2^BOSet&Lasug$B8QxZk;-xNo^H zLH)Nm6O8Fa8F)Ab#!-%qOMNncx>}#;LV?(i`A|gdM?)x-`*;@$^gb3sUBQP?sQA$? z6iEI^401I;(uD%i4@V$h^+PepmHl7{g}NVzK)&$%W00%-Oa$_!pN>MF_WQa}ApTSY z^3{*JP#}M94CMyE9dOEd5H2~-e-?esz!$wJ1C)V7!N4nQ-|>lZnKZX_(`YtG)3%9a z%kXjPtR$b6OCm0vlcjSw{~X3e_-L|wkMsOz(R~KK=tUWz3_R`(96`qiBIkzl{Et=j z9{2sz{ZR%e10e%c{~;B$K^b`B7@+!p;#^KQOc@9naP*&M?lI^NIuEt|9Q!kKk40hk zW7p`^`ZIzcu(xJxZM9C?7BMaNW$65sN_n{=E|*_itcY0`%ZjJ6dMzvJO`B{GQ>yqmS$P+8fHzc=^Idn$%O^b8NUf!-o8)GA=iH@q zS~z{0z3Oh#x?YFB@lY*ty-k{HB=I&A+jye$R8wn^GcYpuaw;vnrLc_NtdSeOmDaWm z_r0o_szZ|5)aq)3*cxm^Q*ke}uTw=CK~dQ4=iSBivgw7TV$00-GI87$Wg+A?;jb;N z-Uj-7FYVPaxiXg)R%Ul&##*~Z8k*YBH%!geji#mI9T2*~W`x;Uw)2eVujG&&1GqRD zJNg|awji?Me&IfQvXL8MKV=Yel3`AwTihx)!MPs@lCt048q5eMPO!IU-38W2UAqZ^ z`i`+`Mcc#iWktJ^Qi>=@EUzqIT&Tj>rAigV;)@LY(lT|!)NP3CK!JgxBq!*h=-Fu5 zR`1?xTC-LsW>&Px4I8ZMnq{lRG>tA~wwp06I#$NoWF>mvlT@Tr3$TK`@e;>)DQ&9#E z83WGm|LO1l4w=*Faw!A*#DMesPca`e=u`F&_A)dM!qu4{&j?df?DmqIGP)^~<-Lx@ zlSU6rW{nS3T!`n8L81w%(Vh~(TxV)5BfK%qc9z_9&MS{uHqP+6M z{89aJW+QV&lGU&}lSs&I-L6AM?$lb6S$B)Tzn0bY=4S8iRig$4lwJdaW$!5d_?h&c z`~ Date: Fri, 14 Jan 2022 20:15:43 -0800 Subject: [PATCH 077/779] Create codeql-analysis.yml (#584) Auto-generated analyzer provided by Github. Figured it's worth a shot. --- .github/workflows/codeql-analysis.yml | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..980259f7a --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,38 @@ +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + schedule: + - cron: '30 0 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript', 'ruby' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 76917d34c2ffabc8c5567f0dc5d4071f66c2140a Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 15 Jan 2022 12:25:40 -0800 Subject: [PATCH 078/779] set up CircleCI (#594) --- .circleci/config.yml | 103 +++++++++++++++++++++++++++++++++++++++ .rubocop_todo.yml | 112 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 198 insertions(+), 17 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..0bd4ed313 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,103 @@ +version: 2.1 + +orbs: + browser-tools: circleci/browser-tools@1.2.3 + node: circleci/node@5.0.0 + +jobs: + build: + parallelism: 1 + docker: + - image: cimg/ruby:2.7.5-browsers + environment: + BUNDLE_JOBS: 3 + BUNDLE_RETRY: 3 + BUNDLE_PATH: vendor/bundle + PGHOST: 127.0.0.1 + PGUSER: postgres + RAILS_ENV: test + - image: cimg/postgres:10.18 + environment: + POSTGRES_USER: postgres + POSTGRES_DB: app_test + POSTGRES_PASSWORD: + + working_directory: ~/app + + steps: + - checkout + - browser-tools/install-browser-tools + + # - node/install: + # node-version: 16.13.1 + # install-yarn: true + + - run: + name: Which bundler? + command: bundle -v + + # https://circleci.com/docs/2.0/caching/ + - restore_cache: + keys: + - bundle-{{ checksum "Gemfile.lock" }} + - bundle- + + - run: # Install Ruby dependencies + name: Bundle Install + command: bundle check || bundle install + + # - run: + # name: Bundler Audit + # command: bundle exec bundle audit + + - save_cache: + key: bundle-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + + # - restore_cache: + # keys: + # - yarn-{{ checksum "yarn.lock" }} + # - yarn- + + # - run: + # name: Yarn Install + # command: yarn install --cache-folder ~/.cache/yarn + + # - save_cache: + # key: yarn-{{ checksum "yarn.lock" }} + # paths: + # - ~/.cache/yarn + + - run: + name: Wait for DB + command: dockerize -wait tcp://localhost:5432 -timeout 1m + + - run: + name: Database setup + command: bundle exec rake db:create db:schema:load --trace + + # - run: + # name: Brakeman + # command: bundle exec brakeman + + # - run: + # name: Stylelint + # command: yarn stylelint + + - run: + name: Rubocop + command: bundle exec rubocop + + - run: + name: Run rspec in parallel + command: | + bundle exec rspec + # bundle exec rspec --profile 10 \ + # --format RspecJunitFormatter \ + # --out test_results/rspec.xml \ + # --format progress \ + # $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) + + - store_test_results: # https://circleci.com/docs/2.0/collect-test-data/ + path: test_results diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e521faa0d..f37b205fc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,18 +1,25 @@ # This configuration was generated by -# `rubocop --auto-gen-config` -# on 2021-03-28 01:11:19 UTC using RuboCop version 1.10.0. +# `rubocop --auto-gen-config --auto-gen-only-exclude` +# on 2022-01-15 20:13:59 UTC using RuboCop version 1.23.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 41 +# Offense count: 40 # Configuration parameters: Include, IgnoredGems, OnlyFor. # Include: **/*.gemfile, **/Gemfile, **/gems.rb Bundler/GemComment: Exclude: - 'Gemfile' +# Offense count: 40 +# Configuration parameters: Include, AllowedGems. +# SupportedStyles: required, forbidden +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/GemVersion: + EnforcedStyle: forbidden + # Offense count: 9 # Cop supports --auto-correct. Layout/FirstMethodArgumentLineBreak: @@ -24,6 +31,14 @@ Layout/FirstMethodArgumentLineBreak: - 'spec/repositories/story_repository_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/LineEndStringConcatenationIndentation: + Exclude: + - 'spec/helpers/url_helpers_spec.rb' + # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -44,7 +59,29 @@ Layout/MultilineMethodArgumentLineBreaks: - 'spec/controllers/sessions_controller_spec.rb' - 'spec/javascript/test_controller.rb' -# Offense count: 744 +# Offense count: 40 +# Cop supports --auto-correct. +# Configuration parameters: InspectBlocks. +Layout/RedundantLineBreak: + Enabled: false + +# Offense count: 8 +# Cop supports --auto-correct. +Layout/SingleLineBlockChain: + Exclude: + - 'app/tasks/change_password.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/AmbiguousOperatorPrecedence: + Exclude: + - 'spec/factories/feed_factory.rb' + - 'spec/factories/group_factory.rb' + +# Offense count: 754 # Configuration parameters: Only, Ignore. Lint/ConstantResolution: Enabled: false @@ -58,6 +95,7 @@ Lint/EmptyBlock: # Offense count: 13 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods, IgnoredClasses. +# IgnoredMethods: ago, from_now, second, seconds, minute, minutes, hour, hours, day, days, week, weeks, fortnight, fortnights, in_milliseconds # IgnoredClasses: Time, DateTime Lint/NumberConversion: Exclude: @@ -132,7 +170,7 @@ RSpec/DescribeClass: - 'spec/integration/feed_importing_spec.rb' - 'spec/utils/i18n_support_spec.rb' -# Offense count: 132 +# Offense count: 141 # Cop supports --auto-correct. # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit @@ -158,9 +196,9 @@ RSpec/EmptyLineAfterHook: - 'spec/controllers/stories_controller_spec.rb' # Offense count: 50 -# Configuration parameters: Max. +# Configuration parameters: CountAsOne. RSpec/ExampleLength: - Enabled: false + Max: 35 # Offense count: 18 # Cop supports --auto-correct. @@ -244,14 +282,17 @@ RSpec/MessageExpectation: RSpec/MessageSpies: Enabled: false -# Offense count: 96 +# Offense count: 97 RSpec/MultipleExpectations: Max: 8 # Offense count: 7 -# Configuration parameters: AllowSubject. +# Configuration parameters: AllowSubject, Max. RSpec/MultipleMemoizedHelpers: - Max: 9 + Exclude: + - 'spec/fever_api_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' # Offense count: 28 # Configuration parameters: IgnoreSharedExamples. @@ -270,8 +311,12 @@ RSpec/NamedSubject: - 'spec/fever_api/write_mark_item_spec.rb' # Offense count: 9 +# Configuration parameters: Max. RSpec/NestedGroups: - Max: 4 + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/integration/feed_importing_spec.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -367,6 +412,17 @@ Rails/RakeEnvironment: Exclude: - 'Rakefile' +# Offense count: 5 +# Configuration parameters: Include. +# Include: db/migrate/*.rb +Rails/ReversibleMigrationMethodDefinition: + Exclude: + - 'db/migrate/20130423001740_drop_email_from_user.rb' + - 'db/migrate/20130423180446_remove_author_from_stories.rb' + - 'db/migrate/20130425222157_add_delayed_job.rb' + - 'db/migrate/20130821020313_update_nil_entry_ids.rb' + - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' + # Offense count: 15 # Cop supports --auto-correct. # Configuration parameters: AllowImplicitReturn, AllowedReceivers. @@ -395,7 +451,7 @@ Rails/SkipsModelValidations: - 'db/migrate/20140421224454_fix_invalid_unicode.rb' - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' -# Offense count: 30 +# Offense count: 27 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible @@ -477,9 +533,9 @@ Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 690 +# Offense count: 699 # Cop supports --auto-correct. -# Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle. +# Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: Enabled: false @@ -506,8 +562,16 @@ Style/NumericPredicate: Exclude: - 'app/commands/stories/mark_group_as_read.rb' +# Offense count: 4 +Style/OpenStructUse: + Exclude: + - 'spec/factories/feed_factory.rb' + - 'spec/factories/group_factory.rb' + - 'spec/factories/story_factory.rb' + - 'spec/factories/user_factory.rb' + # Offense count: 28 -# Configuration parameters: SuspiciousParamNames. +# Configuration parameters: SuspiciousParamNames, Allowlist. # SuspiciousParamNames: options, opts, args, params, parameters Style/OptionHash: Enabled: false @@ -525,6 +589,14 @@ Style/PercentLiteralDelimiters: - 'spec/helpers/url_helpers_spec.rb' - 'spec/javascript/test_controller.rb' +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: same_as_string_literals, single_quotes, double_quotes +Style/QuotedSymbols: + Exclude: + - 'app/controllers/feeds_controller.rb' + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -563,7 +635,7 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' -# Offense count: 19 +# Offense count: 18 # Cop supports --auto-correct. Style/StringHashKeys: Exclude: @@ -581,7 +653,6 @@ Style/StringHashKeys: - 'spec/fever_api/read_links_spec.rb' - 'spec/fever_api/sync_saved_item_ids_spec.rb' - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/helpers/authentications_helper_spec.rb' # Offense count: 7 # Cop supports --auto-correct. @@ -589,3 +660,10 @@ Style/StringHashKeys: # SupportedStyles: percent, brackets Style/SymbolArray: EnforcedStyle: brackets + +# Offense count: 6 +Style/TopLevelMethodDefinition: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/support/active_record.rb' From f39015ff97c58bc5d7ca283851d8fca94dd40e21 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 15 Jan 2022 12:29:36 -0800 Subject: [PATCH 079/779] Deps: switch from Unicorn to Puma (#570) **What** This switches the server we use from Unicorn to Puma **Why** * Puma is the blessed option [on Heroku][heroku]. * It [works with Capybara][capybara] out of the box. * Ruby 3 [removes `webrick`][ruby3] from the core libraries, so we would need to add it as a dependency for Capybara when upgrading. Might as well consolidate on a single server. **Notes** I also moved `pg` out of the `production` group. [heroku]: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#recommended-default-puma-process-and-thread-configuration [capybara]: https://github.com/teamcapybara/capybara#drivers [ruby3]: https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/ --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 1 - Gemfile | 7 ++----- Gemfile.lock | 12 +++++------- Procfile | 2 +- config/{unicorn.rb => puma.rb} | 20 ++++++++++++++------ docker/supervisord.conf | 4 ++-- spec/spec_helper.rb | 2 +- 8 files changed, 28 insertions(+), 23 deletions(-) rename config/{unicorn.rb => puma.rb} (59%) diff --git a/.rubocop.yml b/.rubocop.yml index a725a457d..7516f6ba1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -33,6 +33,9 @@ Style/Documentation: Style/DoubleNegation: Enabled: false +Style/MissingElse: + Enabled: false + Style/NumericLiterals: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f37b205fc..424cd3d62 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -551,7 +551,6 @@ Style/MissingElse: - 'app/fever_api/write_mark_item.rb' - 'app/helpers/url_helpers.rb' - 'app/repositories/story_repository.rb' - - 'config/unicorn.rb' - 'spec/support/coverage.rb' # Offense count: 1 diff --git a/Gemfile b/Gemfile index 59402bc57..5e9b686a8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,11 +2,6 @@ ruby_version_file = File.expand_path(".ruby-version", __dir__) ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file) source "https://rubygems.org" -group :production do - gem "pg" - gem "unicorn" -end - group :development do gem "rubocop", require: false gem "rubocop-rails", require: false @@ -37,6 +32,8 @@ gem "httparty" gem "i18n" gem "loofah" gem "nokogiri" +gem "pg" +gem "puma" gem "rack-protection" gem "racksh" gem "rack-ssl" diff --git a/Gemfile.lock b/Gemfile.lock index 8ee702421..76bb8b5f7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,7 +56,6 @@ GEM multi_xml (>= 0.5.2) i18n (1.8.11) concurrent-ruby (~> 1.0) - kgio (2.11.4) loofah (2.13.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -72,6 +71,7 @@ GEM multi_xml (0.6.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) + nio4r (2.5.8) nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) @@ -87,6 +87,8 @@ GEM byebug (~> 11.0) pry (~> 0.13.0) public_suffix (4.0.6) + puma (5.5.2) + nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) rack-protection (2.1.0) @@ -99,7 +101,6 @@ GEM rack (>= 1.0) rack-test (>= 0.5) rainbow (3.0.0) - raindrops (0.20.0) rake (13.0.6) rb-fsevent (0.11.0) rb-inotify (0.10.1) @@ -192,9 +193,6 @@ GEM uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.1.0) - unicorn (6.0.0) - kgio (~> 2.6) - raindrops (~> 0.7) will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) @@ -219,6 +217,7 @@ DEPENDENCIES nokogiri pg pry-byebug + puma rack-protection rack-ssl rack-test @@ -242,11 +241,10 @@ DEPENDENCIES thread timecop uglifier - unicorn will_paginate RUBY VERSION ruby 2.7.5 BUNDLED WITH - 2.2.12 + 2.2.33 diff --git a/Procfile b/Procfile index dfa2ae6e9..cceb33ddf 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb +web: bundle exec puma -p $PORT -C ./config/puma.rb console: bundle exec racksh diff --git a/config/unicorn.rb b/config/puma.rb similarity index 59% rename from config/unicorn.rb rename to config/puma.rb index 5b139c6bd..968c37cf0 100644 --- a/config/unicorn.rb +++ b/config/puma.rb @@ -1,10 +1,18 @@ -worker_processes 1 -timeout 30 -preload_app true +workers workers Integer(ENV.fetch("WEB_CONCURRENCY", 1)) +threads_count = Integer(ENV.fetch("MAX_THREADS", 2)) +threads threads_count, threads_count + +rackup DefaultRackup +port ENV.fetch("PORT", 3000) +environment ENV.fetch("RACK_ENV", "development") + +worker_timeout Integer(ENV.fetch("PUMA_WORKER_TIMEOUT", 25)) +worker_shutdown_timeout Integer(ENV.fetch("PUMA_WORKER_SHUTDOWN_TIMEOUT", 25)) +preload_app! @delayed_job_pid = nil -before_fork do |_server, _worker| +before_fork do # the following is highly recommended for Rails + "preload_app true" # as there's no need for the master process to hold a connection ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base) @@ -14,7 +22,7 @@ sleep 1 end -after_fork do |_server, _worker| +on_worker_boot do if defined?(ActiveRecord::Base) env = ENV["RACK_ENV"] || "development" config = YAML.safe_load(ERB.new(File.read("config/database.yml")).result)[env] @@ -22,6 +30,6 @@ end end -after_worker_exit do |_server, _worker, _status| +on_worker_shutdown do Process.kill("QUIT", @delayed_job_pid) if !ENV["RACK_ENV"] || ENV["RACK_ENV"] == "development" end diff --git a/docker/supervisord.conf b/docker/supervisord.conf index 61f5b300d..12c76be16 100644 --- a/docker/supervisord.conf +++ b/docker/supervisord.conf @@ -2,8 +2,8 @@ nodaemon=true loglevel=debug -[program:unicorn] -command=bash -c 'bundle exec rake db:migrate && bundle exec unicorn -p $PORT -c ./config/unicorn.rb' +[program:puma] +command=bash -c 'bundle exec rake db:migrate && bundle exec puma -p $PORT -C ./config/puma.rb' directory=/app autostart=true autorestart=true diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b2b783241..8c57bddd5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,7 +15,7 @@ require "./app" -Capybara.server = :webrick +Capybara.server = :puma, { Silent: true } RSpec.configure do |config| config.include Rack::Test::Methods From cf95af4ab53accbd2f384e90c589a77b8c39812f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 15 Jan 2022 12:36:02 -0800 Subject: [PATCH 080/779] CI: remove Travis configuration (#595) We've [moved to CircleCI][circ]. [circ]: https://github.com/stringer-rss/stringer/pull/594 --- .travis.yml | 23 ----------------------- README.md | 2 +- 2 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c094492b8..000000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -before_install: - - gem update bundler - - 'echo "RUBY_VERSION: $RUBY_VERSION"' -before_script: - - bundle exec rake db:create db:schema:load - - npm install -g mocha-phantomjs@4.1.0 - - bundle exec rake test_js &> /dev/null & - - sleep 5 -cache: bundler -language: ruby -rvm: - - 2.7.5 - - ruby-head -services: - - postgresql -matrix: - allow_failures: - - rvm: ruby-head -script: - - bundle exec rspec - - mocha-phantomjs http://localhost:4567/test - - bundle exec rubocop -sudo: false diff --git a/README.md b/README.md index bf68e7230..5e19838ad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Stringer -[![Build Status](https://api.travis-ci.org/swanson/stringer.svg?style=flat)](https://travis-ci.org/swanson/stringer) +[![CircleCI](https://circleci.com/gh/stringer-rss/stringer/tree/main.svg?style=svg)](https://circleci.com/gh/stringer-rss/stringer/tree/main) [![Code Climate](https://codeclimate.com/github/swanson/stringer.svg?style=flat)](https://codeclimate.com/github/swanson/stringer) [![Coverage Status](https://coveralls.io/repos/swanson/stringer/badge.svg?style=flat)](https://coveralls.io/r/swanson/stringer) From d998cc9d9d29ebd281d47e1a45795300095b6004 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sat, 15 Jan 2022 12:38:59 -0800 Subject: [PATCH 081/779] Update all Bundler dependencies (2022-01-15) (#590) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .rubocop.yml | 8 ++++++++ Gemfile.lock | 38 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7516f6ba1..58256ef71 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -41,3 +41,11 @@ Style/NumericLiterals: Style/StringLiterals: EnforcedStyle: double_quotes + +################################################################################ +# +# Rules we don't want to enable +# +################################################################################ + +Rails/SchemaComment: { Enabled: false } diff --git a/Gemfile.lock b/Gemfile.lock index 76bb8b5f7..b7dc517ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,7 +39,7 @@ GEM delayed_job_active_record (4.1.6) activerecord (>= 3.0, < 6.2) delayed_job (>= 3.0, < 5) - diff-lcs (1.4.4) + diff-lcs (1.5.0) docile (1.4.0) execjs (2.8.1) faker (2.19.0) @@ -47,10 +47,10 @@ GEM feedbag (0.10.1) nokogiri (~> 1.8, >= 1.8.2) open_uri_redirections (~> 0.2) - feedjira (3.2.0) + feedjira (3.2.1) loofah (>= 2.3.1) sax-machine (>= 1.0) - ffi (1.15.4) + ffi (1.15.5) httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) @@ -63,21 +63,21 @@ GEM method_source (1.0.0) mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.1115) + mime-types-data (3.2022.0105) mini_mime (1.1.2) - mini_portile2 (2.6.1) + mini_portile2 (2.7.1) minitest (5.15.0) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.13.1) + mini_portile2 (~> 2.7.0) racc (~> 1.4) open_uri_redirections (0.2.1) parallel (1.21.0) - parser (3.0.3.2) + parser (3.1.0.0) ast (~> 2.4.1) pg (1.2.3) pry (0.13.1) @@ -100,7 +100,7 @@ GEM racksh (1.0.0) rack (>= 1.0) rack-test (>= 0.5) - rainbow (3.0.0) + rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.0) rb-inotify (0.10.1) @@ -113,7 +113,7 @@ GEM rspec-mocks (~> 3.10.0) rspec-core (3.10.1) rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec-expectations (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-html-matchers (0.9.4) @@ -123,24 +123,24 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) - rubocop (1.23.0) + rubocop (1.24.1) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.12.0, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.0) + rubocop-ast (1.15.1) parser (>= 3.0.1.1) - rubocop-rails (2.12.4) + rubocop-rails (2.13.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.6.0) + rubocop-rspec (2.7.0) rubocop (~> 1.19) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) @@ -163,7 +163,7 @@ GEM rack (~> 2.2) rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.23) + sinatra-activerecord (2.0.25) activerecord (>= 4.1) sinatra (>= 1.0) sinatra-contrib (2.1.0) @@ -182,11 +182,11 @@ GEM sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) - thor (1.1.0) + thor (1.2.1) thread (0.2.2) tilt (2.0.10) timecop (0.9.4) - tins (1.29.1) + tins (1.31.0) sync tzinfo (2.0.4) concurrent-ruby (~> 1.0) @@ -196,7 +196,7 @@ GEM will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.5.1) + zeitwerk (2.5.3) PLATFORMS ruby From 32a6043cd6c2712d624fc644cd049eac18677af9 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 16 Jan 2022 09:43:17 -0800 Subject: [PATCH 082/779] Docker: upgrade Ruby version (#596) Not sure, but I believe this will fix issues with HTTPS. I also removed the deprecated `--deployment` flag when running `bundle install`. --- Dockerfile | 4 ++-- README.md | 2 +- docker-compose.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8ccb1ad59..c01771de1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.3.3 +FROM ruby:2.7.5 ENV RACK_ENV=production ENV PORT=8080 @@ -7,7 +7,7 @@ EXPOSE 8080 WORKDIR /app ADD Gemfile Gemfile.lock /app/ -RUN bundle install --deployment +RUN bundle install RUN apt-get update \ && apt-get install -y --no-install-recommends \ diff --git a/README.md b/README.md index 5e19838ad..bac28e2df 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ But it does have keyboard shortcuts and was made with love! ## Installation -Stringer is a Ruby (2.3.0+) app based on Sinatra, ActiveRecord, PostgreSQL, Backbone.js and DelayedJob. +Stringer is a Ruby app based on Sinatra, ActiveRecord, PostgreSQL, Backbone.js and DelayedJob. [![Deploy to Heroku](https://cdn.herokuapp.com/deploy/button.svg)](https://heroku.com/deploy) diff --git a/docker-compose.yml b/docker-compose.yml index 06ac17b91..5ee759568 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - POSTGRES_DB=stringer web: - image: mdswanson/stringer + image: mockdeep/stringer depends_on: - postgres restart: always From d7ba8c34cd1eb038f8a6821c0672e9fd99211cd1 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 12:27:06 -0800 Subject: [PATCH 083/779] Update Ruby to version 3.1.0 (#589) Needed to fix an issue with keyword arguments in app.rb Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .circleci/config.yml | 2 +- .rubocop_todo.yml | 31 +++++++++++++------------------ .ruby-version | 2 +- Dockerfile | 2 +- Gemfile.lock | 2 +- app.rb | 4 ++-- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0bd4ed313..b6fd7fa90 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: build: parallelism: 1 docker: - - image: cimg/ruby:2.7.5-browsers + - image: cimg/ruby:3.1.0-browsers environment: BUNDLE_JOBS: 3 BUNDLE_RETRY: 3 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 424cd3d62..b54bf5cfb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude` -# on 2022-01-15 20:13:59 UTC using RuboCop version 1.23.0. +# on 2022-01-22 20:24:27 UTC using RuboCop version 1.24.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -81,7 +81,7 @@ Lint/AmbiguousOperatorPrecedence: - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' -# Offense count: 754 +# Offense count: 761 # Configuration parameters: Only, Ignore. Lint/ConstantResolution: Enabled: false @@ -391,7 +391,7 @@ Rails/HttpPositionalArguments: - 'spec/fever_api_spec.rb' # Offense count: 1 -# Configuration parameters: Include. +# Configuration parameters: IgnoreScopes, Include. # Include: app/models/**/*.rb Rails/InverseOf: Exclude: @@ -414,7 +414,7 @@ Rails/RakeEnvironment: # Offense count: 5 # Configuration parameters: Include. -# Include: db/migrate/*.rb +# Include: db/**/*.rb Rails/ReversibleMigrationMethodDefinition: Exclude: - 'db/migrate/20130423001740_drop_email_from_user.rb' @@ -528,31 +528,26 @@ Style/DocumentationMethod: Style/FrozenStringLiteralComment: Enabled: false +# Offense count: 84 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never +Style/HashSyntax: + Enabled: false + # Offense count: 1 Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 699 +# Offense count: 700 # Cop supports --auto-correct. # Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: Enabled: false -# Offense count: 8 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: if, case, both -Style/MissingElse: - Exclude: - - 'Rakefile' - - 'app.rb' - - 'app/commands/stories/mark_group_as_read.rb' - - 'app/fever_api/write_mark_item.rb' - - 'app/helpers/url_helpers.rb' - - 'app/repositories/story_repository.rb' - - 'spec/support/coverage.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IgnoredMethods. diff --git a/.ruby-version b/.ruby-version index a603bb50a..fd2a01863 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.5 +3.1.0 diff --git a/Dockerfile b/Dockerfile index c01771de1..28d49344b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7.5 +FROM ruby:3.1.0 ENV RACK_ENV=production ENV PORT=8080 diff --git a/Gemfile.lock b/Gemfile.lock index b7dc517ce..251ad8cae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -244,7 +244,7 @@ DEPENDENCIES will_paginate RUBY VERSION - ruby 2.7.5 + ruby 3.1.0 BUNDLED WITH 2.2.33 diff --git a/app.rb b/app.rb index 1169a3b32..6021a8dd3 100644 --- a/app.rb +++ b/app.rb @@ -56,8 +56,8 @@ def render_js(name, locals = {}) erb "js/#{name}.js".to_sym, layout: false, locals: locals end - def t(*args) - I18n.t(*args) + def t(*args, **kwargs) + I18n.t(*args, **kwargs) end end From 4af8012319f61bb6e94283b0702dd12a92f6b0d3 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 24 Jan 2022 09:50:05 -0800 Subject: [PATCH 084/779] Update all Bundler dependencies (2022-01-24) (#597) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 251ad8cae..90a73de9a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,17 +1,16 @@ GEM remote: https://rubygems.org/ specs: - activemodel (6.1.4.4) - activesupport (= 6.1.4.4) - activerecord (6.1.4.4) - activemodel (= 6.1.4.4) - activesupport (= 6.1.4.4) - activesupport (6.1.4.4) + activemodel (7.0.1) + activesupport (= 7.0.1) + activerecord (7.0.1) + activemodel (= 7.0.1) + activesupport (= 7.0.1) + activesupport (7.0.1) 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) @@ -34,10 +33,10 @@ GEM thor (>= 0.20.3, < 2.0) tins (~> 1.16) crass (1.0.6) - delayed_job (4.1.9) - activesupport (>= 3.0, < 6.2) - delayed_job_active_record (4.1.6) - activerecord (>= 3.0, < 6.2) + delayed_job (4.1.10) + activesupport (>= 3.0, < 8.0) + delayed_job_active_record (4.1.7) + activerecord (>= 3.0, < 8.0) delayed_job (>= 3.0, < 5) diff-lcs (1.5.0) docile (1.4.0) @@ -79,7 +78,7 @@ GEM parallel (1.21.0) parser (3.1.0.0) ast (~> 2.4.1) - pg (1.2.3) + pg (1.3.0) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -123,9 +122,9 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) - rubocop (1.24.1) + rubocop (1.25.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml @@ -196,7 +195,6 @@ GEM will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.5.3) PLATFORMS ruby From 6e9c117cc424e2c1b339b191ce96f5ca3beb9d9b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 31 Jan 2022 08:14:35 -0800 Subject: [PATCH 085/779] Update all Bundler dependencies (2022-01-31) (#598) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 90a73de9a..74c9f824a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.8.11) + i18n (1.9.1) concurrent-ruby (~> 1.0) loofah (2.13.0) crass (~> 1.0.2) @@ -86,7 +86,7 @@ GEM byebug (~> 11.0) pry (~> 0.13.0) public_suffix (4.0.6) - puma (5.5.2) + puma (5.6.1) nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) @@ -110,7 +110,7 @@ GEM rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) + rspec-core (3.10.2) rspec-support (~> 3.10.0) rspec-expectations (3.10.2) diff-lcs (>= 1.2.0, < 2.0) @@ -118,7 +118,7 @@ GEM rspec-html-matchers (0.9.4) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.10.2) + rspec-mocks (3.10.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) @@ -139,7 +139,7 @@ GEM rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.7.0) + rubocop-rspec (2.8.0) rubocop (~> 1.19) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) From ad943bb089c9e6443ec88287b71a22642a43ab5f Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 7 Feb 2022 10:09:21 -0800 Subject: [PATCH 086/779] Update all Bundler dependencies (2022-02-07) (#599) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 74c9f824a..cc716ab80 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,7 +78,7 @@ GEM parallel (1.21.0) parser (3.1.0.0) ast (~> 2.4.1) - pg (1.3.0) + pg (1.3.1) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -101,7 +101,7 @@ GEM rack-test (>= 0.5) rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.0) + rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (2.2.0) @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) - rubocop (1.25.0) + rubocop (1.25.1) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) From 65d19e922eb2925d317173ce94db78f59f0aa40a Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sat, 12 Feb 2022 21:10:04 -0800 Subject: [PATCH 087/779] Update puma to version 5.6.2 (#601) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index cc716ab80..d649b3270 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM byebug (~> 11.0) pry (~> 0.13.0) public_suffix (4.0.6) - puma (5.6.1) + puma (5.6.2) nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) From 3c0c3bd84a759b0f8d33c470e035eddee2ed7b63 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 14 Feb 2022 10:09:18 -0800 Subject: [PATCH 088/779] Update all Bundler dependencies (2022-02-14) (#602) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d649b3270..2215878a8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activemodel (7.0.1) - activesupport (= 7.0.1) - activerecord (7.0.1) - activemodel (= 7.0.1) - activesupport (= 7.0.1) - activesupport (7.0.1) + activemodel (7.0.2.2) + activesupport (= 7.0.2.2) + activerecord (7.0.2.2) + activemodel (= 7.0.2.2) + activesupport (= 7.0.2.2) + activesupport (7.0.2.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -55,7 +55,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.9.1) concurrent-ruby (~> 1.0) - loofah (2.13.0) + loofah (2.14.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) matrix (0.4.2) @@ -104,24 +104,24 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.2.0) + regexp_parser (2.2.1) rexml (3.2.5) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.2) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.2) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + 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.10.0) + rspec-support (~> 3.11.0) rspec-html-matchers (0.9.4) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.10.3) + rspec-mocks (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.3) + rspec-support (~> 3.11.0) + rspec-support (3.11.0) rubocop (1.25.1) parallel (~> 1.10) parser (>= 3.1.0.0) @@ -131,7 +131,7 @@ GEM rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) + rubocop-ast (1.15.2) parser (>= 3.0.1.1) rubocop-rails (2.13.2) activesupport (>= 4.2.0) From c6cdd207fbc4623d5269f6a3da45810d98471f80 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 21 Feb 2022 11:06:08 -0800 Subject: [PATCH 089/779] Update all Bundler dependencies (2022-02-21) (#604) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2215878a8..2029f3ab4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.9.1) + i18n (1.10.0) concurrent-ruby (~> 1.0) loofah (2.14.0) crass (~> 1.0.2) @@ -78,7 +78,7 @@ GEM parallel (1.21.0) parser (3.1.0.0) ast (~> 2.4.1) - pg (1.3.1) + pg (1.3.2) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -90,7 +90,7 @@ GEM nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) - rack-protection (2.1.0) + rack-protection (2.2.0) rack rack-ssl (1.4.1) rack @@ -156,20 +156,20 @@ GEM simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) - sinatra (2.1.0) + simplecov_json_formatter (0.1.4) + sinatra (2.2.0) mustermann (~> 1.0) rack (~> 2.2) - rack-protection (= 2.1.0) + rack-protection (= 2.2.0) tilt (~> 2.0) sinatra-activerecord (2.0.25) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (2.1.0) + sinatra-contrib (2.2.0) multi_json mustermann (~> 1.0) - rack-protection (= 2.1.0) - sinatra (= 2.1.0) + rack-protection (= 2.2.0) + sinatra (= 2.2.0) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) From f5097fe09997752521dd1dc9c9d41967b389ae65 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 21 Feb 2022 13:04:42 -0800 Subject: [PATCH 090/779] Update nokogiri to version 1.13.2 (#605) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2029f3ab4..1fec77642 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,15 +64,15 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) mini_mime (1.1.2) - mini_portile2 (2.7.1) + mini_portile2 (2.8.0) minitest (5.15.0) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.1) - mini_portile2 (~> 2.7.0) + nokogiri (1.13.2) + mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) parallel (1.21.0) From 645fcc7357b3dea23eee05f7e6146749475fb234 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 23 Feb 2022 10:41:36 -0800 Subject: [PATCH 091/779] Update Ruby to version 3.1.1 (#603) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .circleci/config.yml | 2 +- .ruby-version | 2 +- Dockerfile | 2 +- Gemfile.lock | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b6fd7fa90..25f7b27fd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: build: parallelism: 1 docker: - - image: cimg/ruby:3.1.0-browsers + - image: cimg/ruby:3.1.1-browsers environment: BUNDLE_JOBS: 3 BUNDLE_RETRY: 3 diff --git a/.ruby-version b/.ruby-version index fd2a01863..94ff29cc4 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.0 +3.1.1 diff --git a/Dockerfile b/Dockerfile index 28d49344b..6879f9f79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.1.0 +FROM ruby:3.1.1 ENV RACK_ENV=production ENV PORT=8080 diff --git a/Gemfile.lock b/Gemfile.lock index 1fec77642..a85a02a10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -242,7 +242,7 @@ DEPENDENCIES will_paginate RUBY VERSION - ruby 3.1.0 + ruby 3.1.1 BUNDLED WITH 2.2.33 From acd55af076ffcda3e17240f82cba5776405c1f79 Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Sun, 27 Feb 2022 16:21:20 -0700 Subject: [PATCH 092/779] Update docker-compose.yml (#607) Add build directive so running `docker-compose up` works. --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 5ee759568..8293e4752 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: web: image: mockdeep/stringer + build: . depends_on: - postgres restart: always From e7796c74c1ac2959bfd25db68faed1463b6a56e4 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 28 Feb 2022 08:41:58 -0800 Subject: [PATCH 093/779] Update all Bundler dependencies (2022-02-28) (#608) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a85a02a10..8f96e9936 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,14 +71,14 @@ GEM mustermann (1.1.1) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.2) + nokogiri (1.13.3) mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) parallel (1.21.0) - parser (3.1.0.0) + parser (3.1.1.0) ast (~> 2.4.1) - pg (1.3.2) + pg (1.3.3) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -131,8 +131,8 @@ GEM rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.2) - parser (>= 3.0.1.1) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) rubocop-rails (2.13.2) activesupport (>= 4.2.0) rack (>= 1.1) From ab86abb80192c4e5190a5c45767f00c3fda587e8 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 09:55:00 -0800 Subject: [PATCH 094/779] Update all Bundler dependencies (2022-03-07) (#609) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- spec/commands/feeds/add_new_feed_spec.rb | 2 +- spec/commands/users/complete_setup_spec.rb | 2 +- spec/controllers/stories_controller_spec.rb | 12 ++++++------ spec/helpers/authentications_helper_spec.rb | 8 ++++---- spec/repositories/story_repository_spec.rb | 2 +- spec/repositories/user_repository_spec.rb | 2 +- spec/utils/feed_discovery_spec.rb | 4 ++-- spec/utils/i18n_support_spec.rb | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8f96e9936..e5f9a4b11 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,8 +41,8 @@ GEM diff-lcs (1.5.0) docile (1.4.0) execjs (2.8.1) - faker (2.19.0) - i18n (>= 1.6, < 2) + faker (2.20.0) + i18n (>= 1.8.11, < 2) feedbag (0.10.1) nokogiri (~> 1.8, >= 1.8.2) open_uri_redirections (~> 0.2) @@ -139,7 +139,7 @@ GEM rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.8.0) + rubocop-rspec (2.9.0) rubocop (~> 1.19) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) @@ -173,7 +173,7 @@ GEM tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) - sprockets (4.0.2) + sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-helpers (1.4.0) diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 38451e2e4..22fde4e76 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -9,7 +9,7 @@ it "returns false if cant discover any feeds" do result = AddNewFeed.add("http://not-a-feed.com", discoverer) - expect(result).to eq(false) + expect(result).to be(false) end end diff --git a/spec/commands/users/complete_setup_spec.rb b/spec/commands/users/complete_setup_spec.rb index df34301c3..b967d6929 100644 --- a/spec/commands/users/complete_setup_spec.rb +++ b/spec/commands/users/complete_setup_spec.rb @@ -8,6 +8,6 @@ expect(user).to receive(:save).once result = CompleteSetup.complete(user) - expect(result.setup_complete).to eq(true) + expect(result.setup_complete).to be(true) end end diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index d0ebe15d9..aacd5840d 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -95,7 +95,7 @@ put "/stories/#{story_one.id}", { is_read: true }.to_json - expect(story_one.is_read).to eq true + expect(story_one.is_read).to be true end end @@ -105,7 +105,7 @@ put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json - expect(story_one.is_read).to eq true + expect(story_one.is_read).to be true end end end @@ -115,7 +115,7 @@ it "marks a story as permanently unread" do put "/stories/#{story_one.id}", { keep_unread: false }.to_json - expect(story_one.keep_unread).to eq false + expect(story_one.keep_unread).to be false end end @@ -123,7 +123,7 @@ it "marks a story as permanently unread" do put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json - expect(story_one.keep_unread).to eq true + expect(story_one.keep_unread).to be true end end end @@ -133,7 +133,7 @@ it "marks a story as permanently starred" do put "/stories/#{story_one.id}", { is_starred: true }.to_json - expect(story_one.is_starred).to eq true + expect(story_one.is_starred).to be true end end @@ -141,7 +141,7 @@ it "marks a story as permanently starred" do put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json - expect(story_one.is_starred).to eq true + expect(story_one.is_starred).to be true end end end diff --git a/spec/helpers/authentications_helper_spec.rb b/spec/helpers/authentications_helper_spec.rb index eb95f0555..0db0086a1 100644 --- a/spec/helpers/authentications_helper_spec.rb +++ b/spec/helpers/authentications_helper_spec.rb @@ -20,14 +20,14 @@ class Helper # rubocop:disable Lint/ConstantDefinitionInBlock it "returns false" do allow(UserRepository).to receive(:setup_complete?).and_return(false) - expect(helper.needs_authentication?(authenticated_path)).to eq(false) + expect(helper.needs_authentication?(authenticated_path)).to be(false) end end %w(/login /logout /heroku).each do |path| context "when `path` is '#{path}'" do it "returns false" do - expect(helper.needs_authentication?(path)).to eq(false) + expect(helper.needs_authentication?(path)).to be(false) end end end @@ -35,14 +35,14 @@ class Helper # rubocop:disable Lint/ConstantDefinitionInBlock %w(css js img).each do |path| context "when `path` contains '#{path}'" do it "returns false" do - expect(helper.needs_authentication?("/#{path}/file.ext")).to eq(false) + expect(helper.needs_authentication?("/#{path}/file.ext")).to be(false) end end end context "otherwise" do it "returns true" do - expect(helper.needs_authentication?(authenticated_path)).to eq(true) + expect(helper.needs_authentication?(authenticated_path)).to be(true) end end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 75ac83dde..fedac02c1 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -385,7 +385,7 @@ feed = double(url: "http://github.com") entry = double(url: nil) - expect(StoryRepository.extract_url(entry, feed)).to eq nil + expect(StoryRepository.extract_url(entry, feed)).to be_nil end end diff --git a/spec/repositories/user_repository_spec.rb b/spec/repositories/user_repository_spec.rb index c6662f63d..26c051598 100644 --- a/spec/repositories/user_repository_spec.rb +++ b/spec/repositories/user_repository_spec.rb @@ -6,7 +6,7 @@ describe UserRepository do describe ".fetch" do it "returns nil when given id is nil" do - expect(UserRepository.fetch(nil)).to be(nil) + expect(UserRepository.fetch(nil)).to be_nil end it "returns the user for the given id" do diff --git a/spec/utils/feed_discovery_spec.rb b/spec/utils/feed_discovery_spec.rb index 19be6b4eb..ccb475948 100644 --- a/spec/utils/feed_discovery_spec.rb +++ b/spec/utils/feed_discovery_spec.rb @@ -20,7 +20,7 @@ result = FeedDiscovery.new.discover(url, finder, parser, client) - expect(result).to eq(false) + expect(result).to be(false) end it "returns a feed if the url provided is parsable" do @@ -43,7 +43,7 @@ result = FeedDiscovery.new.discover(url, finder, parser, client) - expect(result).to eq(false) + expect(result).to be(false) end it "returns the feed if the discovered feed is parsable" do diff --git a/spec/utils/i18n_support_spec.rb b/spec/utils/i18n_support_spec.rb index 861f1f713..edca8a19f 100644 --- a/spec/utils/i18n_support_spec.rb +++ b/spec/utils/i18n_support_spec.rb @@ -12,7 +12,7 @@ it "should load default locale" do expect(I18n.locale.to_s).to eq "en" - expect(I18n.locale.to_s).not_to eq nil + expect(I18n.locale.to_s).not_to be_nil end end From 9044f9c85894432c1f9edcd7f2b30cbf6dbecc92 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 14 Mar 2022 09:43:20 -0700 Subject: [PATCH 095/779] Update all Bundler dependencies (2022-03-14) (#610) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e5f9a4b11..bca5553a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activemodel (7.0.2.2) - activesupport (= 7.0.2.2) - activerecord (7.0.2.2) - activemodel (= 7.0.2.2) - activesupport (= 7.0.2.2) - activesupport (7.0.2.2) + activemodel (7.0.2.3) + activesupport (= 7.0.2.3) + activerecord (7.0.2.3) + activemodel (= 7.0.2.3) + activesupport (= 7.0.2.3) + activesupport (7.0.2.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -27,7 +27,7 @@ GEM xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.1.9) - coveralls_reborn (0.23.1) + coveralls_reborn (0.24.0) simplecov (>= 0.18.1, < 0.22.0) term-ansicolor (~> 1.6) thor (>= 0.20.3, < 2.0) @@ -78,7 +78,7 @@ GEM parallel (1.21.0) parser (3.1.1.0) ast (~> 2.4.1) - pg (1.3.3) + pg (1.3.4) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -122,13 +122,13 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.25.1) + rubocop (1.26.0) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.15.1, < 2.0) + rubocop-ast (>= 1.16.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.16.0) @@ -184,7 +184,7 @@ GEM thor (1.2.1) thread (0.2.2) tilt (2.0.10) - timecop (0.9.4) + timecop (0.9.5) tins (1.31.0) sync tzinfo (2.0.4) From 7027fa56b6a5017afd1ec84635d1cc955edc3467 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sun, 20 Mar 2022 23:54:14 -0700 Subject: [PATCH 096/779] Update all Bundler dependencies (2022-03-21) (#611) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bca5553a9..44af5b6b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ GEM addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) - bcrypt (3.1.16) + bcrypt (3.1.17) byebug (11.1.3) capybara (3.36.0) addressable @@ -55,7 +55,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.10.0) concurrent-ruby (~> 1.0) - loofah (2.14.0) + loofah (2.15.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) matrix (0.4.2) @@ -75,7 +75,7 @@ GEM mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) - parallel (1.21.0) + parallel (1.22.0) parser (3.1.1.0) ast (~> 2.4.1) pg (1.3.4) @@ -133,7 +133,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.16.0) parser (>= 3.1.1.0) - rubocop-rails (2.13.2) + rubocop-rails (2.14.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) From 223f7562613145aa9294cdfb5253e0f211a9179b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:53:29 -0700 Subject: [PATCH 097/779] Update all Bundler dependencies (2022-03-28) (#613) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 44af5b6b3..e9f2582c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,7 +26,7 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) coderay (1.1.3) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) coveralls_reborn (0.24.0) simplecov (>= 0.18.1, < 0.22.0) term-ansicolor (~> 1.6) @@ -75,7 +75,7 @@ GEM mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) - parallel (1.22.0) + parallel (1.22.1) parser (3.1.1.0) ast (~> 2.4.1) pg (1.3.4) @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.26.0) + rubocop (1.26.1) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) From bda1388c7e04f7937b7ff36276cf4524b8090041 Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Wed, 30 Mar 2022 23:24:38 +0200 Subject: [PATCH 098/779] Replace removed update_attributes method (#614) This will replace the method `update_attributes` that was removed in ActiveRecord 6.1. Fixes #612 Refactored tests to not mock out method calls --- app/commands/stories/mark_as_read.rb | 5 ++--- app/commands/stories/mark_as_starred.rb | 5 ++--- app/commands/stories/mark_as_unread.rb | 5 ++--- app/commands/stories/mark_as_unstarred.rb | 5 ++--- spec/commands/stories/mark_as_read_spec.rb | 9 ++++----- spec/commands/stories/mark_as_starred_spec.rb | 9 ++++----- spec/commands/stories/mark_as_unread_spec.rb | 9 ++++----- spec/commands/stories/mark_as_unstarred_spec.rb | 9 ++++----- 8 files changed, 24 insertions(+), 32 deletions(-) diff --git a/app/commands/stories/mark_as_read.rb b/app/commands/stories/mark_as_read.rb index 93fb679ae..a2ddb121a 100644 --- a/app/commands/stories/mark_as_read.rb +++ b/app/commands/stories/mark_as_read.rb @@ -1,12 +1,11 @@ require_relative "../../repositories/story_repository" class MarkAsRead - def initialize(story_id, repository = StoryRepository) + def initialize(story_id) @story_id = story_id - @repo = repository end def mark_as_read - @repo.fetch(@story_id).update_attributes(is_read: true) + StoryRepository.fetch(@story_id).update!(is_read: true) end end diff --git a/app/commands/stories/mark_as_starred.rb b/app/commands/stories/mark_as_starred.rb index aff11e67f..e20ba4f0a 100644 --- a/app/commands/stories/mark_as_starred.rb +++ b/app/commands/stories/mark_as_starred.rb @@ -1,12 +1,11 @@ require_relative "../../repositories/story_repository" class MarkAsStarred - def initialize(story_id, repository = StoryRepository) + def initialize(story_id) @story_id = story_id - @repo = repository end def mark_as_starred - @repo.fetch(@story_id).update_attributes(is_starred: true) + StoryRepository.fetch(@story_id).update!(is_starred: true) end end diff --git a/app/commands/stories/mark_as_unread.rb b/app/commands/stories/mark_as_unread.rb index d1d90fb3c..a16791501 100644 --- a/app/commands/stories/mark_as_unread.rb +++ b/app/commands/stories/mark_as_unread.rb @@ -1,12 +1,11 @@ require_relative "../../repositories/story_repository" class MarkAsUnread - def initialize(story_id, repository = StoryRepository) + def initialize(story_id) @story_id = story_id - @repo = repository end def mark_as_unread - @repo.fetch(@story_id).update_attributes(is_read: false) + StoryRepository.fetch(@story_id).update!(is_read: false) end end diff --git a/app/commands/stories/mark_as_unstarred.rb b/app/commands/stories/mark_as_unstarred.rb index f6e6afe9c..4a616a25a 100644 --- a/app/commands/stories/mark_as_unstarred.rb +++ b/app/commands/stories/mark_as_unstarred.rb @@ -1,12 +1,11 @@ require_relative "../../repositories/story_repository" class MarkAsUnstarred - def initialize(story_id, repository = StoryRepository) + def initialize(story_id) @story_id = story_id - @repo = repository end def mark_as_unstarred - @repo.fetch(@story_id).update_attributes(is_starred: false) + StoryRepository.fetch(@story_id).update!(is_starred: false) end end diff --git a/spec/commands/stories/mark_as_read_spec.rb b/spec/commands/stories/mark_as_read_spec.rb index b24ff9d74..c53e4bf02 100644 --- a/spec/commands/stories/mark_as_read_spec.rb +++ b/spec/commands/stories/mark_as_read_spec.rb @@ -4,13 +4,12 @@ describe MarkAsRead do describe "#mark_as_read" do - let(:story) { double } - let(:repo) { double(fetch: story) } + let(:story) { create_story(is_read: false) } it "marks a story as read" do - command = MarkAsRead.new(1, repo) - expect(story).to receive(:update_attributes).with(is_read: true) - command.mark_as_read + expect { MarkAsRead.new(story.id).mark_as_read } + .to change { Story.find(story.id).is_read } + .to(true) end end end diff --git a/spec/commands/stories/mark_as_starred_spec.rb b/spec/commands/stories/mark_as_starred_spec.rb index ecfca860a..1ddfa15bb 100644 --- a/spec/commands/stories/mark_as_starred_spec.rb +++ b/spec/commands/stories/mark_as_starred_spec.rb @@ -4,13 +4,12 @@ describe MarkAsStarred do describe "#mark_as_starred" do - let(:story) { double } - let(:repo) { double(fetch: story) } + let(:story) { create_story(is_starred: false) } it "marks a story as starred" do - command = MarkAsStarred.new(1, repo) - expect(story).to receive(:update_attributes).with(is_starred: true) - command.mark_as_starred + expect { MarkAsStarred.new(story.id).mark_as_starred } + .to change { Story.find(story.id).is_starred } + .to(true) end end end diff --git a/spec/commands/stories/mark_as_unread_spec.rb b/spec/commands/stories/mark_as_unread_spec.rb index 51716ed01..565def114 100644 --- a/spec/commands/stories/mark_as_unread_spec.rb +++ b/spec/commands/stories/mark_as_unread_spec.rb @@ -4,13 +4,12 @@ describe MarkAsUnread do describe "#mark_as_unread" do - let(:story) { double } - let(:repo) { double(fetch: story) } + let(:story) { create_story(is_read: true) } it "marks a story as unread" do - command = MarkAsUnread.new(1, repo) - expect(story).to receive(:update_attributes).with(is_read: false) - command.mark_as_unread + expect { MarkAsUnread.new(story.id).mark_as_unread } + .to change { Story.find(story.id).is_read } + .to(false) end end end diff --git a/spec/commands/stories/mark_as_unstarred_spec.rb b/spec/commands/stories/mark_as_unstarred_spec.rb index d55d94418..de3844685 100644 --- a/spec/commands/stories/mark_as_unstarred_spec.rb +++ b/spec/commands/stories/mark_as_unstarred_spec.rb @@ -4,13 +4,12 @@ describe MarkAsUnstarred do describe "#mark_as_unstarred" do - let(:story) { double } - let(:repo) { double(fetch: story) } + let(:story) { create_story(is_starred: true) } it "marks a story as unstarred" do - command = MarkAsUnstarred.new(1, repo) - expect(story).to receive(:update_attributes).with(is_starred: false) - command.mark_as_unstarred + expect { MarkAsUnstarred.new(story.id).mark_as_unstarred } + .to change { Story.find(story.id).is_starred } + .to(false) end end end From 94acf07254f2ffab915e279f06e253c348a4bfbb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 15:55:33 -0700 Subject: [PATCH 099/779] Bump puma from 5.6.2 to 5.6.4 (#615) Bumps [puma](https://github.com/puma/puma) from 5.6.2 to 5.6.4. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v5.6.2...v5.6.4) --- updated-dependencies: - dependency-name: puma dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e9f2582c1..8a9a9bc35 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM byebug (~> 11.0) pry (~> 0.13.0) public_suffix (4.0.6) - puma (5.6.2) + puma (5.6.4) nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) From 8a4da941df4f2736baa5482369aba94aadfeccf4 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 4 Apr 2022 09:43:40 -0700 Subject: [PATCH 100/779] Update all Bundler dependencies (2022-04-04) (#616) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8a9a9bc35..fef5c887b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,7 +55,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.10.0) concurrent-ruby (~> 1.0) - loofah (2.15.0) + loofah (2.16.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) matrix (0.4.2) @@ -78,7 +78,7 @@ GEM parallel (1.22.1) parser (3.1.1.0) ast (~> 2.4.1) - pg (1.3.4) + pg (1.3.5) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -118,7 +118,7 @@ GEM rspec-html-matchers (0.9.4) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.11.0) + rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) From 03230785b7608f9e01bdd949fe805e8415bbd5bb Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 23:34:14 -0700 Subject: [PATCH 101/779] Update all Bundler dependencies (2022-04-11) (#617) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fef5c887b..a29b35c19 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,7 +104,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.2.1) + regexp_parser (2.3.0) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.26.1) + rubocop (1.27.0) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) @@ -131,7 +131,7 @@ GEM rubocop-ast (>= 1.16.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.16.0) + rubocop-ast (1.17.0) parser (>= 3.1.1.0) rubocop-rails (2.14.2) activesupport (>= 4.2.0) From 780780d11fd510a778992671f4b804bb1b0844ec Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 21:33:16 -0700 Subject: [PATCH 102/779] Update nokogiri to version 1.13.4 (#618) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index a29b35c19..6dcc7ef8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ GEM mustermann (1.1.1) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.3) + nokogiri (1.13.4) mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) From 7ed8aa697c5d19cd22651cf2877512a6152a4c3f Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Thu, 14 Apr 2022 09:46:42 -0700 Subject: [PATCH 103/779] Update Ruby to version 3.1.2 (#619) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .circleci/config.yml | 2 +- .ruby-version | 2 +- Dockerfile | 2 +- Gemfile.lock | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 25f7b27fd..8c5336ecb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: build: parallelism: 1 docker: - - image: cimg/ruby:3.1.1-browsers + - image: cimg/ruby:3.1.2-browsers environment: BUNDLE_JOBS: 3 BUNDLE_RETRY: 3 diff --git a/.ruby-version b/.ruby-version index 94ff29cc4..ef538c281 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.1 +3.1.2 diff --git a/Dockerfile b/Dockerfile index 6879f9f79..e5952ba18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.1.1 +FROM ruby:3.1.2 ENV RACK_ENV=production ENV PORT=8080 diff --git a/Gemfile.lock b/Gemfile.lock index 6dcc7ef8f..ef697df8c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -242,7 +242,7 @@ DEPENDENCIES will_paginate RUBY VERSION - ruby 3.1.1 + ruby 3.1.2 BUNDLED WITH 2.2.33 From 14a986c45b14a69463a2f14ebd2c39a2cfec26bb Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 10:02:13 -0700 Subject: [PATCH 104/779] Update all Bundler dependencies (2022-04-18) (#620) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ef697df8c..564237a4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,7 +76,7 @@ GEM racc (~> 1.4) open_uri_redirections (0.2.1) parallel (1.22.1) - parser (3.1.1.0) + parser (3.1.2.0) ast (~> 2.4.1) pg (1.3.5) pry (0.13.1) @@ -85,7 +85,7 @@ GEM pry-byebug (3.9.0) byebug (~> 11.0) pry (~> 0.13.0) - public_suffix (4.0.6) + public_suffix (4.0.7) puma (5.6.4) nio4r (~> 2.0) racc (1.6.0) From d576fd480cfb1ec30fcb503a161116aa3fb066fe Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Thu, 21 Apr 2022 18:23:16 +0200 Subject: [PATCH 105/779] Add support for mobile screen sizes (#621) Co-authored-by: guyskk --- app/assets/stylesheets/application.css | 39 ++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 83dc26c0b..acf41f639 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -51,6 +51,23 @@ code { border-top: 7px solid #484948; } +@media (max-width: 768px) { + #footer .row-fluid > * { + display: none; + } + + #footer .row-fluid > .span6:first-child { + display: block; + width: 100%; + text-align: center; + } + + #frame { + padding-top: 7px; + border-top: none; + } +} + .alert { text-align: center; -webkit-border-radius: 0px; @@ -108,6 +125,13 @@ code { margin-bottom: 14px; } +@media (max-width: 768px) { + #action-bar { + margin-left: 8px; + margin-right: 8px; + } +} + ul#story-list, ul#feed-list { list-style-type: none; margin-left: 0px; @@ -176,7 +200,7 @@ li.story.open .story-preview { } .story-lead { - color: #e5e5e5; + color: #c5c5c5; } .story-published { @@ -251,7 +275,7 @@ li.story.open .story-body-container { } p.story-details { - margin-right: 5px; + margin-right: 14px; overflow: hidden; } @@ -369,6 +393,17 @@ li.feed .feed-last-updated { text-align: right; } +@media (max-width: 768px) { + li.feed .feed-last-updated { + display: none; + } + + li.feed .row-fluid .span2 { + float: right; + margin-right: 21px; + } +} + li.feed .last-updated { font-size: 10px; } From 13c13dfd20c33abf131c042125753f30a1c52b06 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 09:28:30 -0700 Subject: [PATCH 106/779] Update all Bundler dependencies (2022-04-25) (#622) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .rubocop_todo.yml | 801 +++++++++++++++++++++++++++++++++++++++++----- Gemfile.lock | 8 +- 2 files changed, 726 insertions(+), 83 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b54bf5cfb..7ca5c9195 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --auto-gen-only-exclude` -# on 2022-01-22 20:24:27 UTC using RuboCop version 1.24.1. +# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` +# on 2022-04-25 16:21:39 UTC using RuboCop version 1.28.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -21,7 +21,7 @@ Bundler/GemVersion: EnforcedStyle: forbidden # Offense count: 9 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). Layout/FirstMethodArgumentLineBreak: Exclude: - 'app/commands/feeds/add_new_feed.rb' @@ -32,7 +32,7 @@ Layout/FirstMethodArgumentLineBreak: - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/LineEndStringConcatenationIndentation: @@ -40,7 +40,7 @@ Layout/LineEndStringConcatenationIndentation: - 'spec/helpers/url_helpers_spec.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedTypes: block, case, class, if, kwbegin, module # SupportedStyles: same_line, new_line @@ -52,21 +52,42 @@ Layout/MultilineAssignmentLayout: - 'app/utils/sample_story.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). Layout/MultilineMethodArgumentLineBreaks: Exclude: - 'app/controllers/debug_controller.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/javascript/test_controller.rb' -# Offense count: 40 -# Cop supports --auto-correct. +# Offense count: 47 +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: InspectBlocks. Layout/RedundantLineBreak: - Enabled: false + Exclude: + - 'Rakefile' + - 'app/commands/feeds/add_new_feed.rb' + - 'app/commands/feeds/export_to_opml.rb' + - 'app/repositories/feed_repository.rb' + - 'app/repositories/story_repository.rb' + - 'app/utils/content_sanitizer.rb' + - 'config/asset_pipeline.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/factories/user_factory.rb' + - 'spec/factories/users.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). Layout/SingleLineBlockChain: Exclude: - 'app/tasks/change_password.rb' @@ -75,16 +96,159 @@ Layout/SingleLineBlockChain: - 'spec/tasks/fetch_feeds_spec.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). Lint/AmbiguousOperatorPrecedence: Exclude: - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' -# Offense count: 761 +# Offense count: 765 # Configuration parameters: Only, Ignore. Lint/ConstantResolution: - Enabled: false + Exclude: + - 'Gemfile' + - 'Rakefile' + - 'app.rb' + - 'app/commands/feeds/add_new_feed.rb' + - 'app/commands/feeds/export_to_opml.rb' + - 'app/commands/feeds/find_new_stories.rb' + - 'app/commands/feeds/import_from_opml.rb' + - 'app/commands/stories/mark_all_as_read.rb' + - 'app/commands/stories/mark_as_read.rb' + - 'app/commands/stories/mark_as_starred.rb' + - 'app/commands/stories/mark_as_unread.rb' + - 'app/commands/stories/mark_as_unstarred.rb' + - 'app/commands/stories/mark_feed_as_read.rb' + - 'app/commands/stories/mark_group_as_read.rb' + - 'app/commands/users/change_user_password.rb' + - 'app/commands/users/create_user.rb' + - 'app/commands/users/sign_in_user.rb' + - 'app/controllers/debug_controller.rb' + - 'app/controllers/feeds_controller.rb' + - 'app/controllers/first_run_controller.rb' + - 'app/controllers/sessions_controller.rb' + - 'app/controllers/stories_controller.rb' + - 'app/fever_api/authentication.rb' + - 'app/fever_api/read_feeds.rb' + - 'app/fever_api/read_feeds_groups.rb' + - 'app/fever_api/read_groups.rb' + - 'app/fever_api/read_items.rb' + - 'app/fever_api/response.rb' + - 'app/fever_api/sync_saved_item_ids.rb' + - 'app/fever_api/sync_unread_item_ids.rb' + - 'app/fever_api/write_mark_feed.rb' + - 'app/fever_api/write_mark_group.rb' + - 'app/fever_api/write_mark_item.rb' + - 'app/helpers/authentication_helpers.rb' + - 'app/helpers/url_helpers.rb' + - 'app/jobs/fetch_feed_job.rb' + - 'app/models/application_record.rb' + - 'app/models/migration_status.rb' + - 'app/models/story.rb' + - 'app/repositories/feed_repository.rb' + - 'app/repositories/group_repository.rb' + - 'app/repositories/story_repository.rb' + - 'app/repositories/user_repository.rb' + - 'app/tasks/change_password.rb' + - 'app/tasks/fetch_feed.rb' + - 'app/tasks/fetch_feeds.rb' + - 'app/tasks/remove_old_stories.rb' + - 'app/utils/api_key.rb' + - 'app/utils/content_sanitizer.rb' + - 'app/utils/feed_discovery.rb' + - 'app/utils/opml_parser.rb' + - 'app/utils/sample_story.rb' + - 'config.ru' + - 'config/asset_pipeline.rb' + - 'config/puma.rb' + - 'db/migrate/20130409010818_create_feeds.rb' + - 'db/migrate/20130409010826_create_stories.rb' + - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' + - 'db/migrate/20130418221144_add_user_model.rb' + - 'db/migrate/20130423001740_drop_email_from_user.rb' + - 'db/migrate/20130423180446_remove_author_from_stories.rb' + - 'db/migrate/20130425211008_add_setup_complete_to_user.rb' + - 'db/migrate/20130425222157_add_delayed_job.rb' + - 'db/migrate/20130429232127_add_status_to_feeds.rb' + - 'db/migrate/20130504005816_text_url.rb' + - 'db/migrate/20130504022615_change_story_permalink_column.rb' + - 'db/migrate/20130509131045_add_unique_constraints.rb' + - 'db/migrate/20130513025939_add_keep_unread_to_stories.rb' + - 'db/migrate/20130513044029_add_is_starred_status_for_stories.rb' + - 'db/migrate/20130522014405_add_api_key_to_user.rb' + - 'db/migrate/20130730120312_add_entry_id_to_stories.rb' + - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' + - 'db/migrate/20130821020313_update_nil_entry_ids.rb' + - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' + - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' + - 'db/migrate/20140421224454_fix_invalid_unicode.rb' + - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' + - 'fever_api.rb' + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/export_to_opml_spec.rb' + - 'spec/commands/feeds/import_from_opml_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_as_read_spec.rb' + - 'spec/commands/stories/mark_as_starred_spec.rb' + - 'spec/commands/stories/mark_as_unread_spec.rb' + - 'spec/commands/stories/mark_as_unstarred_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/commands/users/create_user_spec.rb' + - 'spec/commands/users/sign_in_user_spec.rb' + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/factories/feed_factory.rb' + - 'spec/factories/feeds.rb' + - 'spec/factories/group_factory.rb' + - 'spec/factories/groups.rb' + - 'spec/factories/stories.rb' + - 'spec/factories/story_factory.rb' + - 'spec/factories/user_factory.rb' + - 'spec/factories/users.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_favicons_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/read_links_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/javascript/test_controller.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/group_spec.rb' + - 'spec/models/migration_status_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/group_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/repositories/user_repository_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/support/active_record.rb' + - 'spec/support/coverage.rb' + - 'spec/support/feed_server.rb' + - 'spec/tasks/change_password_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/content_sanitizer_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + - 'spec/utils/opml_parser_spec.rb' # Offense count: 1 # Configuration parameters: AllowComments, AllowEmptyLambdas. @@ -93,7 +257,7 @@ Lint/EmptyBlock: - 'spec/repositories/story_repository_spec.rb' # Offense count: 13 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: IgnoredMethods, IgnoredClasses. # IgnoredMethods: ago, from_now, second, seconds, minute, minutes, hour, hours, day, days, week, weeks, fortnight, fortnights, in_milliseconds # IgnoredClasses: Time, DateTime @@ -120,15 +284,55 @@ Naming/HeredocDelimiterNaming: - 'spec/helpers/url_helpers_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 39 -# Cop supports --auto-correct. +# Offense count: 35 +# This cop supports safe auto-correction (--auto-correct). RSpec/AlignLeftLetBrace: - Enabled: false + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/export_to_opml_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/sign_in_user_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 44 -# Cop supports --auto-correct. +# Offense count: 40 +# This cop supports safe auto-correction (--auto-correct). RSpec/AlignRightLetBrace: - Enabled: false + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/sign_in_user_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' # Offense count: 5 RSpec/AnyInstance: @@ -171,14 +375,50 @@ RSpec/DescribeClass: - 'spec/utils/i18n_support_spec.rb' # Offense count: 141 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit RSpec/DescribedClass: - Enabled: false + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/export_to_opml_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_as_read_spec.rb' + - 'spec/commands/stories/mark_as_starred_spec.rb' + - 'spec/commands/stories/mark_as_unread_spec.rb' + - 'spec/commands/stories/mark_as_unstarred_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/commands/users/create_user_spec.rb' + - 'spec/commands/users/sign_in_user_spec.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_favicons_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/read_links_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/models/group_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/group_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/repositories/user_repository_spec.rb' + - 'spec/tasks/change_password_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/opml_parser_spec.rb' # Offense count: 9 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). RSpec/EmptyLineAfterFinalLet: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' @@ -190,18 +430,39 @@ RSpec/EmptyLineAfterFinalLet: - 'spec/repositories/story_repository_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). RSpec/EmptyLineAfterHook: Exclude: - 'spec/controllers/stories_controller_spec.rb' # Offense count: 50 -# Configuration parameters: CountAsOne. +# Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: - Max: 35 + Exclude: + - 'spec/commands/feeds/export_to_opml_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/read_favicons_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/migration_status_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/group_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/opml_parser_spec.rb' # Offense count: 18 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: CustomTransform, IgnoredWords. RSpec/ExampleWording: Exclude: @@ -226,7 +487,7 @@ RSpec/FilePath: - 'spec/helpers/authentications_helper_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example RSpec/HookArgument: @@ -240,7 +501,7 @@ RSpec/InstanceVariable: - 'spec/integration/feed_importing_spec.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). RSpec/LeadingSubject: Exclude: - 'spec/fever_api/read_feeds_groups_spec.rb' @@ -259,7 +520,7 @@ RSpec/LeakyConstantDeclaration: - 'spec/helpers/url_helpers_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). RSpec/LetBeforeExamples: Exclude: - 'spec/repositories/feed_repository_spec.rb' @@ -270,21 +531,107 @@ RSpec/MessageChain: - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api_spec.rb' -# Offense count: 104 +# Offense count: 100 # Configuration parameters: EnforcedStyle. # SupportedStyles: allow, expect RSpec/MessageExpectation: - Enabled: false + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/commands/users/create_user_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/change_password_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 109 +# Offense count: 105 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: - Enabled: false + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/commands/users/create_user_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/change_password_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' # Offense count: 97 +# Configuration parameters: Max. RSpec/MultipleExpectations: - Max: 8 + Exclude: + - 'spec/app_spec.rb' + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/export_to_opml_spec.rb' + - 'spec/commands/feeds/import_from_opml_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/commands/users/create_user_spec.rb' + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + - 'spec/utils/opml_parser_spec.rb' # Offense count: 7 # Configuration parameters: AllowSubject, Max. @@ -319,7 +666,7 @@ RSpec/NestedGroups: - 'spec/integration/feed_importing_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: not_to, to_not RSpec/NotToNot: @@ -327,7 +674,7 @@ RSpec/NotToNot: - 'spec/integration/feed_importing_spec.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: and_return, block RSpec/ReturnFromStub: @@ -335,7 +682,7 @@ RSpec/ReturnFromStub: - 'spec/tasks/remove_old_stories_spec.rb' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). RSpec/ScatteredLet: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' @@ -343,24 +690,59 @@ RSpec/ScatteredLet: # Offense count: 53 RSpec/StubbedMock: - Enabled: false + Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 100 +# Offense count: 96 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: - Enabled: false - -# Offense count: 4 -# Cop supports --auto-correct. -Rails/ActiveRecordAliases: Exclude: - - 'app/commands/stories/mark_as_read.rb' - - 'app/commands/stories/mark_as_starred.rb' - - 'app/commands/stories/mark_as_unread.rb' - - 'app/commands/stories/mark_as_unstarred.rb' + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/users/sign_in_user_spec.rb' + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/models/migration_status_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports unsafe auto-correction (--auto-correct-all). # Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. # Whitelist: find_by_sql # AllowedMethods: find_by_sql @@ -377,7 +759,7 @@ Rails/HasManyOrHasOneDependent: - 'app/models/group.rb' # Offense count: 28 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: Include. # Include: spec/**/*, test/**/* Rails/HttpPositionalArguments: @@ -398,14 +780,14 @@ Rails/InverseOf: - 'app/models/feed.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. Rails/Present: Exclude: - 'app/tasks/fetch_feeds.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports unsafe auto-correction (--auto-correct-all). # Configuration parameters: Include. # Include: **/Rakefile, **/*.rake Rails/RakeEnvironment: @@ -424,7 +806,7 @@ Rails/ReversibleMigrationMethodDefinition: - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' # Offense count: 15 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowImplicitReturn, AllowedReceivers. Rails/SaveBang: Exclude: @@ -452,7 +834,7 @@ Rails/SkipsModelValidations: - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' # Offense count: 27 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible Rails/TimeZone: @@ -474,7 +856,7 @@ Rails/TimeZone: - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/Validation: @@ -483,20 +865,20 @@ Rails/Validation: - 'app/models/story.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). Rails/WhereEquals: Exclude: - 'app/models/feed.rb' - 'app/repositories/story_repository.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). Rails/WhereNot: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports unsafe auto-correction (--auto-correct-all). # Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. # MethodsAcceptingSymbol: inject, reduce Style/CollectionMethods: @@ -505,7 +887,7 @@ Style/CollectionMethods: - 'app/fever_api/response.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowedCops. Style/DisableCopsWithinSourceCodeDirective: Exclude: @@ -521,18 +903,179 @@ Style/DisableCopsWithinSourceCodeDirective: Style/DocumentationMethod: Enabled: false +# Offense count: 9 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowedVars. +Style/FetchEnvVar: + Exclude: + - 'Rakefile' + - 'app.rb' + - 'config/puma.rb' + # Offense count: 152 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: - Enabled: false + Exclude: + - 'Gemfile' + - 'Rakefile' + - 'app.rb' + - 'app/commands/feeds/add_new_feed.rb' + - 'app/commands/feeds/export_to_opml.rb' + - 'app/commands/feeds/find_new_stories.rb' + - 'app/commands/feeds/import_from_opml.rb' + - 'app/commands/stories/mark_all_as_read.rb' + - 'app/commands/stories/mark_as_read.rb' + - 'app/commands/stories/mark_as_starred.rb' + - 'app/commands/stories/mark_as_unread.rb' + - 'app/commands/stories/mark_as_unstarred.rb' + - 'app/commands/stories/mark_feed_as_read.rb' + - 'app/commands/stories/mark_group_as_read.rb' + - 'app/commands/users/change_user_password.rb' + - 'app/commands/users/complete_setup.rb' + - 'app/commands/users/create_user.rb' + - 'app/commands/users/sign_in_user.rb' + - 'app/controllers/debug_controller.rb' + - 'app/controllers/feeds_controller.rb' + - 'app/controllers/first_run_controller.rb' + - 'app/controllers/sessions_controller.rb' + - 'app/controllers/stories_controller.rb' + - 'app/fever_api/authentication.rb' + - 'app/fever_api/read_favicons.rb' + - 'app/fever_api/read_feeds.rb' + - 'app/fever_api/read_feeds_groups.rb' + - 'app/fever_api/read_groups.rb' + - 'app/fever_api/read_items.rb' + - 'app/fever_api/read_links.rb' + - 'app/fever_api/response.rb' + - 'app/fever_api/sync_saved_item_ids.rb' + - 'app/fever_api/sync_unread_item_ids.rb' + - 'app/fever_api/write_mark_feed.rb' + - 'app/fever_api/write_mark_group.rb' + - 'app/fever_api/write_mark_item.rb' + - 'app/helpers/authentication_helpers.rb' + - 'app/helpers/url_helpers.rb' + - 'app/jobs/fetch_feed_job.rb' + - 'app/models/application_record.rb' + - 'app/models/feed.rb' + - 'app/models/group.rb' + - 'app/models/migration_status.rb' + - 'app/models/story.rb' + - 'app/models/user.rb' + - 'app/repositories/feed_repository.rb' + - 'app/repositories/group_repository.rb' + - 'app/repositories/story_repository.rb' + - 'app/repositories/user_repository.rb' + - 'app/tasks/change_password.rb' + - 'app/tasks/fetch_feed.rb' + - 'app/tasks/fetch_feeds.rb' + - 'app/tasks/remove_old_stories.rb' + - 'app/utils/api_key.rb' + - 'app/utils/content_sanitizer.rb' + - 'app/utils/feed_discovery.rb' + - 'app/utils/opml_parser.rb' + - 'app/utils/sample_story.rb' + - 'config.ru' + - 'config/asset_pipeline.rb' + - 'config/puma.rb' + - 'db/migrate/20130409010818_create_feeds.rb' + - 'db/migrate/20130409010826_create_stories.rb' + - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' + - 'db/migrate/20130418221144_add_user_model.rb' + - 'db/migrate/20130423001740_drop_email_from_user.rb' + - 'db/migrate/20130423180446_remove_author_from_stories.rb' + - 'db/migrate/20130425211008_add_setup_complete_to_user.rb' + - 'db/migrate/20130425222157_add_delayed_job.rb' + - 'db/migrate/20130429232127_add_status_to_feeds.rb' + - 'db/migrate/20130504005816_text_url.rb' + - 'db/migrate/20130504022615_change_story_permalink_column.rb' + - 'db/migrate/20130509131045_add_unique_constraints.rb' + - 'db/migrate/20130513025939_add_keep_unread_to_stories.rb' + - 'db/migrate/20130513044029_add_is_starred_status_for_stories.rb' + - 'db/migrate/20130522014405_add_api_key_to_user.rb' + - 'db/migrate/20130730120312_add_entry_id_to_stories.rb' + - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' + - 'db/migrate/20130821020313_update_nil_entry_ids.rb' + - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' + - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' + - 'db/migrate/20140421224454_fix_invalid_unicode.rb' + - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' + - 'fever_api.rb' + - 'spec/app_spec.rb' + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/export_to_opml_spec.rb' + - 'spec/commands/feeds/import_from_opml_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_as_read_spec.rb' + - 'spec/commands/stories/mark_as_starred_spec.rb' + - 'spec/commands/stories/mark_as_unread_spec.rb' + - 'spec/commands/stories/mark_as_unstarred_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/commands/users/create_user_spec.rb' + - 'spec/commands/users/sign_in_user_spec.rb' + - 'spec/config/asset_pipeline_spec.rb' + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/factories.rb' + - 'spec/factories/feed_factory.rb' + - 'spec/factories/feeds.rb' + - 'spec/factories/group_factory.rb' + - 'spec/factories/groups.rb' + - 'spec/factories/stories.rb' + - 'spec/factories/story_factory.rb' + - 'spec/factories/user_factory.rb' + - 'spec/factories/users.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_favicons_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/read_links_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/javascript/test_controller.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/group_spec.rb' + - 'spec/models/migration_status_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/group_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/repositories/user_repository_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/support/active_record.rb' + - 'spec/support/coverage.rb' + - 'spec/support/feed_server.rb' + - 'spec/tasks/change_password_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/content_sanitizer_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + - 'spec/utils/opml_parser_spec.rb' -# Offense count: 84 -# Cop supports --auto-correct. +# Offense count: 85 +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never +# SupportedShorthandSyntax: always, never, either Style/HashSyntax: Enabled: false @@ -541,15 +1084,98 @@ Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 700 -# Cop supports --auto-correct. -# Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. +# Offense count: 698 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: IgnoreMacros, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: - Enabled: false + Exclude: + - 'Rakefile' + - 'app.rb' + - 'app/commands/feeds/export_to_opml.rb' + - 'app/models/feed.rb' + - 'app/tasks/change_password.rb' + - 'app/tasks/fetch_feed.rb' + - 'config/asset_pipeline.rb' + - 'config/puma.rb' + - 'db/migrate/20130409010818_create_feeds.rb' + - 'db/migrate/20130409010826_create_stories.rb' + - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' + - 'db/migrate/20130418221144_add_user_model.rb' + - 'db/migrate/20130423001740_drop_email_from_user.rb' + - 'db/migrate/20130423180446_remove_author_from_stories.rb' + - 'db/migrate/20130425211008_add_setup_complete_to_user.rb' + - 'db/migrate/20130425222157_add_delayed_job.rb' + - 'db/migrate/20130429232127_add_status_to_feeds.rb' + - 'db/migrate/20130504005816_text_url.rb' + - 'db/migrate/20130504022615_change_story_permalink_column.rb' + - 'db/migrate/20130509131045_add_unique_constraints.rb' + - 'db/migrate/20130513025939_add_keep_unread_to_stories.rb' + - 'db/migrate/20130513044029_add_is_starred_status_for_stories.rb' + - 'db/migrate/20130522014405_add_api_key_to_user.rb' + - 'db/migrate/20130730120312_add_entry_id_to_stories.rb' + - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' + - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' + - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' + - 'spec/app_spec.rb' + - 'spec/commands/feeds/add_new_feed_spec.rb' + - 'spec/commands/feeds/export_to_opml_spec.rb' + - 'spec/commands/feeds/import_from_opml_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/commands/stories/mark_all_as_read_spec.rb' + - 'spec/commands/stories/mark_as_read_spec.rb' + - 'spec/commands/stories/mark_as_starred_spec.rb' + - 'spec/commands/stories/mark_as_unread_spec.rb' + - 'spec/commands/stories/mark_as_unstarred_spec.rb' + - 'spec/commands/stories/mark_feed_as_read_spec.rb' + - 'spec/commands/stories/mark_group_as_read_spec.rb' + - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/commands/users/complete_setup_spec.rb' + - 'spec/commands/users/create_user_spec.rb' + - 'spec/commands/users/sign_in_user_spec.rb' + - 'spec/config/asset_pipeline_spec.rb' + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/controllers/stories_controller_spec.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/read_favicons_spec.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/read_links_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api/write_mark_item_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/javascript/test_controller.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/group_spec.rb' + - 'spec/models/migration_status_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/group_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/repositories/user_repository_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/tasks/change_password_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' + - 'spec/tasks/fetch_feeds_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/content_sanitizer_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + - 'spec/utils/opml_parser_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe auto-correction (--auto-correct-all). # Configuration parameters: EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: @@ -568,10 +1194,27 @@ Style/OpenStructUse: # Configuration parameters: SuspiciousParamNames, Allowlist. # SuspiciousParamNames: options, opts, args, params, parameters Style/OptionHash: - Enabled: false + Exclude: + - 'app/fever_api/authentication.rb' + - 'app/fever_api/read_favicons.rb' + - 'app/fever_api/read_feeds.rb' + - 'app/fever_api/read_feeds_groups.rb' + - 'app/fever_api/read_groups.rb' + - 'app/fever_api/read_items.rb' + - 'app/fever_api/read_links.rb' + - 'app/fever_api/sync_saved_item_ids.rb' + - 'app/fever_api/sync_unread_item_ids.rb' + - 'app/fever_api/write_mark_feed.rb' + - 'app/fever_api/write_mark_group.rb' + - 'app/fever_api/write_mark_item.rb' + - 'spec/factories/feed_factory.rb' + - 'spec/factories/feeds.rb' + - 'spec/factories/group_factory.rb' + - 'spec/factories/groups.rb' + - 'spec/factories/story_factory.rb' # Offense count: 12 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: @@ -584,7 +1227,7 @@ Style/PercentLiteralDelimiters: - 'spec/javascript/test_controller.rb' # Offense count: 6 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: same_as_string_literals, single_quotes, double_quotes Style/QuotedSymbols: @@ -592,7 +1235,7 @@ Style/QuotedSymbols: - 'app/controllers/feeds_controller.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. # SupportedStyles: return, return_nil Style/ReturnNil: @@ -600,15 +1243,15 @@ Style/ReturnNil: - 'app/repositories/user_repository.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - 'app/controllers/feeds_controller.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: Methods. # Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]} Style/SingleLineBlockParams: @@ -630,7 +1273,7 @@ Style/StaticClass: - 'app/utils/content_sanitizer.rb' # Offense count: 18 -# Cop supports --auto-correct. +# This cop supports unsafe auto-correction (--auto-correct-all). Style/StringHashKeys: Exclude: - 'fever_api.rb' @@ -649,7 +1292,7 @@ Style/StringHashKeys: - 'spec/fever_api/sync_unread_item_ids_spec.rb' # Offense count: 7 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: MinSize. # SupportedStyles: percent, brackets Style/SymbolArray: diff --git a/Gemfile.lock b/Gemfile.lock index 564237a4a..04c6df628 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,7 +104,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.3.0) + regexp_parser (2.3.1) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -122,13 +122,13 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.27.0) + rubocop (1.28.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) + rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.17.0) @@ -139,7 +139,7 @@ GEM rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.9.0) + rubocop-rspec (2.10.0) rubocop (~> 1.19) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) From a589979861e804231081973d6799918e84630925 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 09:39:30 -0700 Subject: [PATCH 107/779] Update all Bundler dependencies (2022-05-02) (#623) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 04c6df628..761c59a0b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activemodel (7.0.2.3) - activesupport (= 7.0.2.3) - activerecord (7.0.2.3) - activemodel (= 7.0.2.3) - activesupport (= 7.0.2.3) - activesupport (7.0.2.3) + activemodel (7.0.2.4) + activesupport (= 7.0.2.4) + activerecord (7.0.2.4) + activemodel (= 7.0.2.4) + activesupport (= 7.0.2.4) + activesupport (7.0.2.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -55,7 +55,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.10.0) concurrent-ruby (~> 1.0) - loofah (2.16.0) + loofah (2.17.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) matrix (0.4.2) @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.28.1) + rubocop (1.28.2) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) From 61def1a8849cc3b9a8617be102a687358ab9bcf6 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 09:41:07 -0700 Subject: [PATCH 108/779] Update all Bundler dependencies (2022-05-09) (#624) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 761c59a0b..9010255e3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,7 +16,7 @@ GEM ast (2.4.2) bcrypt (3.1.17) byebug (11.1.3) - capybara (3.36.0) + capybara (3.37.0) addressable matrix mini_mime (>= 0.1.3) @@ -71,7 +71,7 @@ GEM mustermann (1.1.1) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.4) + nokogiri (1.13.6) mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) @@ -122,12 +122,12 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.28.2) + rubocop (1.29.0) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml + rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) @@ -185,7 +185,7 @@ GEM thread (0.2.2) tilt (2.0.10) timecop (0.9.5) - tins (1.31.0) + tins (1.31.1) sync tzinfo (2.0.4) concurrent-ruby (~> 1.0) From 28edadee10d9f0173af4d037ffe4b255b9557a1d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 16 May 2022 11:45:01 -0700 Subject: [PATCH 109/779] Update all Bundler dependencies (2022-05-16) (#625) Had to require `active_support/core_ext/kernel/reporting` per [this issue][is]. [is]: https://github.com/collectiveidea/delayed_job/issues/1168 Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 24 ++++++++++++------------ Rakefile | 1 + app/tasks/fetch_feeds.rb | 1 + 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9010255e3..96323d595 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activemodel (7.0.2.4) - activesupport (= 7.0.2.4) - activerecord (7.0.2.4) - activemodel (= 7.0.2.4) - activesupport (= 7.0.2.4) - activesupport (7.0.2.4) + activemodel (7.0.3) + activesupport (= 7.0.3) + activerecord (7.0.3) + activemodel (= 7.0.3) + activesupport (= 7.0.3) + activesupport (7.0.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -16,7 +16,7 @@ GEM ast (2.4.2) bcrypt (3.1.17) byebug (11.1.3) - capybara (3.37.0) + capybara (3.37.1) addressable matrix mini_mime (>= 0.1.3) @@ -41,7 +41,7 @@ GEM diff-lcs (1.5.0) docile (1.4.0) execjs (2.8.1) - faker (2.20.0) + faker (2.21.0) i18n (>= 1.8.11, < 2) feedbag (0.10.1) nokogiri (~> 1.8, >= 1.8.2) @@ -55,7 +55,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.10.0) concurrent-ruby (~> 1.0) - loofah (2.17.0) + loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) matrix (0.4.2) @@ -104,7 +104,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.3.1) + regexp_parser (2.4.0) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.29.0) + rubocop (1.29.1) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) @@ -131,7 +131,7 @@ GEM rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.17.0) + rubocop-ast (1.18.0) parser (>= 3.1.1.0) rubocop-rails (2.14.2) activesupport (>= 4.2.0) diff --git a/Rakefile b/Rakefile index ec14cc8fc..4e4a44a3e 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,7 @@ Bundler.setup require "rubygems" require "net/http" require "active_record" +require "active_support/core_ext/kernel/reporting" require "delayed_job" require "delayed_job_active_record" diff --git a/app/tasks/fetch_feeds.rb b/app/tasks/fetch_feeds.rb index f4085abc2..c1c1aab66 100644 --- a/app/tasks/fetch_feeds.rb +++ b/app/tasks/fetch_feeds.rb @@ -1,6 +1,7 @@ require "thread/pool" require_relative "fetch_feed" +require "active_support/core_ext/kernel/reporting" require "delayed_job_active_record" class FetchFeeds From b79e1811e3b2c0a98bf40391346ce57d8be650c7 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 23 May 2022 09:58:25 -0700 Subject: [PATCH 110/779] Update all Bundler dependencies (2022-05-23) (#626) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 96323d595..32bea36b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ GEM addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) - bcrypt (3.1.17) + bcrypt (3.1.18) byebug (11.1.3) capybara (3.37.1) addressable @@ -139,7 +139,7 @@ GEM rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.10.0) + rubocop-rspec (2.11.1) rubocop (~> 1.19) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) From 75bebcdd5c1036983038e65211578fe26cbfd71c Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Fri, 27 May 2022 10:41:25 -0700 Subject: [PATCH 111/779] Update rack to version 2.2.3.1 (#627) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 32bea36b1..df0588384 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,7 +89,7 @@ GEM puma (5.6.4) nio4r (~> 2.0) racc (1.6.0) - rack (2.2.3) + rack (2.2.3.1) rack-protection (2.2.0) rack rack-ssl (1.4.1) From 7e442215b644ef8aac7f66ea7adf2dcb903585c7 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 09:59:47 -0700 Subject: [PATCH 112/779] Update all Bundler dependencies (2022-05-30) (#628) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index df0588384..4c5c2dd22 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,7 +104,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.4.0) + regexp_parser (2.5.0) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -122,13 +122,13 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.29.1) + rubocop (1.30.0) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.17.0, < 2.0) + rubocop-ast (>= 1.18.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.18.0) From 9e4867a2963779bca2af08617b1d4a8a1643d93d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 09:47:00 -0700 Subject: [PATCH 113/779] Update all Bundler dependencies (2022-06-13) (#629) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4c5c2dd22..10b71c786 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.30.0) + rubocop (1.30.1) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) From 253cadd00a4d9769ff392474d57ab4a91e726195 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 20 Jun 2022 10:04:35 -0700 Subject: [PATCH 114/779] Update all Bundler dependencies (2022-06-20) (#630) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 10b71c786..c1d577b9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,7 +65,7 @@ GEM mime-types-data (3.2022.0105) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.15.0) + minitest (5.16.0) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) @@ -133,7 +133,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.18.0) parser (>= 3.1.1.0) - rubocop-rails (2.14.2) + rubocop-rails (2.15.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) From 346d755caee93ffd710f38c6d210ea2e83517f21 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 10:39:59 -0700 Subject: [PATCH 115/779] Update all Bundler dependencies (2022-06-27) (#631) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c1d577b9f..e7f8b9a48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,7 +65,7 @@ GEM mime-types-data (3.2022.0105) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.16.0) + minitest (5.16.1) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) @@ -78,7 +78,7 @@ GEM parallel (1.22.1) parser (3.1.2.0) ast (~> 2.4.1) - pg (1.3.5) + pg (1.4.1) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -94,8 +94,8 @@ GEM rack rack-ssl (1.4.1) rack - rack-test (1.1.0) - rack (>= 1.0, < 3) + rack-test (2.0.0) + rack (>= 1.3) racksh (1.0.0) rack (>= 1.0) rack-test (>= 0.5) @@ -122,7 +122,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.30.1) + rubocop (1.31.0) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) @@ -133,7 +133,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.18.0) parser (>= 3.1.1.0) - rubocop-rails (2.15.0) + rubocop-rails (2.15.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) @@ -173,7 +173,7 @@ GEM tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) - sprockets (4.0.3) + sprockets (4.1.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-helpers (1.4.0) @@ -191,7 +191,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.1.0) + unicode-display_width (2.2.0) will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) From 60c075e39f0c19b04dc6f74afe4308e56a695705 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sun, 3 Jul 2022 23:36:58 -0700 Subject: [PATCH 116/779] Update all Bundler dependencies (2022-07-04) (#632) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e7f8b9a48..7f405f82f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.10.0) concurrent-ruby (~> 1.0) + json (2.6.2) loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -65,7 +66,7 @@ GEM mime-types-data (3.2022.0105) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.16.1) + minitest (5.16.2) multi_json (1.15.0) multi_xml (0.6.0) mustermann (1.1.1) @@ -89,12 +90,12 @@ GEM puma (5.6.4) nio4r (~> 2.0) racc (1.6.0) - rack (2.2.3.1) + rack (2.2.4) rack-protection (2.2.0) rack rack-ssl (1.4.1) rack - rack-test (2.0.0) + rack-test (2.0.2) rack (>= 1.3) racksh (1.0.0) rack (>= 1.0) @@ -122,7 +123,8 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.31.0) + rubocop (1.31.1) + json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) @@ -139,8 +141,8 @@ GEM rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.11.1) - rubocop (~> 1.19) + rubocop-rspec (2.12.1) + rubocop (~> 1.31) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) sass (3.7.4) @@ -173,7 +175,7 @@ GEM tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) - sprockets (4.1.0) + sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-helpers (1.4.0) From eeafcbf3e6061caa6f3772fb2715feb10af9100e Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 10:09:17 -0700 Subject: [PATCH 117/779] Update all Bundler dependencies (2022-07-11) (#633) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .rubocop_todo.yml | 6 +----- Gemfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7ca5c9195..12f63172f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1299,8 +1299,4 @@ Style/SymbolArray: EnforcedStyle: brackets # Offense count: 6 -Style/TopLevelMethodDefinition: - Exclude: - - 'spec/integration/feed_importing_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/support/active_record.rb' +Style/TopLevelMethodDefinition: { Enabled: false } diff --git a/Gemfile.lock b/Gemfile.lock index 7f405f82f..3bbe1bdaa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.10.0) + i18n (1.11.0) concurrent-ruby (~> 1.0) json (2.6.2) loofah (2.18.0) @@ -123,7 +123,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.31.1) + rubocop (1.31.2) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.0.0) @@ -133,9 +133,9 @@ GEM rubocop-ast (>= 1.18.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.18.0) + rubocop-ast (1.19.1) parser (>= 3.1.1.0) - rubocop-rails (2.15.1) + rubocop-rails (2.15.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) From 80ddd32de0b5cd7f5e8b11075f16cfb7f40b6fbc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Jul 2022 14:00:17 -0700 Subject: [PATCH 118/779] Bump activerecord from 7.0.3 to 7.0.3.1 (#634) Bumps [activerecord](https://github.com/rails/rails) from 7.0.3 to 7.0.3.1. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v7.0.3.1/activerecord/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v7.0.3...v7.0.3.1) --- updated-dependencies: - dependency-name: activerecord dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3bbe1bdaa..8d9e35e6f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activemodel (7.0.3) - activesupport (= 7.0.3) - activerecord (7.0.3) - activemodel (= 7.0.3) - activesupport (= 7.0.3) - activesupport (7.0.3) + activemodel (7.0.3.1) + activesupport (= 7.0.3.1) + activerecord (7.0.3.1) + activemodel (= 7.0.3.1) + activesupport (= 7.0.3.1) + activesupport (7.0.3.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) From 43cf9ef3fdd79f03c71fe42d7e5a2a4c9c6114d0 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 18 Jul 2022 09:46:41 -0700 Subject: [PATCH 119/779] Update all Bundler dependencies (2022-07-18) (#635) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8d9e35e6f..9a3b5135d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.11.0) + i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.2) loofah (2.18.0) @@ -69,10 +69,10 @@ GEM minitest (5.16.2) multi_json (1.15.0) multi_xml (0.6.0) - mustermann (1.1.1) + mustermann (1.1.2) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.6) + nokogiri (1.13.7) mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) @@ -91,7 +91,7 @@ GEM nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) - rack-protection (2.2.0) + rack-protection (2.2.1) rack rack-ssl (1.4.1) rack @@ -159,19 +159,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (2.2.0) + sinatra (2.2.1) mustermann (~> 1.0) rack (~> 2.2) - rack-protection (= 2.2.0) + rack-protection (= 2.2.1) tilt (~> 2.0) sinatra-activerecord (2.0.25) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (2.2.0) + sinatra-contrib (2.2.1) multi_json mustermann (~> 1.0) - rack-protection (= 2.2.0) - sinatra (= 2.2.0) + rack-protection (= 2.2.1) + sinatra (= 2.2.1) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) From 5e8342be8ebf510a4a99498621e1dc2412c17b4d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 25 Jul 2022 09:44:04 -0700 Subject: [PATCH 120/779] Update all Bundler dependencies (2022-07-25) (#636) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9a3b5135d..95758de8c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,10 +69,10 @@ GEM minitest (5.16.2) multi_json (1.15.0) multi_xml (0.6.0) - mustermann (1.1.2) + mustermann (2.0.2) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.7) + nokogiri (1.13.8) mini_portile2 (~> 2.8.0) racc (~> 1.4) open_uri_redirections (0.2.1) @@ -91,7 +91,7 @@ GEM nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) - rack-protection (2.2.1) + rack-protection (2.2.2) rack rack-ssl (1.4.1) rack @@ -123,14 +123,14 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.31.2) + rubocop (1.32.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.18.0, < 2.0) + rubocop-ast (>= 1.19.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.19.1) @@ -159,19 +159,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (2.2.1) - mustermann (~> 1.0) + sinatra (2.2.2) + mustermann (~> 2.0) rack (~> 2.2) - rack-protection (= 2.2.1) + rack-protection (= 2.2.2) tilt (~> 2.0) sinatra-activerecord (2.0.25) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (2.2.1) + sinatra-contrib (2.2.2) multi_json - mustermann (~> 1.0) - rack-protection (= 2.2.1) - sinatra (= 2.2.1) + mustermann (~> 2.0) + rack-protection (= 2.2.2) + sinatra (= 2.2.2) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) @@ -185,11 +185,11 @@ GEM tins (~> 1.0) thor (1.2.1) thread (0.2.2) - tilt (2.0.10) + tilt (2.0.11) timecop (0.9.5) tins (1.31.1) sync - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) From dc2fb4e7e826c0283d2bcdaf3e201e1f634d7983 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 11:19:00 -0700 Subject: [PATCH 121/779] Update all Bundler dependencies (2022-08-01) (#637) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 95758de8c..d974f7273 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,7 +41,7 @@ GEM diff-lcs (1.5.0) docile (1.4.0) execjs (2.8.1) - faker (2.21.0) + faker (2.22.0) i18n (>= 1.8.11, < 2) feedbag (0.10.1) nokogiri (~> 1.8, >= 1.8.2) @@ -79,7 +79,7 @@ GEM parallel (1.22.1) parser (3.1.2.0) ast (~> 2.4.1) - pg (1.4.1) + pg (1.4.2) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -116,9 +116,9 @@ GEM rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-html-matchers (0.9.4) + rspec-html-matchers (0.10.0) nokogiri (~> 1) - rspec (>= 3.0.0.a, < 4) + rspec (>= 3.0.0.a) rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) From ed059c98bbe8a6b6a5c41cf79886f380d2fcdc3b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 8 Aug 2022 10:10:54 -0700 Subject: [PATCH 122/779] Update all Bundler dependencies (2022-08-08) (#638) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d974f7273..18dddd9bb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,7 +27,7 @@ GEM xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.1.10) - coveralls_reborn (0.24.0) + coveralls_reborn (0.25.0) simplecov (>= 0.18.1, < 0.22.0) term-ansicolor (~> 1.6) thor (>= 0.20.3, < 2.0) @@ -123,7 +123,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.32.0) + rubocop (1.33.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.0.0) @@ -133,7 +133,7 @@ GEM rubocop-ast (>= 1.19.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.19.1) + rubocop-ast (1.20.1) parser (>= 3.1.1.0) rubocop-rails (2.15.2) activesupport (>= 4.2.0) From 8d9819de956eb73dbdd9324e810516ecaf27aa2a Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 15 Aug 2022 09:14:46 -0700 Subject: [PATCH 123/779] Update all Bundler dependencies (2022-08-15) (#639) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 18dddd9bb..3c83dd616 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,9 +77,9 @@ GEM racc (~> 1.4) open_uri_redirections (0.2.1) parallel (1.22.1) - parser (3.1.2.0) + parser (3.1.2.1) ast (~> 2.4.1) - pg (1.4.2) + pg (1.4.3) pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) @@ -123,17 +123,17 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.33.0) + rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.19.1, < 2.0) + rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.20.1) + rubocop-ast (1.21.0) parser (>= 3.1.1.0) rubocop-rails (2.15.2) activesupport (>= 4.2.0) From 33c4bf6e5aab7f3ff84de683dc363ae5f5c9f2c4 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 22 Aug 2022 09:07:55 -0700 Subject: [PATCH 124/779] Update all Bundler dependencies (2022-08-22) (#640) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3c83dd616..a337dc6fd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,8 +11,8 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) bcrypt (3.1.18) byebug (11.1.3) @@ -66,7 +66,7 @@ GEM mime-types-data (3.2022.0105) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.16.2) + minitest (5.16.3) multi_json (1.15.0) multi_xml (0.6.0) mustermann (2.0.2) @@ -80,13 +80,13 @@ GEM parser (3.1.2.1) ast (~> 2.4.1) pg (1.4.3) - pry (0.13.1) + pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.9.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.13.0) - public_suffix (4.0.7) + pry (>= 0.13, < 0.15) + public_suffix (5.0.0) puma (5.6.4) nio4r (~> 2.0) racc (1.6.0) @@ -123,7 +123,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.35.0) + rubocop (1.35.1) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) From 7cacc90259f0e779e21a8dca1916714013cd8852 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 09:22:30 -0700 Subject: [PATCH 125/779] Update all Bundler dependencies (2022-08-29) (#641) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a337dc6fd..b977f646a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,9 +43,8 @@ GEM execjs (2.8.1) faker (2.22.0) i18n (>= 1.8.11, < 2) - feedbag (0.10.1) + feedbag (0.10.3) nokogiri (~> 1.8, >= 1.8.2) - open_uri_redirections (~> 0.2) feedjira (3.2.1) loofah (>= 2.3.1) sax-machine (>= 1.0) @@ -75,7 +74,6 @@ GEM nokogiri (1.13.8) mini_portile2 (~> 2.8.0) racc (~> 1.4) - open_uri_redirections (0.2.1) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) @@ -87,7 +85,7 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) public_suffix (5.0.0) - puma (5.6.4) + puma (5.6.5) nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) From 9c0f63a1bde152fb6f351bf8bc112af467a28b5c Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 5 Sep 2022 09:23:20 -0700 Subject: [PATCH 126/779] Update all Bundler dependencies (2022-09-05) (#642) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b977f646a..0c5f26d4f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,7 +41,7 @@ GEM diff-lcs (1.5.0) docile (1.4.0) execjs (2.8.1) - faker (2.22.0) + faker (2.23.0) i18n (>= 1.8.11, < 2) feedbag (0.10.3) nokogiri (~> 1.8, >= 1.8.2) @@ -100,7 +100,7 @@ GEM rack-test (>= 0.5) rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.1) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (2.5.0) @@ -121,7 +121,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.35.1) + rubocop (1.36.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) From 546c71b564204d6a5e0494654fc4d8f785d6a523 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 12 Sep 2022 09:14:06 -0700 Subject: [PATCH 127/779] Update all Bundler dependencies (2022-09-12) (#643) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0c5f26d4f..9b373eb87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activemodel (7.0.3.1) - activesupport (= 7.0.3.1) - activerecord (7.0.3.1) - activemodel (= 7.0.3.1) - activesupport (= 7.0.3.1) - activesupport (7.0.3.1) + activemodel (7.0.4) + activesupport (= 7.0.4) + activerecord (7.0.4) + activemodel (= 7.0.4) + activesupport (= 7.0.4) + activesupport (7.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -133,10 +133,10 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) - rubocop-rails (2.15.2) + rubocop-rails (2.16.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) + rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) rubocop-rspec (2.12.1) From c9e258893f99719cbd8e7dc11af2e0d8618bd9cf Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:21:17 -0700 Subject: [PATCH 128/779] Update all Bundler dependencies (2022-09-19) (#645) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .rubocop.yml | 3 + .rubocop_todo.yml | 159 ++++++++++++++++++++++++++++------------------ Gemfile.lock | 14 ++-- 3 files changed, 108 insertions(+), 68 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 58256ef71..80584e7ad 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -30,6 +30,9 @@ Style/Copyright: Style/Documentation: Enabled: false +Style/DocumentationMethod: + Enabled: false + Style/DoubleNegation: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 12f63172f..48f3f4ee5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-04-25 16:21:39 UTC using RuboCop version 1.28.1. +# on 2022-09-19 17:13:31 UTC using RuboCop version 1.36.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -21,7 +21,7 @@ Bundler/GemVersion: EnforcedStyle: forbidden # Offense count: 9 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Layout/FirstMethodArgumentLineBreak: Exclude: - 'app/commands/feeds/add_new_feed.rb' @@ -32,7 +32,7 @@ Layout/FirstMethodArgumentLineBreak: - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/LineEndStringConcatenationIndentation: @@ -40,7 +40,7 @@ Layout/LineEndStringConcatenationIndentation: - 'spec/helpers/url_helpers_spec.rb' # Offense count: 4 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedTypes: block, case, class, if, kwbegin, module # SupportedStyles: same_line, new_line @@ -52,7 +52,7 @@ Layout/MultilineAssignmentLayout: - 'app/utils/sample_story.rb' # Offense count: 4 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Layout/MultilineMethodArgumentLineBreaks: Exclude: - 'app/controllers/debug_controller.rb' @@ -60,7 +60,7 @@ Layout/MultilineMethodArgumentLineBreaks: - 'spec/javascript/test_controller.rb' # Offense count: 47 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: InspectBlocks. Layout/RedundantLineBreak: Exclude: @@ -87,7 +87,7 @@ Layout/RedundantLineBreak: - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 8 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Layout/SingleLineBlockChain: Exclude: - 'app/tasks/change_password.rb' @@ -96,7 +96,7 @@ Layout/SingleLineBlockChain: - 'spec/tasks/fetch_feeds_spec.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: Exclude: - 'spec/factories/feed_factory.rb' @@ -257,8 +257,9 @@ Lint/EmptyBlock: - 'spec/repositories/story_repository_spec.rb' # Offense count: 13 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: IgnoredMethods, IgnoredClasses. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, IgnoredClasses. +# AllowedMethods: ago, from_now, second, seconds, minute, minutes, hour, hours, day, days, week, weeks, fortnight, fortnights, in_milliseconds # IgnoredMethods: ago, from_now, second, seconds, minute, minutes, hour, hours, day, days, week, weeks, fortnight, fortnights, in_milliseconds # IgnoredClasses: Time, DateTime Lint/NumberConversion: @@ -285,7 +286,7 @@ Naming/HeredocDelimiterNaming: - 'spec/utils/opml_parser_spec.rb' # Offense count: 35 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). RSpec/AlignLeftLetBrace: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' @@ -310,7 +311,7 @@ RSpec/AlignLeftLetBrace: - 'spec/utils/feed_discovery_spec.rb' # Offense count: 40 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). RSpec/AlignRightLetBrace: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' @@ -353,7 +354,7 @@ RSpec/BeforeAfterAll: - 'spec/integration/feed_importing_spec.rb' # Offense count: 18 -# Configuration parameters: Prefixes. +# Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: @@ -375,7 +376,7 @@ RSpec/DescribeClass: - 'spec/utils/i18n_support_spec.rb' # Offense count: 141 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit RSpec/DescribedClass: @@ -418,7 +419,7 @@ RSpec/DescribedClass: - 'spec/utils/opml_parser_spec.rb' # Offense count: 9 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). RSpec/EmptyLineAfterFinalLet: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' @@ -430,7 +431,8 @@ RSpec/EmptyLineAfterFinalLet: - 'spec/repositories/story_repository_spec.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowConsecutiveOneLiners. RSpec/EmptyLineAfterHook: Exclude: - 'spec/controllers/stories_controller_spec.rb' @@ -462,7 +464,7 @@ RSpec/ExampleLength: - 'spec/utils/opml_parser_spec.rb' # Offense count: 18 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords. RSpec/ExampleWording: Exclude: @@ -487,7 +489,7 @@ RSpec/FilePath: - 'spec/helpers/authentications_helper_spec.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example RSpec/HookArgument: @@ -501,7 +503,7 @@ RSpec/InstanceVariable: - 'spec/integration/feed_importing_spec.rb' # Offense count: 8 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). RSpec/LeadingSubject: Exclude: - 'spec/fever_api/read_feeds_groups_spec.rb' @@ -520,7 +522,7 @@ RSpec/LeakyConstantDeclaration: - 'spec/helpers/url_helpers_spec.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). RSpec/LetBeforeExamples: Exclude: - 'spec/repositories/feed_repository_spec.rb' @@ -658,15 +660,20 @@ RSpec/NamedSubject: - 'spec/fever_api/write_mark_item_spec.rb' # Offense count: 9 -# Configuration parameters: Max. +# Configuration parameters: Max, AllowedGroups. RSpec/NestedGroups: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/integration/feed_importing_spec.rb' +# Offense count: 2 +RSpec/NoExpectationExample: + Exclude: + - 'spec/commands/stories/mark_group_as_read_spec.rb' + # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: not_to, to_not RSpec/NotToNot: @@ -674,7 +681,7 @@ RSpec/NotToNot: - 'spec/integration/feed_importing_spec.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: and_return, block RSpec/ReturnFromStub: @@ -682,7 +689,7 @@ RSpec/ReturnFromStub: - 'spec/tasks/remove_old_stories_spec.rb' # Offense count: 3 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredLet: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' @@ -742,7 +749,7 @@ RSpec/VerifiedDoubles: - 'spec/utils/feed_discovery_spec.rb' # Offense count: 2 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. # Whitelist: find_by_sql # AllowedMethods: find_by_sql @@ -759,7 +766,7 @@ Rails/HasManyOrHasOneDependent: - 'app/models/group.rb' # Offense count: 28 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: spec/**/*, test/**/* Rails/HttpPositionalArguments: @@ -780,14 +787,14 @@ Rails/InverseOf: - 'app/models/feed.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. Rails/Present: Exclude: - 'app/tasks/fetch_feeds.rb' # Offense count: 8 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Include. # Include: **/Rakefile, **/*.rake Rails/RakeEnvironment: @@ -806,7 +813,7 @@ Rails/ReversibleMigrationMethodDefinition: - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' # Offense count: 15 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowImplicitReturn, AllowedReceivers. Rails/SaveBang: Exclude: @@ -834,7 +841,7 @@ Rails/SkipsModelValidations: - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' # Offense count: 27 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible Rails/TimeZone: @@ -856,7 +863,7 @@ Rails/TimeZone: - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/Validation: @@ -865,20 +872,20 @@ Rails/Validation: - 'app/models/story.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). Rails/WhereEquals: Exclude: - 'app/models/feed.rb' - 'app/repositories/story_repository.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Rails/WhereNot: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' # Offense count: 2 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. # MethodsAcceptingSymbol: inject, reduce Style/CollectionMethods: @@ -887,7 +894,7 @@ Style/CollectionMethods: - 'app/fever_api/response.rb' # Offense count: 8 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedCops. Style/DisableCopsWithinSourceCodeDirective: Exclude: @@ -898,22 +905,15 @@ Style/DisableCopsWithinSourceCodeDirective: - 'spec/helpers/authentications_helper_spec.rb' - 'spec/helpers/url_helpers_spec.rb' -# Offense count: 166 -# Configuration parameters: RequireForNonPublicMethods. -Style/DocumentationMethod: - Enabled: false - -# Offense count: 9 -# This cop supports safe auto-correction (--auto-correct). +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedVars. Style/FetchEnvVar: Exclude: - 'Rakefile' - - 'app.rb' - - 'config/puma.rb' # Offense count: 152 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: @@ -1072,12 +1072,45 @@ Style/FrozenStringLiteralComment: - 'spec/utils/opml_parser_spec.rb' # Offense count: 85 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either +# SupportedShorthandSyntax: always, never, either, consistent Style/HashSyntax: - Enabled: false + Exclude: + - 'app.rb' + - 'app/commands/users/create_user.rb' + - 'app/fever_api/read_favicons.rb' + - 'app/fever_api/read_feeds.rb' + - 'app/fever_api/read_feeds_groups.rb' + - 'app/fever_api/read_groups.rb' + - 'app/fever_api/read_links.rb' + - 'app/fever_api/sync_saved_item_ids.rb' + - 'app/fever_api/sync_unread_item_ids.rb' + - 'app/models/feed.rb' + - 'app/models/group.rb' + - 'app/models/story.rb' + - 'app/repositories/story_repository.rb' + - 'app/utils/sample_story.rb' + - 'spec/factories/feed_factory.rb' + - 'spec/factories/group_factory.rb' + - 'spec/factories/story_factory.rb' + - 'spec/fever_api/read_feeds_groups_spec.rb' + - 'spec/fever_api/read_feeds_spec.rb' + - 'spec/fever_api/read_groups_spec.rb' + - 'spec/fever_api/read_items_spec.rb' + - 'spec/fever_api/sync_saved_item_ids_spec.rb' + - 'spec/fever_api/sync_unread_item_ids_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/javascript/test_controller.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/tasks/change_password_spec.rb' + - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 1 Style/InlineComment: @@ -1085,8 +1118,8 @@ Style/InlineComment: - 'app/utils/opml_parser.rb' # Offense count: 698 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: IgnoreMacros, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: Exclude: @@ -1175,8 +1208,8 @@ Style/MethodCallWithArgsParentheses: - 'spec/utils/opml_parser_spec.rb' # Offense count: 1 -# This cop supports unsafe auto-correction (--auto-correct-all). -# Configuration parameters: EnforcedStyle, IgnoredMethods. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: @@ -1214,7 +1247,7 @@ Style/OptionHash: - 'spec/factories/story_factory.rb' # Offense count: 12 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: @@ -1227,7 +1260,7 @@ Style/PercentLiteralDelimiters: - 'spec/javascript/test_controller.rb' # Offense count: 6 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: same_as_string_literals, single_quotes, double_quotes Style/QuotedSymbols: @@ -1235,7 +1268,7 @@ Style/QuotedSymbols: - 'app/controllers/feeds_controller.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: return, return_nil Style/ReturnNil: @@ -1243,7 +1276,7 @@ Style/ReturnNil: - 'app/repositories/user_repository.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: @@ -1251,7 +1284,7 @@ Style/SafeNavigation: - 'app/controllers/feeds_controller.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Methods. # Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]} Style/SingleLineBlockParams: @@ -1273,7 +1306,7 @@ Style/StaticClass: - 'app/utils/content_sanitizer.rb' # Offense count: 18 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). Style/StringHashKeys: Exclude: - 'fever_api.rb' @@ -1292,11 +1325,15 @@ Style/StringHashKeys: - 'spec/fever_api/sync_unread_item_ids_spec.rb' # Offense count: 7 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinSize. # SupportedStyles: percent, brackets Style/SymbolArray: EnforcedStyle: brackets # Offense count: 6 -Style/TopLevelMethodDefinition: { Enabled: false } +Style/TopLevelMethodDefinition: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/support/active_record.rb' diff --git a/Gemfile.lock b/Gemfile.lock index 9b373eb87..8ebb8e217 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,7 +55,7 @@ GEM i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.2) - loofah (2.18.0) + loofah (2.19.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) matrix (0.4.2) @@ -111,7 +111,7 @@ GEM rspec-mocks (~> 3.11.0) rspec-core (3.11.0) rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec-expectations (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-html-matchers (0.10.0) @@ -120,7 +120,7 @@ GEM rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-support (3.11.0) + rspec-support (3.11.1) rubocop (1.36.0) json (~> 2.3) parallel (~> 1.10) @@ -133,14 +133,14 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) parser (>= 3.1.1.0) - rubocop-rails (2.16.0) + rubocop-rails (2.16.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.12.1) - rubocop (~> 1.31) + rubocop-rspec (2.13.1) + rubocop (~> 1.33) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) sass (3.7.4) @@ -191,7 +191,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.2.0) + unicode-display_width (2.3.0) will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) From 82b8cd53d293b1ca5fdf8efd4133fbb495cd81ba Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Sep 2022 12:01:30 -0700 Subject: [PATCH 129/779] Errors: add active_support require to config.ru (#646) This adds an additional `active_support` require to `config.ru`. This should (hopefully) fix [this issue][is] where an error is thrown when loading `Delayed::Job`. [is]: https://github.com/stringer-rss/stringer/issues/644 --- config.ru | 1 + 1 file changed, 1 insertion(+) diff --git a/config.ru b/config.ru index 3720996aa..a45d484f3 100644 --- a/config.ru +++ b/config.ru @@ -1,6 +1,7 @@ require "rubygems" require "bundler" +require "active_support/core_ext/kernel/reporting" Bundler.require require "./fever_api" From 1b22eefd682f1d331efeb1d9c31493e00e4f8dbf Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 26 Sep 2022 10:53:12 -0700 Subject: [PATCH 130/779] Update all Bundler dependencies (2022-09-26) (#648) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ebb8e217..89db417fd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,7 +43,7 @@ GEM execjs (2.8.1) faker (2.23.0) i18n (>= 1.8.11, < 2) - feedbag (0.10.3) + feedbag (1.0.0) nokogiri (~> 1.8, >= 1.8.2) feedjira (3.2.1) loofah (>= 2.3.1) @@ -68,7 +68,7 @@ GEM minitest (5.16.3) multi_json (1.15.0) multi_xml (0.6.0) - mustermann (2.0.2) + mustermann (3.0.0) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) nokogiri (1.13.8) @@ -89,7 +89,7 @@ GEM nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) - rack-protection (2.2.2) + rack-protection (3.0.0) rack rack-ssl (1.4.1) rack @@ -139,7 +139,7 @@ GEM rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.13.1) + rubocop-rspec (2.13.2) rubocop (~> 1.33) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) @@ -157,19 +157,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (2.2.2) - mustermann (~> 2.0) - rack (~> 2.2) - rack-protection (= 2.2.2) + sinatra (3.0.0) + mustermann (~> 3.0) + rack (~> 2.2, >= 2.2.4) + rack-protection (= 3.0.0) tilt (~> 2.0) sinatra-activerecord (2.0.25) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (2.2.2) + sinatra-contrib (3.0.0) multi_json - mustermann (~> 2.0) - rack-protection (= 2.2.2) - sinatra (= 2.2.2) + mustermann (~> 3.0) + rack-protection (= 3.0.0) + sinatra (= 3.0.0) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) From 8de93096c28728c8b6aa92c4d8396087c2535c52 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 3 Oct 2022 09:40:33 -0700 Subject: [PATCH 131/779] Update all Bundler dependencies (2022-10-03) (#649) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 89db417fd..5fe9e54fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,7 +33,7 @@ GEM thor (>= 0.20.3, < 2.0) tins (~> 1.16) crass (1.0.6) - delayed_job (4.1.10) + delayed_job (4.1.11) activesupport (>= 3.0, < 8.0) delayed_job_active_record (4.1.7) activerecord (>= 3.0, < 8.0) @@ -89,7 +89,7 @@ GEM nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) - rack-protection (3.0.0) + rack-protection (3.0.2) rack rack-ssl (1.4.1) rack @@ -103,7 +103,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.5.0) + regexp_parser (2.6.0) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -157,19 +157,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (3.0.0) + sinatra (3.0.2) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.0.0) + rack-protection (= 3.0.2) tilt (~> 2.0) sinatra-activerecord (2.0.25) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (3.0.0) + sinatra-contrib (3.0.2) multi_json mustermann (~> 3.0) - rack-protection (= 3.0.0) - sinatra (= 3.0.0) + rack-protection (= 3.0.2) + sinatra (= 3.0.2) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) From d5c418c7a74ad327c6e53b7226b19d525af15e35 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 14 Oct 2022 12:32:47 -0700 Subject: [PATCH 132/779] update links and branch names (#650) Update GitHub links to point to `stringer-rss/stringer` and rename `master` to `main`. --- README.md | 9 ++++++--- app.json | 4 ++-- app.rb | 2 +- app/views/partials/_footer.erb | 2 +- docs/Heroku.md | 6 +++--- docs/OpenShift.md | 4 ++-- docs/VPS.md | 2 +- docs/docker.md | 2 +- spec/controllers/stories_controller_spec.rb | 2 +- spec/repositories/story_repository_spec.rb | 8 ++++---- 10 files changed, 22 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index bac28e2df..f7569ef96 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Stringer [![CircleCI](https://circleci.com/gh/stringer-rss/stringer/tree/main.svg?style=svg)](https://circleci.com/gh/stringer-rss/stringer/tree/main) -[![Code Climate](https://codeclimate.com/github/swanson/stringer.svg?style=flat)](https://codeclimate.com/github/swanson/stringer) -[![Coverage Status](https://coveralls.io/repos/swanson/stringer/badge.svg?style=flat)](https://coveralls.io/r/swanson/stringer) +[![Code Climate](https://api.codeclimate.com/v1/badges/899c5407c870e541af4e/maintainability)](https://codeclimate.com/github/stringer-rss/stringer/maintainability) +[![Coverage Status](https://coveralls.io/repos/github/stringer-rss/stringer/badge.svg?branch=main)](https://coveralls.io/github/stringer-rss/stringer?branch=main) ### A self-hosted, anti-social RSS reader. @@ -128,6 +128,9 @@ If you have a question, feature idea, or are running into problems, our preferre ## Maintainers -Matt Swanson, [mdswanson.com](http://mdswanson.com), [@_swanson](http://twitter.com/_swanson) +Robert Fletcher [boon.gl](https://boon.gl) +## Alumni + +Matt Swanson (creator), [mdswanson.com](http://mdswanson.com), [@_swanson](http://twitter.com/_swanson) Victor Koronen, [victor.koronen.se](http://victor.koronen.se/), [@victorkoronen](https://twitter.com/victorkoronen) diff --git a/app.json b/app.json index 33f03cdaf..4288d8c97 100644 --- a/app.json +++ b/app.json @@ -1,12 +1,12 @@ { "name": "Stringer", "description": "A self-hosted, anti-social RSS reader.", - "logo": "https://raw.githubusercontent.com/swanson/stringer/master/screenshots/logo.png", + "logo": "https://raw.githubusercontent.com/stringer-rss/stringer/main/screenshots/logo.png", "keywords": [ "RSS", "Ruby" ], - "website": "https://github.com/swanson/stringer", + "website": "https://github.com/stringer-rss/stringer", "success_url": "/heroku", "scripts": { "postdeploy": "bundle exec rake db:migrate" diff --git a/app.rb b/app.rb index 6021a8dd3..9f0d3fcb4 100644 --- a/app.rb +++ b/app.rb @@ -19,7 +19,7 @@ I18n.config.enforce_available_locales = false class Stringer < Sinatra::Base - # need to exclude assets for sinatra assetpack, see https://github.com/swanson/stringer/issues/112 + # need to exclude assets for sinatra assetpack, see https://github.com/stringer-rss/stringer/issues/112 use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } if ENV["ENFORCE_SSL"] == "true" register Sinatra::ActiveRecordExtension diff --git a/app/views/partials/_footer.erb b/app/views/partials/_footer.erb index 5f5619930..42d74a31e 100644 --- a/app/views/partials/_footer.erb +++ b/app/views/partials/_footer.erb @@ -13,7 +13,7 @@

  • ·
  • <% end %> -
  • <%= t('layout.support') %>
  • +
  • <%= t('layout.support') %>
  • diff --git a/docs/Heroku.md b/docs/Heroku.md index 0e75c49b0..5c90e2ab4 100644 --- a/docs/Heroku.md +++ b/docs/Heroku.md @@ -1,8 +1,8 @@ ```sh -git clone git://github.com/swanson/stringer.git +git clone git@github.com:stringer-rss/stringer.git cd stringer heroku create -git push heroku master +git push heroku main heroku config:set APP_URL=`heroku apps:info --shell | grep web_url | cut -d= -f2` heroku config:set SECRET_TOKEN=`openssl rand -hex 20` @@ -26,7 +26,7 @@ From the app's directory: ```sh git pull -git push heroku master +git push heroku main heroku run rake db:migrate heroku restart ``` diff --git a/docs/OpenShift.md b/docs/OpenShift.md index be9d7dbfe..3299cd066 100644 --- a/docs/OpenShift.md +++ b/docs/OpenShift.md @@ -14,8 +14,8 @@ Deploying into OpenShift ```sh cd feeds - git remote add upstream git://github.com/swanson/stringer.git - git pull -s recursive -X theirs upstream master + git remote add upstream git@github.com:stringer-rss/stringer.git + git pull -s recursive -X theirs upstream main ``` 3. To enable migrations for the application, a new action_hook is required. Add the file, .openshift/action_hooks/deploy, with the below 3 lines into it. diff --git a/docs/VPS.md b/docs/VPS.md index 4bb635de7..9c05452d2 100644 --- a/docs/VPS.md +++ b/docs/VPS.md @@ -79,7 +79,7 @@ Install Stringer and set it up Grab Stringer from github - git clone https://github.com/swanson/stringer.git + git clone git@github.com:stringer-rss/stringer.git cd stringer Use bundler to grab and build Stringer's dependencies diff --git a/docs/docker.md b/docs/docker.md index 72f252a32..442553f30 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -40,7 +40,7 @@ docker run --detach \ -e FETCH_FEEDS_CRON="*/5 * * * *" \ # optional -e CLEANUP_CRON="0 0 * * *" \ # optional -p 127.0.0.1:8080:8080 \ - mdswanson/stringer + stringer-rss/stringer ``` That's it! You now have a fully working Stringer instance up and running! diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index aacd5840d..60ab88c0c 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -44,7 +44,7 @@ page = last_response.body expect(page).to have_tag("a", with: { href: "/feeds/export" }) expect(page).to have_tag("a", with: { href: "/logout" }) - expect(page).to have_tag("a", with: { href: "https://github.com/swanson/stringer" }) + expect(page).to have_tag("a", with: { href: "https://github.com/stringer-rss/stringer" }) end it "displays a zen-like message when there are no unread stories" do diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index fedac02c1..463b877f2 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -369,16 +369,16 @@ describe ".extract_url" do it "returns the url" do feed = double(url: "http://github.com") - entry = double(url: "https://github.com/swanson/stringer") + entry = double(url: "https://github.com/stringer-rss/stringer") - expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/swanson/stringer" + expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" end it "returns the enclosure_url when the url is nil" do feed = double(url: "http://github.com") - entry = double(url: nil, enclosure_url: "https://github.com/swanson/stringer") + entry = double(url: nil, enclosure_url: "https://github.com/stringer-rss/stringer") - expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/swanson/stringer" + expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" end it "does not crash if url is nil but enclosure_url does not exist" do From f612c0f3853987e724fcc12caf673c0ced793793 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 14 Oct 2022 12:49:32 -0700 Subject: [PATCH 133/779] update deploy button link (#651) For some reason it doesn't work without the `template` param for me. Maybe I'm using a privacy extension that strips out the `referer`. Explicitly passing the `template` will provide a more reliable experience, even if it's a little less flexible, as forks will no longer be able to be deployed as easily. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f7569ef96..5f5b44196 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ But it does have keyboard shortcuts and was made with love! Stringer is a Ruby app based on Sinatra, ActiveRecord, PostgreSQL, Backbone.js and DelayedJob. -[![Deploy to Heroku](https://cdn.herokuapp.com/deploy/button.svg)](https://heroku.com/deploy) +[![Deploy to Heroku](https://cdn.herokuapp.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/stringer-rss/stringer) Stringer will run just fine on the Heroku free plan. From 5ef0426e39935dd83fdced7dca9cf5b46ebc5f52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 21:47:14 -0700 Subject: [PATCH 134/779] Bump nokogiri from 1.13.8 to 1.13.9 (#654) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.8 to 1.13.9. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.8...v1.13.9) --- updated-dependencies: - dependency-name: nokogiri dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5fe9e54fb..e1138ce1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ GEM mustermann (3.0.0) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.8) + nokogiri (1.13.9) mini_portile2 (~> 2.8.0) racc (~> 1.4) parallel (1.22.1) From 3551e87ed7d1f861f5786f7160cd5d70f3d5bf33 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 23 Oct 2022 11:51:48 -0700 Subject: [PATCH 135/779] Set a logger inside FetchFeed (#655) Logging feed errors should be helpful for debugging. --- app/tasks/fetch_feed.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index e52862ce9..c683823e3 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -6,7 +6,7 @@ require_relative "../commands/feeds/find_new_stories" class FetchFeed - def initialize(feed, parser: Feedjira, client: HTTParty, logger: nil) + def initialize(feed, parser: Feedjira, client: HTTParty, logger: Logger.new($stdout)) @feed = feed @parser = parser @client = client From bab8f165a7d08320981e060c1ee4eeef47ff9ccd Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 24 Oct 2022 10:56:06 -0700 Subject: [PATCH 136/779] Deps: lock down puma version (#657) The latest version of Puma causes some breakage in Capybara, so we'll lock it down until Capybara gets around to releasing an update. --- .rubocop_todo.yml | 11 ++++++----- Gemfile | 2 +- Gemfile.lock | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 48f3f4ee5..a327a4052 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-09-19 17:13:31 UTC using RuboCop version 1.36.0. +# on 2022-10-24 17:51:19 UTC using RuboCop version 1.36.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -13,12 +13,13 @@ Bundler/GemComment: Exclude: - 'Gemfile' -# Offense count: 40 -# Configuration parameters: Include, AllowedGems. +# Offense count: 39 +# Configuration parameters: EnforcedStyle, Include, AllowedGems. # SupportedStyles: required, forbidden # Include: **/*.gemfile, **/Gemfile, **/gems.rb Bundler/GemVersion: - EnforcedStyle: forbidden + Exclude: + - 'Gemfile' # Offense count: 9 # This cop supports safe autocorrection (--autocorrect). @@ -102,7 +103,7 @@ Lint/AmbiguousOperatorPrecedence: - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' -# Offense count: 765 +# Offense count: 766 # Configuration parameters: Only, Ignore. Lint/ConstantResolution: Exclude: diff --git a/Gemfile b/Gemfile index 5e9b686a8..575f0885a 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ gem "i18n" gem "loofah" gem "nokogiri" gem "pg" -gem "puma" +gem "puma", "~> 5.6" gem "rack-protection" gem "racksh" gem "rack-ssl" diff --git a/Gemfile.lock b/Gemfile.lock index e1138ce1a..17cfb246d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -215,7 +215,7 @@ DEPENDENCIES nokogiri pg pry-byebug - puma + puma (~> 5.6) rack-protection rack-ssl rack-test From 59d5e8e682ea7278f3f6848159b94109bbb5bfed Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 11:04:15 -0700 Subject: [PATCH 137/779] Update all Bundler dependencies (2022-10-24) (#656) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 17cfb246d..56b5f621b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GEM i18n (>= 1.8.11, < 2) feedbag (1.0.0) nokogiri (~> 1.8, >= 1.8.2) - feedjira (3.2.1) + feedjira (3.2.2) loofah (>= 2.3.1) sax-machine (>= 1.0) ffi (1.15.5) @@ -77,7 +77,7 @@ GEM parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) - pg (1.4.3) + pg (1.4.4) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) @@ -121,25 +121,25 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.1) - rubocop (1.36.0) + rubocop (1.37.1) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.1, < 2.0) + rubocop-ast (>= 1.23.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.21.0) + rubocop-ast (1.23.0) parser (>= 3.1.1.0) - rubocop-rails (2.16.1) + rubocop-rails (2.17.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.13.2) + rubocop-rspec (2.14.1) rubocop (~> 1.33) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) @@ -162,7 +162,7 @@ GEM rack (~> 2.2, >= 2.2.4) rack-protection (= 3.0.2) tilt (~> 2.0) - sinatra-activerecord (2.0.25) + sinatra-activerecord (2.0.26) activerecord (>= 4.1) sinatra (>= 1.0) sinatra-contrib (3.0.2) From 591c515836916378186e0466659811254b8e99fb Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 09:40:30 -0700 Subject: [PATCH 138/779] Update all Bundler dependencies (2022-10-31) (#658) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 56b5f621b..212b72828 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,22 +105,22 @@ GEM ffi (~> 1.0) regexp_parser (2.6.0) rexml (3.2.5) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.1) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.0) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) + rspec-support (~> 3.12.0) rspec-html-matchers (0.10.0) nokogiri (~> 1) rspec (>= 3.0.0.a) - rspec-mocks (3.11.1) + rspec-mocks (3.12.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.1) + rspec-support (~> 3.12.0) + rspec-support (3.12.0) rubocop (1.37.1) json (~> 2.3) parallel (~> 1.10) @@ -133,13 +133,13 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.23.0) parser (>= 3.1.1.0) - rubocop-rails (2.17.0) + rubocop-rails (2.17.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.14.1) + rubocop-rspec (2.14.2) rubocop (~> 1.33) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) From 7f647da491d603da70c4f7e3d12531e5393a38c4 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 09:18:31 -0800 Subject: [PATCH 139/779] Update all Bundler dependencies (2022-11-07) (#659) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 212b72828..b1bd008c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,7 +16,7 @@ GEM ast (2.4.2) bcrypt (3.1.18) byebug (11.1.3) - capybara (3.37.1) + capybara (3.38.0) addressable matrix mini_mime (>= 0.1.3) @@ -41,7 +41,7 @@ GEM diff-lcs (1.5.0) docile (1.4.0) execjs (2.8.1) - faker (2.23.0) + faker (3.0.0) i18n (>= 1.8.11, < 2) feedbag (1.0.0) nokogiri (~> 1.8, >= 1.8.2) @@ -121,7 +121,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.0) - rubocop (1.37.1) + rubocop (1.38.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) @@ -139,7 +139,7 @@ GEM rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.14.2) + rubocop-rspec (2.15.0) rubocop (~> 1.33) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) From 8433d0f8dabd77a3dd775a0ca89d3ba7ed71d7d4 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 10:34:18 -0800 Subject: [PATCH 140/779] Update all Bundler dependencies (2022-11-14) (#660) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b1bd008c1..8e5998c2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,7 +89,7 @@ GEM nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) - rack-protection (3.0.2) + rack-protection (3.0.3) rack rack-ssl (1.4.1) rack @@ -121,7 +121,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.0) - rubocop (1.38.0) + rubocop (1.39.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) @@ -157,19 +157,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (3.0.2) + sinatra (3.0.3) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.0.2) + rack-protection (= 3.0.3) tilt (~> 2.0) sinatra-activerecord (2.0.26) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (3.0.2) + sinatra-contrib (3.0.3) multi_json mustermann (~> 3.0) - rack-protection (= 3.0.2) - sinatra (= 3.0.2) + rack-protection (= 3.0.3) + sinatra (= 3.0.3) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) From 69b153c1a48461dc8f1a8dacd92e7c0ede4ab18b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 09:01:58 -0800 Subject: [PATCH 141/779] Update all Bundler dependencies (2022-11-21) (#661) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8e5998c2c..2299b778b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,7 +77,7 @@ GEM parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) - pg (1.4.4) + pg (1.4.5) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) @@ -103,7 +103,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.6.0) + regexp_parser (2.6.1) rexml (3.2.5) rspec (3.12.0) rspec-core (~> 3.12.0) @@ -133,7 +133,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.23.0) parser (>= 3.1.1.0) - rubocop-rails (2.17.2) + rubocop-rails (2.17.3) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -185,7 +185,7 @@ GEM thread (0.2.2) tilt (2.0.11) timecop (0.9.5) - tins (1.31.1) + tins (1.32.0) sync tzinfo (2.0.5) concurrent-ruby (~> 1.0) From a9a32516e6ba0bacf3f1940e3c16b06b1e3b73a9 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sun, 27 Nov 2022 22:37:17 -0800 Subject: [PATCH 142/779] Update all Bundler dependencies (2022-11-28) (#663) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2299b778b..ba5745e84 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,7 +75,7 @@ GEM mini_portile2 (~> 2.8.0) racc (~> 1.4) parallel (1.22.1) - parser (3.1.2.1) + parser (3.1.3.0) ast (~> 2.4.1) pg (1.4.5) pry (0.14.1) @@ -89,7 +89,7 @@ GEM nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) - rack-protection (3.0.3) + rack-protection (3.0.4) rack rack-ssl (1.4.1) rack @@ -157,19 +157,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (3.0.3) + sinatra (3.0.4) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.0.3) + rack-protection (= 3.0.4) tilt (~> 2.0) sinatra-activerecord (2.0.26) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (3.0.3) + sinatra-contrib (3.0.4) multi_json mustermann (~> 3.0) - rack-protection (= 3.0.3) - sinatra (= 3.0.3) + rack-protection (= 3.0.4) + sinatra (= 3.0.4) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) @@ -185,7 +185,7 @@ GEM thread (0.2.2) tilt (2.0.11) timecop (0.9.5) - tins (1.32.0) + tins (1.32.1) sync tzinfo (2.0.5) concurrent-ruby (~> 1.0) From 62c8a0f5f5c63b359e42a1cdbade5de1b36cd74a Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 16:23:55 -0800 Subject: [PATCH 143/779] Update puma to version 6.0.0 (#664) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- config/puma.rb | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 575f0885a..6174e4a96 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ gem "i18n" gem "loofah" gem "nokogiri" gem "pg" -gem "puma", "~> 5.6" +gem "puma", "~> 6.0" gem "rack-protection" gem "racksh" gem "rack-ssl" diff --git a/Gemfile.lock b/Gemfile.lock index ba5745e84..68a3f0c18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,7 +85,7 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) public_suffix (5.0.0) - puma (5.6.5) + puma (6.0.0) nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) @@ -215,7 +215,7 @@ DEPENDENCIES nokogiri pg pry-byebug - puma (~> 5.6) + puma (~> 6.0) rack-protection rack-ssl rack-test diff --git a/config/puma.rb b/config/puma.rb index 968c37cf0..0e079d63c 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -2,7 +2,6 @@ threads_count = Integer(ENV.fetch("MAX_THREADS", 2)) threads threads_count, threads_count -rackup DefaultRackup port ENV.fetch("PORT", 3000) environment ENV.fetch("RACK_ENV", "development") From bd36c54d7d5310e38151f21204713013c5e42f17 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 16:34:24 -0800 Subject: [PATCH 144/779] Update Ruby to version 3.1.3 (#662) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .circleci/config.yml | 8 ++++---- .ruby-version | 2 +- Dockerfile | 2 +- Gemfile.lock | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c5336ecb..6c8e2edd9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: build: parallelism: 1 docker: - - image: cimg/ruby:3.1.2-browsers + - image: cimg/ruby:3.1.3-browsers environment: BUNDLE_JOBS: 3 BUNDLE_RETRY: 3 @@ -39,8 +39,8 @@ jobs: # https://circleci.com/docs/2.0/caching/ - restore_cache: keys: - - bundle-{{ checksum "Gemfile.lock" }} - - bundle- + - bundle-v1-{{ checksum "Gemfile.lock" }} + - bundle-v1- - run: # Install Ruby dependencies name: Bundle Install @@ -51,7 +51,7 @@ jobs: # command: bundle exec bundle audit - save_cache: - key: bundle-{{ checksum "Gemfile.lock" }} + key: bundle-v1-{{ checksum "Gemfile.lock" }} paths: - vendor/bundle diff --git a/.ruby-version b/.ruby-version index ef538c281..ff365e06b 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.1.3 diff --git a/Dockerfile b/Dockerfile index e5952ba18..307350dfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.1.2 +FROM ruby:3.1.3 ENV RACK_ENV=production ENV PORT=8080 diff --git a/Gemfile.lock b/Gemfile.lock index 68a3f0c18..c47468fa1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -242,7 +242,7 @@ DEPENDENCIES will_paginate RUBY VERSION - ruby 3.1.2 + ruby 3.1.3 BUNDLED WITH 2.2.33 From 66b7d730b7454419dc5082b73fe8ab4387cc675d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 5 Dec 2022 15:58:10 -0800 Subject: [PATCH 145/779] Update all Bundler dependencies (2022-12-05) (#665) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c47468fa1..d3a14d15e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -87,7 +87,7 @@ GEM public_suffix (5.0.0) puma (6.0.0) nio4r (~> 2.0) - racc (1.6.0) + racc (1.6.1) rack (2.2.4) rack-protection (3.0.4) rack @@ -131,7 +131,7 @@ GEM rubocop-ast (>= 1.23.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.23.0) + rubocop-ast (1.24.0) parser (>= 3.1.1.0) rubocop-rails (2.17.3) activesupport (>= 4.2.0) @@ -184,7 +184,7 @@ GEM thor (1.2.1) thread (0.2.2) tilt (2.0.11) - timecop (0.9.5) + timecop (0.9.6) tins (1.32.1) sync tzinfo (2.0.5) From 4e654c6d764f2fd19866c65dfe350ef09bb44ebf Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 6 Dec 2022 21:04:23 -0800 Subject: [PATCH 146/779] Remove unused files (#669) I'm not seeing any usage of these files in the codebase. It appears they were used before when there was a `/read` page, but that was renamed to `/archive`. --- app/views/partials/_story.erb | 46 ----------------------------------- app/views/read.erb | 26 -------------------- 2 files changed, 72 deletions(-) delete mode 100644 app/views/partials/_story.erb delete mode 100644 app/views/read.erb diff --git a/app/views/partials/_story.erb b/app/views/partials/_story.erb deleted file mode 100644 index 19926f492..000000000 --- a/app/views/partials/_story.erb +++ /dev/null @@ -1,46 +0,0 @@ -<% if story.is_read %> -
  • -<% else %> -
  • -<% end %> -
    -
    -

    - <%= story.source %> -

    -
    -
    -

    - - <%= story.headline %> - - - — <%= story.lead %> - -

    -
    -
    - - - -
  • \ No newline at end of file diff --git a/app/views/read.erb b/app/views/read.erb deleted file mode 100644 index b37ad9663..000000000 --- a/app/views/read.erb +++ /dev/null @@ -1,26 +0,0 @@ -
    - <%= render_partial :feed_action_bar %> -
    - -<% unless @read_stories.empty? %> -
    -
      - <% @read_stories.each do |story| %> - <%= render_partial :story, { story: story } %> - <% end %> -
    -
    - -<% else %> -
    -

    Sorry, you haven't read any stories yet!

    -
    -<% end %> \ No newline at end of file From 5e3bef97d6f15881c61a0fc333b941b8dde310ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:31:34 -0800 Subject: [PATCH 147/779] Bump nokogiri from 1.13.9 to 1.13.10 (#670) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.9 to 1.13.10. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.9...v1.13.10) --- updated-dependencies: - dependency-name: nokogiri dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d3a14d15e..ea3f69a40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ GEM mustermann (3.0.0) ruby2_keywords (~> 0.0.1) nio4r (2.5.8) - nokogiri (1.13.9) + nokogiri (1.13.10) mini_portile2 (~> 2.8.0) racc (~> 1.4) parallel (1.22.1) From beb4245b3fe48667592c7a90a41fa956bf457d7d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 10 Dec 2022 15:16:26 -0800 Subject: [PATCH 148/779] Add download link when story has enclosure (#667) Many podcast and other media feeds have both a `url` and an `enclosure_url`. For example, [the Welcome to Nightvale feed][wn]. In these cases, there's a good chance the user might want to get straight to the enclosure rather than being directed to another site to listen to the track. This allows us to directly download the enclosure rather than having to hunt it down somewhere else. [wn]: http://feeds.nightvalepresents.com/welcometonightvalepodcast --- .rubocop_todo.yml | 1 + app/assets/stylesheets/application.css | 2 +- app/repositories/story_repository.rb | 2 ++ app/views/js/templates/_story.js.erb | 5 +++++ ...1206231914_add_enclosure_url_to_stories.rb | 7 ++++++ db/schema.rb | 4 ++-- spec/javascript/spec/views/story_view_spec.js | 17 ++++++++++++++ spec/models/story_spec.rb | 1 + spec/repositories/story_repository_spec.rb | 22 +++++++++++++++++++ 9 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20221206231914_add_enclosure_url_to_stories.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a327a4052..d80bd135b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -184,6 +184,7 @@ Lint/ConstantResolution: - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' - 'db/migrate/20140421224454_fix_invalid_unicode.rb' - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' + - 'db/migrate/20221206231914_add_enclosure_url_to_stories.rb' - 'fever_api.rb' - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/feeds/export_to_opml_spec.rb' diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index acf41f639..6b8864c83 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -207,7 +207,7 @@ li.story.open .story-preview { margin-left: 20px; } -.story-keep-unread, .story-starred { +.story-keep-unread, .story-starred, .story-enclosure { display: inline-block; cursor: pointer; -webkit-touch-callout: none; diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 73a65d904..75fbdd1b9 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -7,9 +7,11 @@ class StoryRepository extend UrlHelpers def self.add(entry, feed) + enclosure_url = entry.enclosure_url if entry.respond_to?(:enclosure_url) Story.create(feed: feed, title: extract_title(entry), permalink: extract_url(entry, feed), + enclosure_url: enclosure_url, body: extract_content(entry), is_read: false, is_starred: false, diff --git a/app/views/js/templates/_story.js.erb b/app/views/js/templates/_story.js.erb index dae33201a..874520322 100644 --- a/app/views/js/templates/_story.js.erb +++ b/app/views/js/templates/_story.js.erb @@ -38,6 +38,11 @@
    + {{ if (enclosure_url) { }} + + + + {{ } }} diff --git a/db/migrate/20221206231914_add_enclosure_url_to_stories.rb b/db/migrate/20221206231914_add_enclosure_url_to_stories.rb new file mode 100644 index 000000000..1c20b317d --- /dev/null +++ b/db/migrate/20221206231914_add_enclosure_url_to_stories.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddEnclosureUrlToStories < ActiveRecord::Migration[4.2] + def change + add_column(:stories, :enclosure_url, :string) + end +end diff --git a/db/schema.rb b/db/schema.rb index f4d5a1075..d55f58167 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,8 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2014_11_02_103617) do - +ActiveRecord::Schema[7.0].define(version: 2022_12_06_231914) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -59,6 +58,7 @@ t.boolean "keep_unread", default: false t.boolean "is_starred", default: false t.text "entry_id" + t.string "enclosure_url" t.index ["entry_id", "feed_id"], name: "index_stories_on_entry_id_and_feed_id", unique: true end diff --git a/spec/javascript/spec/views/story_view_spec.js b/spec/javascript/spec/views/story_view_spec.js index c7a556c97..737ac7f5e 100644 --- a/spec/javascript/spec/views/story_view_spec.js +++ b/spec/javascript/spec/views/story_view_spec.js @@ -9,6 +9,7 @@ describe("Storyiew", function(){ before(function() { this.story = new Story({ source: "TechKrunch", + enclosure_url: null, headline: "Every startups acquired by Yahoo!", lead: "This is the lead.", title: "Every startups acquired by Yahoo! NOT!!", @@ -34,6 +35,10 @@ describe("Storyiew", function(){ el.find(tagName).should.have.length(count); }; + var assertNoTagExists = function(el, tagName) { + el.find(tagName).should.have.length(0); + }; + var assertPropertyRendered = function(el, model, propName) { el.html().should.have.string(model.get(propName)); }; @@ -104,6 +109,18 @@ describe("Storyiew", function(){ assertTagExists(this.view.$el, ".story-starred .icon-star", 2); }); + it("should not render enclosure link when not present", function(){ + assertNoTagExists(this.view.$el, ".story-enclosure"); + }); + + it("should render enclosure link when present", function(){ + this.story.set("enclosure_url", "http://example.com/enclosure"); + this.view.render(); + + assertTagExists(this.view.$el, ".story-enclosure"); + assertPropertyRendered(this.view.$el, this.story, "enclosure_url"); + }); + describe("Handling click on story", function(){ beforeEach(function() { this.toggle_stub = sinon.stub(this.story, "toggle"); diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index b695f5ff6..e0674b4cc 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -85,6 +85,7 @@ expect(story.as_json).to eq({ body: "story body", created_at: created_at.utc.as_json, + enclosure_url: nil, entry_id: "5", feed_id: feed.id, headline: "the story title", diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 463b877f2..19ea42bb0 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -34,6 +34,28 @@ StoryRepository.add(entry, feed) end + + it "sets the enclosure url when present" do + entry = instance_double(Feedjira::Parser::ITunesRSSItem, + enclosure_url: "http://example.com/audio.mp3", + title: "", + summary: "", + content: "").as_null_object + allow(StoryRepository).to receive(:normalize_url) + + expect(Story).to receive(:create).with(hash_including(enclosure_url: "http://example.com/audio.mp3")) + + StoryRepository.add(entry, feed) + end + + it "does not set the enclosure url when not present" do + entry = instance_double(Feedjira::Parser::RSSEntry, title: "", summary: "", content: "").as_null_object + allow(StoryRepository).to receive(:normalize_url) + + expect(Story).to receive(:create).with(hash_including(enclosure_url: nil)) + + StoryRepository.add(entry, feed) + end end describe ".fetch" do From 68e9c3d17b1ceea39b8f65c888bc4c43c463aa4a Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 12 Dec 2022 10:12:17 -0800 Subject: [PATCH 149/779] Update all Bundler dependencies (2022-12-12) (#673) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .rubocop.yml | 1 + Gemfile.lock | 8 ++++---- spec/controllers/feeds_controller_spec.rb | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 80584e7ad..a616fda72 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -52,3 +52,4 @@ Style/StringLiterals: ################################################################################ Rails/SchemaComment: { Enabled: false } +Style/RequireOrder: { Enabled: false } diff --git a/Gemfile.lock b/Gemfile.lock index ea3f69a40..ce444c04f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -54,7 +54,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.12.0) concurrent-ruby (~> 1.0) - json (2.6.2) + json (2.6.3) loofah (2.19.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -84,7 +84,7 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - public_suffix (5.0.0) + public_suffix (5.0.1) puma (6.0.0) nio4r (~> 2.0) racc (1.6.1) @@ -117,11 +117,11 @@ GEM rspec-html-matchers (0.10.0) nokogiri (~> 1) rspec (>= 3.0.0.a) - rspec-mocks (3.12.0) + rspec-mocks (3.12.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.0) - rubocop (1.39.0) + rubocop (1.40.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 90c8c3d3d..3917ba408 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -87,7 +87,7 @@ expect(AddNewFeed).to receive(:add).with(feed_url).and_return(valid_feed) expect(FetchFeeds).to receive(:enqueue).with([valid_feed]) - post "/feeds", feed_url: feed_url + post("/feeds", feed_url:) expect(last_response.status).to be 302 expect(URI.parse(last_response.location).path).to eq "/" @@ -100,7 +100,7 @@ it "adds the feed and queues it to be fetched" do expect(AddNewFeed).to receive(:add).with(feed_url).and_return(false) - post "/feeds", feed_url: feed_url + post("/feeds", feed_url:) page = last_response.body expect(page).to have_tag(".error") @@ -114,7 +114,7 @@ it "adds the feed and queues it to be fetched" do expect(AddNewFeed).to receive(:add).with(feed_url).and_return(invalid_feed) - post "/feeds", feed_url: feed_url + post("/feeds", feed_url:) page = last_response.body expect(page).to have_tag(".error") From b8da572be2286ece12a67af64352b157510e895c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:24:56 -0800 Subject: [PATCH 150/779] Bump loofah from 2.19.0 to 2.19.1 (#674) Bumps [loofah](https://github.com/flavorjones/loofah) from 2.19.0 to 2.19.1. - [Release notes](https://github.com/flavorjones/loofah/releases) - [Changelog](https://github.com/flavorjones/loofah/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/loofah/compare/v2.19.0...v2.19.1) --- updated-dependencies: - dependency-name: loofah dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ce444c04f..56f3d615f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,7 +55,7 @@ GEM i18n (1.12.0) concurrent-ruby (~> 1.0) json (2.6.3) - loofah (2.19.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) matrix (0.4.2) From 4a63bc56498a35a6d17a11a5ee8e5433fb1a9c70 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Wed, 14 Dec 2022 20:14:27 -0800 Subject: [PATCH 151/779] Deps: add a `.tool-versions` file (#676) This file allows us to use tools like [`asdf`][asdf] to manage a wide variety of application dependencies. [asdf]: https://github.com/asdf-vm/asdf --- .tool-versions | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..a19bf3ddd --- /dev/null +++ b/.tool-versions @@ -0,0 +1,3 @@ +ruby 3.1.3 +bundler 2.2.33 +postgres 14.6 From f251cb48c3cc30d230c07c616d93206d9f4445d0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 13:08:38 -0800 Subject: [PATCH 152/779] Deps: update bundler version (#677) This updates our bundler version to match the latest version [currently supported by Heroku][he]. [he]: https://devcenter.heroku.com/articles/ruby-support#libraries --- .tool-versions | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index a19bf3ddd..ddf26c264 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ ruby 3.1.3 -bundler 2.2.33 +bundler 2.3.25 postgres 14.6 diff --git a/Gemfile.lock b/Gemfile.lock index 56f3d615f..95b6db04c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -245,4 +245,4 @@ RUBY VERSION ruby 3.1.3 BUNDLED WITH - 2.2.33 + 2.3.25 From 8055a898e2043a63dc65b534c3a062a533f41eaa Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 13:59:42 -0800 Subject: [PATCH 153/779] Move enclosure download link to the heading (#678) It's kind of a pain to hunt down the download link all the way at the bottom, especially in cases where the body is longer. --- app/assets/stylesheets/application.css | 6 +++++- app/views/js/templates/_story.js.erb | 14 ++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 6b8864c83..5adda52ac 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -207,7 +207,11 @@ li.story.open .story-preview { margin-left: 20px; } -.story-keep-unread, .story-starred, .story-enclosure { +.story-enclosure { + float: right; +} + +.story-keep-unread, .story-starred { display: inline-block; cursor: pointer; -webkit-touch-callout: none; diff --git a/app/views/js/templates/_story.js.erb b/app/views/js/templates/_story.js.erb index 874520322..2c10c12fc 100644 --- a/app/views/js/templates/_story.js.erb +++ b/app/views/js/templates/_story.js.erb @@ -22,7 +22,14 @@
    -

    {{= title }}

    +

    + {{= title }} + {{ if (enclosure_url) { }} + + + + {{ } }} +

    {{= body }}
    @@ -38,11 +45,6 @@
    - {{ if (enclosure_url) { }} - - - - {{ } }} From 123e232850c5884d51cdd24688d9f63c3271fb5e Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 15:54:01 -0800 Subject: [PATCH 154/779] Set timezone in app.rb (#679) This sets `Time.zone` inside `app.rb`. Currently it isn't set, which causes `delayed_job_active_record` to [go down a deprecated path][dj]. `ActiveRecord#default_timezone` is deprecated and will be removed in Rails 7.1, so setting the timezone avoids this issue and punts the problem of an outdated queueing system down the road. [dj]: https://github.com/collectiveidea/delayed_job_active_record/blob/d65b0f9900f5b0c78c341c7c0209c2d138d64ec5/lib/delayed/backend/active_record.rb#L175 --- app.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app.rb b/app.rb index 9f0d3fcb4..b312f052f 100644 --- a/app.rb +++ b/app.rb @@ -17,6 +17,7 @@ I18n.load_path += Dir[File.join(File.dirname(__FILE__), "config/locales", "*.yml").to_s] I18n.config.enforce_available_locales = false +Time.zone = ENV.fetch("TZ", "UTC") class Stringer < Sinatra::Base # need to exclude assets for sinatra assetpack, see https://github.com/stringer-rss/stringer/issues/112 From 45d06b292d23a06bd58fcfa0271b7ab3c5d8054c Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 20:27:32 -0800 Subject: [PATCH 155/779] RuboCop: enable Layout/FirstMethodArgumentLineBreak (#680) --- .rubocop_todo.yml | 11 ------ app/commands/feeds/add_new_feed.rb | 8 +++-- app/commands/users/create_user.rb | 10 +++--- app/repositories/story_repository.rb | 20 ++++++----- spec/models/story_spec.rb | 40 +++++++++++---------- spec/repositories/story_repository_spec.rb | 42 +++++++++++++--------- spec/tasks/fetch_feed_spec.rb | 10 +++--- 7 files changed, 75 insertions(+), 66 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d80bd135b..4b662f2a7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,17 +21,6 @@ Bundler/GemVersion: Exclude: - 'Gemfile' -# Offense count: 9 -# This cop supports safe autocorrection (--autocorrect). -Layout/FirstMethodArgumentLineBreak: - Exclude: - - 'app/commands/feeds/add_new_feed.rb' - - 'app/commands/users/create_user.rb' - - 'app/repositories/story_repository.rb' - - 'spec/models/story_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/app/commands/feeds/add_new_feed.rb b/app/commands/feeds/add_new_feed.rb index 2d7502e29..5fa5810db 100644 --- a/app/commands/feeds/add_new_feed.rb +++ b/app/commands/feeds/add_new_feed.rb @@ -9,8 +9,10 @@ def self.add(url, discoverer = FeedDiscovery.new, repo = Feed) result = discoverer.discover(url) return false unless result - repo.create(name: ContentSanitizer.sanitize(result.title), - url: result.feed_url, - last_fetched: Time.now - ONE_DAY) + repo.create( + name: ContentSanitizer.sanitize(result.title), + url: result.feed_url, + last_fetched: Time.now - ONE_DAY + ) end end diff --git a/app/commands/users/create_user.rb b/app/commands/users/create_user.rb index d3de6fe27..c295500f1 100644 --- a/app/commands/users/create_user.rb +++ b/app/commands/users/create_user.rb @@ -7,9 +7,11 @@ def initialize(repository = User) def create(password) @repo.delete_all - @repo.create(password: password, - password_confirmation: password, - setup_complete: false, - api_key: ApiKey.compute(password)) + @repo.create( + password: password, + password_confirmation: password, + setup_complete: false, + api_key: ApiKey.compute(password) + ) end end diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 75fbdd1b9..b33ea2e70 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -8,15 +8,17 @@ class StoryRepository def self.add(entry, feed) enclosure_url = entry.enclosure_url if entry.respond_to?(:enclosure_url) - Story.create(feed: feed, - title: extract_title(entry), - permalink: extract_url(entry, feed), - enclosure_url: enclosure_url, - body: extract_content(entry), - is_read: false, - is_starred: false, - published: entry.published || Time.now, - entry_id: entry.id) + Story.create( + feed: feed, + title: extract_title(entry), + permalink: extract_url(entry, feed), + enclosure_url: enclosure_url, + body: extract_content(entry), + is_read: false, + is_starred: false, + published: entry.published || Time.now, + entry_id: entry.id + ) end def self.fetch(id) diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index e0674b4cc..2375d0b29 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -82,25 +82,27 @@ updated_at: updated_at ) - expect(story.as_json).to eq({ - body: "story body", - created_at: created_at.utc.as_json, - enclosure_url: nil, - entry_id: "5", - feed_id: feed.id, - headline: "the story title", - id: story.id, - is_read: true, - is_starred: false, - keep_unread: true, - lead: "story body", - permalink: "www.exampoo.com/perma", - pretty_date: I18n.l(published_at.utc), - published: published_at.utc.as_json, - source: "my feed", - title: "the story title", - updated_at: updated_at.utc.as_json - }.stringify_keys) + expect(story.as_json).to eq( + { + body: "story body", + created_at: created_at.utc.as_json, + enclosure_url: nil, + entry_id: "5", + feed_id: feed.id, + headline: "the story title", + id: story.id, + is_read: true, + is_starred: false, + keep_unread: true, + lead: "story body", + permalink: "www.exampoo.com/perma", + pretty_date: I18n.l(published_at.utc), + published: published_at.utc.as_json, + source: "my feed", + title: "the story title", + updated_at: updated_at.utc.as_json + }.stringify_keys + ) end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 19ea42bb0..10ab76f46 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -36,11 +36,13 @@ end it "sets the enclosure url when present" do - entry = instance_double(Feedjira::Parser::ITunesRSSItem, - enclosure_url: "http://example.com/audio.mp3", - title: "", - summary: "", - content: "").as_null_object + entry = instance_double( + Feedjira::Parser::ITunesRSSItem, + enclosure_url: "http://example.com/audio.mp3", + title: "", + summary: "", + content: "" + ).as_null_object allow(StoryRepository).to receive(:normalize_url) expect(Story).to receive(:create).with(hash_including(enclosure_url: "http://example.com/audio.mp3")) @@ -430,14 +432,18 @@ describe ".extract_content" do let(:entry) do - double(url: "http://mdswanson.com", - content: "Some test content") + double( + url: "http://mdswanson.com", + content: "Some test content" + ) end let(:summary_only) do - double(url: "http://mdswanson.com", - content: nil, - summary: "Dumb publisher") + double( + url: "http://mdswanson.com", + content: nil, + summary: "Dumb publisher" + ) end it "sanitizes content" do @@ -449,17 +455,21 @@ end it "expands urls" do - entry = double(url: "http://mdswanson.com", - content: nil, - summary: "Page") + entry = double( + url: "http://mdswanson.com", + content: nil, + summary: "Page" + ) expect(StoryRepository.extract_content(entry)).to eq "Page" end it "ignores URL expansion if entry url is nil" do - entry = double(url: nil, - content: nil, - summary: "Page") + entry = double( + url: nil, + content: nil, + summary: "Page" + ) expect(StoryRepository.extract_content(entry)).to eq "Page" end diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index d8fb83b22..455ff0d3f 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -4,10 +4,12 @@ describe FetchFeed do describe "#fetch" do let(:daring_fireball) do - double(id: 1, - url: "http://daringfireball.com/feed", - last_fetched: Time.new(2013, 1, 1), - stories: []) + double( + id: 1, + url: "http://daringfireball.com/feed", + last_fetched: Time.new(2013, 1, 1), + stories: [] + ) end before do From 72840ad4e220951e2f99ad4efc7d3549e749bac2 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 20:33:46 -0800 Subject: [PATCH 156/779] RuboCop: enable Layout/LineEndStringConcatenationIndentation (#681) --- .rubocop_todo.yml | 8 -------- spec/helpers/url_helpers_spec.rb | 12 ++++++------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4b662f2a7..78be8c1a1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,14 +21,6 @@ Bundler/GemVersion: Exclude: - 'Gemfile' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/LineEndStringConcatenationIndentation: - Exclude: - - 'spec/helpers/url_helpers_spec.rb' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index db775744e..27a044ed1 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -61,12 +61,12 @@ class Helper # rubocop:disable Lint/ConstantDefinitionInBlock it "leaves the url as-is if it cannot be parsed" do weird_url = "https://github.com/aphyr/jepsen/blob/" \ - "1403f2d6e61c595bafede0d404fd4a893371c036/" \ - "elasticsearch/src/jepsen/system/elasticsearch.clj#" \ - "L161-L226.%20Then%20we'll%20write%20a%20%5Bregister%20test%5D(" \ - "https://github.com/aphyr/jepsen/blob/" \ - "1403f2d6e61c595bafede0d404fd4a893371c036/" \ - "elasticsearch/test/jepsen/system/elasticsearch_test.clj#L18-L50)" + "1403f2d6e61c595bafede0d404fd4a893371c036/" \ + "elasticsearch/src/jepsen/system/elasticsearch.clj#" \ + "L161-L226.%20Then%20we'll%20write%20a%20%5Bregister%20test%5D(" \ + "https://github.com/aphyr/jepsen/blob/" \ + "1403f2d6e61c595bafede0d404fd4a893371c036/" \ + "elasticsearch/test/jepsen/system/elasticsearch_test.clj#L18-L50)" content = "" From 6799fe0428a1a6d2ce62d0eff0d3474e1478d3d1 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 20:43:39 -0800 Subject: [PATCH 157/779] RuboCop: enable Layout/MultilineAssignmentLayout (#682) --- .rubocop_todo.yml | 12 --- app/commands/feeds/export_to_opml.rb | 29 +++--- app/fever_api/read_items.rb | 11 +-- app/jobs/fetch_feed_job.rb | 11 +-- app/utils/sample_story.rb | 127 ++++++++++++++------------- 5 files changed, 91 insertions(+), 99 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 78be8c1a1..1f9ded5b6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,18 +21,6 @@ Bundler/GemVersion: Exclude: - 'Gemfile' -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedTypes: block, case, class, if, kwbegin, module -# SupportedStyles: same_line, new_line -Layout/MultilineAssignmentLayout: - Exclude: - - 'app/commands/feeds/export_to_opml.rb' - - 'app/fever_api/read_items.rb' - - 'app/jobs/fetch_feed_job.rb' - - 'app/utils/sample_story.rb' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Layout/MultilineMethodArgumentLineBreaks: diff --git a/app/commands/feeds/export_to_opml.rb b/app/commands/feeds/export_to_opml.rb index 707274e60..38715904e 100644 --- a/app/commands/feeds/export_to_opml.rb +++ b/app/commands/feeds/export_to_opml.rb @@ -6,23 +6,24 @@ def initialize(feeds) end def to_xml # rubocop:disable Metrics/MethodLength - builder = Nokogiri::XML::Builder.new do |xml| - xml.opml(version: "1.0") do - xml.head do - xml.title "Feeds from Stringer" - end - xml.body do - @feeds.each do |feed| - xml.outline( - text: feed.name, - title: feed.name, - type: "rss", - xmlUrl: feed.url - ) + builder = + Nokogiri::XML::Builder.new do |xml| + xml.opml(version: "1.0") do + xml.head do + xml.title "Feeds from Stringer" + end + xml.body do + @feeds.each do |feed| + xml.outline( + text: feed.name, + title: feed.name, + type: "rss", + xmlUrl: feed.url + ) + end end end end - end builder.to_xml end diff --git a/app/fever_api/read_items.rb b/app/fever_api/read_items.rb index 84c94e4ae..ca26d04b9 100644 --- a/app/fever_api/read_items.rb +++ b/app/fever_api/read_items.rb @@ -8,11 +8,12 @@ def initialize(options = {}) def call(params = {}) if params.keys.include?("items") - item_ids = begin - params[:with_ids].split(",") - rescue StandardError - nil - end + item_ids = + begin + params[:with_ids].split(",") + rescue StandardError + nil + end { items: items(item_ids, params[:since_id]), diff --git a/app/jobs/fetch_feed_job.rb b/app/jobs/fetch_feed_job.rb index 4f5915a1b..77bedc4d1 100644 --- a/app/jobs/fetch_feed_job.rb +++ b/app/jobs/fetch_feed_job.rb @@ -1,6 +1,7 @@ -FetchFeedJob = Struct.new(:feed_id) do - def perform - feed = FeedRepository.fetch(feed_id) - FetchFeed.new(feed).fetch +FetchFeedJob = + Struct.new(:feed_id) do + def perform + feed = FeedRepository.fetch(feed_id) + FetchFeed.new(feed).fetch + end end -end diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 0bcc41558..7c3985e40 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -1,74 +1,75 @@ -SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do - BODY = <<~EOS.freeze # rubocop:disable Lint/ConstantDefinitionInBlock -

    Tofu shoreditch intelligentsia umami, fashion axe photo booth - try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic - salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee - street art gentrify. Quinoa PBR readymade 90's. Chambray Austin aesthetic - meggings, carles vinyl intelligentsia tattooed. Keffiyeh mumblecore - fingerstache, sartorial sriracha disrupt biodiesel cred. Skateboard yr cosby - sweater, narwhal beard ethnic jean shorts aesthetic. Post-ironic flannel mlkshk, - pickled VHS wolf banjo forage portland wayfarers.

    - -

    Selfies mumblecore odd future irony DIY messenger bag. - Authentic neutra next level selvage squid. Four loko freegan occupy, tousled - vinyl leggings selvage messenger bag. Four loko wayfarers kale chips, next level - banksy banh mi umami flannel hella. Street art odd future scenester, - intelligentsia brunch fingerstache YOLO narwhal single-origin coffee tousled - tumblr pop-up four loko you probably haven't heard of them dreamcatcher. - Single-origin coffee direct trade retro biodiesel, truffaut fanny pack portland - blue bottle scenester bushwick. Skateboard squid fanny pack bushwick, photo - booth vice literally.

    - EOS +SampleStory = + Struct.new(:source, :title, :lead, :is_read, :published) do + BODY = <<~EOS.freeze # rubocop:disable Lint/ConstantDefinitionInBlock +

    Tofu shoreditch intelligentsia umami, fashion axe photo booth + try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic + salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee + street art gentrify. Quinoa PBR readymade 90's. Chambray Austin aesthetic + meggings, carles vinyl intelligentsia tattooed. Keffiyeh mumblecore + fingerstache, sartorial sriracha disrupt biodiesel cred. Skateboard yr cosby + sweater, narwhal beard ethnic jean shorts aesthetic. Post-ironic flannel mlkshk, + pickled VHS wolf banjo forage portland wayfarers.

    + +

    Selfies mumblecore odd future irony DIY messenger bag. + Authentic neutra next level selvage squid. Four loko freegan occupy, tousled + vinyl leggings selvage messenger bag. Four loko wayfarers kale chips, next level + banksy banh mi umami flannel hella. Street art odd future scenester, + intelligentsia brunch fingerstache YOLO narwhal single-origin coffee tousled + tumblr pop-up four loko you probably haven't heard of them dreamcatcher. + Single-origin coffee direct trade retro biodiesel, truffaut fanny pack portland + blue bottle scenester bushwick. Skateboard squid fanny pack bushwick, photo + booth vice literally.

    + EOS - def id - -1 * rand(100) - end + def id + -1 * rand(100) + end - def headline - title - end + def headline + title + end - def permalink - "#" - end + def permalink + "#" + end - def lead - "Tofu shoreditch intelligentsia umami, fashion axe photo booth try-hard" - end + def lead + "Tofu shoreditch intelligentsia umami, fashion axe photo booth try-hard" + end - def body - BODY - end + def body + BODY + end - def is_read # rubocop:disable Naming/PredicateName - false - end + def is_read # rubocop:disable Naming/PredicateName + false + end - def keep_unread - false - end + def keep_unread + false + end - def is_starred # rubocop:disable Naming/PredicateName - false - end + def is_starred # rubocop:disable Naming/PredicateName + false + end - def published - Time.now - end + def published + Time.now + end - def as_json(_options = {}) - { - id: id, - headline: headline, - lead: lead, - source: source, - title: title, - pretty_date: published.strftime("%A, %B %d"), - body: body, - permalink: permalink, - is_read: is_read, - is_starred: is_starred, - keep_unread: keep_unread - } + def as_json(_options = {}) + { + id: id, + headline: headline, + lead: lead, + source: source, + title: title, + pretty_date: published.strftime("%A, %B %d"), + body: body, + permalink: permalink, + is_read: is_read, + is_starred: is_starred, + keep_unread: keep_unread + } + end end -end From 18664ffbe0cac8a71e658720357b7407413f34c0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 20:48:17 -0800 Subject: [PATCH 158/779] RuboCop: enable Layout/MultilineMethodArgumentLineBreaks (#683) --- .rubocop_todo.yml | 8 -------- app/controllers/debug_controller.rb | 9 +++++---- spec/controllers/sessions_controller_spec.rb | 4 ++-- spec/javascript/test_controller.rb | 10 ++++++---- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1f9ded5b6..59acfd8d7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,14 +21,6 @@ Bundler/GemVersion: Exclude: - 'Gemfile' -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Layout/MultilineMethodArgumentLineBreaks: - Exclude: - - 'app/controllers/debug_controller.rb' - - 'spec/controllers/sessions_controller_spec.rb' - - 'spec/javascript/test_controller.rb' - # Offense count: 47 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: InspectBlocks. diff --git a/app/controllers/debug_controller.rb b/app/controllers/debug_controller.rb index f38594201..018a29d4d 100644 --- a/app/controllers/debug_controller.rb +++ b/app/controllers/debug_controller.rb @@ -2,10 +2,11 @@ class Stringer < Sinatra::Base get "/debug" do - erb :debug, locals: { - queued_jobs_count: Delayed::Job.count, - pending_migrations: MigrationStatus.new.pending_migrations - } + erb :debug, + locals: { + queued_jobs_count: Delayed::Job.count, + pending_migrations: MigrationStatus.new.pending_migrations + } end get "/heroku" do diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index cb67be117..87ef61b18 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -37,8 +37,8 @@ it "redirects to the previous path when present" do allow(SignInUser).to receive(:sign_in).and_return(double(id: 1)) - post "/login", { password: "the-password" }, - "rack.session" => { redirect_to: "/archive" } + params = { password: "the-password" } + post "/login", params, "rack.session" => { redirect_to: "/archive" } expect(session[:redirect_to]).to be_nil expect(URI.parse(last_response.location).path).to eq "/archive" diff --git a/spec/javascript/test_controller.rb b/spec/javascript/test_controller.rb index c79b0993e..7a13e99d8 100644 --- a/spec/javascript/test_controller.rb +++ b/spec/javascript/test_controller.rb @@ -4,10 +4,12 @@ def self.test_path(*chunks) end get "/test" do - erb File.read(self.class.test_path("support", "views", "index.erb")), layout: false, locals: { - js_files: js_files, - js_templates: js_templates - } + erb File.read(self.class.test_path("support", "views", "index.erb")), + layout: false, + locals: { + js_files: js_files, + js_templates: js_templates + } end get "/spec/*" do From 2606402f3e4e603b5784079fbe6e53f722c5451b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 15 Dec 2022 21:13:11 -0800 Subject: [PATCH 159/779] RuboCop: reduce line length to 110 (#684) --- .rubocop.yml | 2 +- spec/controllers/debug_controller_spec.rb | 4 +++- spec/fever_api_spec.rb | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a616fda72..fb86053c1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 120 + Max: 110 Metrics/BlockLength: Exclude: diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index 3c435ef9a..864ae989c 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -11,7 +11,9 @@ stub_const("Delayed::Job", delayed_job) migration_status_instance = double "migration_status_instance" - allow(migration_status_instance).to receive(:pending_migrations).and_return ["Migration B - 2", "Migration C - 3"] + allow(migration_status_instance) + .to receive(:pending_migrations) + .and_return(["Migration B - 2", "Migration C - 3"]) migration_status = double "MigrationStatus" allow(migration_status).to receive(:new).and_return(migration_status_instance) stub_const("MigrationStatus", migration_status) diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 011d0eb43..74353690b 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -223,7 +223,9 @@ def make_request(extra_headers = {}) end it "commands to mark group as read" do - expect(MarkGroupAsRead).to receive(:new).with("10", "1375080946").and_return(double(mark_group_as_read: true)) + expect(MarkGroupAsRead) + .to receive(:new).with("10", "1375080946") + .and_return(double(mark_group_as_read: true)) make_request(mark: "group", as: "read", id: 10, before: 1375080946) @@ -232,7 +234,9 @@ def make_request(extra_headers = {}) end it "commands to mark entire feed as read" do - expect(MarkFeedAsRead).to receive(:new).with("20", "1375080945").and_return(double(mark_feed_as_read: true)) + expect(MarkFeedAsRead) + .to receive(:new).with("20", "1375080945") + .and_return(double(mark_feed_as_read: true)) make_request(mark: "feed", as: "read", id: 20, before: 1375080945) From 7af842b8891bef746f2cc42416a9418bf7e1517f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 16 Dec 2022 11:37:57 -0800 Subject: [PATCH 160/779] Security: enforce SSL in tests (#687) I had to add a monkey patch for `Rack::Test` as they don't seem to have a good way to enable SSL by default otherwise. --- spec/spec_helper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8c57bddd5..db68aa468 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,5 @@ ENV["RACK_ENV"] = "test" +ENV["ENFORCE_SSL"] = "true" require "capybara" require "capybara/server" @@ -17,6 +18,19 @@ Capybara.server = :puma, { Silent: true } +module Rack + module Test + class Session + alias old_custom_request custom_request + + def custom_request(method, path, params = {}, env = {}, &) + env["HTTPS"] = "on" + old_custom_request(method, path, params, env, &) + end + end + end +end + RSpec.configure do |config| config.include Rack::Test::Methods config.include RSpecHtmlMatchers From 5686409ceffd279e3dffb67610f20e0dd302d364 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 16 Dec 2022 11:45:05 -0800 Subject: [PATCH 161/779] RuboCop: reduce line length to 100 (#685) --- .rubocop.yml | 2 +- app.rb | 2 +- app/repositories/story_repository.rb | 5 ++++- spec/commands/feeds/add_new_feed_spec.rb | 4 +++- spec/commands/feeds/import_from_opml_spec.rb | 6 ++++-- spec/commands/stories/mark_group_as_read_spec.rb | 4 +++- spec/controllers/feeds_controller_spec.rb | 14 ++++++++++++-- spec/controllers/stories_controller_spec.rb | 3 ++- spec/fever_api_spec.rb | 3 ++- spec/models/migration_status_spec.rb | 3 ++- spec/repositories/story_repository_spec.rb | 7 ++++++- spec/tasks/fetch_feed_spec.rb | 4 +++- spec/tasks/remove_old_stories_spec.rb | 3 ++- spec/utils/i18n_support_spec.rb | 3 ++- 14 files changed, 47 insertions(+), 16 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fb86053c1..00ada93d0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 110 + Max: 100 Metrics/BlockLength: Exclude: diff --git a/app.rb b/app.rb index b312f052f..4bce33b72 100644 --- a/app.rb +++ b/app.rb @@ -21,7 +21,7 @@ class Stringer < Sinatra::Base # need to exclude assets for sinatra assetpack, see https://github.com/stringer-rss/stringer/issues/112 - use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } if ENV["ENFORCE_SSL"] == "true" + use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } register Sinatra::ActiveRecordExtension register Sinatra::Flash diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index b33ea2e70..a1c051e7f 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -118,7 +118,10 @@ def self.extract_title(entry) def self.samples [ SampleStory.new("Darin' Fireballs", "Why you should trade your firstborn for a Retina iPad"), - SampleStory.new("TechKrunch", "SugarGlidr raises $1.2M Series A for Social Network for Photo Filters"), + SampleStory.new( + "TechKrunch", + "SugarGlidr raises $1.2M Series A for Social Network for Photo Filters" + ), SampleStory.new("Lambda Da Ultimate", "Flimsy types are the new hotness") ] end diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 22fde4e76..54526730d 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -29,7 +29,9 @@ end context "title includes a script tag" do - let(:feed_result) { double(title: "foobar", feed_url: feed.url) } + let(:feed_result) do + double(title: "foobar", feed_url: feed.url) + end it "deletes the script tag from the title" do allow(repo).to receive(:create) diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 49661795a..6516ece9e 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -3,7 +3,9 @@ app_require "commands/feeds/import_from_opml" describe ImportFromOpml do - let(:subscriptions) { File.open(File.expand_path("../../support/files/subscriptions.xml", __dir__)) } + let(:subscriptions) do + File.open(File.expand_path("../../support/files/subscriptions.xml", __dir__)) + end def import described_class.import(subscriptions) @@ -15,7 +17,7 @@ def import end let(:group1) { Group.find_by_name("Football News") } - let(:group2) { Group.find_by_name("RoR") } + let(:group2) { Group.find_by_name("RoR") } context "adding group_id for existing feeds" do let!(:feed1) do diff --git a/spec/commands/stories/mark_group_as_read_spec.rb b/spec/commands/stories/mark_group_as_read_spec.rb index 84d68b81a..452b2446d 100644 --- a/spec/commands/stories/mark_group_as_read_spec.rb +++ b/spec/commands/stories/mark_group_as_read_spec.rb @@ -15,7 +15,9 @@ def run_command(group_id) it "marks group as read" do command = run_command(2) expect(stories).to receive(:update_all).with(is_read: true) - expect(repo).to receive(:fetch_unread_by_timestamp_and_group).with(timestamp, 2).and_return(stories) + expect(repo).to receive(:fetch_unread_by_timestamp_and_group) + .with(timestamp, 2).and_return(stories) + command.mark_group_as_read end diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 3917ba408..3319b98d6 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -133,7 +133,9 @@ end describe "POST /feeds/import" do - let(:opml_file) { Rack::Test::UploadedFile.new("spec/sample_data/subscriptions.xml", "application/xml") } + let(:opml_file) do + Rack::Test::UploadedFile.new("spec/sample_data/subscriptions.xml", "application/xml") + end it "parse OPML and starts fetching" do expect(ImportFromOpml).to receive(:import).once @@ -155,8 +157,16 @@ get "/feeds/export" expect(last_response.body).to eq some_xml + end + + it "responds with OPML headers" do + expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) + + get "/feeds/export" + expect(last_response.header["Content-Type"]).to include "application/xml" - expect(last_response.header["Content-Disposition"]).to eq("attachment; filename=\"stringer.opml\"") + expect(last_response.header["Content-Disposition"]) + .to eq("attachment; filename=\"stringer.opml\"") end end end diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 60ab88c0c..87169ceb7 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -160,7 +160,8 @@ describe "GET /feed/:feed_id" do it "looks for a particular feed" do - expect(FeedRepository).to receive(:fetch).with(story_one.feed.id.to_s).and_return(story_one.feed) + expect(FeedRepository).to receive(:fetch) + .with(story_one.feed.id.to_s).and_return(story_one.feed) expect(StoryRepository).to receive(:feed).with(story_one.feed.id.to_s).and_return([story_one]) get "/feed/#{story_one.feed.id}" diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 74353690b..d5327a55a 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -214,7 +214,8 @@ def make_request(extra_headers = {}) end it "commands to unsave story" do - expect(MarkAsUnstarred).to receive(:new).with("10").and_return(double(mark_as_unstarred: true)) + expect(MarkAsUnstarred).to receive(:new) + .with("10").and_return(double(mark_as_unstarred: true)) make_request(mark: "item", as: "unsaved", id: 10) diff --git a/spec/models/migration_status_spec.rb b/spec/models/migration_status_spec.rb index e05961abc..bb3791d5d 100644 --- a/spec/models/migration_status_spec.rb +++ b/spec/models/migration_status_spec.rb @@ -15,7 +15,8 @@ allow(migrator).to receive(:migrations_path) allow(migrator).to receive(:current_version).and_return 1 - expect(MigrationStatus.new(migrator).pending_migrations).to eq ["Migration B - 2", "Migration C - 3"] + expect(MigrationStatus.new(migrator).pending_migrations) + .to eq(["Migration B - 2", "Migration C - 3"]) end end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 10ab76f46..47e6af66c 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -51,7 +51,12 @@ end it "does not set the enclosure url when not present" do - entry = instance_double(Feedjira::Parser::RSSEntry, title: "", summary: "", content: "").as_null_object + entry = instance_double( + Feedjira::Parser::RSSEntry, + title: "", + summary: "", + content: "" + ).as_null_object allow(StoryRepository).to receive(:normalize_url) expect(Story).to receive(:create).with(hash_including(enclosure_url: nil)) diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 455ff0d3f..1c1ff0f8a 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -52,7 +52,9 @@ let(:fake_client) { class_spy(HTTParty) } let(:fake_parser) { class_double(Feedjira, parse: fake_feed) } - before { allow_any_instance_of(FindNewStories).to receive(:new_stories).and_return([new_story]) } + before do + allow_any_instance_of(FindNewStories).to receive(:new_stories).and_return([new_story]) + end it "should only add posts that are new" do expect(StoryRepository).to receive(:add).with(new_story, daring_fireball) diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index 23271155e..e038ce10b 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -12,7 +12,8 @@ it "should pass along the number of days to the story repository query" do allow(RemoveOldStories).to receive(:pruned_feeds) { [] } - expect(StoryRepository).to receive(:unstarred_read_stories_older_than).with(7).and_return(stories_mock) + expect(StoryRepository).to receive(:unstarred_read_stories_older_than) + .with(7).and_return(stories_mock) RemoveOldStories.remove!(7) end diff --git a/spec/utils/i18n_support_spec.rb b/spec/utils/i18n_support_spec.rb index edca8a19f..e60e77b2d 100644 --- a/spec/utils/i18n_support_spec.rb +++ b/spec/utils/i18n_support_spec.rb @@ -29,7 +29,8 @@ let(:locale) { "xx" } it "should not find localization strings" do - expect(I18n.t("layout.title", locale: ENV["LOCALE"].to_sym)).not_to eq "stringer | your rss buddy" + expect(I18n.t("layout.title", locale: ENV["LOCALE"].to_sym)) + .not_to eq "stringer | your rss buddy" end end end From a5ab61feadcaaae1d562b1fe99075f6a46b862ba Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 16 Dec 2022 12:22:04 -0800 Subject: [PATCH 162/779] RuboCop: reduce line length to 95 (#688) --- .rubocop.yml | 2 +- app/commands/feeds/find_new_stories.rb | 5 +++- app/commands/stories/mark_group_as_read.rb | 5 +++- app/fever_api/write_mark_feed.rb | 4 +++- app/fever_api/write_mark_group.rb | 4 +++- app/repositories/story_repository.rb | 5 +++- config/puma.rb | 8 +++++-- spec/controllers/feeds_controller_spec.rb | 23 +++++++++++++++---- spec/controllers/first_run_controller_spec.rb | 3 ++- spec/controllers/stories_controller_spec.rb | 3 ++- spec/fever_api/read_items_spec.rb | 3 ++- spec/fever_api_spec.rb | 15 ++++++++---- 12 files changed, 60 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 00ada93d0..d339f6614 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 100 + Max: 95 Metrics/BlockLength: Exclude: diff --git a/app/commands/feeds/find_new_stories.rb b/app/commands/feeds/find_new_stories.rb index 609198562..0aabad8f9 100644 --- a/app/commands/feeds/find_new_stories.rb +++ b/app/commands/feeds/find_new_stories.rb @@ -15,7 +15,10 @@ def new_stories @raw_feed.entries.each do |story| break if @latest_entry_id && story.id == @latest_entry_id - next if story_age_exceeds_threshold?(story) || StoryRepository.exists?(story.id, @feed_id) + next if story_age_exceeds_threshold?(story) || StoryRepository.exists?( + story.id, + @feed_id + ) stories << story end diff --git a/app/commands/stories/mark_group_as_read.rb b/app/commands/stories/mark_group_as_read.rb index 286b0821c..ff24c9ce8 100644 --- a/app/commands/stories/mark_group_as_read.rb +++ b/app/commands/stories/mark_group_as_read.rb @@ -16,7 +16,10 @@ def mark_group_as_read if [KINDLING_GROUP_ID, SPARKS_GROUP_ID].include?(@group_id.to_i) @repo.fetch_unread_by_timestamp(@timestamp).update_all(is_read: true) elsif @group_id.to_i > 0 - @repo.fetch_unread_by_timestamp_and_group(@timestamp, @group_id).update_all(is_read: true) + @repo.fetch_unread_by_timestamp_and_group( + @timestamp, + @group_id + ).update_all(is_read: true) end end end diff --git a/app/fever_api/write_mark_feed.rb b/app/fever_api/write_mark_feed.rb index 1c4d72961..b4b582e6b 100644 --- a/app/fever_api/write_mark_feed.rb +++ b/app/fever_api/write_mark_feed.rb @@ -7,7 +7,9 @@ def initialize(options = {}) end def call(params = {}) - @marker_class.new(params[:id], params[:before]).mark_feed_as_read if params[:mark] == "feed" + if params[:mark] == "feed" + @marker_class.new(params[:id], params[:before]).mark_feed_as_read + end {} end diff --git a/app/fever_api/write_mark_group.rb b/app/fever_api/write_mark_group.rb index 3ef39a0e1..7ccbe127b 100644 --- a/app/fever_api/write_mark_group.rb +++ b/app/fever_api/write_mark_group.rb @@ -7,7 +7,9 @@ def initialize(options = {}) end def call(params = {}) - @marker_class.new(params[:id], params[:before]).mark_group_as_read if params[:mark] == "group" + if params[:mark] == "group" + @marker_class.new(params[:id], params[:before]).mark_group_as_read + end {} end diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index a1c051e7f..a85019a8a 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -117,7 +117,10 @@ def self.extract_title(entry) def self.samples [ - SampleStory.new("Darin' Fireballs", "Why you should trade your firstborn for a Retina iPad"), + SampleStory.new( + "Darin' Fireballs", + "Why you should trade your firstborn for a Retina iPad" + ), SampleStory.new( "TechKrunch", "SugarGlidr raises $1.2M Series A for Social Network for Photo Filters" diff --git a/config/puma.rb b/config/puma.rb index 0e079d63c..24fa3537c 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -16,7 +16,9 @@ # as there's no need for the master process to hold a connection ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base) - @delayed_job_pid ||= spawn("bundle exec rake work_jobs") unless ENV["WORKER_EMBEDDED"] == "false" + unless ENV["WORKER_EMBEDDED"] == "false" + @delayed_job_pid ||= spawn("bundle exec rake work_jobs") + end sleep 1 end @@ -30,5 +32,7 @@ end on_worker_shutdown do - Process.kill("QUIT", @delayed_job_pid) if !ENV["RACK_ENV"] || ENV["RACK_ENV"] == "development" + if !ENV["RACK_ENV"] || ENV["RACK_ENV"] == "development" + Process.kill("QUIT", @delayed_job_pid) + end end diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 3319b98d6..3f61f6efa 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -38,11 +38,25 @@ end end + def mock_feed(feed, name, url, group_id = nil) + expect(FeedRepository).to receive(:fetch).with("123").and_return(feed) + expect(FeedRepository).to receive(:update_feed).with(feed, name, url, group_id) + end + + def params(feed, **overrides) + { + feed_id: feed.id, + feed_name: feed.name, + feed_url: feed.url, + group_id: feed.group_id, + **overrides + } + end + describe "PUT /feeds/:feed_id" do it "updates a feed given the id" do feed = FeedFactory.build(url: "example.com/atom") - expect(FeedRepository).to receive(:fetch).with("123").and_return(feed) - expect(FeedRepository).to receive(:update_feed).with(feed, "Test", "example.com/feed", nil) + mock_feed(feed, "Test", "example.com/feed") put "/feeds/123", feed_id: "123", feed_name: "Test", feed_url: "example.com/feed" @@ -51,10 +65,9 @@ it "updates a feed group given the id" do feed = FeedFactory.build(url: "example.com/atom") - expect(FeedRepository).to receive(:fetch).with("123").and_return(feed) - expect(FeedRepository).to receive(:update_feed).with(feed, feed.name, feed.url, "321") + mock_feed(feed, feed.name, feed.url, "321") - put "/feeds/123", feed_id: "123", feed_name: feed.name, feed_url: feed.url, group_id: "321" + put "/feeds/123", **params(feed, feed_id: "123", group_id: "321") expect(last_response).to be_redirect end diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 878cc3037..b9ec24a93 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -37,7 +37,8 @@ end it "accepts confirmed passwords and redirects to next step" do - expect_any_instance_of(CreateUser).to receive(:create).with("foo").and_return(double(id: 1)) + expect_any_instance_of(CreateUser) + .to receive(:create).with("foo").and_return(double(id: 1)) post "/setup/password", password: "foo", password_confirmation: "foo" diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 87169ceb7..234dcc024 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -162,7 +162,8 @@ it "looks for a particular feed" do expect(FeedRepository).to receive(:fetch) .with(story_one.feed.id.to_s).and_return(story_one.feed) - expect(StoryRepository).to receive(:feed).with(story_one.feed.id.to_s).and_return([story_one]) + expect(StoryRepository) + .to receive(:feed).with(story_one.feed.id.to_s).and_return([story_one]) get "/feed/#{story_one.feed.id}" end diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index a124341d0..ad8c167c7 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -31,7 +31,8 @@ double("story", as_fever_json: { id: 5 }), double("story", as_fever_json: { id: 7 }) ] - expect(story_repository).to receive(:unread_since_id).with(3).and_return(unread_since_stories) + expect(story_repository) + .to receive(:unread_since_id).with(3).and_return(unread_since_stories) unread_stories = [ double("story", as_fever_json: { id: 2 }), double("story", as_fever_json: { id: 5 }), diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index d5327a55a..ebeeac78e 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -102,7 +102,7 @@ def make_request(extra_headers = {}) favicons: [ { id: 0, - data: "image/gif;base64,R0lGODlhAQABAIAAAObm5gAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" + data: a_string_including("image/gif;base64") } ] ) @@ -136,7 +136,8 @@ def make_request(extra_headers = {}) end it "returns stories ids when 'items' header is provided along with 'with_ids'" do - expect(StoryRepository).to receive(:fetch_by_ids).twice.with(["5"]).and_return([story_one]) + expect(StoryRepository) + .to receive(:fetch_by_ids).twice.with(["5"]).and_return([story_one]) make_request(items: nil, with_ids: 5) @@ -169,7 +170,12 @@ def make_request(extra_headers = {}) end it "returns starred items when 'saved_item_ids' header is provided" do - expect(Story).to receive(:where).with(is_starred: true).and_return([story_one, story_two]) + expect(Story).to receive(:where).with(is_starred: true).and_return( + [ + story_one, + story_two + ] + ) make_request(saved_item_ids: nil) @@ -205,7 +211,8 @@ def make_request(extra_headers = {}) end it "commands to save story" do - expect(MarkAsStarred).to receive(:new).with("10").and_return(double(mark_as_starred: true)) + expect(MarkAsStarred) + .to receive(:new).with("10").and_return(double(mark_as_starred: true)) make_request(mark: "item", as: "saved", id: 10) From 5c5a45d520878b784b980145fa27d45d03659b9b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 17 Dec 2022 14:35:20 -0800 Subject: [PATCH 163/779] Rearrange gemfile (#691) Put common gems ahead of environment based ones. --- Gemfile | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Gemfile b/Gemfile index 6174e4a96..a1dce645d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,26 +2,6 @@ ruby_version_file = File.expand_path(".ruby-version", __dir__) ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file) source "https://rubygems.org" -group :development do - gem "rubocop", require: false - gem "rubocop-rails", require: false - gem "rubocop-rake", require: false - gem "rubocop-rspec", require: false -end - -group :development, :test do - gem "capybara" - gem "coveralls_reborn", require: false - gem "faker" - gem "pry-byebug" - gem "rack-test" - gem "rspec" - gem "rspec-html-matchers" - gem "shotgun" - gem "simplecov" - gem "timecop" -end - gem "activerecord" gem "bcrypt" gem "delayed_job" @@ -48,3 +28,23 @@ gem "sprockets-helpers" gem "thread" gem "uglifier" gem "will_paginate" + +group :development do + gem "rubocop", require: false + gem "rubocop-rails", require: false + gem "rubocop-rake", require: false + gem "rubocop-rspec", require: false +end + +group :development, :test do + gem "capybara" + gem "coveralls_reborn", require: false + gem "faker" + gem "pry-byebug" + gem "rack-test" + gem "rspec" + gem "rspec-html-matchers" + gem "shotgun" + gem "simplecov" + gem "timecop" +end From 24a22e806462f0800fe2766e0c669851accf65e8 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 17 Dec 2022 15:25:03 -0800 Subject: [PATCH 164/779] Put SSL configuration back (#692) This got lost in a recent change. --- app.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index 4bce33b72..80a22b60b 100644 --- a/app.rb +++ b/app.rb @@ -21,7 +21,9 @@ class Stringer < Sinatra::Base # need to exclude assets for sinatra assetpack, see https://github.com/stringer-rss/stringer/issues/112 - use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } + if ENV["ENFORCE_SSL"] == "true" + use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } + end register Sinatra::ActiveRecordExtension register Sinatra::Flash From 0a38c921a48adb167d370e03ead6d3d6bb82fc5b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 17 Dec 2022 15:48:24 -0800 Subject: [PATCH 165/779] Deps: introduce Rails gem (#693) **What** This adds the Rails gem and removes dependencies from our Gemfile that are depended on by Rails. **Why** This is a step in the direction of switching the app over from Sinatra to Rails. --- .rubocop_todo.yml | 61 +++++++++++++------------ Gemfile | 9 +--- Gemfile.lock | 114 +++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 141 insertions(+), 43 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 59acfd8d7..c32b4ef89 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,19 +1,19 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-10-24 17:51:19 UTC using RuboCop version 1.36.0. +# on 2022-12-17 23:28:03 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 40 +# Offense count: 34 # Configuration parameters: Include, IgnoredGems, OnlyFor. # Include: **/*.gemfile, **/Gemfile, **/gems.rb Bundler/GemComment: Exclude: - 'Gemfile' -# Offense count: 39 +# Offense count: 32 # Configuration parameters: EnforcedStyle, Include, AllowedGems. # SupportedStyles: required, forbidden # Include: **/*.gemfile, **/Gemfile, **/gems.rb @@ -21,30 +21,19 @@ Bundler/GemVersion: Exclude: - 'Gemfile' -# Offense count: 47 +# Offense count: 25 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: InspectBlocks. Layout/RedundantLineBreak: Exclude: - - 'Rakefile' - - 'app/commands/feeds/add_new_feed.rb' - 'app/commands/feeds/export_to_opml.rb' - - 'app/repositories/feed_repository.rb' - 'app/repositories/story_repository.rb' - 'app/utils/content_sanitizer.rb' - - 'config/asset_pipeline.rb' - - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - 'spec/factories/user_factory.rb' - 'spec/factories/users.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api_spec.rb' - 'spec/helpers/url_helpers_spec.rb' - 'spec/integration/feed_importing_spec.rb' - - 'spec/models/feed_spec.rb' - - 'spec/models/story_spec.rb' - 'spec/repositories/story_repository_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' @@ -64,7 +53,7 @@ Lint/AmbiguousOperatorPrecedence: - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' -# Offense count: 766 +# Offense count: 776 # Configuration parameters: Only, Ignore. Lint/ConstantResolution: Exclude: @@ -298,7 +287,7 @@ RSpec/AlignRightLetBrace: - 'spec/tasks/fetch_feeds_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 5 +# Offense count: 6 RSpec/AnyInstance: Exclude: - 'spec/controllers/feeds_controller_spec.rb' @@ -338,7 +327,7 @@ RSpec/DescribeClass: - 'spec/integration/feed_importing_spec.rb' - 'spec/utils/i18n_support_spec.rb' -# Offense count: 141 +# Offense count: 145 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit @@ -400,7 +389,7 @@ RSpec/EmptyLineAfterHook: Exclude: - 'spec/controllers/stories_controller_spec.rb' -# Offense count: 50 +# Offense count: 56 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -428,7 +417,8 @@ RSpec/ExampleLength: # Offense count: 18 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: CustomTransform, IgnoredWords. +# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. +# DisallowedExamples: works RSpec/ExampleWording: Exclude: - 'spec/commands/find_new_stories_spec.rb' @@ -562,7 +552,7 @@ RSpec/MessageSpies: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 97 +# Offense count: 96 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -607,7 +597,8 @@ RSpec/MultipleMemoizedHelpers: - 'spec/utils/feed_discovery_spec.rb' # Offense count: 28 -# Configuration parameters: IgnoreSharedExamples. +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/fever_api/read_favicons_spec.rb' @@ -631,6 +622,8 @@ RSpec/NestedGroups: - 'spec/integration/feed_importing_spec.rb' # Offense count: 2 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ RSpec/NoExpectationExample: Exclude: - 'spec/commands/stories/mark_group_as_read_spec.rb' @@ -711,12 +704,21 @@ RSpec/VerifiedDoubles: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' +# Offense count: 2 +# Configuration parameters: Database, Include. +# SupportedDatabases: mysql, postgresql +# Include: db/migrate/*.rb +Rails/BulkChangeTable: + Exclude: + - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' + - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' + # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. -# Whitelist: find_by_sql -# AllowedMethods: find_by_sql -# AllowedReceivers: Gem::Specification +# Whitelist: find_by_sql, find_by_token_for +# AllowedMethods: find_by_sql, find_by_token_for +# AllowedReceivers: Gem::Specification, page Rails/DynamicFindBy: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' @@ -728,7 +730,7 @@ Rails/HasManyOrHasOneDependent: Exclude: - 'app/models/group.rb' -# Offense count: 28 +# Offense count: 27 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: spec/**/*, test/**/* @@ -803,7 +805,7 @@ Rails/SkipsModelValidations: - 'db/migrate/20140421224454_fix_invalid_unicode.rb' - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' -# Offense count: 27 +# Offense count: 26 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible @@ -1034,7 +1036,7 @@ Style/FrozenStringLiteralComment: - 'spec/utils/i18n_support_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 85 +# Offense count: 86 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -1080,7 +1082,7 @@ Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 698 +# Offense count: 699 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -1255,6 +1257,7 @@ Style/SingleLineBlockParams: - 'app/fever_api/response.rb' # Offense count: 10 +# This cop supports unsafe autocorrection (--autocorrect-all). Style/StaticClass: Exclude: - 'app/commands/feeds/add_new_feed.rb' diff --git a/Gemfile b/Gemfile index a1dce645d..5b2241596 100644 --- a/Gemfile +++ b/Gemfile @@ -2,22 +2,18 @@ ruby_version_file = File.expand_path(".ruby-version", __dir__) ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file) source "https://rubygems.org" -gem "activerecord" +gem "rails", "~> 7.0.1" + gem "bcrypt" gem "delayed_job" gem "delayed_job_active_record" gem "feedbag" gem "feedjira" gem "httparty" -gem "i18n" -gem "loofah" -gem "nokogiri" gem "pg" gem "puma", "~> 6.0" -gem "rack-protection" gem "racksh" gem "rack-ssl" -gem "rake" gem "sass" gem "sinatra" gem "sinatra-activerecord" @@ -41,7 +37,6 @@ group :development, :test do gem "coveralls_reborn", require: false gem "faker" gem "pry-byebug" - gem "rack-test" gem "rspec" gem "rspec-html-matchers" gem "shotgun" diff --git a/Gemfile.lock b/Gemfile.lock index 95b6db04c..134b84c26 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,66 @@ GEM remote: https://rubygems.org/ specs: + actioncable (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.4) + actionpack (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activesupport (= 7.0.4) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.4) + actionview (= 7.0.4) + activesupport (= 7.0.4) + rack (~> 2.0, >= 2.2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.4) + actionpack (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.4) + activesupport (= 7.0.4) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.4) + activesupport (= 7.0.4) + globalid (>= 0.3.6) activemodel (7.0.4) activesupport (= 7.0.4) activerecord (7.0.4) activemodel (= 7.0.4) activesupport (= 7.0.4) + activestorage (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activesupport (= 7.0.4) + marcel (~> 1.0) + mini_mime (>= 1.1.0) activesupport (7.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) @@ -15,6 +70,7 @@ GEM public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) bcrypt (3.1.18) + builder (3.2.4) byebug (11.1.3) capybara (3.38.0) addressable @@ -33,6 +89,7 @@ GEM thor (>= 0.20.3, < 2.0) tins (~> 1.16) crass (1.0.6) + date (3.3.2) delayed_job (4.1.11) activesupport (>= 3.0, < 8.0) delayed_job_active_record (4.1.7) @@ -40,6 +97,7 @@ GEM delayed_job (>= 3.0, < 5) diff-lcs (1.5.0) docile (1.4.0) + erubi (1.11.0) execjs (2.8.1) faker (3.0.0) i18n (>= 1.8.11, < 2) @@ -49,6 +107,8 @@ GEM loofah (>= 2.3.1) sax-machine (>= 1.0) ffi (1.15.5) + globalid (1.0.0) + activesupport (>= 5.0) httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) @@ -58,6 +118,12 @@ GEM loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) + mail (2.8.0) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) mime-types (3.4.1) @@ -70,6 +136,15 @@ GEM multi_xml (0.6.0) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) + net-imap (0.3.2) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol nio4r (2.5.8) nokogiri (1.13.10) mini_portile2 (~> 2.8.0) @@ -98,6 +173,32 @@ GEM racksh (1.0.0) rack (>= 1.0) rack-test (>= 0.5) + rails (7.0.4) + actioncable (= 7.0.4) + actionmailbox (= 7.0.4) + actionmailer (= 7.0.4) + actionpack (= 7.0.4) + actiontext (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activemodel (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + bundler (>= 1.15.0) + railties (= 7.0.4) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.4.4) + loofah (~> 2.19, >= 2.19.1) + railties (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.2) @@ -185,6 +286,7 @@ GEM thread (0.2.2) tilt (2.0.11) timecop (0.9.6) + timeout (0.3.1) tins (1.32.1) sync tzinfo (2.0.5) @@ -192,15 +294,18 @@ GEM uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.3.0) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.6.6) PLATFORMS ruby DEPENDENCIES - activerecord bcrypt capybara coveralls_reborn @@ -210,17 +315,12 @@ DEPENDENCIES feedbag feedjira httparty - i18n - loofah - nokogiri pg pry-byebug puma (~> 6.0) - rack-protection rack-ssl - rack-test racksh - rake + rails (~> 7.0.1) rspec rspec-html-matchers rubocop From e365b4b71bad8ce6badcd4bf73e85ac785add02d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 17 Dec 2022 16:46:58 -0800 Subject: [PATCH 166/779] fix debug page (#694) The mocking hid the fact that the migration methods were no longer available, so I updated the tests to use the actual classes. `ActiveRecord::Base.connection.migration_context.open` always returns a new instance, so for now we continue passing it down in order to avoid needing to use `allow_any_instance_of`. --- app/models/migration_status.rb | 12 ++++-------- spec/models/migration_status_spec.rb | 16 ++++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/app/models/migration_status.rb b/app/models/migration_status.rb index b89956cbe..6c4d3dc41 100644 --- a/app/models/migration_status.rb +++ b/app/models/migration_status.rb @@ -1,17 +1,13 @@ class MigrationStatus attr_reader :migrator - def initialize(migrator = ActiveRecord::Migrator) + def initialize(migrator = ActiveRecord::Base.connection.migration_context.open) @migrator = migrator end def pending_migrations - migrations_path = migrator.migrations_path - migrations = migrator.migrations(migrations_path) - current_version = migrator.current_version - - migrations - .select { |m| current_version < m.version } - .map { |m| "#{m.name} - #{m.version}" } + migrator.pending_migrations.map do |migration| + "#{migration.name} - #{migration.version}" + end end end diff --git a/spec/models/migration_status_spec.rb b/spec/models/migration_status_spec.rb index bb3791d5d..d32f79683 100644 --- a/spec/models/migration_status_spec.rb +++ b/spec/models/migration_status_spec.rb @@ -6,14 +6,14 @@ describe "MigrationStatus" do describe "pending_migrations" do it "returns array of strings representing pending migrations" do - migrator = double "Migrator" - allow(migrator).to receive(:migrations).and_return [ - double("First Migration", name: "Migration A", version: 1), - double("Second Migration", name: "Migration B", version: 2), - double("Third Migration", name: "Migration C", version: 3) - ] - allow(migrator).to receive(:migrations_path) - allow(migrator).to receive(:current_version).and_return 1 + migrator = ActiveRecord::Base.connection.migration_context.open + + allow(migrator).to receive(:pending_migrations).and_return( + [ + ActiveRecord::Migration.new("Migration B", 2), + ActiveRecord::Migration.new("Migration C", 3) + ] + ) expect(MigrationStatus.new(migrator).pending_migrations) .to eq(["Migration B - 2", "Migration C - 3"]) From 1c366cacac599875625cec2bbd57539efbc16a58 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 17 Dec 2022 22:57:08 -0800 Subject: [PATCH 167/779] RuboCop: disable ConstantResolution linter (#695) --- .rubocop.yml | 1 + .rubocop_todo.yml | 156 +--------------------------------------------- 2 files changed, 4 insertions(+), 153 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d339f6614..8c8b74124 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,5 +51,6 @@ Style/StringLiterals: # ################################################################################ +Lint/ConstantResolution: { Enabled: false } Rails/SchemaComment: { Enabled: false } Style/RequireOrder: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c32b4ef89..1af91c2cd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-12-17 23:28:03 UTC using RuboCop version 1.40.0. +# on 2022-12-18 06:47:47 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -53,155 +53,6 @@ Lint/AmbiguousOperatorPrecedence: - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' -# Offense count: 776 -# Configuration parameters: Only, Ignore. -Lint/ConstantResolution: - Exclude: - - 'Gemfile' - - 'Rakefile' - - 'app.rb' - - 'app/commands/feeds/add_new_feed.rb' - - 'app/commands/feeds/export_to_opml.rb' - - 'app/commands/feeds/find_new_stories.rb' - - 'app/commands/feeds/import_from_opml.rb' - - 'app/commands/stories/mark_all_as_read.rb' - - 'app/commands/stories/mark_as_read.rb' - - 'app/commands/stories/mark_as_starred.rb' - - 'app/commands/stories/mark_as_unread.rb' - - 'app/commands/stories/mark_as_unstarred.rb' - - 'app/commands/stories/mark_feed_as_read.rb' - - 'app/commands/stories/mark_group_as_read.rb' - - 'app/commands/users/change_user_password.rb' - - 'app/commands/users/create_user.rb' - - 'app/commands/users/sign_in_user.rb' - - 'app/controllers/debug_controller.rb' - - 'app/controllers/feeds_controller.rb' - - 'app/controllers/first_run_controller.rb' - - 'app/controllers/sessions_controller.rb' - - 'app/controllers/stories_controller.rb' - - 'app/fever_api/authentication.rb' - - 'app/fever_api/read_feeds.rb' - - 'app/fever_api/read_feeds_groups.rb' - - 'app/fever_api/read_groups.rb' - - 'app/fever_api/read_items.rb' - - 'app/fever_api/response.rb' - - 'app/fever_api/sync_saved_item_ids.rb' - - 'app/fever_api/sync_unread_item_ids.rb' - - 'app/fever_api/write_mark_feed.rb' - - 'app/fever_api/write_mark_group.rb' - - 'app/fever_api/write_mark_item.rb' - - 'app/helpers/authentication_helpers.rb' - - 'app/helpers/url_helpers.rb' - - 'app/jobs/fetch_feed_job.rb' - - 'app/models/application_record.rb' - - 'app/models/migration_status.rb' - - 'app/models/story.rb' - - 'app/repositories/feed_repository.rb' - - 'app/repositories/group_repository.rb' - - 'app/repositories/story_repository.rb' - - 'app/repositories/user_repository.rb' - - 'app/tasks/change_password.rb' - - 'app/tasks/fetch_feed.rb' - - 'app/tasks/fetch_feeds.rb' - - 'app/tasks/remove_old_stories.rb' - - 'app/utils/api_key.rb' - - 'app/utils/content_sanitizer.rb' - - 'app/utils/feed_discovery.rb' - - 'app/utils/opml_parser.rb' - - 'app/utils/sample_story.rb' - - 'config.ru' - - 'config/asset_pipeline.rb' - - 'config/puma.rb' - - 'db/migrate/20130409010818_create_feeds.rb' - - 'db/migrate/20130409010826_create_stories.rb' - - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' - - 'db/migrate/20130418221144_add_user_model.rb' - - 'db/migrate/20130423001740_drop_email_from_user.rb' - - 'db/migrate/20130423180446_remove_author_from_stories.rb' - - 'db/migrate/20130425211008_add_setup_complete_to_user.rb' - - 'db/migrate/20130425222157_add_delayed_job.rb' - - 'db/migrate/20130429232127_add_status_to_feeds.rb' - - 'db/migrate/20130504005816_text_url.rb' - - 'db/migrate/20130504022615_change_story_permalink_column.rb' - - 'db/migrate/20130509131045_add_unique_constraints.rb' - - 'db/migrate/20130513025939_add_keep_unread_to_stories.rb' - - 'db/migrate/20130513044029_add_is_starred_status_for_stories.rb' - - 'db/migrate/20130522014405_add_api_key_to_user.rb' - - 'db/migrate/20130730120312_add_entry_id_to_stories.rb' - - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' - - 'db/migrate/20130821020313_update_nil_entry_ids.rb' - - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' - - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' - - 'db/migrate/20140421224454_fix_invalid_unicode.rb' - - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' - - 'db/migrate/20221206231914_add_enclosure_url_to_stories.rb' - - 'fever_api.rb' - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/feeds/export_to_opml_spec.rb' - - 'spec/commands/feeds/import_from_opml_spec.rb' - - 'spec/commands/find_new_stories_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_as_read_spec.rb' - - 'spec/commands/stories/mark_as_starred_spec.rb' - - 'spec/commands/stories/mark_as_unread_spec.rb' - - 'spec/commands/stories/mark_as_unstarred_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/commands/users/create_user_spec.rb' - - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/factories/feed_factory.rb' - - 'spec/factories/feeds.rb' - - 'spec/factories/group_factory.rb' - - 'spec/factories/groups.rb' - - 'spec/factories/stories.rb' - - 'spec/factories/story_factory.rb' - - 'spec/factories/user_factory.rb' - - 'spec/factories/users.rb' - - 'spec/fever_api/authentication_spec.rb' - - 'spec/fever_api/read_favicons_spec.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/read_links_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - - 'spec/fever_api_spec.rb' - - 'spec/helpers/authentications_helper_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - - 'spec/integration/feed_importing_spec.rb' - - 'spec/javascript/test_controller.rb' - - 'spec/models/feed_spec.rb' - - 'spec/models/group_spec.rb' - - 'spec/models/migration_status_spec.rb' - - 'spec/models/story_spec.rb' - - 'spec/repositories/feed_repository_spec.rb' - - 'spec/repositories/group_repository_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/repositories/user_repository_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/support/active_record.rb' - - 'spec/support/coverage.rb' - - 'spec/support/feed_server.rb' - - 'spec/tasks/change_password_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - - 'spec/tasks/remove_old_stories_spec.rb' - - 'spec/utils/content_sanitizer_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' - - 'spec/utils/i18n_support_spec.rb' - - 'spec/utils/opml_parser_spec.rb' - # Offense count: 1 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: @@ -674,7 +525,7 @@ RSpec/StubbedMock: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 96 +# Offense count: 92 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -698,7 +549,6 @@ RSpec/VerifiedDoubles: - 'spec/fever_api/write_mark_group_spec.rb' - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' - - 'spec/models/migration_status_spec.rb' - 'spec/repositories/story_repository_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' - 'spec/tasks/remove_old_stories_spec.rb' @@ -1082,7 +932,7 @@ Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 699 +# Offense count: 694 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses From f8ccc6b82a29b5ed09c95c03fdd6f5d512e1486b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 09:41:44 -0800 Subject: [PATCH 168/779] Rails: switch DebugController to use ActionController (#696) This introduces a new helper method that allows us to render views via `ActionController` rather than `Sinatra::Base`. This will help us more incrementally move the app to Rails. --- .rubocop_todo.yml | 2 + Gemfile | 1 + Gemfile.lock | 9 ++++ app.rb | 13 ++++- app/controllers/application_controller.rb | 18 +++++++ app/controllers/debug_controller.rb | 19 ++++--- app/helpers/controller_helpers.rb | 17 +++++++ .../{heroku.erb => debug/heroku.html.erb} | 0 app/views/{debug.erb => debug/index.html.erb} | 0 app/views/layouts/_flash.html.erb | 29 +++++++++++ app/views/layouts/_footer.html.erb | 25 ++++++++++ app/views/layouts/_shortcuts.html.erb | 24 +++++++++ app/views/layouts/application.html.erb | 49 +++++++++++++++++++ config/asset_pipeline.rb | 8 +-- spec/controllers/debug_controller_spec.rb | 7 ++- 15 files changed, 206 insertions(+), 15 deletions(-) create mode 100644 app/controllers/application_controller.rb create mode 100644 app/helpers/controller_helpers.rb rename app/views/{heroku.erb => debug/heroku.html.erb} (100%) rename app/views/{debug.erb => debug/index.html.erb} (100%) create mode 100644 app/views/layouts/_flash.html.erb create mode 100644 app/views/layouts/_footer.html.erb create mode 100644 app/views/layouts/_shortcuts.html.erb create mode 100644 app/views/layouts/application.html.erb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1af91c2cd..13212ec00 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -141,6 +141,7 @@ RSpec/AlignRightLetBrace: # Offense count: 6 RSpec/AnyInstance: Exclude: + - 'spec/controllers/debug_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' @@ -1125,6 +1126,7 @@ Style/StaticClass: # This cop supports unsafe autocorrection (--autocorrect-all). Style/StringHashKeys: Exclude: + - 'app/helpers/controller_helpers.rb' - 'fever_api.rb' - 'spec/app_spec.rb' - 'spec/controllers/debug_controller_spec.rb' diff --git a/Gemfile b/Gemfile index 5b2241596..0574bd935 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,7 @@ group :development, :test do gem "pry-byebug" gem "rspec" gem "rspec-html-matchers" + gem "rspec-rails" gem "shotgun" gem "simplecov" gem "timecop" diff --git a/Gemfile.lock b/Gemfile.lock index 134b84c26..e96b88b78 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,6 +221,14 @@ GEM rspec-mocks (3.12.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) + rspec-rails (6.0.1) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.11) + rspec-expectations (~> 3.11) + rspec-mocks (~> 3.11) + rspec-support (~> 3.11) rspec-support (3.12.0) rubocop (1.40.0) json (~> 2.3) @@ -323,6 +331,7 @@ DEPENDENCIES rails (~> 7.0.1) rspec rspec-html-matchers + rspec-rails rubocop rubocop-rails rubocop-rake diff --git a/app.rb b/app.rb index 80a22b60b..2e47ab51a 100644 --- a/app.rb +++ b/app.rb @@ -1,3 +1,6 @@ +require "action_pack" +require "action_view" +require "action_controller" require "sinatra/base" require "sinatra/activerecord" require "sinatra/flash" @@ -12,9 +15,13 @@ require "securerandom" require_relative "app/helpers/authentication_helpers" +require_relative "app/helpers/controller_helpers" require_relative "app/repositories/user_repository" require_relative "config/asset_pipeline" +require_relative "app/controllers/application_controller" +require_relative "app/controllers/debug_controller" + I18n.load_path += Dir[File.join(File.dirname(__FILE__), "config/locales", "*.yml").to_s] I18n.config.enforce_available_locales = false Time.zone = ENV.fetch("TZ", "UTC") @@ -25,6 +32,8 @@ class Stringer < Sinatra::Base use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } end + extend Sinatra::ControllerHelpers + register Sinatra::ActiveRecordExtension register Sinatra::Flash register Sinatra::Contrib @@ -80,10 +89,12 @@ def t(*args, **kwargs) redirect to("/setup/password") end end + + rails_route(:get, "/debug", to: "debug#index") + rails_route(:get, "/heroku", to: "debug#heroku") end require_relative "app/controllers/stories_controller" require_relative "app/controllers/first_run_controller" require_relative "app/controllers/sessions_controller" require_relative "app/controllers/feeds_controller" -require_relative "app/controllers/debug_controller" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 000000000..b0599055d --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class ApplicationController < ActionController::Base + include Sinatra::AuthenticationHelpers + helper_method :current_user + + before_action :append_view_path + + # needed for Sinatra + def append_view_path + super("./app/views") + end + + def flash + session["flash"] + end + helper_method :flash +end diff --git a/app/controllers/debug_controller.rb b/app/controllers/debug_controller.rb index 018a29d4d..feece9b69 100644 --- a/app/controllers/debug_controller.rb +++ b/app/controllers/debug_controller.rb @@ -1,15 +1,14 @@ require_relative "../models/migration_status" -class Stringer < Sinatra::Base - get "/debug" do - erb :debug, - locals: { - queued_jobs_count: Delayed::Job.count, - pending_migrations: MigrationStatus.new.pending_migrations - } +class DebugController < ApplicationController + def index + render( + locals: { + queued_jobs_count: Delayed::Job.count, + pending_migrations: MigrationStatus.new.pending_migrations + } + ) end - get "/heroku" do - erb :heroku - end + def heroku; end end diff --git a/app/helpers/controller_helpers.rb b/app/helpers/controller_helpers.rb new file mode 100644 index 000000000..efee39f79 --- /dev/null +++ b/app/helpers/controller_helpers.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Sinatra + module ControllerHelpers + def rails_route(method, path, options) + options = options.with_indifferent_access + to = options.delete(:to) + controller_name, action_name = to.split("#") + controller_klass = "#{controller_name.camelize}Controller".constantize + route(method.to_s.upcase, path, options) do + # Make sure that our parsed URL params are where Rack (and ActionDispatch) expect them + app = controller_klass.action(action_name) + app.call(request.env.merge("rack.request.query_hash" => params)) + end + end + end +end diff --git a/app/views/heroku.erb b/app/views/debug/heroku.html.erb similarity index 100% rename from app/views/heroku.erb rename to app/views/debug/heroku.html.erb diff --git a/app/views/debug.erb b/app/views/debug/index.html.erb similarity index 100% rename from app/views/debug.erb rename to app/views/debug/index.html.erb diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb new file mode 100644 index 000000000..2155dc810 --- /dev/null +++ b/app/views/layouts/_flash.html.erb @@ -0,0 +1,29 @@ +<% if flash.has_key? :success %> +
    + <%= flash[:success] %> +
    +<% end %> + +<% if flash.has_key? :error %> +
    + <%= flash[:error] %> +
    +<% end %> + + + + + + \ No newline at end of file diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb new file mode 100644 index 000000000..42d74a31e --- /dev/null +++ b/app/views/layouts/_footer.html.erb @@ -0,0 +1,25 @@ +
    +
    +
    + +
    +
    +

    + <%= t('layout.hey') %> <%= t('layout.back_to_work') %> +

    +
    +
    +
    diff --git a/app/views/layouts/_shortcuts.html.erb b/app/views/layouts/_shortcuts.html.erb new file mode 100644 index 000000000..94e255753 --- /dev/null +++ b/app/views/layouts/_shortcuts.html.erb @@ -0,0 +1,24 @@ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 000000000..e04bd2698 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,49 @@ + + + + + <%= content_for(:title) %> + <%= t('layout.title') %> + + + + + + + + + + + + <%= content_for(:head) %> + + + + + +
    +
    + <%= render 'layouts/flash' %> + <%= render 'layouts/shortcuts' if current_user %> +
    +
    +
    + <%= yield %> +
    +
    +
    +
    + +
    +
    + + + + + + diff --git a/config/asset_pipeline.rb b/config/asset_pipeline.rb index 68fc62ed1..914008343 100644 --- a/config/asset_pipeline.rb +++ b/config/asset_pipeline.rb @@ -2,9 +2,11 @@ module AssetPipeline def registered(app) app.set :sprockets, Sprockets::Environment.new(app.root) - app.get "/assets/*" do - env["PATH_INFO"].sub!(%r{^/assets}, "") - settings.sprockets.call(env) + %w[assets stylesheets javascripts].each do |path| + app.get "/#{path}/*" do + env["PATH_INFO"].sub!(%r{^/#{path}}, "") + settings.sprockets.call(env) + end end append_paths(app) diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index 864ae989c..63a3825e3 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -3,7 +3,12 @@ app_require "controllers/debug_controller" -describe "DebugController" do +describe DebugController do + before do + # for Sinatra + allow_any_instance_of(described_class).to receive(:session).and_return({ "flash" => {} }) + end + describe "GET /debug" do before do delayed_job = double "Delayed::Job" From 9975a1322426610a40dca4a83cebcc950e6d5437 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 10:09:27 -0800 Subject: [PATCH 169/779] Rails: relocate sinatra controllers (#697) This will allow us to gradually port actions to ActionController. Leaving the controller specs where they are, as they should largely work the same for both. --- .rubocop_todo.yml | 30 +++++++++---------- app.rb | 8 ++--- .../{ => sinatra}/feeds_controller.rb | 6 ++-- .../{ => sinatra}/first_run_controller.rb | 12 ++++---- .../{ => sinatra}/sessions_controller.rb | 2 +- .../{ => sinatra}/stories_controller.rb | 4 +-- spec/controllers/feeds_controller_spec.rb | 2 +- spec/controllers/first_run_controller_spec.rb | 2 +- spec/controllers/sessions_controller_spec.rb | 2 +- spec/controllers/stories_controller_spec.rb | 2 +- 10 files changed, 35 insertions(+), 35 deletions(-) rename app/controllers/{ => sinatra}/feeds_controller.rb (89%) rename app/controllers/{ => sinatra}/first_run_controller.rb (74%) rename app/controllers/{ => sinatra}/sessions_controller.rb (91%) rename app/controllers/{ => sinatra}/stories_controller.rb (89%) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 13212ec00..214123d58 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,19 +1,19 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-12-18 06:47:47 UTC using RuboCop version 1.40.0. +# on 2022-12-18 18:04:01 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 34 +# Offense count: 35 # Configuration parameters: Include, IgnoredGems, OnlyFor. # Include: **/*.gemfile, **/Gemfile, **/gems.rb Bundler/GemComment: Exclude: - 'Gemfile' -# Offense count: 32 +# Offense count: 33 # Configuration parameters: EnforcedStyle, Include, AllowedGems. # SupportedStyles: required, forbidden # Include: **/*.gemfile, **/Gemfile, **/gems.rb @@ -138,7 +138,7 @@ RSpec/AlignRightLetBrace: - 'spec/tasks/fetch_feeds_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 6 +# Offense count: 7 RSpec/AnyInstance: Exclude: - 'spec/controllers/debug_controller_spec.rb' @@ -638,8 +638,8 @@ Rails/SaveBang: - 'app/commands/users/change_user_password.rb' - 'app/commands/users/complete_setup.rb' - 'app/commands/users/create_user.rb' - - 'app/controllers/first_run_controller.rb' - - 'app/controllers/stories_controller.rb' + - 'app/controllers/sinatra/first_run_controller.rb' + - 'app/controllers/sinatra/stories_controller.rb' - 'app/repositories/feed_repository.rb' - 'app/repositories/story_repository.rb' - 'app/repositories/user_repository.rb' @@ -706,7 +706,7 @@ Rails/WhereNot: # MethodsAcceptingSymbol: inject, reduce Style/CollectionMethods: Exclude: - - 'app/controllers/stories_controller.rb' + - 'app/controllers/sinatra/stories_controller.rb' - 'app/fever_api/response.rb' # Offense count: 8 @@ -753,10 +753,10 @@ Style/FrozenStringLiteralComment: - 'app/commands/users/create_user.rb' - 'app/commands/users/sign_in_user.rb' - 'app/controllers/debug_controller.rb' - - 'app/controllers/feeds_controller.rb' - - 'app/controllers/first_run_controller.rb' - - 'app/controllers/sessions_controller.rb' - - 'app/controllers/stories_controller.rb' + - 'app/controllers/sinatra/feeds_controller.rb' + - 'app/controllers/sinatra/first_run_controller.rb' + - 'app/controllers/sinatra/sessions_controller.rb' + - 'app/controllers/sinatra/stories_controller.rb' - 'app/fever_api/authentication.rb' - 'app/fever_api/read_favicons.rb' - 'app/fever_api/read_feeds.rb' @@ -933,7 +933,7 @@ Style/InlineComment: Exclude: - 'app/utils/opml_parser.rb' -# Offense count: 694 +# Offense count: 695 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -1081,7 +1081,7 @@ Style/PercentLiteralDelimiters: # SupportedStyles: same_as_string_literals, single_quotes, double_quotes Style/QuotedSymbols: Exclude: - - 'app/controllers/feeds_controller.rb' + - 'app/controllers/sinatra/feeds_controller.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -1097,7 +1097,7 @@ Style/ReturnNil: # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - - 'app/controllers/feeds_controller.rb' + - 'app/controllers/sinatra/feeds_controller.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -1122,7 +1122,7 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' -# Offense count: 18 +# Offense count: 20 # This cop supports unsafe autocorrection (--autocorrect-all). Style/StringHashKeys: Exclude: diff --git a/app.rb b/app.rb index 2e47ab51a..f32f75c93 100644 --- a/app.rb +++ b/app.rb @@ -94,7 +94,7 @@ def t(*args, **kwargs) rails_route(:get, "/heroku", to: "debug#heroku") end -require_relative "app/controllers/stories_controller" -require_relative "app/controllers/first_run_controller" -require_relative "app/controllers/sessions_controller" -require_relative "app/controllers/feeds_controller" +require_relative "app/controllers/sinatra/stories_controller" +require_relative "app/controllers/sinatra/first_run_controller" +require_relative "app/controllers/sinatra/sessions_controller" +require_relative "app/controllers/sinatra/feeds_controller" diff --git a/app/controllers/feeds_controller.rb b/app/controllers/sinatra/feeds_controller.rb similarity index 89% rename from app/controllers/feeds_controller.rb rename to app/controllers/sinatra/feeds_controller.rb index 0cbb0edb7..ecf7da92e 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/sinatra/feeds_controller.rb @@ -1,6 +1,6 @@ -require_relative "../repositories/feed_repository" -require_relative "../commands/feeds/add_new_feed" -require_relative "../commands/feeds/export_to_opml" +require_relative "../../repositories/feed_repository" +require_relative "../../commands/feeds/add_new_feed" +require_relative "../../commands/feeds/export_to_opml" class Stringer < Sinatra::Base get "/feeds" do diff --git a/app/controllers/first_run_controller.rb b/app/controllers/sinatra/first_run_controller.rb similarity index 74% rename from app/controllers/first_run_controller.rb rename to app/controllers/sinatra/first_run_controller.rb index 6be12f769..79eb8f58d 100644 --- a/app/controllers/first_run_controller.rb +++ b/app/controllers/sinatra/first_run_controller.rb @@ -1,9 +1,9 @@ -require_relative "../commands/feeds/import_from_opml" -require_relative "../commands/users/create_user" -require_relative "../commands/users/complete_setup" -require_relative "../repositories/user_repository" -require_relative "../repositories/story_repository" -require_relative "../tasks/fetch_feeds" +require_relative "../../commands/feeds/import_from_opml" +require_relative "../../commands/users/create_user" +require_relative "../../commands/users/complete_setup" +require_relative "../../repositories/user_repository" +require_relative "../../repositories/story_repository" +require_relative "../../tasks/fetch_feeds" class Stringer < Sinatra::Base namespace "/setup" do diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sinatra/sessions_controller.rb similarity index 91% rename from app/controllers/sessions_controller.rb rename to app/controllers/sinatra/sessions_controller.rb index 54d40df42..bd305b390 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sinatra/sessions_controller.rb @@ -1,4 +1,4 @@ -require_relative "../commands/users/sign_in_user" +require_relative "../../commands/users/sign_in_user" class Stringer < Sinatra::Base get "/login" do diff --git a/app/controllers/stories_controller.rb b/app/controllers/sinatra/stories_controller.rb similarity index 89% rename from app/controllers/stories_controller.rb rename to app/controllers/sinatra/stories_controller.rb index 052682046..bf9cb3049 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/sinatra/stories_controller.rb @@ -1,5 +1,5 @@ -require_relative "../repositories/story_repository" -require_relative "../commands/stories/mark_all_as_read" +require_relative "../../repositories/story_repository" +require_relative "../../commands/stories/mark_all_as_read" class Stringer < Sinatra::Base get "/news" do diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 3f61f6efa..22e843dc7 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -app_require "controllers/feeds_controller" +app_require "controllers/sinatra/feeds_controller" describe "FeedsController" do let(:feeds) { [FeedFactory.build, FeedFactory.build] } diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index b9ec24a93..192a8e1b2 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require "support/active_record" -app_require "controllers/first_run_controller" +app_require "controllers/sinatra/first_run_controller" describe "FirstRunController" do context "when a user has not been setup" do diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 87ef61b18..85eda0ade 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -app_require "controllers/sessions_controller" +app_require "controllers/sinatra/sessions_controller" describe "SessionsController" do describe "GET /login" do diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 234dcc024..f1a4ea52e 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require "will_paginate/array" -app_require "controllers/stories_controller" +app_require "controllers/sinatra/stories_controller" describe "StoriesController" do let(:story_one) { StoryFactory.build } From 715796355b77d5f3f9f828faec58baa5471b9385 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 10:27:22 -0800 Subject: [PATCH 170/779] Rails: switch feeds#index to ActionController (#698) --- app.rb | 2 ++ app/controllers/feeds_controller.rb | 7 ++++++ app/controllers/sinatra/feeds_controller.rb | 6 ----- app/views/feeds/_action_bar.html.erb | 22 +++++++++++++++++++ app/views/{partials => feeds}/_feed.erb | 0 app/views/feeds/{index.erb => index.html.erb} | 6 ++--- spec/controllers/feeds_controller_spec.rb | 5 +++++ 7 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 app/controllers/feeds_controller.rb create mode 100644 app/views/feeds/_action_bar.html.erb rename app/views/{partials => feeds}/_feed.erb (100%) rename app/views/feeds/{index.erb => index.html.erb} (81%) diff --git a/app.rb b/app.rb index f32f75c93..80ab35d74 100644 --- a/app.rb +++ b/app.rb @@ -21,6 +21,7 @@ require_relative "app/controllers/application_controller" require_relative "app/controllers/debug_controller" +require_relative "app/controllers/feeds_controller" I18n.load_path += Dir[File.join(File.dirname(__FILE__), "config/locales", "*.yml").to_s] I18n.config.enforce_available_locales = false @@ -92,6 +93,7 @@ def t(*args, **kwargs) rails_route(:get, "/debug", to: "debug#index") rails_route(:get, "/heroku", to: "debug#heroku") + rails_route(:get, "/feeds", to: "feeds#index") end require_relative "app/controllers/sinatra/stories_controller" diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb new file mode 100644 index 000000000..3f6ae66a2 --- /dev/null +++ b/app/controllers/feeds_controller.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class FeedsController < ApplicationController + def index + @feeds = FeedRepository.list + end +end diff --git a/app/controllers/sinatra/feeds_controller.rb b/app/controllers/sinatra/feeds_controller.rb index ecf7da92e..8fd63fd36 100644 --- a/app/controllers/sinatra/feeds_controller.rb +++ b/app/controllers/sinatra/feeds_controller.rb @@ -3,12 +3,6 @@ require_relative "../../commands/feeds/export_to_opml" class Stringer < Sinatra::Base - get "/feeds" do - @feeds = FeedRepository.list - - erb :'feeds/index' - end - get "/feeds/:id/edit" do @feed = FeedRepository.fetch(params[:id]) diff --git a/app/views/feeds/_action_bar.html.erb b/app/views/feeds/_action_bar.html.erb new file mode 100644 index 000000000..f11a3d0c4 --- /dev/null +++ b/app/views/feeds/_action_bar.html.erb @@ -0,0 +1,22 @@ +
    +
    + + + +
    + + +
    diff --git a/app/views/partials/_feed.erb b/app/views/feeds/_feed.erb similarity index 100% rename from app/views/partials/_feed.erb rename to app/views/feeds/_feed.erb diff --git a/app/views/feeds/index.erb b/app/views/feeds/index.html.erb similarity index 81% rename from app/views/feeds/index.erb rename to app/views/feeds/index.html.erb index 0dad10031..7709e4633 100644 --- a/app/views/feeds/index.erb +++ b/app/views/feeds/index.html.erb @@ -1,12 +1,12 @@
    - <%= render_partial :feed_action_bar %> + <%= render "feeds/action_bar" %>
    <% unless @feeds.empty? %>
      <% @feeds.each do |feed| %> - <%= render_partial :feed, { feed: feed } %> + <%= render "feeds/feed", { feed: feed } %> <% end %>
    @@ -20,4 +20,4 @@ $(document).ready(function () { $(".status").tooltip(); }); - \ No newline at end of file + diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 22e843dc7..c986e6dd1 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -5,6 +5,11 @@ describe "FeedsController" do let(:feeds) { [FeedFactory.build, FeedFactory.build] } + before do + # for Sinatra + allow_any_instance_of(FeedsController).to receive(:session).and_return({ "flash" => {} }) + end + describe "GET /feeds" do it "renders a list of feeds" do expect(FeedRepository).to receive(:list).and_return(feeds) From af417bc56aa687f9d5dfc9fdf0e07f694cc4bdef Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 10:37:10 -0800 Subject: [PATCH 171/779] Rails: fix issue with Delayed::Job (#699) Now that we're loading `ActionController` it's also loading `ActionDispatch`, causing the second case in [this line][tl] to raise an error. For now we'll stub out `Rails` to prevent it. [tl]: https://github.com/collectiveidea/delayed_job/blob/5ac5adea8d18325d0470eeebfa81227b1f5961e3/lib/delayed/worker.rb#L119 --- .rubocop_todo.yml | 1 + app.rb | 6 ++++++ spec/app_spec.rb | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 214123d58..32562e00f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1034,6 +1034,7 @@ Style/NumericPredicate: # Offense count: 4 Style/OpenStructUse: Exclude: + - 'app.rb' - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' - 'spec/factories/story_factory.rb' diff --git a/app.rb b/app.rb index 80ab35d74..593e90d5c 100644 --- a/app.rb +++ b/app.rb @@ -23,6 +23,12 @@ require_relative "app/controllers/debug_controller" require_relative "app/controllers/feeds_controller" +module Rails + def self.application + OpenStruct.new(config: OpenStruct.new(cache_classes: true)) + end +end + I18n.load_path += Dir[File.join(File.dirname(__FILE__), "config/locales", "*.yml").to_s] I18n.config.enforce_available_locales = false Time.zone = ENV.fetch("TZ", "UTC") diff --git a/spec/app_spec.rb b/spec/app_spec.rb index b8faeebf9..bdffb08d3 100644 --- a/spec/app_spec.rb +++ b/spec/app_spec.rb @@ -2,6 +2,12 @@ require "support/active_record" describe "App" do + describe "Rails" do + it "returns a fake application" do + expect(Rails.application.config.cache_classes).to be(true) + end + end + context "when user is not authenticated and page requires authentication" do it "sets the session redirect_to" do create_user(:setup_complete) From 69093cf8af04ab50b25f2f25ef88baa4a8c5bccc Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 11:08:29 -0800 Subject: [PATCH 172/779] Rails: convert Feeds edit/update to ActionController (#700) --- app.rb | 2 ++ app/controllers/feeds_controller.rb | 13 +++++++++++++ app/controllers/sinatra/feeds_controller.rb | 15 --------------- app/views/feeds/{_feed.erb => _feed.html.erb} | 0 app/views/feeds/{edit.erb => edit.html.erb} | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) rename app/views/feeds/{_feed.erb => _feed.html.erb} (100%) rename app/views/feeds/{edit.erb => edit.html.erb} (97%) diff --git a/app.rb b/app.rb index 593e90d5c..d4671f1b7 100644 --- a/app.rb +++ b/app.rb @@ -100,6 +100,8 @@ def t(*args, **kwargs) rails_route(:get, "/debug", to: "debug#index") rails_route(:get, "/heroku", to: "debug#heroku") rails_route(:get, "/feeds", to: "feeds#index") + rails_route(:get, "/feeds/:id/edit", to: "feeds#edit") + rails_route(:put, "/feeds/:id", to: "feeds#update") end require_relative "app/controllers/sinatra/stories_controller" diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 3f6ae66a2..7cef7d6d6 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -4,4 +4,17 @@ class FeedsController < ApplicationController def index @feeds = FeedRepository.list end + + def edit + @feed = FeedRepository.fetch(params[:id]) + end + + def update + feed = FeedRepository.fetch(params[:id]) + + FeedRepository.update_feed(feed, params[:feed_name], params[:feed_url], params[:group_id]) + + flash[:success] = t("feeds.edit.flash.updated_successfully") + redirect_to("/feeds") + end end diff --git a/app/controllers/sinatra/feeds_controller.rb b/app/controllers/sinatra/feeds_controller.rb index 8fd63fd36..3425fd090 100644 --- a/app/controllers/sinatra/feeds_controller.rb +++ b/app/controllers/sinatra/feeds_controller.rb @@ -3,21 +3,6 @@ require_relative "../../commands/feeds/export_to_opml" class Stringer < Sinatra::Base - get "/feeds/:id/edit" do - @feed = FeedRepository.fetch(params[:id]) - - erb :'feeds/edit' - end - - put "/feeds/:id" do - feed = FeedRepository.fetch(params[:id]) - - FeedRepository.update_feed(feed, params[:feed_name], params[:feed_url], params[:group_id]) - - flash[:success] = t("feeds.edit.flash.updated_successfully") - redirect to("/feeds") - end - delete "/feeds/:feed_id" do FeedRepository.delete(params[:feed_id]) diff --git a/app/views/feeds/_feed.erb b/app/views/feeds/_feed.html.erb similarity index 100% rename from app/views/feeds/_feed.erb rename to app/views/feeds/_feed.html.erb diff --git a/app/views/feeds/edit.erb b/app/views/feeds/edit.html.erb similarity index 97% rename from app/views/feeds/edit.erb rename to app/views/feeds/edit.html.erb index 7f0565daf..77ae96539 100644 --- a/app/views/feeds/edit.erb +++ b/app/views/feeds/edit.html.erb @@ -1,5 +1,5 @@
    - <%= render_partial :feed_action_bar %> + <%= render "feeds/action_bar" %>
    From 4b8c42374049f7b20e25b6915112ae3a3487b47d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 12:01:30 -0800 Subject: [PATCH 173/779] Rails: use Sinatra hash in controller (#701) We'll be needing a bit more robust flash support in subsequent changes. --- .rubocop.yml | 1 + app/controllers/application_controller.rb | 7 ++++++- spec/controllers/debug_controller_spec.rb | 5 ----- spec/controllers/feeds_controller_spec.rb | 5 ----- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8c8b74124..80453fba5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -53,4 +53,5 @@ Style/StringLiterals: Lint/ConstantResolution: { Enabled: false } Rails/SchemaComment: { Enabled: false } +Style/InlineComment: { Enabled: false } Style/RequireOrder: { Enabled: false } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b0599055d..3b6863bfa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base helper_method :current_user before_action :append_view_path + after_action :rotate_flash # needed for Sinatra def append_view_path @@ -12,7 +13,11 @@ def append_view_path end def flash - session["flash"] + @flash ||= Sinatra::Flash::FlashHash.new(session[:flash]) end helper_method :flash + + def rotate_flash + session[:flash] = flash.next # for Sinatra + end end diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index 63a3825e3..937ea10d5 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -4,11 +4,6 @@ app_require "controllers/debug_controller" describe DebugController do - before do - # for Sinatra - allow_any_instance_of(described_class).to receive(:session).and_return({ "flash" => {} }) - end - describe "GET /debug" do before do delayed_job = double "Delayed::Job" diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index c986e6dd1..22e843dc7 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -5,11 +5,6 @@ describe "FeedsController" do let(:feeds) { [FeedFactory.build, FeedFactory.build] } - before do - # for Sinatra - allow_any_instance_of(FeedsController).to receive(:session).and_return({ "flash" => {} }) - end - describe "GET /feeds" do it "renders a list of feeds" do expect(FeedRepository).to receive(:list).and_return(feeds) From 3ad07bad537928b623a4fa9b8e1edd2c8355088b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 12:20:24 -0800 Subject: [PATCH 174/779] Rails: move feed new/create/destroy to ActionController (#702) --- .rubocop.yml | 1 + .rubocop_todo.yml | 14 +++++----- app.rb | 3 +++ app/controllers/feeds_controller.rb | 28 ++++++++++++++++++++ app/controllers/sinatra/feeds_controller.rb | 29 --------------------- app/views/feeds/{add.erb => new.html.erb} | 2 +- 6 files changed, 39 insertions(+), 38 deletions(-) rename app/views/feeds/{add.erb => new.html.erb} (94%) diff --git a/.rubocop.yml b/.rubocop.yml index 80453fba5..83bd588ff 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -55,3 +55,4 @@ Lint/ConstantResolution: { Enabled: false } Rails/SchemaComment: { Enabled: false } Style/InlineComment: { Enabled: false } Style/RequireOrder: { Enabled: false } +Style/SafeNavigation: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 32562e00f..01b06c0c3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -79,6 +79,12 @@ Lint/NumberConversion: - 'spec/models/feed_spec.rb' - 'spec/models/story_spec.rb' +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes, Max. +Metrics/AbcSize: + Exclude: + - 'app/controllers/feeds_controller.rb' + # Offense count: 9 # Configuration parameters: ForbiddenDelimiters. # ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) @@ -1092,14 +1098,6 @@ Style/ReturnNil: Exclude: - 'app/repositories/user_repository.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. -# AllowedMethods: present?, blank?, presence, try, try! -Style/SafeNavigation: - Exclude: - - 'app/controllers/sinatra/feeds_controller.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Methods. diff --git a/app.rb b/app.rb index d4671f1b7..cd8efd417 100644 --- a/app.rb +++ b/app.rb @@ -102,6 +102,9 @@ def t(*args, **kwargs) rails_route(:get, "/feeds", to: "feeds#index") rails_route(:get, "/feeds/:id/edit", to: "feeds#edit") rails_route(:put, "/feeds/:id", to: "feeds#update") + rails_route(:delete, "/feeds/:id", to: "feeds#destroy") + rails_route(:get, "/feeds/new", to: "feeds#new") + rails_route(:post, "/feeds", to: "feeds#create") end require_relative "app/controllers/sinatra/stories_controller" diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 7cef7d6d6..2027f0edd 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -5,10 +5,32 @@ def index @feeds = FeedRepository.list end + def new + @feed_url = params[:feed_url] + end + def edit @feed = FeedRepository.fetch(params[:id]) end + def create + @feed_url = params[:feed_url] + feed = AddNewFeed.add(@feed_url) + + if feed && feed.valid? + FetchFeeds.enqueue([feed]) + + flash[:success] = t("feeds.add.flash.added_successfully") + redirect_to("/") + elsif feed + flash.now[:error] = t("feeds.add.flash.already_subscribed_error") + render(:new) + else + flash.now[:error] = t("feeds.add.flash.feed_not_found_error") + render(:new) + end + end + def update feed = FeedRepository.fetch(params[:id]) @@ -17,4 +39,10 @@ def update flash[:success] = t("feeds.edit.flash.updated_successfully") redirect_to("/feeds") end + + def destroy + FeedRepository.delete(params[:id]) + + head(:ok) + end end diff --git a/app/controllers/sinatra/feeds_controller.rb b/app/controllers/sinatra/feeds_controller.rb index 3425fd090..1bd6cdade 100644 --- a/app/controllers/sinatra/feeds_controller.rb +++ b/app/controllers/sinatra/feeds_controller.rb @@ -3,35 +3,6 @@ require_relative "../../commands/feeds/export_to_opml" class Stringer < Sinatra::Base - delete "/feeds/:feed_id" do - FeedRepository.delete(params[:feed_id]) - - status 200 - end - - get "/feeds/new" do - @feed_url = params[:feed_url] - erb :'feeds/add' - end - - post "/feeds" do - @feed_url = params[:feed_url] - feed = AddNewFeed.add(@feed_url) - - if feed && feed.valid? - FetchFeeds.enqueue([feed]) - - flash[:success] = t("feeds.add.flash.added_successfully") - redirect to("/") - elsif feed - flash.now[:error] = t("feeds.add.flash.already_subscribed_error") - erb :'feeds/add' - else - flash.now[:error] = t("feeds.add.flash.feed_not_found_error") - erb :'feeds/add' - end - end - get "/feeds/import" do erb :'feeds/import' end diff --git a/app/views/feeds/add.erb b/app/views/feeds/new.html.erb similarity index 94% rename from app/views/feeds/add.erb rename to app/views/feeds/new.html.erb index 7ead0fde7..c9358838a 100644 --- a/app/views/feeds/add.erb +++ b/app/views/feeds/new.html.erb @@ -1,5 +1,5 @@
    - <%= render_partial :feed_action_bar %> + <%= render "feeds/action_bar" %>
    From 85acafafa4597f03cfe7e8cf9a3746f4821ab111 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 15:20:07 -0800 Subject: [PATCH 175/779] Rails: move remaining feeds actions to ActionController (#703) --- .rubocop.yml | 5 ++ .rubocop_todo.yml | 74 +++++-------------- app.rb | 6 +- app/controllers/exports_controller.rb | 16 ++++ app/controllers/imports_controller.rb | 11 +++ app/controllers/sinatra/feeds_controller.rb | 22 ------ .../import.erb => imports/new.html.erb} | 0 spec/controllers/exports_controller_spec.rb | 28 +++++++ spec/controllers/feeds_controller_spec.rb | 50 +------------ spec/controllers/imports_controller_spec.rb | 30 ++++++++ 10 files changed, 115 insertions(+), 127 deletions(-) create mode 100644 app/controllers/exports_controller.rb create mode 100644 app/controllers/imports_controller.rb delete mode 100644 app/controllers/sinatra/feeds_controller.rb rename app/views/{feeds/import.erb => imports/new.html.erb} (100%) create mode 100644 spec/controllers/exports_controller_spec.rb create mode 100644 spec/controllers/imports_controller_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index 83bd588ff..9b99d5078 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,6 +45,11 @@ Style/NumericLiterals: Style/StringLiterals: EnforcedStyle: double_quotes +Style/MethodCallWithArgsParentheses: + AllowedMethods: + - to + - not_to + ################################################################################ # # Rules we don't want to enable diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 01b06c0c3..27b6ffbc0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-12-18 18:04:01 UTC using RuboCop version 1.40.0. +# on 2022-12-18 23:12:14 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -144,11 +144,10 @@ RSpec/AlignRightLetBrace: - 'spec/tasks/fetch_feeds_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 7 +# Offense count: 6 RSpec/AnyInstance: Exclude: - - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' @@ -235,7 +234,7 @@ RSpec/EmptyLineAfterFinalLet: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/feeds/import_from_opml_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/models/story_spec.rb' - 'spec/repositories/story_repository_spec.rb' @@ -358,6 +357,7 @@ RSpec/MessageExpectation: - 'spec/commands/users/create_user_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/authentication_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' @@ -391,6 +391,7 @@ RSpec/MessageSpies: - 'spec/commands/users/create_user_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/authentication_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' @@ -423,8 +424,10 @@ RSpec/MultipleExpectations: - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/authentication_spec.rb' @@ -515,6 +518,7 @@ RSpec/StubbedMock: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/stories/mark_group_as_read_spec.rb' - 'spec/commands/users/change_user_password_spec.rb' + - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' @@ -597,6 +601,7 @@ Rails/HttpPositionalArguments: - 'spec/controllers/debug_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api_spec.rb' @@ -734,7 +739,7 @@ Style/FetchEnvVar: Exclude: - 'Rakefile' -# Offense count: 152 +# Offense count: 153 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -759,7 +764,6 @@ Style/FrozenStringLiteralComment: - 'app/commands/users/create_user.rb' - 'app/commands/users/sign_in_user.rb' - 'app/controllers/debug_controller.rb' - - 'app/controllers/sinatra/feeds_controller.rb' - 'app/controllers/sinatra/first_run_controller.rb' - 'app/controllers/sinatra/sessions_controller.rb' - 'app/controllers/sinatra/stories_controller.rb' @@ -842,8 +846,10 @@ Style/FrozenStringLiteralComment: - 'spec/commands/users/sign_in_user_spec.rb' - 'spec/config/asset_pipeline_spec.rb' - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/factories.rb' @@ -934,12 +940,7 @@ Style/HashSyntax: - 'spec/tasks/change_password_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' -# Offense count: 1 -Style/InlineComment: - Exclude: - - 'app/utils/opml_parser.rb' - -# Offense count: 695 +# Offense count: 187 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -972,58 +973,29 @@ Style/MethodCallWithArgsParentheses: - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' - - 'spec/app_spec.rb' - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/feeds/export_to_opml_spec.rb' - 'spec/commands/feeds/import_from_opml_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_as_read_spec.rb' - - 'spec/commands/stories/mark_as_starred_spec.rb' - - 'spec/commands/stories/mark_as_unread_spec.rb' - - 'spec/commands/stories/mark_as_unstarred_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/commands/users/create_user_spec.rb' - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/config/asset_pipeline_spec.rb' - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - - 'spec/fever_api/authentication_spec.rb' - - 'spec/fever_api/read_favicons_spec.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/read_links_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' - 'spec/helpers/authentications_helper_spec.rb' - 'spec/helpers/url_helpers_spec.rb' - 'spec/integration/feed_importing_spec.rb' - 'spec/javascript/test_controller.rb' - - 'spec/models/feed_spec.rb' - 'spec/models/group_spec.rb' - - 'spec/models/migration_status_spec.rb' - 'spec/models/story_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - - 'spec/repositories/group_repository_spec.rb' - 'spec/repositories/story_repository_spec.rb' - - 'spec/repositories/user_repository_spec.rb' - 'spec/spec_helper.rb' - - 'spec/tasks/change_password_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/content_sanitizer_spec.rb' - 'spec/utils/feed_discovery_spec.rb' - 'spec/utils/i18n_support_spec.rb' @@ -1037,7 +1009,7 @@ Style/NumericPredicate: Exclude: - 'app/commands/stories/mark_group_as_read.rb' -# Offense count: 4 +# Offense count: 6 Style/OpenStructUse: Exclude: - 'app.rb' @@ -1082,14 +1054,6 @@ Style/PercentLiteralDelimiters: - 'spec/helpers/url_helpers_spec.rb' - 'spec/javascript/test_controller.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: same_as_string_literals, single_quotes, double_quotes -Style/QuotedSymbols: - Exclude: - - 'app/controllers/sinatra/feeds_controller.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -1121,7 +1085,7 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' -# Offense count: 20 +# Offense count: 19 # This cop supports unsafe autocorrection (--autocorrect-all). Style/StringHashKeys: Exclude: @@ -1129,8 +1093,8 @@ Style/StringHashKeys: - 'fever_api.rb' - 'spec/app_spec.rb' - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' + - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/fever_api/read_favicons_spec.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' diff --git a/app.rb b/app.rb index cd8efd417..8b4557e5c 100644 --- a/app.rb +++ b/app.rb @@ -22,6 +22,8 @@ require_relative "app/controllers/application_controller" require_relative "app/controllers/debug_controller" require_relative "app/controllers/feeds_controller" +require_relative "app/controllers/exports_controller" +require_relative "app/controllers/imports_controller" module Rails def self.application @@ -105,9 +107,11 @@ def t(*args, **kwargs) rails_route(:delete, "/feeds/:id", to: "feeds#destroy") rails_route(:get, "/feeds/new", to: "feeds#new") rails_route(:post, "/feeds", to: "feeds#create") + rails_route(:get, "/feeds/export", to: "exports#index") + rails_route(:get, "/feeds/import", to: "imports#new") + rails_route(:post, "/feeds/import", to: "imports#create") end require_relative "app/controllers/sinatra/stories_controller" require_relative "app/controllers/sinatra/first_run_controller" require_relative "app/controllers/sinatra/sessions_controller" -require_relative "app/controllers/sinatra/feeds_controller" diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb new file mode 100644 index 000000000..f7a58f99f --- /dev/null +++ b/app/controllers/exports_controller.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require_relative "../commands/feeds/export_to_opml" + +class ExportsController < ApplicationController + def index + xml = ExportToOpml.new(Feed.all).to_xml + + send_data( + xml, + type: "application/xml", + disposition: "attachment", + filename: "stringer.opml" + ) + end +end diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb new file mode 100644 index 000000000..83c3ef2a3 --- /dev/null +++ b/app/controllers/imports_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class ImportsController < ApplicationController + def new; end + + def create + ImportFromOpml.import(params["opml_file"].read) + + redirect_to("/setup/tutorial") + end +end diff --git a/app/controllers/sinatra/feeds_controller.rb b/app/controllers/sinatra/feeds_controller.rb deleted file mode 100644 index 1bd6cdade..000000000 --- a/app/controllers/sinatra/feeds_controller.rb +++ /dev/null @@ -1,22 +0,0 @@ -require_relative "../../repositories/feed_repository" -require_relative "../../commands/feeds/add_new_feed" -require_relative "../../commands/feeds/export_to_opml" - -class Stringer < Sinatra::Base - get "/feeds/import" do - erb :'feeds/import' - end - - post "/feeds/import" do - ImportFromOpml.import(params["opml_file"][:tempfile].read) - - redirect to("/setup/tutorial") - end - - get "/feeds/export" do - content_type "application/xml" - attachment "stringer.opml" - - ExportToOpml.new(Feed.all).to_xml - end -end diff --git a/app/views/feeds/import.erb b/app/views/imports/new.html.erb similarity index 100% rename from app/views/feeds/import.erb rename to app/views/imports/new.html.erb diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb new file mode 100644 index 000000000..f4f0016be --- /dev/null +++ b/spec/controllers/exports_controller_spec.rb @@ -0,0 +1,28 @@ +require "spec_helper" + +app_require "controllers/exports_controller" + +describe ExportsController do + describe "GET /feeds/export" do + let(:some_xml) { "some dummy opml" } + before { allow(Feed).to receive(:all) } + + it "returns an OPML file" do + expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) + + get "/feeds/export" + + expect(last_response.body).to eq some_xml + end + + it "responds with OPML headers" do + expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) + + get "/feeds/export" + + expect(last_response.header["Content-Type"]).to include "application/xml" + expect(last_response.header["Content-Disposition"]) + .to eq("attachment; filename=\"stringer.opml\"; filename*=UTF-8''stringer.opml") + end + end +end diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 22e843dc7..80290eb8d 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -app_require "controllers/sinatra/feeds_controller" +app_require "controllers/feeds_controller" describe "FeedsController" do let(:feeds) { [FeedFactory.build, FeedFactory.build] } @@ -134,52 +134,4 @@ def params(feed, **overrides) end end end - - describe "GET /feeds/import" do - it "displays the import options" do - get "/feeds/import" - - page = last_response.body - expect(page).to have_tag("input#opml_file") - expect(page).to have_tag("a#skip") - end - end - - describe "POST /feeds/import" do - let(:opml_file) do - Rack::Test::UploadedFile.new("spec/sample_data/subscriptions.xml", "application/xml") - end - - it "parse OPML and starts fetching" do - expect(ImportFromOpml).to receive(:import).once - - post "/feeds/import", "opml_file" => opml_file - - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/setup/tutorial" - end - end - - describe "GET /feeds/export" do - let(:some_xml) { "some dummy opml" } - before { allow(Feed).to receive(:all) } - - it "returns an OPML file" do - expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) - - get "/feeds/export" - - expect(last_response.body).to eq some_xml - end - - it "responds with OPML headers" do - expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) - - get "/feeds/export" - - expect(last_response.header["Content-Type"]).to include "application/xml" - expect(last_response.header["Content-Disposition"]) - .to eq("attachment; filename=\"stringer.opml\"") - end - end end diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb new file mode 100644 index 000000000..f6df9f35d --- /dev/null +++ b/spec/controllers/imports_controller_spec.rb @@ -0,0 +1,30 @@ +require "spec_helper" + +app_require "controllers/imports_controller" + +describe ImportsController do + describe "GET /feeds/import" do + it "displays the import options" do + get "/feeds/import" + + page = last_response.body + expect(page).to have_tag("input#opml_file") + expect(page).to have_tag("a#skip") + end + end + + describe "POST /feeds/import" do + let(:opml_file) do + Rack::Test::UploadedFile.new("spec/sample_data/subscriptions.xml", "application/xml") + end + + it "parse OPML and starts fetching" do + expect(ImportFromOpml).to receive(:import).once + + post "/feeds/import", "opml_file" => opml_file + + expect(last_response.status).to be 302 + expect(URI.parse(last_response.location).path).to eq "/setup/tutorial" + end + end +end From a5d86ed80a7e2d5a3280f6ff743862442594195f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 15:28:27 -0800 Subject: [PATCH 176/779] Specs: eliminate logger output from tests (#704) --- spec/tasks/fetch_feed_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 1c1ff0f8a..f8095025f 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -25,7 +25,7 @@ expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser: parser, client: client).fetch + FetchFeed.new(daring_fireball, parser: parser, client: client, logger: nil).fetch end end @@ -98,7 +98,7 @@ expect(FeedRepository).to receive(:set_status) .with(:red, daring_fireball) - FetchFeed.new(daring_fireball, parser: parser, client: client).fetch + FetchFeed.new(daring_fireball, parser: parser, client: client, logger: nil).fetch end end end From 5da8a6fc02ff93a502f2c123a5aa61318d25674b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 18:44:42 -0800 Subject: [PATCH 177/779] Coverage: enable branch coverage for tests (#705) --- .rubocop.yml | 1 + .rubocop_todo.yml | 21 ++++++++++++--------- spec/jobs/fetch_feed_job_spec.rb | 15 +++++++++++++++ spec/support/coverage.rb | 9 +++------ 4 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 spec/jobs/fetch_feed_job_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index 9b99d5078..860a6184d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -49,6 +49,7 @@ Style/MethodCallWithArgsParentheses: AllowedMethods: - to - not_to + - describe ################################################################################ # diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 27b6ffbc0..daafc95d8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-12-18 23:12:14 UTC using RuboCop version 1.40.0. +# on 2022-12-19 02:34:30 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -343,7 +343,7 @@ RSpec/MessageChain: - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api_spec.rb' -# Offense count: 100 +# Offense count: 102 # Configuration parameters: EnforcedStyle. # SupportedStyles: allow, expect RSpec/MessageExpectation: @@ -369,6 +369,7 @@ RSpec/MessageExpectation: - 'spec/fever_api/write_mark_group_spec.rb' - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' + - 'spec/jobs/fetch_feed_job_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - 'spec/repositories/story_repository_spec.rb' - 'spec/tasks/change_password_spec.rb' @@ -377,7 +378,7 @@ RSpec/MessageExpectation: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 105 +# Offense count: 107 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -403,6 +404,7 @@ RSpec/MessageSpies: - 'spec/fever_api/write_mark_group_spec.rb' - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' + - 'spec/jobs/fetch_feed_job_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - 'spec/repositories/story_repository_spec.rb' - 'spec/tasks/change_password_spec.rb' @@ -411,7 +413,7 @@ RSpec/MessageSpies: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 96 +# Offense count: 97 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -440,6 +442,7 @@ RSpec/MultipleExpectations: - 'spec/fever_api/write_mark_group_spec.rb' - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' + - 'spec/jobs/fetch_feed_job_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - 'spec/repositories/story_repository_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' @@ -512,7 +515,7 @@ RSpec/ScatteredLet: - 'spec/commands/feeds/import_from_opml_spec.rb' - 'spec/repositories/feed_repository_spec.rb' -# Offense count: 53 +# Offense count: 55 RSpec/StubbedMock: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' @@ -532,11 +535,12 @@ RSpec/StubbedMock: - 'spec/fever_api/write_mark_group_spec.rb' - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' + - 'spec/jobs/fetch_feed_job_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 92 +# Offense count: 93 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -560,6 +564,7 @@ RSpec/VerifiedDoubles: - 'spec/fever_api/write_mark_group_spec.rb' - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' + - 'spec/jobs/fetch_feed_job_spec.rb' - 'spec/repositories/story_repository_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' - 'spec/tasks/remove_old_stories_spec.rb' @@ -940,7 +945,7 @@ Style/HashSyntax: - 'spec/tasks/change_password_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' -# Offense count: 187 +# Offense count: 184 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -987,11 +992,9 @@ Style/MethodCallWithArgsParentheses: - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api_spec.rb' - - 'spec/helpers/authentications_helper_spec.rb' - 'spec/helpers/url_helpers_spec.rb' - 'spec/integration/feed_importing_spec.rb' - 'spec/javascript/test_controller.rb' - - 'spec/models/group_spec.rb' - 'spec/models/story_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - 'spec/repositories/story_repository_spec.rb' diff --git a/spec/jobs/fetch_feed_job_spec.rb b/spec/jobs/fetch_feed_job_spec.rb new file mode 100644 index 000000000..f3db61959 --- /dev/null +++ b/spec/jobs/fetch_feed_job_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "spec_helper" + +app_require "jobs/fetch_feed_job" + +RSpec.describe FetchFeedJob do + it "fetches feeds" do + job = described_class.new(123) + feed = Feed.new(id: 123, url: "http://example.com/feed") + expect(FeedRepository).to receive(:fetch).with(123).and_return(feed) + expect(FetchFeed).to receive(:new).with(feed).and_return(double(fetch: nil)) + job.perform + end +end diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb index 03b601a45..441491114 100644 --- a/spec/support/coverage.rb +++ b/spec/support/coverage.rb @@ -5,15 +5,12 @@ SimpleCov.formatter = Coveralls::SimpleCov::Formatter end -SimpleCov.start("test_frameworks") do +SimpleCov.start(:rails) do add_group("Commands", "app/commands") - add_group("Controllers", "app/controllers") add_group("Fever API", "app/fever_api") - add_group("Helpers", "app/helpers") - add_group("Models", "app/models") add_group("Repositories", "app/repositories") add_group("Tasks", "app/tasks") add_group("Utils", "app/utils") - add_filter("/db/migrate/") + enable_coverage :branch end -SimpleCov.minimum_coverage(100) +SimpleCov.minimum_coverage(line: 100, branch: 91) From 0a81d75f7d6ce4bba0304c8afc9bf34c8bc9ef5b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 18:55:51 -0800 Subject: [PATCH 178/779] Coverage: add branch tests for FetchFeeds (#706) --- .rubocop.yml | 1 + spec/tasks/fetch_feeds_spec.rb | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 860a6184d..53befaa58 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -59,6 +59,7 @@ Style/MethodCallWithArgsParentheses: Lint/ConstantResolution: { Enabled: false } Rails/SchemaComment: { Enabled: false } +RSpec/StubbedMock: { Enabled: false } Style/InlineComment: { Enabled: false } Style/RequireOrder: { Enabled: false } Style/SafeNavigation: { Enabled: false } diff --git a/spec/tasks/fetch_feeds_spec.rb b/spec/tasks/fetch_feeds_spec.rb index 9a7ce4ffd..08a3325f7 100644 --- a/spec/tasks/fetch_feeds_spec.rb +++ b/spec/tasks/fetch_feeds_spec.rb @@ -4,8 +4,8 @@ describe FetchFeeds do describe "#fetch_all" do let(:feeds) { [FeedFactory.build, FeedFactory.build] } - let(:fetcher_one) { double } - let(:fetcher_two) { double } + let(:fetcher_one) { instance_double(FetchFeed) } + let(:fetcher_two) { instance_double(FetchFeed) } let(:pool) { double } it "calls FetchFeed#fetch for every feed" do @@ -19,6 +19,18 @@ FetchFeeds.new(feeds, pool).fetch_all end + + it "finds feeds when run after a delay" do + allow(pool).to receive(:process).and_yield + allow(FetchFeed).to receive(:new).and_return(fetcher_one, fetcher_two) + expect(FeedRepository).to receive(:fetch_by_ids).with(feeds.map(&:id)).and_return(feeds) + expect(fetcher_one).to receive(:fetch).once + expect(fetcher_two).to receive(:fetch).once + + expect(pool).to receive(:shutdown) + + FetchFeeds.new(feeds, pool).prepare_to_delay.fetch_all + end end describe "#prepare_to_delay" do From 6634332a697ba3b7e90a2fe3d0aaa44e0154807d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 19:01:12 -0800 Subject: [PATCH 179/779] Coverage: add branch coverage for Story (#707) --- spec/models/story_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 2375d0b29..413e97558 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -131,5 +131,15 @@ created_on_time: published_at.to_i ) end + + it "returns is_read as 0 if story is unread" do + story = create_story(is_read: false) + expect(story.as_fever_json[:is_read]).to eq(0) + end + + it "returns is_saved as 1 if story is starred" do + story = create_story(is_starred: true) + expect(story.as_fever_json[:is_saved]).to eq(1) + end end end From c7eb0dfea57d0236769de00c213d7b409cd52a75 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 19:07:09 -0800 Subject: [PATCH 180/779] Coverage: add branch coverage for FetchFeed (#708) --- spec/tasks/fetch_feed_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index f8095025f..36c7be165 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -27,6 +27,17 @@ FetchFeed.new(daring_fireball, parser: parser, client: client, logger: nil).fetch end + + it "logs a message" do + client = class_spy(HTTParty) + parser = class_double(Feedjira, parse: 304) + output = StringIO.new + logger = Logger.new(output) + + FetchFeed.new(daring_fireball, parser: parser, client: client, logger:).fetch + + expect(output.string).to include("has not been modified") + end end context "when no new posts have been added" do @@ -100,6 +111,17 @@ FetchFeed.new(daring_fireball, parser: parser, client: client, logger: nil).fetch end + + it "outputs a message when things go wrong" do + client = class_spy(HTTParty) + parser = class_double(Feedjira, parse: 404) + output = StringIO.new + logger = Logger.new(output) + + FetchFeed.new(daring_fireball, parser: parser, client: client, logger: logger).fetch + + expect(output.string).to include("Something went wrong") + end end end end From 337f9397707f190769296eebb8060317603c69bd Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 20:08:37 -0800 Subject: [PATCH 181/779] Coverage: remove unused branch from FeedDiscovery (#709) --- app/utils/feed_discovery.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/feed_discovery.rb b/app/utils/feed_discovery.rb index dd65d4740..c55ad3484 100644 --- a/app/utils/feed_discovery.rb +++ b/app/utils/feed_discovery.rb @@ -20,6 +20,6 @@ def get_feed_for_url(url, parser, client) feed.feed_url ||= url feed rescue StandardError - yield if block_given? + yield end end From d923992fa4ef4321296bdc15c53351a6d5698574 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 20:13:37 -0800 Subject: [PATCH 182/779] Coverage: remove unused condition from MarkGroupAsRead (#710) It shouldn't be possible to get this far unless `group_id` is greater than 0. --- app/commands/stories/mark_group_as_read.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/commands/stories/mark_group_as_read.rb b/app/commands/stories/mark_group_as_read.rb index ff24c9ce8..c177e49b6 100644 --- a/app/commands/stories/mark_group_as_read.rb +++ b/app/commands/stories/mark_group_as_read.rb @@ -15,7 +15,7 @@ def mark_group_as_read if [KINDLING_GROUP_ID, SPARKS_GROUP_ID].include?(@group_id.to_i) @repo.fetch_unread_by_timestamp(@timestamp).update_all(is_read: true) - elsif @group_id.to_i > 0 + else @repo.fetch_unread_by_timestamp_and_group( @timestamp, @group_id From f009b39efb8d0bc4acbe37268938ded851325080 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 20:30:47 -0800 Subject: [PATCH 183/779] Coverage: update branch coverage for WriteMarkItem (#711) --- spec/fever_api/write_mark_item_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/fever_api/write_mark_item_spec.rb b/spec/fever_api/write_mark_item_spec.rb index 2a2929409..ef70c519f 100644 --- a/spec/fever_api/write_mark_item_spec.rb +++ b/spec/fever_api/write_mark_item_spec.rb @@ -55,6 +55,6 @@ end it "returns an empty hash otherwise" do - expect(subject.call).to eq({}) + expect(subject.call({ mark: "item" })).to eq({}) end end From 1b7713ecaca06afb65cafa908a718afc0c7e6a73 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 21:41:37 -0800 Subject: [PATCH 184/779] Coverage: cover branch in StoryRepository (#712) --- spec/repositories/story_repository_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 47e6af66c..92e457bd1 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -459,6 +459,12 @@ expect(StoryRepository.extract_content(summary_only)).to eq "Dumb publisher" end + it "returns empty string if there is no content or summary" do + entry = double(url: "http://mdswanson.com", content: nil, summary: nil) + + expect(StoryRepository.extract_content(entry)).to eq "" + end + it "expands urls" do entry = double( url: "http://mdswanson.com", From 74a603268134325e18bdc4c261ca569d7500b73e Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 21:46:49 -0800 Subject: [PATCH 185/779] Coverage: remove unused clause in importer (#713) Based on the implementation of `OpmlParser` it doesn't look like there's any way to hit this guard clause. --- app/commands/feeds/import_from_opml.rb | 2 -- spec/commands/feeds/import_from_opml_spec.rb | 26 +++++++++++++++++--- spec/support/coverage.rb | 2 +- spec/support/files/subscriptions.xml | 2 ++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/commands/feeds/import_from_opml.rb b/app/commands/feeds/import_from_opml.rb index 9fb6ae47b..8a3841ba9 100644 --- a/app/commands/feeds/import_from_opml.rb +++ b/app/commands/feeds/import_from_opml.rb @@ -14,8 +14,6 @@ def import(opml_contents) # for existing feeds. Feeds without groups are in 'Ungrouped' group, we don't # create such group and create such feeds with group_id = nil. feeds_with_groups.each do |group_name, parsed_feeds| - next if parsed_feeds.empty? - group = Group.where(name: group_name).first_or_create unless group_name == "Ungrouped" parsed_feeds.each { |parsed_feed| create_feed(parsed_feed, group) } diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 6516ece9e..be2e7a9e4 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -29,19 +29,24 @@ def import url: "http://feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots" ) end - before { import } it "retains exising feeds" do + described_class.import(subscriptions) + expect(feed1).to be_valid expect(feed2).to be_valid end it "creates new groups" do + described_class.import(subscriptions) + expect(group1).to be expect(group2).to be end it "sets group_id for existing feeds" do + described_class.import(subscriptions) + expect(feed1.reload.group).to eq group1 expect(feed2.reload.group).to eq group2 end @@ -57,35 +62,48 @@ def import url: "http://feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots" ) end - before { import } it "creates groups" do + described_class.import(subscriptions) + expect(group1).to be expect(group1).to be end it "creates feeds" do + described_class.import(subscriptions) + expect(feed1).to exist expect(feed2).to exist end it "sets group" do + described_class.import(subscriptions) + expect(feed1.first.group).to eq group1 expect(feed2.first.group).to eq group2 end + + it "does not create empty group" do + described_class.import(subscriptions) + + expect(Group.find_by_name("Empty Group")).to be_nil + end end context "creates new feeds without group" do let(:feed1) { Feed.where(name: "Autoblog", url: "http://feeds.autoblog.com/weblogsinc/autoblog/").first } let(:feed2) { Feed.where(name: "City Guide News", url: "http://www.probki.net/news/RSS_news_feed.asp").first } - before { import } - it "does not create any new group for feeds without group" do + described_class.import(subscriptions) + expect(Group.where("id NOT IN (?)", [group1.id, group2.id]).count).to eq 0 end it "creates feeds without group_id" do + described_class.import(subscriptions) + expect(feed1.group_id).to be_nil expect(feed2.group_id).to be_nil end diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb index 441491114..2f2a2b83b 100644 --- a/spec/support/coverage.rb +++ b/spec/support/coverage.rb @@ -13,4 +13,4 @@ add_group("Utils", "app/utils") enable_coverage :branch end -SimpleCov.minimum_coverage(line: 100, branch: 91) +SimpleCov.minimum_coverage(line: 100, branch: 99) diff --git a/spec/support/files/subscriptions.xml b/spec/support/files/subscriptions.xml index bb44ada99..832f59b48 100755 --- a/spec/support/files/subscriptions.xml +++ b/spec/support/files/subscriptions.xml @@ -23,5 +23,7 @@ + + From 7a459f5c1483595f3d7d90abf833e13e78c2f58f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 21:55:26 -0800 Subject: [PATCH 186/779] RuboCop: reduce line length to 90 (#689) --- .rubocop.yml | 2 +- app/commands/feeds/import_from_opml.rb | 6 ++++-- app/commands/stories/mark_feed_as_read.rb | 4 +++- app/controllers/feeds_controller.rb | 7 ++++++- app/fever_api/read_favicons.rb | 4 +++- app/helpers/controller_helpers.rb | 3 ++- app/repositories/story_repository.rb | 11 +++++------ app/tasks/fetch_feeds.rb | 4 +++- spec/controllers/imports_controller_spec.rb | 5 ++++- spec/controllers/stories_controller_spec.rb | 5 ++++- spec/fever_api/read_favicons_spec.rb | 2 +- spec/fever_api/read_items_spec.rb | 3 ++- spec/fever_api/sync_saved_item_ids_spec.rb | 3 ++- spec/fever_api/sync_unread_item_ids_spec.rb | 3 ++- spec/fever_api_spec.rb | 9 ++++++--- spec/integration/feed_importing_spec.rb | 14 +++++++------- spec/javascript/test_controller.rb | 9 ++++++++- spec/repositories/story_repository_spec.rb | 6 +++++- spec/tasks/fetch_feed_spec.rb | 10 ++++++++-- spec/tasks/fetch_feeds_spec.rb | 3 ++- spec/tasks/remove_old_stories_spec.rb | 3 ++- 21 files changed, 80 insertions(+), 36 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 53befaa58..64a7ed716 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 95 + Max: 90 Metrics/BlockLength: Exclude: diff --git a/app/commands/feeds/import_from_opml.rb b/app/commands/feeds/import_from_opml.rb index 8a3841ba9..b0133e20e 100644 --- a/app/commands/feeds/import_from_opml.rb +++ b/app/commands/feeds/import_from_opml.rb @@ -14,7 +14,9 @@ def import(opml_contents) # for existing feeds. Feeds without groups are in 'Ungrouped' group, we don't # create such group and create such feeds with group_id = nil. feeds_with_groups.each do |group_name, parsed_feeds| - group = Group.where(name: group_name).first_or_create unless group_name == "Ungrouped" + unless group_name == "Ungrouped" + group = Group.where(name: group_name).first_or_create + end parsed_feeds.each { |parsed_feed| create_feed(parsed_feed, group) } end @@ -23,7 +25,7 @@ def import(opml_contents) private def create_feed(parsed_feed, group) - feed = Feed.where(name: parsed_feed[:name], url: parsed_feed[:url]).first_or_initialize + feed = Feed.where(parsed_feed.slice(:name, :url)).first_or_initialize feed.last_fetched = Time.now - ONE_DAY if feed.new_record? feed.group_id = group.id if group feed.save diff --git a/app/commands/stories/mark_feed_as_read.rb b/app/commands/stories/mark_feed_as_read.rb index 035f50e1d..8c28b8dbe 100644 --- a/app/commands/stories/mark_feed_as_read.rb +++ b/app/commands/stories/mark_feed_as_read.rb @@ -8,6 +8,8 @@ def initialize(feed_id, timestamp, repository = StoryRepository) end def mark_feed_as_read - @repo.fetch_unread_for_feed_by_timestamp(@feed_id, @timestamp).update_all(is_read: true) + @repo + .fetch_unread_for_feed_by_timestamp(@feed_id, @timestamp) + .update_all(is_read: true) end end diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 2027f0edd..0f1488707 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -34,7 +34,12 @@ def create def update feed = FeedRepository.fetch(params[:id]) - FeedRepository.update_feed(feed, params[:feed_name], params[:feed_url], params[:group_id]) + FeedRepository.update_feed( + feed, + params[:feed_name], + params[:feed_url], + params[:group_id] + ) flash[:success] = t("feeds.edit.flash.updated_successfully") redirect_to("/feeds") diff --git a/app/fever_api/read_favicons.rb b/app/fever_api/read_favicons.rb index f49393198..c924b7cfd 100644 --- a/app/fever_api/read_favicons.rb +++ b/app/fever_api/read_favicons.rb @@ -1,5 +1,7 @@ module FeverAPI class ReadFavicons + ICON = "R0lGODlhAQABAIAAAObm5gAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==".freeze + def call(params = {}) if params.keys.include?("favicons") { favicons: favicons } @@ -14,7 +16,7 @@ def favicons [ { id: 0, - data: "image/gif;base64,R0lGODlhAQABAIAAAObm5gAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" + data: "image/gif;base64,#{ICON}" } ] end diff --git a/app/helpers/controller_helpers.rb b/app/helpers/controller_helpers.rb index efee39f79..4070c9c0e 100644 --- a/app/helpers/controller_helpers.rb +++ b/app/helpers/controller_helpers.rb @@ -8,7 +8,8 @@ def rails_route(method, path, options) controller_name, action_name = to.split("#") controller_klass = "#{controller_name.camelize}Controller".constantize route(method.to_s.upcase, path, options) do - # Make sure that our parsed URL params are where Rack (and ActionDispatch) expect them + # Make sure that our parsed URL params are where Rack (and + # ActionDispatch) expect them app = controller_klass.action(action_name) app.call(request.env.merge("rack.request.query_hash" => params)) end diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index a85019a8a..941d2cd3f 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -40,7 +40,9 @@ def self.fetch_unread_by_timestamp_and_group(timestamp, group_id) def self.fetch_unread_for_feed_by_timestamp(feed_id, timestamp) timestamp = Time.at(timestamp.to_i) - Story.where(feed_id: feed_id).where("created_at < ? AND is_read = ?", timestamp, false) + Story + .where(feed_id: feed_id) + .where("created_at < ? AND is_read = ?", timestamp, false) end def self.save(story) @@ -95,11 +97,8 @@ def self.extract_url(entry, feed) def self.extract_content(entry) sanitized_content = "" - if entry.content - sanitized_content = ContentSanitizer.sanitize(entry.content) - elsif entry.summary - sanitized_content = ContentSanitizer.sanitize(entry.summary) - end + content = entry.content || entry.summary + sanitized_content = ContentSanitizer.sanitize(content) if content if entry.url.present? expand_absolute_urls(sanitized_content, entry.url) diff --git a/app/tasks/fetch_feeds.rb b/app/tasks/fetch_feeds.rb index c1c1aab66..bb7867525 100644 --- a/app/tasks/fetch_feeds.rb +++ b/app/tasks/fetch_feeds.rb @@ -14,7 +14,9 @@ def initialize(feeds, pool = nil) def fetch_all @pool ||= Thread.pool(10) - @feeds = FeedRepository.fetch_by_ids(@feeds_ids) if @feeds.blank? && !@feeds_ids.blank? + if @feeds.blank? && !@feeds_ids.blank? + @feeds = FeedRepository.fetch_by_ids(@feeds_ids) + end @feeds.each do |feed| @pool.process do diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb index f6df9f35d..b62500cd4 100644 --- a/spec/controllers/imports_controller_spec.rb +++ b/spec/controllers/imports_controller_spec.rb @@ -15,7 +15,10 @@ describe "POST /feeds/import" do let(:opml_file) do - Rack::Test::UploadedFile.new("spec/sample_data/subscriptions.xml", "application/xml") + Rack::Test::UploadedFile.new( + "spec/sample_data/subscriptions.xml", + "application/xml" + ) end it "parse OPML and starts fetching" do diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index f1a4ea52e..47a668d5f 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -44,7 +44,10 @@ page = last_response.body expect(page).to have_tag("a", with: { href: "/feeds/export" }) expect(page).to have_tag("a", with: { href: "/logout" }) - expect(page).to have_tag("a", with: { href: "https://github.com/stringer-rss/stringer" }) + expect(page).to have_tag( + "a", + with: { href: "https://github.com/stringer-rss/stringer" } + ) end it "displays a zen-like message when there are no unread stories" do diff --git a/spec/fever_api/read_favicons_spec.rb b/spec/fever_api/read_favicons_spec.rb index 5b91e4b5e..93bb4efa1 100644 --- a/spec/fever_api/read_favicons_spec.rb +++ b/spec/fever_api/read_favicons_spec.rb @@ -10,7 +10,7 @@ favicons: [ { id: 0, - data: "image/gif;base64,R0lGODlhAQABAIAAAObm5gAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" + data: "image/gif;base64,#{described_class::ICON}" } ] ) diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index ad8c167c7..fef8e3131 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -53,7 +53,8 @@ double("story", as_fever_json: { id: 5 }), double("story", as_fever_json: { id: 11 }) ] - expect(story_repository).to receive(:fetch_by_ids).with(%w(5 11)).twice.and_return(stories) + expect(story_repository) + .to receive(:fetch_by_ids).with(%w(5 11)).twice.and_return(stories) expect(subject.call("items" => nil, with_ids: "5,11")).to eq( items: [ diff --git a/spec/fever_api/sync_saved_item_ids_spec.rb b/spec/fever_api/sync_saved_item_ids_spec.rb index e9efefb64..5907df49a 100644 --- a/spec/fever_api/sync_saved_item_ids_spec.rb +++ b/spec/fever_api/sync_saved_item_ids_spec.rb @@ -13,7 +13,8 @@ it "returns a list of starred items if requested" do expect(story_repository).to receive(:all_starred).and_return(stories) - expect(subject.call("saved_item_ids" => nil)).to eq(saved_item_ids: story_ids.join(",")) + expect(subject.call("saved_item_ids" => nil)) + .to eq(saved_item_ids: story_ids.join(",")) end it "returns an empty hash otherwise" do diff --git a/spec/fever_api/sync_unread_item_ids_spec.rb b/spec/fever_api/sync_unread_item_ids_spec.rb index b7f9925f4..e7f98e9c8 100644 --- a/spec/fever_api/sync_unread_item_ids_spec.rb +++ b/spec/fever_api/sync_unread_item_ids_spec.rb @@ -13,7 +13,8 @@ it "returns a list of unread items if requested" do expect(story_repository).to receive(:unread).and_return(stories) - expect(subject.call("unread_item_ids" => nil)).to eq(unread_item_ids: story_ids.join(",")) + expect(subject.call("unread_item_ids" => nil)) + .to eq(unread_item_ids: story_ids.join(",")) end it "returns an empty hash otherwise" do diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index ebeeac78e..c2e0d2959 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -109,7 +109,8 @@ def make_request(extra_headers = {}) end it "returns stories when 'items' header is provided along with 'since_id'" do - expect(StoryRepository).to receive(:unread_since_id).with("5").and_return([story_one]) + expect(StoryRepository) + .to receive(:unread_since_id).with("5").and_return([story_one]) expect(StoryRepository).to receive(:unread).and_return([story_one, story_two]) make_request(items: nil, since_id: 5) @@ -193,7 +194,8 @@ def make_request(extra_headers = {}) end it "commands to mark story as read" do - expect(MarkAsRead).to receive(:new).with("10").and_return(double(mark_as_read: true)) + expect(MarkAsRead) + .to receive(:new).with("10").and_return(double(mark_as_read: true)) make_request(mark: "item", as: "read", id: 10) @@ -202,7 +204,8 @@ def make_request(extra_headers = {}) end it "commands to mark story as unread" do - expect(MarkAsUnread).to receive(:new).with("10").and_return(double(mark_as_unread: true)) + expect(MarkAsUnread) + .to receive(:new).with("10").and_return(double(mark_as_unread: true)) make_request(mark: "item", as: "unread", id: 10) diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index f938381cf..d1abbb14f 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -63,13 +63,13 @@ context "has been fetched before" do it "imports all new stories" do # This spec describes a scenario where the feed is reporting incorrect - # published dates for stories. - # The feed in question is feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots. - # When an article is published the published date is always set to 00:00 of - # the day the article was published. - # This specs shows that with the current behaviour (08-15-2014) Stringer - # will not detect this article, if the last time this feed was fetched is - # after 00:00 the day the article was published. + # published dates for stories. The feed in question is + # feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots. When an + # article is published the published date is always set to 00:00 of the + # day the article was published. This specs shows that with the current + # behaviour (08-15-2014) Stringer will not detect this article, if the + # last time this feed was fetched is after 00:00 the day the article + # was published. feed.last_fetched = Time.parse("2014-08-12T00:01:00Z") @server.response = sample_data("feeds/feed02_invalid_published_dates/feed.xml") diff --git a/spec/javascript/test_controller.rb b/spec/javascript/test_controller.rb index 7a13e99d8..97c62a491 100644 --- a/spec/javascript/test_controller.rb +++ b/spec/javascript/test_controller.rb @@ -23,7 +23,14 @@ def self.test_path(*chunks) private def vendor_js_files - %w(mocha.js sinon.js chai.js chai-changes.js chai-backbone.js sinon-chai.js).map do |name| + %w( + mocha.js + sinon.js + chai.js + chai-changes.js + chai-backbone.js + sinon-chai.js + ).map do |name| File.join "vendor", "js", name end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 92e457bd1..bb50912f0 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -11,7 +11,11 @@ end it "normalizes story urls" do - entry = double(url: "//blog.golang.org/context", title: "", content: "").as_null_object + entry = double( + url: "//blog.golang.org/context", + title: "", + content: "" + ).as_null_object expect(StoryRepository).to receive(:normalize_url).with(entry.url, feed.url) StoryRepository.add(entry, feed) diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 36c7be165..86432b7ba 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -64,7 +64,8 @@ let(:fake_parser) { class_double(Feedjira, parse: fake_feed) } before do - allow_any_instance_of(FindNewStories).to receive(:new_stories).and_return([new_story]) + allow_any_instance_of(FindNewStories) + .to receive(:new_stories).and_return([new_story]) end it "should only add posts that are new" do @@ -118,7 +119,12 @@ output = StringIO.new logger = Logger.new(output) - FetchFeed.new(daring_fireball, parser: parser, client: client, logger: logger).fetch + FetchFeed.new( + daring_fireball, + parser: parser, + client: client, + logger: logger + ).fetch expect(output.string).to include("Something went wrong") end diff --git a/spec/tasks/fetch_feeds_spec.rb b/spec/tasks/fetch_feeds_spec.rb index 08a3325f7..8070b6988 100644 --- a/spec/tasks/fetch_feeds_spec.rb +++ b/spec/tasks/fetch_feeds_spec.rb @@ -23,7 +23,8 @@ it "finds feeds when run after a delay" do allow(pool).to receive(:process).and_yield allow(FetchFeed).to receive(:new).and_return(fetcher_one, fetcher_two) - expect(FeedRepository).to receive(:fetch_by_ids).with(feeds.map(&:id)).and_return(feeds) + expect(FeedRepository) + .to receive(:fetch_by_ids).with(feeds.map(&:id)).and_return(feeds) expect(fetcher_one).to receive(:fetch).once expect(fetcher_two).to receive(:fetch).once diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index e038ce10b..671e3e45f 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -20,7 +20,8 @@ it "should request deletion of all old stories" do allow(RemoveOldStories).to receive(:pruned_feeds) { [] } - allow(StoryRepository).to receive(:unstarred_read_stories_older_than) { stories_mock } + allow(StoryRepository) + .to receive(:unstarred_read_stories_older_than) { stories_mock } expect(stories_mock).to receive(:delete_all) From c6d4324701ab627b059060434f36375f85136d9f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 22:00:55 -0800 Subject: [PATCH 187/779] RuboCop: reduce line length to 89 (#714) --- .rubocop.yml | 2 +- app/fever_api/write_mark_item.rb | 3 ++- app/repositories/story_repository.rb | 3 ++- spec/fever_api_spec.rb | 9 ++++++--- spec/repositories/story_repository_spec.rb | 3 ++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 64a7ed716..8a93a9f45 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 90 + Max: 89 Metrics/BlockLength: Exclude: diff --git a/app/fever_api/write_mark_item.rb b/app/fever_api/write_mark_item.rb index 28346bc08..7a4a563b8 100644 --- a/app/fever_api/write_mark_item.rb +++ b/app/fever_api/write_mark_item.rb @@ -9,7 +9,8 @@ def initialize(options = {}) @read_marker_class = options.fetch(:read_marker_class) { MarkAsRead } @unread_marker_class = options.fetch(:unread_marker_class) { MarkAsUnread } @starred_marker_class = options.fetch(:starred_marker_class) { MarkAsStarred } - @unstarred_marker_class = options.fetch(:unstarred_marker_class) { MarkAsUnstarred } + @unstarred_marker_class = + options.fetch(:unstarred_marker_class) { MarkAsUnstarred } end def call(params = {}) diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 941d2cd3f..f111b9151 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -35,7 +35,8 @@ def self.fetch_unread_by_timestamp(timestamp) end def self.fetch_unread_by_timestamp_and_group(timestamp, group_id) - fetch_unread_by_timestamp(timestamp).joins(:feed).where(feeds: { group_id: group_id }) + fetch_unread_by_timestamp(timestamp) + .joins(:feed).where(feeds: { group_id: group_id }) end def self.fetch_unread_for_feed_by_timestamp(feed_id, timestamp) diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index c2e0d2959..6746e67f3 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -67,7 +67,8 @@ def make_request(extra_headers = {}) it "returns groups and feeds by groups when 'groups' header is provided" do allow(GroupRepository).to receive(:list).and_return([group]) - allow(FeedRepository).to receive_message_chain(:in_group, :order).and_return([feed]) + allow(FeedRepository) + .to receive_message_chain(:in_group, :order).and_return([feed]) make_request(groups: nil) @@ -81,7 +82,8 @@ def make_request(extra_headers = {}) it "returns feeds and feeds by groups when 'feeds' header is provided" do allow(FeedRepository).to receive(:list).and_return([feed]) - allow(FeedRepository).to receive_message_chain(:in_group, :order).and_return([feed]) + allow(FeedRepository) + .to receive_message_chain(:in_group, :order).and_return([feed]) make_request(feeds: nil) @@ -124,7 +126,8 @@ def make_request(extra_headers = {}) end it "returns stories when 'items' header is provided without 'since_id'" do - expect(StoryRepository).to receive(:unread).twice.and_return([story_one, story_two]) + expect(StoryRepository) + .to receive(:unread).twice.and_return([story_one, story_two]) make_request(items: nil) diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index bb50912f0..ca83cfb3d 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -31,7 +31,8 @@ end it "deletes script tags from titles" do - entry = double(title: "n", content: "").as_null_object + entry = double(title: "n", content: "") + .as_null_object allow(StoryRepository).to receive(:normalize_url) expect(Story).to receive(:create).with(hash_including(title: "n")) From 0cd1646f6b4526bf90878332fc72e1be68e4fa2f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 22:17:32 -0800 Subject: [PATCH 188/779] RuboCop: reduce line length to 88 (#715) --- .rubocop.yml | 2 +- app/fever_api/read_feeds_groups.rb | 3 ++- spec/commands/find_new_stories_spec.rb | 12 ++++++++++-- spec/fever_api/read_feeds_spec.rb | 6 +++++- spec/tasks/fetch_feed_spec.rb | 14 ++++++++++++-- spec/tasks/remove_old_stories_spec.rb | 5 ++++- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8a93a9f45..1f497fe7d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 89 + Max: 88 Metrics/BlockLength: Exclude: diff --git a/app/fever_api/read_feeds_groups.rb b/app/fever_api/read_feeds_groups.rb index 6e6513b47..13cec3b93 100644 --- a/app/fever_api/read_feeds_groups.rb +++ b/app/fever_api/read_feeds_groups.rb @@ -17,7 +17,8 @@ def call(params = {}) private def feeds_groups - grouped_feeds = @feed_repository.in_group.order("LOWER(name)").group_by(&:group_id) + grouped_feeds = + @feed_repository.in_group.order("LOWER(name)").group_by(&:group_id) grouped_feeds.map do |group_id, feeds| { group_id: group_id, diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index 41cce2054..0fdccf4a2 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -39,7 +39,12 @@ old_story = double(published: nil, id: "old-story") feed = double(last_modified: nil, entries: [new_story, old_story]) - result = FindNewStories.new(feed, 1, Time.new(2013, 1, 3), "old-story").new_stories + result = FindNewStories.new( + feed, + 1, + Time.new(2013, 1, 3), + "old-story" + ).new_stories expect(result).to eq [new_story] end @@ -54,7 +59,10 @@ double(published: 4.days.ago, id: "new-story") ] - feed = double(last_modified: nil, entries: new_stories + stories_older_than_3_days) + feed = double( + last_modified: nil, + entries: new_stories + stories_older_than_3_days + ) result = FindNewStories.new(feed, 1, nil, nil).new_stories expect(result).not_to include(stories_older_than_3_days) diff --git a/spec/fever_api/read_feeds_spec.rb b/spec/fever_api/read_feeds_spec.rb index e09fa0ab7..3b0c36998 100644 --- a/spec/fever_api/read_feeds_spec.rb +++ b/spec/fever_api/read_feeds_spec.rb @@ -4,7 +4,11 @@ describe FeverAPI::ReadFeeds do let(:feed_ids) { [5, 7, 11] } - let(:feeds) { feed_ids.map { |id| double("feed", id: id, as_fever_json: { id: id }) } } + let(:feeds) do + feed_ids.map do |id| + double("feed", id: id, as_fever_json: { id: id }) + end + end let(:feed_repository) { double("repo") } subject do diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 86432b7ba..73950908b 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -25,7 +25,12 @@ expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser: parser, client: client, logger: nil).fetch + FetchFeed.new( + daring_fireball, + parser: parser, + client: client, + logger: nil + ).fetch end it "logs a message" do @@ -110,7 +115,12 @@ expect(FeedRepository).to receive(:set_status) .with(:red, daring_fireball) - FetchFeed.new(daring_fireball, parser: parser, client: client, logger: nil).fetch + FetchFeed.new( + daring_fireball, + parser: parser, + client: client, + logger: nil + ).fetch end it "outputs a message when things go wrong" do diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index 671e3e45f..f9ba2e35d 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -45,7 +45,10 @@ allow(RemoveOldStories).to receive(:pruned_feeds) { feeds } allow(RemoveOldStories).to receive(:old_stories) { stories_mock } - expect(FeedRepository).to receive(:update_last_fetched).with(feeds.first, anything) + expect(FeedRepository).to receive(:update_last_fetched).with( + feeds.first, + anything + ) expect(FeedRepository).to receive(:update_last_fetched).with(feeds.last, anything) RemoveOldStories.remove!(13) From 03c7f4159694d4668ed493c20095cf70dfce6df8 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 22:27:26 -0800 Subject: [PATCH 189/779] RuboCop: reduce line length to 87 (#716) --- .rubocop.yml | 2 +- app.rb | 3 ++- app/tasks/fetch_feed.rb | 7 ++++++- ...0805113712_update_stories_unique_constraints.rb | 5 ++++- spec/controllers/exports_controller_spec.rb | 14 +++++++++++--- spec/fever_api/read_feeds_groups_spec.rb | 6 ++++-- spec/tasks/remove_old_stories_spec.rb | 9 ++++----- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1f497fe7d..98d051a3c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 88 + Max: 87 Metrics/BlockLength: Exclude: diff --git a/app.rb b/app.rb index 8b4557e5c..4baa6c30a 100644 --- a/app.rb +++ b/app.rb @@ -31,7 +31,8 @@ def self.application end end -I18n.load_path += Dir[File.join(File.dirname(__FILE__), "config/locales", "*.yml").to_s] +I18n.load_path += + Dir[File.join(File.dirname(__FILE__), "config/locales", "*.yml").to_s] I18n.config.enforce_available_locales = false Time.zone = ENV.fetch("TZ", "UTC") diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index c683823e3..49d982421 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -49,7 +49,12 @@ def feed_modified(raw_feed) end def new_entries_from(raw_feed) - finder = FindNewStories.new(raw_feed, @feed.id, @feed.last_fetched, latest_entry_id) + finder = FindNewStories.new( + raw_feed, + @feed.id, + @feed.last_fetched, + latest_entry_id + ) finder.new_stories end diff --git a/db/migrate/20130805113712_update_stories_unique_constraints.rb b/db/migrate/20130805113712_update_stories_unique_constraints.rb index 53ec20b71..b18812948 100644 --- a/db/migrate/20130805113712_update_stories_unique_constraints.rb +++ b/db/migrate/20130805113712_update_stories_unique_constraints.rb @@ -6,6 +6,9 @@ def up def down remove_index :stories, [:entry_id, :feed_id] - add_index :stories, [:permalink, :feed_id], unique: true, length: { permalink: 767 } + add_index :stories, + [:permalink, :feed_id], + unique: true, + length: { permalink: 767 } end end diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb index f4f0016be..44cad0ed2 100644 --- a/spec/controllers/exports_controller_spec.rb +++ b/spec/controllers/exports_controller_spec.rb @@ -15,14 +15,22 @@ expect(last_response.body).to eq some_xml end - it "responds with OPML headers" do + it "responds with xml content type" do expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) get "/feeds/export" expect(last_response.header["Content-Type"]).to include "application/xml" - expect(last_response.header["Content-Disposition"]) - .to eq("attachment; filename=\"stringer.opml\"; filename*=UTF-8''stringer.opml") + end + + it "responds with disposition attachment" do + expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) + + get "/feeds/export" + + expected_disposition = + "attachment; filename=\"stringer.opml\"; filename*=UTF-8''stringer.opml" + expect(last_response.header["Content-Disposition"]).to eq(expected_disposition) end end end diff --git a/spec/fever_api/read_feeds_groups_spec.rb b/spec/fever_api/read_feeds_groups_spec.rb index 7da9707de..81204fc3a 100644 --- a/spec/fever_api/read_feeds_groups_spec.rb +++ b/spec/fever_api/read_feeds_groups_spec.rb @@ -12,7 +12,8 @@ end it "returns a list of groups requested through feeds" do - allow(feed_repository).to receive_message_chain(:in_group, :order).and_return(feeds) + allow(feed_repository) + .to receive_message_chain(:in_group, :order).and_return(feeds) expect(subject.call("feeds" => nil)).to eq( feeds_groups: [ @@ -25,7 +26,8 @@ end it "returns a list of groups requested through groups" do - allow(feed_repository).to receive_message_chain(:in_group, :order).and_return(feeds) + allow(feed_repository) + .to receive_message_chain(:in_group, :order).and_return(feeds) expect(subject.call("groups" => nil)).to eq( feeds_groups: [ diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index f9ba2e35d..cca650096 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -45,11 +45,10 @@ allow(RemoveOldStories).to receive(:pruned_feeds) { feeds } allow(RemoveOldStories).to receive(:old_stories) { stories_mock } - expect(FeedRepository).to receive(:update_last_fetched).with( - feeds.first, - anything - ) - expect(FeedRepository).to receive(:update_last_fetched).with(feeds.last, anything) + expect(FeedRepository) + .to receive(:update_last_fetched).with(feeds.first, anything) + expect(FeedRepository) + .to receive(:update_last_fetched).with(feeds.last, anything) RemoveOldStories.remove!(13) end From 97f4008934bf9967dbe3ec901ade7ad244b7dc22 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 22:32:21 -0800 Subject: [PATCH 190/779] RuboCop: reduce line length to 86 (#717) --- .rubocop.yml | 2 +- app/tasks/fetch_feed.rb | 7 ++++++- ...30805113712_update_stories_unique_constraints.rb | 5 ++++- spec/commands/find_new_stories_spec.rb | 3 ++- spec/controllers/feeds_controller_spec.rb | 5 +++-- spec/factories/feed_factory.rb | 13 +++++++------ spec/integration/feed_importing_spec.rb | 3 ++- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 98d051a3c..562ce3a6e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 87 + Max: 86 Metrics/BlockLength: Exclude: diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index 49d982421..aed06a496 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -6,7 +6,12 @@ require_relative "../commands/feeds/find_new_stories" class FetchFeed - def initialize(feed, parser: Feedjira, client: HTTParty, logger: Logger.new($stdout)) + def initialize( + feed, + parser: Feedjira, + client: HTTParty, + logger: Logger.new($stdout) + ) @feed = feed @parser = parser @client = client diff --git a/db/migrate/20130805113712_update_stories_unique_constraints.rb b/db/migrate/20130805113712_update_stories_unique_constraints.rb index b18812948..2c320babb 100644 --- a/db/migrate/20130805113712_update_stories_unique_constraints.rb +++ b/db/migrate/20130805113712_update_stories_unique_constraints.rb @@ -1,7 +1,10 @@ class UpdateStoriesUniqueConstraints < ActiveRecord::Migration[4.2] def up remove_index :stories, [:permalink, :feed_id] - add_index :stories, [:entry_id, :feed_id], unique: true, length: { permalink: 767 } + add_index :stories, + [:entry_id, :feed_id], + unique: true, + length: { permalink: 767 } end def down diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index 0fdccf4a2..0d5edbb85 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -27,7 +27,8 @@ feed = double(entries: [story1, story2]) allow(StoryRepository).to receive(:exists?).with("story1", 1).and_return(true) - allow(StoryRepository).to receive(:exists?).with("story2", 1).and_return(false) + allow(StoryRepository) + .to receive(:exists?).with("story2", 1).and_return(false) result = FindNewStories.new(feed, 1, Time.new(2013, 1, 2)).new_stories expect(result).to eq [story2] diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 80290eb8d..f8771ae3a 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -55,10 +55,11 @@ def params(feed, **overrides) describe "PUT /feeds/:feed_id" do it "updates a feed given the id" do - feed = FeedFactory.build(url: "example.com/atom") + feed = FeedFactory.build(url: "example.com/atom", id: "12", group_id: nil) mock_feed(feed, "Test", "example.com/feed") - put "/feeds/123", feed_id: "123", feed_name: "Test", feed_url: "example.com/feed" + feed_url = "example.com/feed" + put "/feeds/123", **params(feed, feed_name: "Test", feed_url:) expect(last_response).to be_redirect end diff --git a/spec/factories/feed_factory.rb b/spec/factories/feed_factory.rb index 3c64ab1ef..3355d2374 100644 --- a/spec/factories/feed_factory.rb +++ b/spec/factories/feed_factory.rb @@ -16,12 +16,13 @@ def as_fever_json def self.build(params = {}) FakeFeed.new( id: rand(100), - group_id: params[:group_id] || rand(100), - name: params[:name] || Faker::Name.name + " on Software", # rubocop:disable Style/StringConcatenation - url: params[:url] || Faker::Internet.url, - last_fetched: params[:last_fetched] || Time.now, - stories: params[:stories] || [], - unread_stories: [] + group_id: rand(100), + name: Faker::Name.name + " on Software", # rubocop:disable Style/StringConcatenation + url: Faker::Internet.url, + last_fetched: Time.now, + stories: [], + unread_stories: [], + **params ) end end diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index d1abbb14f..636f13df9 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -72,7 +72,8 @@ # was published. feed.last_fetched = Time.parse("2014-08-12T00:01:00Z") - @server.response = sample_data("feeds/feed02_invalid_published_dates/feed.xml") + @server.response = + sample_data("feeds/feed02_invalid_published_dates/feed.xml") expect { fetch_feed(feed) }.to change { feed.stories.count }.by(1) end From fadd0b07374c82b7980b03dd53d71948b94e5b70 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 22:37:54 -0800 Subject: [PATCH 191/779] RuboCop: reduce line length to 85 (#719) --- .rubocop.yml | 2 +- spec/commands/find_new_stories_spec.rb | 3 ++- spec/fever_api/write_mark_group_spec.rb | 3 ++- spec/repositories/story_repository_spec.rb | 10 ++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 562ce3a6e..37b794ec3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 86 + Max: 85 Metrics/BlockLength: Exclude: diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index 0d5edbb85..c0992e592 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -26,7 +26,8 @@ story2 = double(published: nil, id: "story2") feed = double(entries: [story1, story2]) - allow(StoryRepository).to receive(:exists?).with("story1", 1).and_return(true) + allow(StoryRepository) + .to receive(:exists?).with("story1", 1).and_return(true) allow(StoryRepository) .to receive(:exists?).with("story2", 1).and_return(false) diff --git a/spec/fever_api/write_mark_group_spec.rb b/spec/fever_api/write_mark_group_spec.rb index 1262f048c..91044ea56 100644 --- a/spec/fever_api/write_mark_group_spec.rb +++ b/spec/fever_api/write_mark_group_spec.rb @@ -11,7 +11,8 @@ end it "instantiates a group marker and calls mark_group_as_read if requested" do - expect(marker_class).to receive(:new).with(5, 1234567890).and_return(group_marker) + expect(marker_class) + .to receive(:new).with(5, 1234567890).and_return(group_marker) expect(group_marker).to receive(:mark_group_as_read) expect(subject.call(mark: "group", id: 5, before: 1234567890)).to eq({}) end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index ca83cfb3d..b2d0c7d15 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -481,13 +481,11 @@ end it "ignores URL expansion if entry url is nil" do - entry = double( - url: nil, - content: nil, - summary: "Page" - ) + entry = + double(url: nil, content: nil, summary: "Page") - expect(StoryRepository.extract_content(entry)).to eq "Page" + expect(StoryRepository.extract_content(entry)) + .to eq "Page" end end end From 8468b690c3988e84f2dcc691c9cf26a0705a21a9 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 22:46:44 -0800 Subject: [PATCH 192/779] RuboCop: reduce line length to 84 (#720) --- .rubocop.yml | 2 +- app/commands/feeds/import_from_opml.rb | 9 +++++---- app/repositories/story_repository.rb | 4 ++-- spec/controllers/exports_controller_spec.rb | 4 ++-- spec/fever_api/write_mark_feed_spec.rb | 3 ++- spec/fever_api/write_mark_item_spec.rb | 8 ++++---- spec/fever_api_spec.rb | 4 ++-- spec/tasks/fetch_feed_spec.rb | 17 +++++++++++++---- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 37b794ec3..38514ceb2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 85 + Max: 84 Metrics/BlockLength: Exclude: diff --git a/app/commands/feeds/import_from_opml.rb b/app/commands/feeds/import_from_opml.rb index b0133e20e..a0d911cc8 100644 --- a/app/commands/feeds/import_from_opml.rb +++ b/app/commands/feeds/import_from_opml.rb @@ -9,10 +9,11 @@ class << self def import(opml_contents) feeds_with_groups = OpmlParser.new.parse_feeds(opml_contents) - # It considers a situation when feeds are already imported without groups, - # so it's possible to re-import the same subscriptions.xml just to set group_id - # for existing feeds. Feeds without groups are in 'Ungrouped' group, we don't - # create such group and create such feeds with group_id = nil. + # It considers a situation when feeds are already imported without + # groups, so it's possible to re-import the same subscriptions.xml just + # to set group_id for existing feeds. Feeds without groups are in + # 'Ungrouped' group, we don't create such group and create such feeds + # with group_id = nil. feeds_with_groups.each do |group_name, parsed_feeds| unless group_name == "Ungrouped" group = Group.where(name: group_name).first_or_create diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index f111b9151..b6d8a7e47 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -90,9 +90,9 @@ def self.read_count end def self.extract_url(entry, feed) - return entry.enclosure_url if entry.url.nil? && entry.respond_to?(:enclosure_url) + return normalize_url(entry.url, feed.url) if entry.url.present? - normalize_url(entry.url, feed.url) unless entry.url.nil? + entry.enclosure_url if entry.respond_to?(:enclosure_url) end def self.extract_content(entry) diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb index 44cad0ed2..e6539c7d8 100644 --- a/spec/controllers/exports_controller_spec.rb +++ b/spec/controllers/exports_controller_spec.rb @@ -28,9 +28,9 @@ get "/feeds/export" - expected_disposition = + expected = "attachment; filename=\"stringer.opml\"; filename*=UTF-8''stringer.opml" - expect(last_response.header["Content-Disposition"]).to eq(expected_disposition) + expect(last_response.header["Content-Disposition"]).to eq(expected) end end end diff --git a/spec/fever_api/write_mark_feed_spec.rb b/spec/fever_api/write_mark_feed_spec.rb index 793112034..65efde1d8 100644 --- a/spec/fever_api/write_mark_feed_spec.rb +++ b/spec/fever_api/write_mark_feed_spec.rb @@ -11,7 +11,8 @@ end it "instantiates a feed marker and calls mark_feed_as_read if requested" do - expect(marker_class).to receive(:new).with(5, 1234567890).and_return(feed_marker) + expect(marker_class) + .to receive(:new).with(5, 1234567890).and_return(feed_marker) expect(feed_marker).to receive(:mark_feed_as_read) expect(subject.call(mark: "feed", id: 5, before: 1234567890)).to eq({}) end diff --git a/spec/fever_api/write_mark_item_spec.rb b/spec/fever_api/write_mark_item_spec.rb index ef70c519f..483d2eba9 100644 --- a/spec/fever_api/write_mark_item_spec.rb +++ b/spec/fever_api/write_mark_item_spec.rb @@ -11,7 +11,7 @@ FeverAPI::WriteMarkItem.new(read_marker_class: marker_class) end - it "instantiates an item marker and calls mark_item_as_read if requested" do + it "calls mark_item_as_read if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) expect(item_marker).to receive(:mark_as_read) expect(subject.call(mark: "item", as: "read", id: 5)).to eq({}) @@ -23,7 +23,7 @@ FeverAPI::WriteMarkItem.new(unread_marker_class: marker_class) end - it "instantiates an item marker and calls mark_item_as_unread if requested" do + it "calls mark_item_as_unread if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) expect(item_marker).to receive(:mark_as_unread) expect(subject.call(mark: "item", as: "unread", id: 5)).to eq({}) @@ -35,7 +35,7 @@ FeverAPI::WriteMarkItem.new(starred_marker_class: marker_class) end - it "instantiates an item marker and calls mark_item_as_starred if requested" do + it "calls mark_item_as_starred if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) expect(item_marker).to receive(:mark_as_starred) expect(subject.call(mark: "item", as: "saved", id: 5)).to eq({}) @@ -47,7 +47,7 @@ FeverAPI::WriteMarkItem.new(unstarred_marker_class: marker_class) end - it "instantiates an item marker and calls mark_item_as_unstarred if requested" do + it "calls marks_item_as_unstarred if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) expect(item_marker).to receive(:mark_as_unstarred) expect(subject.call(mark: "item", as: "unsaved", id: 5)).to eq({}) diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 6746e67f3..3071a873a 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -110,7 +110,7 @@ def make_request(extra_headers = {}) ) end - it "returns stories when 'items' header is provided along with 'since_id'" do + it "returns stories when 'items' and 'since_id'" do expect(StoryRepository) .to receive(:unread_since_id).with("5").and_return([story_one]) expect(StoryRepository).to receive(:unread).and_return([story_one, story_two]) @@ -139,7 +139,7 @@ def make_request(extra_headers = {}) ) end - it "returns stories ids when 'items' header is provided along with 'with_ids'" do + it "returns stories ids when 'items' and 'with_ids'" do expect(StoryRepository) .to receive(:fetch_by_ids).twice.with(["5"]).and_return([story_one]) diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 73950908b..6d99204f0 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -39,7 +39,12 @@ output = StringIO.new logger = Logger.new(output) - FetchFeed.new(daring_fireball, parser: parser, client: client, logger:).fetch + FetchFeed.new( + daring_fireball, + parser: parser, + client: client, + logger: + ).fetch expect(output.string).to include("has not been modified") end @@ -51,7 +56,8 @@ client = class_spy(HTTParty) parser = class_double(Feedjira, parse: fake_feed) - allow_any_instance_of(FindNewStories).to receive(:new_stories).and_return([]) + allow_any_instance_of(FindNewStories) + .to receive(:new_stories).and_return([]) expect(StoryRepository).not_to receive(:add) @@ -64,7 +70,9 @@ let(:new_story) { double } let(:old_story) { double } - let(:fake_feed) { double(last_modified: now, entries: [new_story, old_story]) } + let(:fake_feed) do + double(last_modified: now, entries: [new_story, old_story]) + end let(:fake_client) { class_spy(HTTParty) } let(:fake_parser) { class_double(Feedjira, parse: fake_feed) } @@ -75,7 +83,8 @@ it "should only add posts that are new" do expect(StoryRepository).to receive(:add).with(new_story, daring_fireball) - expect(StoryRepository).not_to receive(:add).with(old_story, daring_fireball) + expect(StoryRepository) + .not_to receive(:add).with(old_story, daring_fireball) FetchFeed.new( daring_fireball, From 020975bf34ff789fe059744d9b4ae632765157a6 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 22:56:57 -0800 Subject: [PATCH 193/779] RuboCop: reduce line length to 83 (#721) --- .rubocop.yml | 2 +- app/fever_api/write_mark_item.rb | 3 ++- spec/controllers/debug_controller_spec.rb | 3 ++- spec/fever_api_spec.rb | 14 ++++++-------- spec/helpers/url_helpers_spec.rb | 15 ++++++++------- spec/integration/feed_importing_spec.rb | 3 ++- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 38514ceb2..2726a0ac7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 84 + Max: 83 Metrics/BlockLength: Exclude: diff --git a/app/fever_api/write_mark_item.rb b/app/fever_api/write_mark_item.rb index 7a4a563b8..0ac82c1b4 100644 --- a/app/fever_api/write_mark_item.rb +++ b/app/fever_api/write_mark_item.rb @@ -8,7 +8,8 @@ class WriteMarkItem def initialize(options = {}) @read_marker_class = options.fetch(:read_marker_class) { MarkAsRead } @unread_marker_class = options.fetch(:unread_marker_class) { MarkAsUnread } - @starred_marker_class = options.fetch(:starred_marker_class) { MarkAsStarred } + @starred_marker_class = + options.fetch(:starred_marker_class) { MarkAsStarred } @unstarred_marker_class = options.fetch(:unstarred_marker_class) { MarkAsUnstarred } end diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index 937ea10d5..d5cae8cbc 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -15,7 +15,8 @@ .to receive(:pending_migrations) .and_return(["Migration B - 2", "Migration C - 3"]) migration_status = double "MigrationStatus" - allow(migration_status).to receive(:new).and_return(migration_status_instance) + allow(migration_status) + .to receive(:new).and_return(migration_status_instance) stub_const("MigrationStatus", migration_status) end diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 3071a873a..4c3bef019 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -113,7 +113,8 @@ def make_request(extra_headers = {}) it "returns stories when 'items' and 'since_id'" do expect(StoryRepository) .to receive(:unread_since_id).with("5").and_return([story_one]) - expect(StoryRepository).to receive(:unread).and_return([story_one, story_two]) + expect(StoryRepository) + .to receive(:unread).and_return([story_one, story_two]) make_request(items: nil, since_id: 5) @@ -162,7 +163,8 @@ def make_request(extra_headers = {}) end it "returns unread items ids when 'unread_item_ids' header is provided" do - expect(StoryRepository).to receive(:unread).and_return([story_one, story_two]) + expect(StoryRepository) + .to receive(:unread).and_return([story_one, story_two]) make_request(unread_item_ids: nil) @@ -174,12 +176,8 @@ def make_request(extra_headers = {}) end it "returns starred items when 'saved_item_ids' header is provided" do - expect(Story).to receive(:where).with(is_starred: true).and_return( - [ - story_one, - story_two - ] - ) + expect(Story).to receive(:where).with(is_starred: true) + .and_return([story_one, story_two]) make_request(saved_item_ids: nil) diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index 27a044ed1..e49fc7ebe 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -60,13 +60,14 @@ class Helper # rubocop:disable Lint/ConstantDefinitionInBlock end it "leaves the url as-is if it cannot be parsed" do - weird_url = "https://github.com/aphyr/jepsen/blob/" \ - "1403f2d6e61c595bafede0d404fd4a893371c036/" \ - "elasticsearch/src/jepsen/system/elasticsearch.clj#" \ - "L161-L226.%20Then%20we'll%20write%20a%20%5Bregister%20test%5D(" \ - "https://github.com/aphyr/jepsen/blob/" \ - "1403f2d6e61c595bafede0d404fd4a893371c036/" \ - "elasticsearch/test/jepsen/system/elasticsearch_test.clj#L18-L50)" + weird_url = + "https://github.com/aphyr/jepsen/blob/" \ + "1403f2d6e61c595bafede0d404fd4a893371c036/" \ + "elasticsearch/src/jepsen/system/elasticsearch.clj#" \ + "L161-L226.%20Then%20we'll%20write%20a%20%5Bregister%20test%5D(" \ + "https://github.com/aphyr/jepsen/blob/" \ + "1403f2d6e61c595bafede0d404fd4a893371c036/" \ + "elasticsearch/test/jepsen/system/elasticsearch_test.clj#L18-L50)" content = "" diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index 636f13df9..f7d99df80 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -48,7 +48,8 @@ context "new entries" do it "creates new stories" do - @server.response = sample_data("feeds/feed01_valid_feed/feed_updated.xml") + @server.response = + sample_data("feeds/feed01_valid_feed/feed_updated.xml") expect { fetch_feed(feed) }.to change(feed.stories, :count).by(1) end end From 8d2391b66fa722c3ae1d0c5778b27ea68d798aac Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 23:01:06 -0800 Subject: [PATCH 194/779] RuboCop: reduce line length to 82 (#722) --- .rubocop.yml | 2 +- app/tasks/change_password.rb | 2 +- spec/commands/feeds/add_new_feed_spec.rb | 5 ++++- spec/controllers/exports_controller_spec.rb | 11 ++++++++--- spec/controllers/feeds_controller_spec.rb | 10 ++++++++-- spec/repositories/feed_repository_spec.rb | 2 +- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2726a0ac7..ef47d19d2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 83 + Max: 82 Metrics/BlockLength: Exclude: diff --git a/app/tasks/change_password.rb b/app/tasks/change_password.rb index 585ba3f1d..a038f5ec5 100644 --- a/app/tasks/change_password.rb +++ b/app/tasks/change_password.rb @@ -11,7 +11,7 @@ def initialize(command = ChangeUserPassword.new, output: $stdout, input: $stdin) def change_password while (password = ask_password) != ask_confirmation - @output.puts "The confirmation doesn't match the password. Please try again." + @output.puts I18n.t("first_run.flash.passwords_dont_match") end @command.change_user_password(password) end diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 54526730d..3cc19ee65 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -30,7 +30,10 @@ context "title includes a script tag" do let(:feed_result) do - double(title: "foobar", feed_url: feed.url) + double( + title: "foobar", + feed_url: feed.url + ) end it "deletes the script tag from the title" do diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb index e6539c7d8..f94891239 100644 --- a/spec/controllers/exports_controller_spec.rb +++ b/spec/controllers/exports_controller_spec.rb @@ -7,8 +7,13 @@ let(:some_xml) { "some dummy opml" } before { allow(Feed).to receive(:all) } + def mock_export + expect_any_instance_of(ExportToOpml) + .to receive(:to_xml).and_return(some_xml) + end + it "returns an OPML file" do - expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) + mock_export get "/feeds/export" @@ -16,7 +21,7 @@ end it "responds with xml content type" do - expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) + mock_export get "/feeds/export" @@ -24,7 +29,7 @@ end it "responds with disposition attachment" do - expect_any_instance_of(ExportToOpml).to receive(:to_xml).and_return(some_xml) + mock_export get "/feeds/export" diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index f8771ae3a..e070f07c3 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -40,7 +40,12 @@ def mock_feed(feed, name, url, group_id = nil) expect(FeedRepository).to receive(:fetch).with("123").and_return(feed) - expect(FeedRepository).to receive(:update_feed).with(feed, name, url, group_id) + expect(FeedRepository).to receive(:update_feed).with( + feed, + name, + url, + group_id + ) end def params(feed, **overrides) @@ -126,7 +131,8 @@ def params(feed, **overrides) let(:invalid_feed) { double(valid?: false) } it "adds the feed and queues it to be fetched" do - expect(AddNewFeed).to receive(:add).with(feed_url).and_return(invalid_feed) + expect(AddNewFeed) + .to receive(:add).with(feed_url).and_return(invalid_feed) post("/feeds", feed_url:) diff --git a/spec/repositories/feed_repository_spec.rb b/spec/repositories/feed_repository_spec.rb index 75ab32846..e67bcfc03 100644 --- a/spec/repositories/feed_repository_spec.rb +++ b/spec/repositories/feed_repository_spec.rb @@ -68,7 +68,7 @@ expect(feed.last_fetched).to eq timestamp end - it "doesn't update if timestamp is nil (feed does not report last modified)" do + it "doesn't update if timestamp is nil" do feed = Feed.new(last_fetched: timestamp) FeedRepository.update_last_fetched(feed, nil) From 0a3ed12562f22d114f9a7623d37782a0b887324f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 23:05:35 -0800 Subject: [PATCH 195/779] RuboCop: reduce line length to 81 (#723) --- .rubocop.yml | 2 +- app/tasks/change_password.rb | 6 +++++- config/puma.rb | 3 ++- spec/commands/users/create_user_spec.rb | 2 +- spec/fever_api/read_groups_spec.rb | 4 +++- spec/repositories/story_repository_spec.rb | 9 ++++++--- spec/tasks/remove_old_stories_spec.rb | 3 ++- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ef47d19d2..03f17941d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 82 + Max: 81 Metrics/BlockLength: Exclude: diff --git a/app/tasks/change_password.rb b/app/tasks/change_password.rb index a038f5ec5..0a16acbfe 100644 --- a/app/tasks/change_password.rb +++ b/app/tasks/change_password.rb @@ -3,7 +3,11 @@ require_relative "../commands/users/change_user_password" class ChangePassword - def initialize(command = ChangeUserPassword.new, output: $stdout, input: $stdin) + def initialize( + command = ChangeUserPassword.new, + output: $stdout, + input: $stdin + ) @command = command @output = output @input = input diff --git a/config/puma.rb b/config/puma.rb index 24fa3537c..dd0037c77 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -26,7 +26,8 @@ on_worker_boot do if defined?(ActiveRecord::Base) env = ENV["RACK_ENV"] || "development" - config = YAML.safe_load(ERB.new(File.read("config/database.yml")).result)[env] + config = + YAML.safe_load(ERB.new(File.read("config/database.yml")).result)[env] ActiveRecord::Base.establish_connection(config) end end diff --git a/spec/commands/users/create_user_spec.rb b/spec/commands/users/create_user_spec.rb index ffbcc5133..189f44900 100644 --- a/spec/commands/users/create_user_spec.rb +++ b/spec/commands/users/create_user_spec.rb @@ -6,7 +6,7 @@ let(:repo) { double } describe "#create" do - it "remove any existing users and create a user with the password supplied" do + it "removes existing users and create a user with the password supplied" do command = CreateUser.new(repo) expect(repo).to receive(:create) diff --git a/spec/fever_api/read_groups_spec.rb b/spec/fever_api/read_groups_spec.rb index 6c5bbf33d..6adc080ff 100644 --- a/spec/fever_api/read_groups_spec.rb +++ b/spec/fever_api/read_groups_spec.rb @@ -4,7 +4,9 @@ describe FeverAPI::ReadGroups do let(:group1) { double("group1", as_fever_json: { id: 1, title: "IT news" }) } - let(:group2) { double("group2", as_fever_json: { id: 2, title: "World news" }) } + let(:group2) do + double("group2", as_fever_json: { id: 2, title: "World news" }) + end let(:group_repository) { double("repo") } subject { FeverAPI::ReadGroups.new(group_repository: group_repository) } diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index b2d0c7d15..0babe6f70 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -16,7 +16,8 @@ title: "", content: "" ).as_null_object - expect(StoryRepository).to receive(:normalize_url).with(entry.url, feed.url) + expect(StoryRepository) + .to receive(:normalize_url).with(entry.url, feed.url) StoryRepository.add(entry, feed) end @@ -461,7 +462,8 @@ end it "falls back to summary if there is no content" do - expect(StoryRepository.extract_content(summary_only)).to eq "Dumb publisher" + expect(StoryRepository.extract_content(summary_only)) + .to eq "Dumb publisher" end it "returns empty string if there is no content or summary" do @@ -477,7 +479,8 @@ summary: "Page" ) - expect(StoryRepository.extract_content(entry)).to eq "Page" + expect(StoryRepository.extract_content(entry)) + .to eq "Page" end it "ignores URL expansion if entry url is nil" do diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index cca650096..2bba7bc47 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -35,7 +35,8 @@ stories end - expect(FeedRepository).to receive(:fetch_by_ids).with([3, 5]).and_return([]) + expect(FeedRepository) + .to receive(:fetch_by_ids).with([3, 5]).and_return([]) RemoveOldStories.remove!(13) end From 83ea265bc4e5710823ecc7e19cf5d7255bdc37b8 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 18 Dec 2022 23:11:37 -0800 Subject: [PATCH 196/779] RuboCop: reduce line length to 80 (#724) --- .rubocop.yml | 2 +- app/fever_api/write_mark_item.rb | 5 ++++- app/models/migration_status.rb | 4 ++-- config/asset_pipeline.rb | 14 ++++++++++++-- spec/commands/feeds/import_from_opml_spec.rb | 7 ++++++- spec/controllers/feeds_controller_spec.rb | 6 +++--- spec/repositories/story_repository_spec.rb | 3 ++- spec/tasks/fetch_feed_spec.rb | 5 ++++- spec/utils/content_sanitizer_spec.rb | 7 ++++++- 9 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 03f17941d..4bba0aa0d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: - Max: 81 + Max: 80 Metrics/BlockLength: Exclude: diff --git a/app/fever_api/write_mark_item.rb b/app/fever_api/write_mark_item.rb index 0ac82c1b4..fe18a78b4 100644 --- a/app/fever_api/write_mark_item.rb +++ b/app/fever_api/write_mark_item.rb @@ -7,7 +7,10 @@ module FeverAPI class WriteMarkItem def initialize(options = {}) @read_marker_class = options.fetch(:read_marker_class) { MarkAsRead } - @unread_marker_class = options.fetch(:unread_marker_class) { MarkAsUnread } + @unread_marker_class = + options.fetch(:unread_marker_class) do + MarkAsUnread + end @starred_marker_class = options.fetch(:starred_marker_class) { MarkAsStarred } @unstarred_marker_class = diff --git a/app/models/migration_status.rb b/app/models/migration_status.rb index 6c4d3dc41..a358ad49d 100644 --- a/app/models/migration_status.rb +++ b/app/models/migration_status.rb @@ -1,8 +1,8 @@ class MigrationStatus attr_reader :migrator - def initialize(migrator = ActiveRecord::Base.connection.migration_context.open) - @migrator = migrator + def initialize(migrator = nil) + @migrator = migrator || ActiveRecord::Base.connection.migration_context.open end def pending_migrations diff --git a/config/asset_pipeline.rb b/config/asset_pipeline.rb index 914008343..32f2b2a83 100644 --- a/config/asset_pipeline.rb +++ b/config/asset_pipeline.rb @@ -19,8 +19,18 @@ def registered(app) def append_paths(app) app.sprockets.append_path File.join(app.root, "app", "assets") - app.sprockets.append_path File.join(app.root, "app", "assets", "stylesheets") - app.sprockets.append_path File.join(app.root, "app", "assets", "javascripts") + app.sprockets.append_path File.join( + app.root, + "app", + "assets", + "stylesheets" + ) + app.sprockets.append_path File.join( + app.root, + "app", + "assets", + "javascripts" + ) end def configure_development(app) diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index be2e7a9e4..8a3386b1d 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -4,7 +4,12 @@ describe ImportFromOpml do let(:subscriptions) do - File.open(File.expand_path("../../support/files/subscriptions.xml", __dir__)) + File.open( + File.expand_path( + "../../support/files/subscriptions.xml", + __dir__ + ) + ) end def import diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index e070f07c3..170cb3373 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -100,11 +100,11 @@ def params(feed, **overrides) describe "POST /feeds" do context "when the feed url is valid" do let(:feed_url) { "http://example.com/" } - let(:valid_feed) { double(valid?: true) } + let(:feed) { double(valid?: true) } it "adds the feed and queues it to be fetched" do - expect(AddNewFeed).to receive(:add).with(feed_url).and_return(valid_feed) - expect(FetchFeeds).to receive(:enqueue).with([valid_feed]) + expect(AddNewFeed).to receive(:add).with(feed_url).and_return(feed) + expect(FetchFeeds).to receive(:enqueue).with([feed]) post("/feeds", feed_url:) diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 0babe6f70..d45af9afe 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -361,7 +361,8 @@ it "returns unstarred read stories older than given number of days" do story = create_story(:read, published: 6.days.ago) - expect(StoryRepository.unstarred_read_stories_older_than(5)).to eq([story]) + expect(StoryRepository.unstarred_read_stories_older_than(5)) + .to eq([story]) end it "does not return starred stories older than the given number of days" do diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 6d99204f0..a5bc4d88b 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -82,7 +82,10 @@ end it "should only add posts that are new" do - expect(StoryRepository).to receive(:add).with(new_story, daring_fireball) + expect(StoryRepository).to receive(:add).with( + new_story, + daring_fireball + ) expect(StoryRepository) .not_to receive(:add).with(old_story, daring_fireball) diff --git a/spec/utils/content_sanitizer_spec.rb b/spec/utils/content_sanitizer_spec.rb index 9fd3e18a7..a5056fb12 100644 --- a/spec/utils/content_sanitizer_spec.rb +++ b/spec/utils/content_sanitizer_spec.rb @@ -6,22 +6,27 @@ describe ".sanitize" do context "regressions" do it "handles tag properly" do - result = described_class.sanitize("WM_ERROR asdf") + result = + described_class.sanitize("WM_ERROR asdf") + expect(result).to eq "WM_ERROR asdf" end it "handles
    tag properly" do result = described_class.sanitize("
    some code
    ") + expect(result).to eq "
    some code
    " end it "handles unprintable characters" do result = described_class.sanitize("n\u2028\u2029") + expect(result).to eq "n" end it "preserves line endings" do result = described_class.sanitize("test\r\ncase") + expect(result).to eq "test\r\ncase" end end From da95293c5fa3c24185c1bd1206cac60947640ddf Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 19 Dec 2022 08:50:45 -0800 Subject: [PATCH 197/779] RuboCop: clean up .rubocop.yml (#725) --- .rubocop.yml | 44 ++++-------------- .rubocop_todo.yml | 114 ++++++++++++++++++++-------------------------- 2 files changed, 60 insertions(+), 98 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4bba0aa0d..3fa9fe2e2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,45 +11,18 @@ AllCops: - 'db/schema.rb' - 'vendor/**/*' -Layout/LineLength: - Max: 80 - -Metrics/BlockLength: - Exclude: - - 'spec/**/*_spec.rb' - -Metrics/MethodLength: - Max: 15 - -Style/ConstantVisibility: - Enabled: false - -Style/Copyright: - Enabled: false - -Style/Documentation: - Enabled: false - -Style/DocumentationMethod: - Enabled: false - -Style/DoubleNegation: - Enabled: false - -Style/MissingElse: - Enabled: false - -Style/NumericLiterals: - Enabled: false - -Style/StringLiterals: - EnforcedStyle: double_quotes - +Layout/LineLength: { Max: 80 } +Metrics/BlockLength: { Exclude: ['spec/**/*_spec.rb'] } Style/MethodCallWithArgsParentheses: AllowedMethods: - to - not_to - describe +Style/StringLiterals: { EnforcedStyle: double_quotes } + +# want to enable these, but they don't work right when using `.rubocop_todo.yml` +Style/DocumentationMethod: { Enabled: false } +Style/Documentation: { Enabled: false } ################################################################################ # @@ -63,3 +36,6 @@ RSpec/StubbedMock: { Enabled: false } Style/InlineComment: { Enabled: false } Style/RequireOrder: { Enabled: false } Style/SafeNavigation: { Enabled: false } +Style/ConstantVisibility: { Enabled: false } +Style/Copyright: { Enabled: false } +Style/MissingElse: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index daafc95d8..921c1bbb3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-12-19 02:34:30 UTC using RuboCop version 1.40.0. +# on 2022-12-19 06:51:16 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -21,21 +21,13 @@ Bundler/GemVersion: Exclude: - 'Gemfile' -# Offense count: 25 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: InspectBlocks. Layout/RedundantLineBreak: Exclude: - - 'app/commands/feeds/export_to_opml.rb' - - 'app/repositories/story_repository.rb' - - 'app/utils/content_sanitizer.rb' - 'spec/factories/user_factory.rb' - 'spec/factories/users.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - - 'spec/integration/feed_importing_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). @@ -46,11 +38,10 @@ Layout/SingleLineBlockChain: - 'spec/models/story_spec.rb' - 'spec/tasks/fetch_feeds_spec.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: Exclude: - - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' # Offense count: 1 @@ -59,7 +50,7 @@ Lint/EmptyBlock: Exclude: - 'spec/repositories/story_repository_spec.rb' -# Offense count: 13 +# Offense count: 12 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, IgnoredClasses. # AllowedMethods: ago, from_now, second, seconds, minute, minutes, hour, hours, day, days, week, weeks, fortnight, fortnights, in_milliseconds @@ -85,6 +76,22 @@ Metrics/AbcSize: Exclude: - 'app/controllers/feeds_controller.rb' +# Offense count: 14 +# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. +Metrics/MethodLength: + Exclude: + - 'app/controllers/feeds_controller.rb' + - 'app/fever_api/read_items.rb' + - 'app/helpers/url_helpers.rb' + - 'app/models/story.rb' + - 'app/repositories/story_repository.rb' + - 'app/tasks/fetch_feeds.rb' + - 'app/utils/opml_parser.rb' + - 'app/utils/sample_story.rb' + - 'config/asset_pipeline.rb' + - 'db/migrate/20130425222157_add_delayed_job.rb' + - 'spec/factories/story_factory.rb' + # Offense count: 9 # Configuration parameters: ForbiddenDelimiters. # ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) @@ -94,7 +101,7 @@ Naming/HeredocDelimiterNaming: - 'spec/helpers/url_helpers_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 35 +# Offense count: 31 # This cop supports safe autocorrection (--autocorrect). RSpec/AlignLeftLetBrace: Exclude: @@ -108,8 +115,6 @@ RSpec/AlignLeftLetBrace: - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - 'spec/fever_api/sync_saved_item_ids_spec.rb' - 'spec/fever_api/sync_unread_item_ids_spec.rb' - 'spec/fever_api/write_mark_feed_spec.rb' @@ -119,7 +124,7 @@ RSpec/AlignLeftLetBrace: - 'spec/tasks/fetch_feeds_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 40 +# Offense count: 35 # This cop supports safe autocorrection (--autocorrect). RSpec/AlignRightLetBrace: Exclude: @@ -133,8 +138,6 @@ RSpec/AlignRightLetBrace: - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - 'spec/fever_api/sync_saved_item_ids_spec.rb' - 'spec/fever_api/sync_unread_item_ids_spec.rb' - 'spec/fever_api/write_mark_feed_spec.rb' @@ -144,7 +147,7 @@ RSpec/AlignRightLetBrace: - 'spec/tasks/fetch_feeds_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 6 +# Offense count: 5 RSpec/AnyInstance: Exclude: - 'spec/controllers/exports_controller_spec.rb' @@ -184,7 +187,7 @@ RSpec/DescribeClass: - 'spec/integration/feed_importing_spec.rb' - 'spec/utils/i18n_support_spec.rb' -# Offense count: 145 +# Offense count: 149 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit @@ -227,12 +230,11 @@ RSpec/DescribedClass: - 'spec/utils/feed_discovery_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 9 +# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). RSpec/EmptyLineAfterFinalLet: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/feeds/import_from_opml_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' @@ -246,7 +248,7 @@ RSpec/EmptyLineAfterHook: Exclude: - 'spec/controllers/stories_controller_spec.rb' -# Offense count: 56 +# Offense count: 63 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -343,7 +345,7 @@ RSpec/MessageChain: - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api_spec.rb' -# Offense count: 102 +# Offense count: 106 # Configuration parameters: EnforcedStyle. # SupportedStyles: allow, expect RSpec/MessageExpectation: @@ -378,7 +380,7 @@ RSpec/MessageExpectation: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 107 +# Offense count: 111 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -413,7 +415,7 @@ RSpec/MessageSpies: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 97 +# Offense count: 96 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -426,7 +428,6 @@ RSpec/MultipleExpectations: - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/imports_controller_spec.rb' @@ -515,32 +516,7 @@ RSpec/ScatteredLet: - 'spec/commands/feeds/import_from_opml_spec.rb' - 'spec/repositories/feed_repository_spec.rb' -# Offense count: 55 -RSpec/StubbedMock: - Exclude: - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/controllers/exports_controller_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/fever_api/authentication_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - - 'spec/fever_api_spec.rb' - - 'spec/jobs/fetch_feed_job_spec.rb' - - 'spec/repositories/feed_repository_spec.rb' - - 'spec/tasks/remove_old_stories_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' - -# Offense count: 93 +# Offense count: 94 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -579,7 +555,7 @@ Rails/BulkChangeTable: - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' -# Offense count: 2 +# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. # Whitelist: find_by_sql, find_by_token_for @@ -596,7 +572,7 @@ Rails/HasManyOrHasOneDependent: Exclude: - 'app/models/group.rb' -# Offense count: 27 +# Offense count: 26 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: spec/**/*, test/**/* @@ -737,6 +713,14 @@ Style/DisableCopsWithinSourceCodeDirective: - 'spec/helpers/authentications_helper_spec.rb' - 'spec/helpers/url_helpers_spec.rb' +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: allowed_in_returns, forbidden +Style/DoubleNegation: + Exclude: + - 'app/controllers/sinatra/stories_controller.rb' + # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedVars. @@ -904,7 +888,7 @@ Style/FrozenStringLiteralComment: - 'spec/utils/i18n_support_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 86 +# Offense count: 91 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -945,7 +929,7 @@ Style/HashSyntax: - 'spec/tasks/change_password_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' -# Offense count: 184 +# Offense count: 185 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -1004,13 +988,15 @@ Style/MethodCallWithArgsParentheses: - 'spec/utils/i18n_support_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinDigits, Strict, AllowedNumbers, AllowedPatterns. +Style/NumericLiterals: Exclude: - - 'app/commands/stories/mark_group_as_read.rb' + - 'spec/fever_api/authentication_spec.rb' + - 'spec/fever_api/write_mark_feed_spec.rb' + - 'spec/fever_api/write_mark_group_spec.rb' + - 'spec/fever_api_spec.rb' # Offense count: 6 Style/OpenStructUse: From 7fafa8cba5203c0efe2f4e3e152f9389cbdc3103 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 19 Dec 2022 08:50:59 -0800 Subject: [PATCH 198/779] Update all Bundler dependencies (2022-12-19) (#718) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e96b88b78..c2881390d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,7 +89,7 @@ GEM thor (>= 0.20.3, < 2.0) tins (~> 1.16) crass (1.0.6) - date (3.3.2) + date (3.3.3) delayed_job (4.1.11) activesupport (>= 3.0, < 8.0) delayed_job_active_record (4.1.7) @@ -164,7 +164,7 @@ GEM nio4r (~> 2.0) racc (1.6.1) rack (2.2.4) - rack-protection (3.0.4) + rack-protection (3.0.5) rack rack-ssl (1.4.1) rack @@ -212,7 +212,7 @@ GEM rspec-mocks (~> 3.12.0) rspec-core (3.12.0) rspec-support (~> 3.12.0) - rspec-expectations (3.12.0) + rspec-expectations (3.12.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-html-matchers (0.10.0) @@ -248,7 +248,7 @@ GEM rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.15.0) + rubocop-rspec (2.16.0) rubocop (~> 1.33) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) @@ -266,19 +266,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sinatra (3.0.4) + sinatra (3.0.5) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.0.4) + rack-protection (= 3.0.5) tilt (~> 2.0) sinatra-activerecord (2.0.26) activerecord (>= 4.1) sinatra (>= 1.0) - sinatra-contrib (3.0.4) + sinatra-contrib (3.0.5) multi_json mustermann (~> 3.0) - rack-protection (= 3.0.4) - sinatra (= 3.0.4) + rack-protection (= 3.0.5) + sinatra (= 3.0.5) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) From 73ca19fbf10a0b27e03f78cdf49397f1d11d015c Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 11:26:12 -0800 Subject: [PATCH 199/779] RuboCop: move gem lints to not wanted (#726) --- .rubocop.yml | 10 ++++++---- .rubocop_todo.yml | 15 --------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3fa9fe2e2..40ad0144f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -30,12 +30,14 @@ Style/Documentation: { Enabled: false } # ################################################################################ +Bundler/GemComment: { Enabled: false } +Bundler/GemVersion: { Enabled: false } Lint/ConstantResolution: { Enabled: false } -Rails/SchemaComment: { Enabled: false } RSpec/StubbedMock: { Enabled: false } -Style/InlineComment: { Enabled: false } -Style/RequireOrder: { Enabled: false } -Style/SafeNavigation: { Enabled: false } +Rails/SchemaComment: { Enabled: false } Style/ConstantVisibility: { Enabled: false } Style/Copyright: { Enabled: false } +Style/InlineComment: { Enabled: false } Style/MissingElse: { Enabled: false } +Style/RequireOrder: { Enabled: false } +Style/SafeNavigation: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 921c1bbb3..1217ea77b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,21 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 35 -# Configuration parameters: Include, IgnoredGems, OnlyFor. -# Include: **/*.gemfile, **/Gemfile, **/gems.rb -Bundler/GemComment: - Exclude: - - 'Gemfile' - -# Offense count: 33 -# Configuration parameters: EnforcedStyle, Include, AllowedGems. -# SupportedStyles: required, forbidden -# Include: **/*.gemfile, **/Gemfile, **/gems.rb -Bundler/GemVersion: - Exclude: - - 'Gemfile' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: InspectBlocks. From 291885f180a66ebc83c5eff3c677b82eb5d1822f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 11:38:27 -0800 Subject: [PATCH 200/779] RuboCop: fix RedundantLineBreak offenses (#727) --- .rubocop_todo.yml | 8 -------- spec/factories/user_factory.rb | 5 +---- spec/factories/users.rb | 4 +--- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1217ea77b..b97d82108 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,14 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: InspectBlocks. -Layout/RedundantLineBreak: - Exclude: - - 'spec/factories/user_factory.rb' - - 'spec/factories/users.rb' - # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). Layout/SingleLineBlockChain: diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index ced5ad345..108370ee4 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -4,9 +4,6 @@ class UserFactory class FakeUser < OpenStruct; end def self.build - FakeUser.new( - id: rand(100), - setup_complete: false - ) + FakeUser.new(id: rand(100), setup_complete: false) end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 4a76ebe07..84d6f494e 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,7 +1,5 @@ module Factories - USER_TRAITS = { - setup_complete: -> { { setup_complete: true } } - }.freeze + USER_TRAITS = { setup_complete: -> { { setup_complete: true } } }.freeze def create_user(*traits, **params) build_user(*traits, **params).tap(&:save!) From dcb4e86aae7df31fd6e7791324ea523b09c1a1c8 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 11:49:34 -0800 Subject: [PATCH 201/779] RuboCop: move SingleLineBlockChain to not wanted (#728) --- .rubocop.yml | 1 + .rubocop_todo.yml | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 40ad0144f..824da5e97 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -32,6 +32,7 @@ Style/Documentation: { Enabled: false } Bundler/GemComment: { Enabled: false } Bundler/GemVersion: { Enabled: false } +Layout/SingleLineBlockChain: { Enabled: false } Lint/ConstantResolution: { Enabled: false } RSpec/StubbedMock: { Enabled: false } Rails/SchemaComment: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b97d82108..f657c76f7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,15 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -Layout/SingleLineBlockChain: - Exclude: - - 'app/tasks/change_password.rb' - - 'spec/integration/feed_importing_spec.rb' - - 'spec/models/story_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: From b0ea0947ff4c44579f72b34b8dc607112f677920 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 12:16:17 -0800 Subject: [PATCH 202/779] RuboCop: fix AmbiguousOperatorPrecedence offense (#729) --- .rubocop_todo.yml | 6 ------ spec/factories/group_factory.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f657c76f7..fdc62e1a4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,12 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Lint/AmbiguousOperatorPrecedence: - Exclude: - - 'spec/factories/group_factory.rb' - # Offense count: 1 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rb index bcbcd6d00..58814dab5 100644 --- a/spec/factories/group_factory.rb +++ b/spec/factories/group_factory.rb @@ -11,7 +11,7 @@ def as_fever_json def self.build(params = {}) FakeGroup.new( id: rand(100), - name: params[:name] || Faker::Name.name + " group" # rubocop:disable Style/StringConcatenation + name: params[:name] || "#{Faker::Name.name} group" ) end end From 645e24d8cd918b951b69b27d0cfd30f95230f446 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 12:56:51 -0800 Subject: [PATCH 203/779] RuboCop: remove in-line disables (#730) --- .rubocop_todo.yml | 43 ++++++++++++++------- app/commands/feeds/export_to_opml.rb | 2 +- app/utils/sample_story.rb | 6 +-- spec/factories/feed_factory.rb | 2 +- spec/helpers/authentications_helper_spec.rb | 2 +- spec/helpers/url_helpers_spec.rb | 2 +- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fdc62e1a4..e3d3ead66 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,20 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-12-19 06:51:16 UTC using RuboCop version 1.40.0. +# on 2022-12-19 07:00:21 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 3 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'app/utils/sample_story.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + # Offense count: 1 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: @@ -38,10 +47,11 @@ Metrics/AbcSize: Exclude: - 'app/controllers/feeds_controller.rb' -# Offense count: 14 +# Offense count: 15 # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. Metrics/MethodLength: Exclude: + - 'app/commands/feeds/export_to_opml.rb' - 'app/controllers/feeds_controller.rb' - 'app/fever_api/read_items.rb' - 'app/helpers/url_helpers.rb' @@ -63,6 +73,16 @@ Naming/HeredocDelimiterNaming: - 'spec/helpers/url_helpers_spec.rb' - 'spec/utils/opml_parser_spec.rb' +# Offense count: 2 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'app/utils/sample_story.rb' + # Offense count: 31 # This cop supports safe autocorrection (--autocorrect). RSpec/AlignLeftLetBrace: @@ -663,18 +683,6 @@ Style/CollectionMethods: - 'app/controllers/sinatra/stories_controller.rb' - 'app/fever_api/response.rb' -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedCops. -Style/DisableCopsWithinSourceCodeDirective: - Exclude: - - 'app/commands/feeds/export_to_opml.rb' - - 'app/utils/sample_story.rb' - - 'spec/factories/feed_factory.rb' - - 'spec/factories/group_factory.rb' - - 'spec/helpers/authentications_helper_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -1036,6 +1044,13 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'spec/factories/feed_factory.rb' + # Offense count: 19 # This cop supports unsafe autocorrection (--autocorrect-all). Style/StringHashKeys: diff --git a/app/commands/feeds/export_to_opml.rb b/app/commands/feeds/export_to_opml.rb index 38715904e..c6e37810c 100644 --- a/app/commands/feeds/export_to_opml.rb +++ b/app/commands/feeds/export_to_opml.rb @@ -5,7 +5,7 @@ def initialize(feeds) @feeds = feeds end - def to_xml # rubocop:disable Metrics/MethodLength + def to_xml builder = Nokogiri::XML::Builder.new do |xml| xml.opml(version: "1.0") do diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 7c3985e40..efb6b9edc 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -1,6 +1,6 @@ SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do - BODY = <<~EOS.freeze # rubocop:disable Lint/ConstantDefinitionInBlock + BODY = <<~EOS.freeze

    Tofu shoreditch intelligentsia umami, fashion axe photo booth try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee @@ -41,7 +41,7 @@ def body BODY end - def is_read # rubocop:disable Naming/PredicateName + def is_read false end @@ -49,7 +49,7 @@ def keep_unread false end - def is_starred # rubocop:disable Naming/PredicateName + def is_starred false end diff --git a/spec/factories/feed_factory.rb b/spec/factories/feed_factory.rb index 3355d2374..b649894a6 100644 --- a/spec/factories/feed_factory.rb +++ b/spec/factories/feed_factory.rb @@ -17,7 +17,7 @@ def self.build(params = {}) FakeFeed.new( id: rand(100), group_id: rand(100), - name: Faker::Name.name + " on Software", # rubocop:disable Style/StringConcatenation + name: Faker::Name.name + " on Software", url: Faker::Internet.url, last_fetched: Time.now, stories: [], diff --git a/spec/helpers/authentications_helper_spec.rb b/spec/helpers/authentications_helper_spec.rb index 0db0086a1..b7457b884 100644 --- a/spec/helpers/authentications_helper_spec.rb +++ b/spec/helpers/authentications_helper_spec.rb @@ -3,7 +3,7 @@ app_require "helpers/authentication_helpers" RSpec.describe Sinatra::AuthenticationHelpers do - class Helper # rubocop:disable Lint/ConstantDefinitionInBlock + class Helper include Sinatra::AuthenticationHelpers end diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index e49fc7ebe..31a935aa8 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -3,7 +3,7 @@ app_require "helpers/url_helpers" RSpec.describe UrlHelpers do - class Helper # rubocop:disable Lint/ConstantDefinitionInBlock + class Helper include UrlHelpers end From 9f3bcbf06de26c2f1316b7e586e4127e61350fbd Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 13:25:07 -0800 Subject: [PATCH 204/779] RuboCop: enable ConstantDefinitionInBlock cop (#731) --- .rubocop_todo.yml | 9 ----- app/utils/sample_story.rb | 44 ++++++++++----------- spec/helpers/authentications_helper_spec.rb | 7 ++-- spec/helpers/url_helpers_spec.rb | 7 ++-- 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e3d3ead66..b2c36dd04 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,15 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: - Exclude: - - 'app/utils/sample_story.rb' - - 'spec/helpers/authentications_helper_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - # Offense count: 1 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index efb6b9edc..469465990 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -1,26 +1,26 @@ +SAMPLE_BODY = <<~EOS.freeze +

    Tofu shoreditch intelligentsia umami, fashion axe photo booth + try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic + salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee + street art gentrify. Quinoa PBR readymade 90's. Chambray Austin aesthetic + meggings, carles vinyl intelligentsia tattooed. Keffiyeh mumblecore + fingerstache, sartorial sriracha disrupt biodiesel cred. Skateboard yr cosby + sweater, narwhal beard ethnic jean shorts aesthetic. Post-ironic flannel mlkshk, + pickled VHS wolf banjo forage portland wayfarers.

    + +

    Selfies mumblecore odd future irony DIY messenger bag. + Authentic neutra next level selvage squid. Four loko freegan occupy, tousled + vinyl leggings selvage messenger bag. Four loko wayfarers kale chips, next level + banksy banh mi umami flannel hella. Street art odd future scenester, + intelligentsia brunch fingerstache YOLO narwhal single-origin coffee tousled + tumblr pop-up four loko you probably haven't heard of them dreamcatcher. + Single-origin coffee direct trade retro biodiesel, truffaut fanny pack portland + blue bottle scenester bushwick. Skateboard squid fanny pack bushwick, photo + booth vice literally.

    +EOS + SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do - BODY = <<~EOS.freeze -

    Tofu shoreditch intelligentsia umami, fashion axe photo booth - try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic - salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee - street art gentrify. Quinoa PBR readymade 90's. Chambray Austin aesthetic - meggings, carles vinyl intelligentsia tattooed. Keffiyeh mumblecore - fingerstache, sartorial sriracha disrupt biodiesel cred. Skateboard yr cosby - sweater, narwhal beard ethnic jean shorts aesthetic. Post-ironic flannel mlkshk, - pickled VHS wolf banjo forage portland wayfarers.

    - -

    Selfies mumblecore odd future irony DIY messenger bag. - Authentic neutra next level selvage squid. Four loko freegan occupy, tousled - vinyl leggings selvage messenger bag. Four loko wayfarers kale chips, next level - banksy banh mi umami flannel hella. Street art odd future scenester, - intelligentsia brunch fingerstache YOLO narwhal single-origin coffee tousled - tumblr pop-up four loko you probably haven't heard of them dreamcatcher. - Single-origin coffee direct trade retro biodiesel, truffaut fanny pack portland - blue bottle scenester bushwick. Skateboard squid fanny pack bushwick, photo - booth vice literally.

    - EOS - def id -1 * rand(100) end @@ -38,7 +38,7 @@ def lead end def body - BODY + SAMPLE_BODY end def is_read diff --git a/spec/helpers/authentications_helper_spec.rb b/spec/helpers/authentications_helper_spec.rb index b7457b884..e66496e00 100644 --- a/spec/helpers/authentications_helper_spec.rb +++ b/spec/helpers/authentications_helper_spec.rb @@ -3,12 +3,11 @@ app_require "helpers/authentication_helpers" RSpec.describe Sinatra::AuthenticationHelpers do - class Helper - include Sinatra::AuthenticationHelpers + let(:helper) do + helper_class = Class.new { include Sinatra::AuthenticationHelpers } + helper_class.new end - let(:helper) { Helper.new } - describe "#needs_authentication?" do let(:authenticated_path) { "/news" } diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index 31a935aa8..7a422d2ee 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -3,12 +3,11 @@ app_require "helpers/url_helpers" RSpec.describe UrlHelpers do - class Helper - include UrlHelpers + let(:helper) do + helper_class = Class.new { include UrlHelpers } + helper_class.new end - let(:helper) { Helper.new } - describe "#expand_absolute_urls" do it "preserves existing absolute urls" do content = 'bar' From 487ab19bfb0fbebc4e1e7a9273c0124ebb317842 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 15:35:17 -0800 Subject: [PATCH 205/779] RuboCop: fix EmptyBlock offense (#732) --- .rubocop_todo.yml | 6 ------ spec/repositories/story_repository_spec.rb | 3 --- 2 files changed, 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b2c36dd04..d8e2537a8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,12 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# Configuration parameters: AllowComments, AllowEmptyLambdas. -Lint/EmptyBlock: - Exclude: - - 'spec/repositories/story_repository_spec.rb' - # Offense count: 12 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, IgnoredClasses. diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index d45af9afe..623c3eb37 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -426,9 +426,6 @@ end describe ".extract_title" do - let(:entry) do - end - it "returns the title if there is a title" do entry = double(title: "title", summary: "summary") From c726f7a6a4f4447572c3840d84a74aebb43df2d0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 15:39:42 -0800 Subject: [PATCH 206/779] Factories: introduce FactoryBot (#733) --- .rubocop_todo.yml | 2 -- Gemfile | 1 + Gemfile.lock | 6 ++++ spec/app_spec.rb | 8 ++--- spec/commands/users/complete_setup_spec.rb | 2 +- spec/controllers/first_run_controller_spec.rb | 2 +- spec/factories.rb | 1 - spec/factories/user_factory.rb | 9 ------ spec/factories/users.rb | 16 ++++------ spec/repositories/user_repository_spec.rb | 12 +++---- spec/spec_helper.rb | 1 + spec/support/factory_bot.rb | 32 +++++++++++++++++++ 12 files changed, 58 insertions(+), 34 deletions(-) delete mode 100644 spec/factories/user_factory.rb create mode 100644 spec/support/factory_bot.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d8e2537a8..113d91945 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -803,7 +803,6 @@ Style/FrozenStringLiteralComment: - 'spec/factories/groups.rb' - 'spec/factories/stories.rb' - 'spec/factories/story_factory.rb' - - 'spec/factories/user_factory.rb' - 'spec/factories/users.rb' - 'spec/fever_api/authentication_spec.rb' - 'spec/fever_api/read_favicons_spec.rb' @@ -960,7 +959,6 @@ Style/OpenStructUse: - 'spec/factories/feed_factory.rb' - 'spec/factories/group_factory.rb' - 'spec/factories/story_factory.rb' - - 'spec/factories/user_factory.rb' # Offense count: 28 # Configuration parameters: SuspiciousParamNames, Allowlist. diff --git a/Gemfile b/Gemfile index 0574bd935..18c1bba94 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,7 @@ end group :development, :test do gem "capybara" gem "coveralls_reborn", require: false + gem "factory_bot_rails" gem "faker" gem "pry-byebug" gem "rspec" diff --git a/Gemfile.lock b/Gemfile.lock index c2881390d..a8c143966 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,6 +99,11 @@ GEM docile (1.4.0) erubi (1.11.0) execjs (2.8.1) + factory_bot (6.2.1) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) faker (3.0.0) i18n (>= 1.8.11, < 2) feedbag (1.0.0) @@ -319,6 +324,7 @@ DEPENDENCIES coveralls_reborn delayed_job delayed_job_active_record + factory_bot_rails faker feedbag feedjira diff --git a/spec/app_spec.rb b/spec/app_spec.rb index bdffb08d3..0d79af4cf 100644 --- a/spec/app_spec.rb +++ b/spec/app_spec.rb @@ -10,7 +10,7 @@ context "when user is not authenticated and page requires authentication" do it "sets the session redirect_to" do - create_user(:setup_complete) + create(:user, :setup_complete) get("/news") @@ -18,7 +18,7 @@ end it "redirects to /login" do - create_user(:setup_complete) + create(:user, :setup_complete) get("/news") @@ -28,7 +28,7 @@ end it "does not redirect when page needs no authentication" do - create_user(:setup_complete) + create(:user, :setup_complete) get("/login") @@ -36,7 +36,7 @@ end it "does not redirect when user is authenticated" do - user = create_user(:setup_complete) + user = create(:user, :setup_complete) get("/news", {}, "rack.session" => { user_id: user.id }) diff --git a/spec/commands/users/complete_setup_spec.rb b/spec/commands/users/complete_setup_spec.rb index b967d6929..cc938a7e1 100644 --- a/spec/commands/users/complete_setup_spec.rb +++ b/spec/commands/users/complete_setup_spec.rb @@ -3,7 +3,7 @@ app_require "commands/users/complete_setup" describe CompleteSetup do - let(:user) { UserFactory.build } + let(:user) { build(:user) } it "marks setup as complete" do expect(user).to receive(:save).once diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 192a8e1b2..baf706c92 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -75,7 +75,7 @@ context "when a user has been setup" do it "should redirect any requests to first run stuff" do - user = create_user(:setup_complete) + user = create(:user, :setup_complete) session = { "rack.session" => { user_id: user.id } } get "/", {}, session diff --git a/spec/factories.rb b/spec/factories.rb index 4b0718ff2..6b2ba18e4 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,6 +1,5 @@ require_relative "factories/feed_factory" require_relative "factories/story_factory" -require_relative "factories/user_factory" require_relative "factories/group_factory" require_relative "factories/feeds" require_relative "factories/groups" diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb deleted file mode 100644 index 108370ee4..000000000 --- a/spec/factories/user_factory.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative "./feed_factory" - -class UserFactory - class FakeUser < OpenStruct; end - - def self.build - FakeUser.new(id: rand(100), setup_complete: false) - end -end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 84d6f494e..a3192ad95 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,13 +1,9 @@ -module Factories - USER_TRAITS = { setup_complete: -> { { setup_complete: true } } }.freeze +FactoryBot.define do + factory(:user) do + password { "super-secret" } - def create_user(*traits, **params) - build_user(*traits, **params).tap(&:save!) - end - - def build_user(*traits, **params) - traits.each { |trait| params.merge!(USER_TRAITS.fetch(trait).call) } - - User.new(password: "super-secret", **params) + trait :setup_complete do + setup_complete { true } + end end end diff --git a/spec/repositories/user_repository_spec.rb b/spec/repositories/user_repository_spec.rb index 26c051598..2e969b000 100644 --- a/spec/repositories/user_repository_spec.rb +++ b/spec/repositories/user_repository_spec.rb @@ -10,7 +10,7 @@ end it "returns the user for the given id" do - user = create_user + user = create(:user) expect(UserRepository.fetch(user.id)).to eq(user) end @@ -22,13 +22,13 @@ end it "returns false when user has not completed setup" do - create_user + create(:user) expect(UserRepository.setup_complete?).to be(false) end it "returns true when user has completed setup" do - create_user(setup_complete: true) + create(:user, :setup_complete) expect(UserRepository.setup_complete?).to be(true) end @@ -36,7 +36,7 @@ describe ".save" do it "saves the given user" do - user = build_user + user = build(:user) expect { UserRepository.save(user) } .to change(user, :persisted?).from(false).to(true) @@ -51,8 +51,8 @@ describe ".first" do it "returns the first user" do - user = create_user - create_user + user = create(:user) + create(:user) expect(UserRepository.first).to eq(user) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index db68aa468..6bfd9b0b5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,6 +12,7 @@ require "date" require_relative "support/coverage" +require_relative "support/factory_bot" require_relative "factories" require "./app" diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb new file mode 100644 index 000000000..84cf4a0c8 --- /dev/null +++ b/spec/support/factory_bot.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require "factory_bot" + +module FactoryCache + def self.user + @user ||= FactoryBot.create(:user) + end + + def self.reset + @user = nil + end +end + +RSpec.configure do |config| + config.include(FactoryBot::Syntax::Methods) + + config.after do + FactoryBot.rewind_sequences + FactoryCache.reset + end +end + +module FactoryBot + module Syntax + module Methods + def default_user + FactoryCache.user + end + end + end +end From 50a854e26929984fe45fe20f3d6390ddcd705e26 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 15:54:54 -0800 Subject: [PATCH 207/779] Factories: switch feeds to FactoryBot (#734) --- spec/factories/feeds.rb | 10 +++----- spec/factories/stories.rb | 2 +- spec/models/story_spec.rb | 4 ++-- spec/repositories/feed_repository_spec.rb | 25 +++++++++---------- spec/repositories/story_repository_spec.rb | 28 +++++++++++----------- spec/tasks/fetch_feeds_spec.rb | 4 ++-- 6 files changed, 33 insertions(+), 40 deletions(-) diff --git a/spec/factories/feeds.rb b/spec/factories/feeds.rb index e0a2f50f5..8fd25e7aa 100644 --- a/spec/factories/feeds.rb +++ b/spec/factories/feeds.rb @@ -1,9 +1,5 @@ -module Factories - def create_feed(params = {}) - build_feed(params).tap(&:save!) - end - - def build_feed(params = {}) - Feed.new(url: "https://exampoo.com/#{next_id}", **params) +FactoryBot.define do + factory(:feed) do + sequence(:url, 100) { |n| "http://exampoo.com/#{n}" } end end diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index c4c622868..4713b0521 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -12,6 +12,6 @@ def create_story(*traits, **params) def build_story(*traits, **params) traits.each { |trait| params.merge!(STORY_TRAITS.fetch(trait).call) } - Story.new(entry_id: next_id, feed: build_feed, **params) + Story.new(entry_id: next_id, feed: FactoryBot.build(:feed), **params) end end diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 413e97558..ce43ea6cf 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -64,7 +64,7 @@ describe "#as_json" do it "returns a hash of the story" do - feed = create_feed(name: "my feed") + feed = create(:feed, name: "my feed") published_at = 1.day.ago created_at = 1.hour.ago updated_at = 1.minute.ago @@ -108,7 +108,7 @@ describe "#as_fever_json" do it "returns a hash of the story in fever format" do - feed = create_feed(name: "my feed") + feed = create(:feed, name: "my feed") published_at = 1.day.ago story = create_story( feed: feed, diff --git a/spec/repositories/feed_repository_spec.rb b/spec/repositories/feed_repository_spec.rb index e67bcfc03..2f2dac5d4 100644 --- a/spec/repositories/feed_repository_spec.rb +++ b/spec/repositories/feed_repository_spec.rb @@ -23,14 +23,13 @@ describe ".fetch_by_ids" do it "finds all feeds by id" do - feeds = [create_feed, create_feed] + feeds = create_pair(:feed) expect(FeedRepository.fetch_by_ids(feeds.map(&:id))).to match_array(feeds) end it "does not find other feeds" do - feed1 = create_feed - create_feed + feed1, = create_pair(:feed) expect(FeedRepository.fetch_by_ids(feed1.id)).to eq([feed1]) end @@ -88,7 +87,7 @@ describe ".delete" do it "deletes the feed by id" do - feed = create_feed + feed = create(:feed) FeedRepository.delete(feed.id) @@ -96,8 +95,7 @@ end it "does not delete other feeds" do - feed1 = create_feed - feed2 = create_feed + feed1, feed2 = create_pair(:feed) FeedRepository.delete(feed1.id) @@ -107,10 +105,10 @@ describe ".list" do it "returns all feeds ordered by name, case insensitive" do - feed1 = create_feed(name: "foo") - feed2 = create_feed(name: "Fabulous") - feed3 = create_feed(name: "Zooby") - feed4 = create_feed(name: "zabby") + feed1 = create(:feed, name: "foo") + feed2 = create(:feed, name: "Fabulous") + feed3 = create(:feed, name: "Zooby") + feed4 = create(:feed, name: "zabby") expect(FeedRepository.list).to eq([feed2, feed1, feed4, feed3]) end @@ -118,15 +116,14 @@ describe ".in_group" do it "returns feeds that are in a group" do - feed1 = create_feed(group_id: 5) - feed2 = create_feed(group_id: 6) + feed1 = create(:feed, group_id: 5) + feed2 = create(:feed, group_id: 6) expect(FeedRepository.in_group).to match_array([feed1, feed2]) end it "does not return feeds that are not in a group" do - create_feed - create_feed + create_pair(:feed) expect(FeedRepository.in_group).to be_empty end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 623c3eb37..ffdd28dd0 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -119,7 +119,7 @@ describe ".fetch_unread_by_timestamp_and_group" do it "returns unread stories before timestamp for group_id" do - feed = create_feed(group_id: 52) + feed = create(:feed, group_id: 52) story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) time = Time.now @@ -129,7 +129,7 @@ end it "does not return read stories before timestamp for group_id" do - feed = create_feed(group_id: 52) + feed = create(:feed, group_id: 52) create_story(feed: feed, created_at: 5.minutes.ago) time = Time.now @@ -139,7 +139,7 @@ end it "does not return unread stories after timestamp for group_id" do - feed = create_feed(group_id: 52) + feed = create(:feed, group_id: 52) create_story(:unread, feed: feed, created_at: 5.minutes.ago) time = 6.minutes.ago @@ -149,7 +149,7 @@ end it "does not return stories before timestamp for other group_id" do - feed = create_feed(group_id: 52) + feed = create(:feed, group_id: 52) create_story(:unread, feed: feed, created_at: 5.minutes.ago) time = Time.now @@ -159,7 +159,7 @@ end it "does not return stories with no group_id before timestamp" do - feed = create_feed + feed = create(:feed) create_story(:unread, feed: feed, created_at: 5.minutes.ago) time = Time.now @@ -169,7 +169,7 @@ end it "returns unread stories before timestamp for nil group_id" do - feed = create_feed + feed = create(:feed) story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) time = Time.now @@ -181,7 +181,7 @@ describe ".fetch_unread_for_feed_by_timestamp" do it "returns unread stories for the feed before timestamp" do - feed = create_feed + feed = create(:feed) story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) time = 4.minutes.ago @@ -192,7 +192,7 @@ end it "returns unread stories for the feed before string timestamp" do - feed = create_feed + feed = create(:feed) story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) timestamp = Integer(4.minutes.ago).to_s @@ -203,7 +203,7 @@ end it "does not return read stories for the feed before timestamp" do - feed = create_feed + feed = create(:feed) create_story(feed: feed, created_at: 5.minutes.ago) time = 4.minutes.ago @@ -214,7 +214,7 @@ end it "does not return unread stories for the feed after timestamp" do - feed = create_feed + feed = create(:feed) create_story(:unread, feed: feed, created_at: 5.minutes.ago) time = 6.minutes.ago @@ -225,7 +225,7 @@ end it "does not return unread stories for another feed before timestamp" do - feed = create_feed + feed = create(:feed) create_story(:unread, created_at: 5.minutes.ago) time = 4.minutes.ago @@ -277,14 +277,14 @@ describe ".feed" do it "returns stories for the given feed id" do - feed = create_feed + feed = create(:feed) story = create_story(feed: feed) expect(StoryRepository.feed(feed.id)).to eq([story]) end it "sorts stories by published" do - feed = create_feed + feed = create(:feed) story1 = create_story(feed: feed, published: 1.day.ago) story2 = create_story(feed: feed, published: 1.hour.ago) @@ -292,7 +292,7 @@ end it "does not return stories for other feeds" do - feed = create_feed + feed = create(:feed) create_story expect(StoryRepository.feed(feed.id)).to be_empty diff --git a/spec/tasks/fetch_feeds_spec.rb b/spec/tasks/fetch_feeds_spec.rb index 8070b6988..d3ba07b18 100644 --- a/spec/tasks/fetch_feeds_spec.rb +++ b/spec/tasks/fetch_feeds_spec.rb @@ -36,7 +36,7 @@ describe "#prepare_to_delay" do it "serializes the instance for backgrounding" do - feeds = [create_feed, create_feed] + feeds = create_pair(:feed) feeds_ids = feeds.map(&:id) fetch_feeds = FetchFeeds.new(feeds) @@ -49,7 +49,7 @@ describe ".enqueue" do it "enqueues a fetch_all job" do - feeds = [create_feed, create_feed] + feeds = create_pair(:feed) feeds_ids = feeds.map(&:id) expect { FetchFeeds.enqueue(feeds) }.to change(Delayed::Job, :count).by(1) From 45bd00496d09ded422d45955144dbdcb724509f7 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 16:03:54 -0800 Subject: [PATCH 208/779] Factories: switch stories to FactoryBot (#735) --- spec/commands/stories/mark_as_read_spec.rb | 2 +- spec/commands/stories/mark_as_starred_spec.rb | 2 +- spec/commands/stories/mark_as_unread_spec.rb | 2 +- .../stories/mark_as_unstarred_spec.rb | 2 +- spec/factories/stories.rb | 26 ++--- spec/models/story_spec.rb | 10 +- spec/repositories/story_repository_spec.rb | 100 +++++++++--------- 7 files changed, 73 insertions(+), 71 deletions(-) diff --git a/spec/commands/stories/mark_as_read_spec.rb b/spec/commands/stories/mark_as_read_spec.rb index c53e4bf02..7d10291ff 100644 --- a/spec/commands/stories/mark_as_read_spec.rb +++ b/spec/commands/stories/mark_as_read_spec.rb @@ -4,7 +4,7 @@ describe MarkAsRead do describe "#mark_as_read" do - let(:story) { create_story(is_read: false) } + let(:story) { create(:story, is_read: false) } it "marks a story as read" do expect { MarkAsRead.new(story.id).mark_as_read } diff --git a/spec/commands/stories/mark_as_starred_spec.rb b/spec/commands/stories/mark_as_starred_spec.rb index 1ddfa15bb..5413d80dd 100644 --- a/spec/commands/stories/mark_as_starred_spec.rb +++ b/spec/commands/stories/mark_as_starred_spec.rb @@ -4,7 +4,7 @@ describe MarkAsStarred do describe "#mark_as_starred" do - let(:story) { create_story(is_starred: false) } + let(:story) { create(:story, is_starred: false) } it "marks a story as starred" do expect { MarkAsStarred.new(story.id).mark_as_starred } diff --git a/spec/commands/stories/mark_as_unread_spec.rb b/spec/commands/stories/mark_as_unread_spec.rb index 565def114..0971ceb63 100644 --- a/spec/commands/stories/mark_as_unread_spec.rb +++ b/spec/commands/stories/mark_as_unread_spec.rb @@ -4,7 +4,7 @@ describe MarkAsUnread do describe "#mark_as_unread" do - let(:story) { create_story(is_read: true) } + let(:story) { create(:story, is_read: true) } it "marks a story as unread" do expect { MarkAsUnread.new(story.id).mark_as_unread } diff --git a/spec/commands/stories/mark_as_unstarred_spec.rb b/spec/commands/stories/mark_as_unstarred_spec.rb index de3844685..b1d06be36 100644 --- a/spec/commands/stories/mark_as_unstarred_spec.rb +++ b/spec/commands/stories/mark_as_unstarred_spec.rb @@ -4,7 +4,7 @@ describe MarkAsUnstarred do describe "#mark_as_unstarred" do - let(:story) { create_story(is_starred: true) } + let(:story) { create(:story, is_starred: true) } it "marks a story as unstarred" do expect { MarkAsUnstarred.new(story.id).mark_as_unstarred } diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index 4713b0521..11a8add66 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -1,17 +1,19 @@ -module Factories - STORY_TRAITS = { - read: -> { { is_read: true } }, - starred: -> { { is_starred: true } }, - unread: -> { { is_read: false } } - }.freeze +FactoryBot.define do + factory(:story) do + feed - def create_story(*traits, **params) - build_story(*traits, **params).tap(&:save!) - end + sequence(:entry_id, 100) { |n| "entry-#{n}" } + + trait :read do + is_read { true } + end - def build_story(*traits, **params) - traits.each { |trait| params.merge!(STORY_TRAITS.fetch(trait).call) } + trait :starred do + is_starred { true } + end - Story.new(entry_id: next_id, feed: FactoryBot.build(:feed), **params) + trait :unread do + is_read { false } + end end end diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index ce43ea6cf..27fb71ac0 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -68,7 +68,8 @@ published_at = 1.day.ago created_at = 1.hour.ago updated_at = 1.minute.ago - story = create_story( + story = create( + :story, body: "story body", created_at: created_at, entry_id: 5, @@ -110,7 +111,8 @@ it "returns a hash of the story in fever format" do feed = create(:feed, name: "my feed") published_at = 1.day.ago - story = create_story( + story = create( + :story, feed: feed, title: "the story title", body: "story body", @@ -133,12 +135,12 @@ end it "returns is_read as 0 if story is unread" do - story = create_story(is_read: false) + story = create(:story, is_read: false) expect(story.as_fever_json[:is_read]).to eq(0) end it "returns is_saved as 1 if story is starred" do - story = create_story(is_starred: true) + story = create(:story, is_starred: true) expect(story.as_fever_json[:is_saved]).to eq(1) end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index ffdd28dd0..816bedb6a 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -73,7 +73,7 @@ describe ".fetch" do it "finds the story by id" do - story = create_story + story = create(:story) expect(StoryRepository.fetch(story.id)).to eq(story) end @@ -81,8 +81,8 @@ describe ".fetch_by_ids" do it "finds all stories by id" do - story1 = create_story - story2 = create_story + story1 = create(:story) + story2 = create(:story) expected_stories = [story1, story2] actual_stories = StoryRepository.fetch_by_ids(expected_stories.map(&:id)) @@ -93,7 +93,7 @@ describe ".fetch_unread_by_timestamp" do it "returns unread stories from before the timestamp" do - story = create_story(created_at: 1.week.ago, is_read: false) + story = create(:story, created_at: 1.week.ago, is_read: false) actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) @@ -101,7 +101,7 @@ end it "does not return unread stories from after the timestamp" do - create_story(created_at: 3.days.ago, is_read: false) + create(:story, created_at: 3.days.ago, is_read: false) actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) @@ -109,7 +109,7 @@ end it "does not return read stories from before the timestamp" do - create_story(created_at: 1.week.ago, is_read: true) + create(:story, created_at: 1.week.ago, is_read: true) actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) @@ -120,7 +120,7 @@ describe ".fetch_unread_by_timestamp_and_group" do it "returns unread stories before timestamp for group_id" do feed = create(:feed, group_id: 52) - story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -130,7 +130,7 @@ it "does not return read stories before timestamp for group_id" do feed = create(:feed, group_id: 52) - create_story(feed: feed, created_at: 5.minutes.ago) + create(:story, feed: feed, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -140,7 +140,7 @@ it "does not return unread stories after timestamp for group_id" do feed = create(:feed, group_id: 52) - create_story(:unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed: feed, created_at: 5.minutes.ago) time = 6.minutes.ago stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -150,7 +150,7 @@ it "does not return stories before timestamp for other group_id" do feed = create(:feed, group_id: 52) - create_story(:unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed: feed, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 55) @@ -160,7 +160,7 @@ it "does not return stories with no group_id before timestamp" do feed = create(:feed) - create_story(:unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed: feed, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -170,7 +170,7 @@ it "returns unread stories before timestamp for nil group_id" do feed = create(:feed) - story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, nil) @@ -182,7 +182,7 @@ describe ".fetch_unread_for_feed_by_timestamp" do it "returns unread stories for the feed before timestamp" do feed = create(:feed) - story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) time = 4.minutes.ago stories = @@ -193,7 +193,7 @@ it "returns unread stories for the feed before string timestamp" do feed = create(:feed) - story = create_story(:unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) timestamp = Integer(4.minutes.ago).to_s stories = @@ -204,7 +204,7 @@ it "does not return read stories for the feed before timestamp" do feed = create(:feed) - create_story(feed: feed, created_at: 5.minutes.ago) + create(:story, feed: feed, created_at: 5.minutes.ago) time = 4.minutes.ago stories = @@ -215,7 +215,7 @@ it "does not return unread stories for the feed after timestamp" do feed = create(:feed) - create_story(:unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed: feed, created_at: 5.minutes.ago) time = 6.minutes.ago stories = @@ -226,7 +226,7 @@ it "does not return unread stories for another feed before timestamp" do feed = create(:feed) - create_story(:unread, created_at: 5.minutes.ago) + create(:story, :unread, created_at: 5.minutes.ago) time = 4.minutes.ago stories = @@ -238,15 +238,15 @@ describe ".unread" do it "returns unread stories ordered by published date descending" do - story1 = create_story(:unread, published: 5.minutes.ago) - story2 = create_story(:unread, published: 4.minutes.ago) + story1 = create(:story, :unread, published: 5.minutes.ago) + story2 = create(:story, :unread, published: 4.minutes.ago) expect(StoryRepository.unread).to eq([story2, story1]) end it "does not return read stories" do - create_story(published: 5.minutes.ago) - create_story(published: 4.minutes.ago) + create(:story, published: 5.minutes.ago) + create(:story, published: 4.minutes.ago) expect(StoryRepository.unread).to be_empty end @@ -254,22 +254,22 @@ describe ".unread_since_id" do it "returns unread stories with id greater than given id" do - story1 = create_story(:unread) - story2 = create_story(:unread) + story1 = create(:story, :unread) + story2 = create(:story, :unread) expect(StoryRepository.unread_since_id(story1.id)).to eq([story2]) end it "does not return read stories with id greater than given id" do - story1 = create_story(:unread) - create_story + story1 = create(:story, :unread) + create(:story) expect(StoryRepository.unread_since_id(story1.id)).to be_empty end it "does not return unread stories with id less than given id" do - create_story(:unread) - story2 = create_story(:unread) + create(:story, :unread) + story2 = create(:story, :unread) expect(StoryRepository.unread_since_id(story2.id)).to be_empty end @@ -278,22 +278,22 @@ describe ".feed" do it "returns stories for the given feed id" do feed = create(:feed) - story = create_story(feed: feed) + story = create(:story, feed: feed) expect(StoryRepository.feed(feed.id)).to eq([story]) end it "sorts stories by published" do feed = create(:feed) - story1 = create_story(feed: feed, published: 1.day.ago) - story2 = create_story(feed: feed, published: 1.hour.ago) + story1 = create(:story, feed: feed, published: 1.day.ago) + story2 = create(:story, feed: feed, published: 1.hour.ago) expect(StoryRepository.feed(feed.id)).to eq([story2, story1]) end it "does not return stories for other feeds" do feed = create(:feed) - create_story + create(:story) expect(StoryRepository.feed(feed.id)).to be_empty end @@ -301,27 +301,27 @@ describe ".read" do it "returns read stories" do - story = create_story(:read) + story = create(:story, :read) expect(StoryRepository.read).to eq([story]) end it "sorts stories by published" do - story1 = create_story(:read, published: 1.day.ago) - story2 = create_story(:read, published: 1.hour.ago) + story1 = create(:story, :read, published: 1.day.ago) + story2 = create(:story, :read, published: 1.hour.ago) expect(StoryRepository.read).to eq([story2, story1]) end it "does not return unread stories" do - create_story(:unread) + create(:story, :unread) expect(StoryRepository.read).to be_empty end it "paginates results" do stories = - 21.times.map { |num| create_story(:read, published: num.days.ago) } + 21.times.map { |num| create(:story, :read, published: num.days.ago) } expect(StoryRepository.read).to eq(stories[0...20]) expect(StoryRepository.read(2)).to eq([stories.last]) @@ -330,27 +330,27 @@ describe ".starred" do it "returns starred stories" do - story = create_story(:starred) + story = create(:story, :starred) expect(StoryRepository.starred).to eq([story]) end it "sorts stories by published" do - story1 = create_story(:starred, published: 1.day.ago) - story2 = create_story(:starred, published: 1.hour.ago) + story1 = create(:story, :starred, published: 1.day.ago) + story2 = create(:story, :starred, published: 1.hour.ago) expect(StoryRepository.starred).to eq([story2, story1]) end it "does not return unstarred stories" do - create_story + create(:story) expect(StoryRepository.starred).to be_empty end it "paginates results" do stories = - 21.times.map { |num| create_story(:starred, published: num.days.ago) } + 21.times.map { |num| create(:story, :starred, published: num.days.ago) } expect(StoryRepository.starred).to eq(stories[0...20]) expect(StoryRepository.starred(2)).to eq([stories.last]) @@ -359,26 +359,26 @@ describe ".unstarred_read_stories_older_than" do it "returns unstarred read stories older than given number of days" do - story = create_story(:read, published: 6.days.ago) + story = create(:story, :read, published: 6.days.ago) expect(StoryRepository.unstarred_read_stories_older_than(5)) .to eq([story]) end it "does not return starred stories older than the given number of days" do - create_story(:read, :starred, published: 6.days.ago) + create(:story, :read, :starred, published: 6.days.ago) expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty end it "does not return unread stories older than the given number of days" do - create_story(:unread, published: 6.days.ago) + create(:story, :unread, published: 6.days.ago) expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty end it "does not return stories newer than given number of days" do - create_story(:read, published: 4.days.ago) + create(:story, :read, published: 4.days.ago) expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty end @@ -386,17 +386,15 @@ describe ".read_count" do it "returns the count of read stories" do - create_story(:read) - create_story(:read) - create_story(:read) + create(:story, :read) + create(:story, :read) + create(:story, :read) expect(StoryRepository.read_count).to eq(3) end it "does not count unread stories" do - create_story(:unread) - create_story(:unread) - create_story(:unread) + create_list(:story, 3, :unread) expect(StoryRepository.read_count).to eq(0) end From 7681b79a37f47b5873fece07a80f47cd1a1e993e Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 16:23:50 -0800 Subject: [PATCH 209/779] Factories: switch groups to FactoryBot (#736) --- spec/factories/groups.rb | 10 ++-------- spec/repositories/group_repository_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb index 9d7ba4e85..3feda95ef 100644 --- a/spec/factories/groups.rb +++ b/spec/factories/groups.rb @@ -1,9 +1,3 @@ -module Factories - def create_group(params = {}) - build_group(params).tap(&:save!) - end - - def build_group(params = {}) - Group.new(**params) - end +FactoryBot.define do + factory(:group) end diff --git a/spec/repositories/group_repository_spec.rb b/spec/repositories/group_repository_spec.rb index b1ab5c268..fd119fa27 100644 --- a/spec/repositories/group_repository_spec.rb +++ b/spec/repositories/group_repository_spec.rb @@ -6,10 +6,10 @@ describe GroupRepository do describe ".list" do it "lists groups ordered by lower name" do - group1 = create_group(name: "Zabba") - group2 = create_group(name: "zlabba") - group3 = create_group(name: "blabba") - group4 = create_group(name: "Babba") + group1 = create(:group, name: "Zabba") + group2 = create(:group, name: "zlabba") + group3 = create(:group, name: "blabba") + group4 = create(:group, name: "Babba") expected_groups = [group4, group3, group1, group2] expect(GroupRepository.list).to eq(expected_groups) From e4f08b0d39e6f7acb24dada11b9cfdad8e76456f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 16:42:52 -0800 Subject: [PATCH 210/779] Factories: switch GroupFactory to FactoryBot (#737) --- .rubocop_todo.yml | 4 ---- spec/factories.rb | 1 - spec/factories/group_factory.rb | 17 ----------------- spec/fever_api_spec.rb | 2 +- 4 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 spec/factories/group_factory.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 113d91945..285089a8b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -799,7 +799,6 @@ Style/FrozenStringLiteralComment: - 'spec/factories.rb' - 'spec/factories/feed_factory.rb' - 'spec/factories/feeds.rb' - - 'spec/factories/group_factory.rb' - 'spec/factories/groups.rb' - 'spec/factories/stories.rb' - 'spec/factories/story_factory.rb' @@ -864,7 +863,6 @@ Style/HashSyntax: - 'app/repositories/story_repository.rb' - 'app/utils/sample_story.rb' - 'spec/factories/feed_factory.rb' - - 'spec/factories/group_factory.rb' - 'spec/factories/story_factory.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' @@ -957,7 +955,6 @@ Style/OpenStructUse: Exclude: - 'app.rb' - 'spec/factories/feed_factory.rb' - - 'spec/factories/group_factory.rb' - 'spec/factories/story_factory.rb' # Offense count: 28 @@ -979,7 +976,6 @@ Style/OptionHash: - 'app/fever_api/write_mark_item.rb' - 'spec/factories/feed_factory.rb' - 'spec/factories/feeds.rb' - - 'spec/factories/group_factory.rb' - 'spec/factories/groups.rb' - 'spec/factories/story_factory.rb' diff --git a/spec/factories.rb b/spec/factories.rb index 6b2ba18e4..762511d70 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,6 +1,5 @@ require_relative "factories/feed_factory" require_relative "factories/story_factory" -require_relative "factories/group_factory" require_relative "factories/feeds" require_relative "factories/groups" require_relative "factories/stories" diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rb deleted file mode 100644 index 58814dab5..000000000 --- a/spec/factories/group_factory.rb +++ /dev/null @@ -1,17 +0,0 @@ -class GroupFactory - class FakeGroup < OpenStruct - def as_fever_json - { - id: id, - title: name - } - end - end - - def self.build(params = {}) - FakeGroup.new( - id: rand(100), - name: params[:name] || "#{Faker::Name.name} group" - ) - end -end diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 4c3bef019..7d643fbe2 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -11,7 +11,7 @@ def app let(:api_key) { "apisecretkey" } let(:story_one) { StoryFactory.build } let(:story_two) { StoryFactory.build } - let(:group) { GroupFactory.build } + let(:group) { build(:group) } let(:feed) { FeedFactory.build(group_id: group.id) } let(:stories) { [story_one, story_two] } let(:standard_answer) do From 39a6a8859fd64426e1d5eae742e371d76e15bf53 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 17:26:09 -0800 Subject: [PATCH 211/779] Factories: replace StoryFactory with FactoryBot (#738) --- .rubocop_todo.yml | 7 ---- spec/controllers/stories_controller_spec.rb | 12 +++--- spec/factories.rb | 1 - spec/factories/feeds.rb | 1 + spec/factories/stories.rb | 2 + spec/factories/story_factory.rb | 41 --------------------- spec/fever_api_spec.rb | 4 +- spec/support/factory_bot.rb | 1 + 8 files changed, 12 insertions(+), 57 deletions(-) delete mode 100644 spec/factories/story_factory.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 285089a8b..0f666e620 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,7 +22,6 @@ Lint/NumberConversion: - 'app/models/story.rb' - 'app/repositories/story_repository.rb' - 'spec/factories/feed_factory.rb' - - 'spec/factories/story_factory.rb' - 'spec/models/feed_spec.rb' - 'spec/models/story_spec.rb' @@ -47,7 +46,6 @@ Metrics/MethodLength: - 'app/utils/sample_story.rb' - 'config/asset_pipeline.rb' - 'db/migrate/20130425222157_add_delayed_job.rb' - - 'spec/factories/story_factory.rb' # Offense count: 9 # Configuration parameters: ForbiddenDelimiters. @@ -629,7 +627,6 @@ Rails/TimeZone: - 'app/utils/sample_story.rb' - 'spec/commands/find_new_stories_spec.rb' - 'spec/factories/feed_factory.rb' - - 'spec/factories/story_factory.rb' - 'spec/fever_api_spec.rb' - 'spec/integration/feed_importing_spec.rb' - 'spec/models/story_spec.rb' @@ -801,7 +798,6 @@ Style/FrozenStringLiteralComment: - 'spec/factories/feeds.rb' - 'spec/factories/groups.rb' - 'spec/factories/stories.rb' - - 'spec/factories/story_factory.rb' - 'spec/factories/users.rb' - 'spec/fever_api/authentication_spec.rb' - 'spec/fever_api/read_favicons_spec.rb' @@ -863,7 +859,6 @@ Style/HashSyntax: - 'app/repositories/story_repository.rb' - 'app/utils/sample_story.rb' - 'spec/factories/feed_factory.rb' - - 'spec/factories/story_factory.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' - 'spec/fever_api/read_groups_spec.rb' @@ -955,7 +950,6 @@ Style/OpenStructUse: Exclude: - 'app.rb' - 'spec/factories/feed_factory.rb' - - 'spec/factories/story_factory.rb' # Offense count: 28 # Configuration parameters: SuspiciousParamNames, Allowlist. @@ -977,7 +971,6 @@ Style/OptionHash: - 'spec/factories/feed_factory.rb' - 'spec/factories/feeds.rb' - 'spec/factories/groups.rb' - - 'spec/factories/story_factory.rb' # Offense count: 12 # This cop supports safe autocorrection (--autocorrect). diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 47a668d5f..88e4a42fc 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -4,8 +4,8 @@ app_require "controllers/sinatra/stories_controller" describe "StoriesController" do - let(:story_one) { StoryFactory.build } - let(:story_two) { StoryFactory.build } + let(:story_one) { create(:story) } + let(:story_two) { create(:story) } let(:stories) { [story_one, story_two] } describe "GET /news" do @@ -60,8 +60,8 @@ end describe "GET /archive" do - let(:read_one) { StoryFactory.build(is_read: true) } - let(:read_two) { StoryFactory.build(is_read: true) } + let(:read_one) { build(:story, :read) } + let(:read_two) { build(:story, :read) } let(:stories) { [read_one, read_two].paginate } before { allow(StoryRepository).to receive(:read).and_return(stories) } @@ -75,8 +75,8 @@ end describe "GET /starred" do - let(:starred_one) { StoryFactory.build(is_starred: true) } - let(:starred_two) { StoryFactory.build(is_starred: true) } + let(:starred_one) { build(:story, :starred) } + let(:starred_two) { build(:story, :starred) } let(:stories) { [starred_one, starred_two].paginate } before { allow(StoryRepository).to receive(:starred).and_return(stories) } diff --git a/spec/factories.rb b/spec/factories.rb index 762511d70..e7de0de90 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,5 +1,4 @@ require_relative "factories/feed_factory" -require_relative "factories/story_factory" require_relative "factories/feeds" require_relative "factories/groups" require_relative "factories/stories" diff --git a/spec/factories/feeds.rb b/spec/factories/feeds.rb index 8fd25e7aa..a74858e7e 100644 --- a/spec/factories/feeds.rb +++ b/spec/factories/feeds.rb @@ -1,5 +1,6 @@ FactoryBot.define do factory(:feed) do + sequence(:name, 100) { |n| "Feed #{n}" } sequence(:url, 100) { |n| "http://exampoo.com/#{n}" } end end diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index 11a8add66..22859cbb1 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -4,6 +4,8 @@ sequence(:entry_id, 100) { |n| "entry-#{n}" } + published { Time.zone.now } + trait :read do is_read { true } end diff --git a/spec/factories/story_factory.rb b/spec/factories/story_factory.rb deleted file mode 100644 index 0b4557465..000000000 --- a/spec/factories/story_factory.rb +++ /dev/null @@ -1,41 +0,0 @@ -require_relative "./feed_factory" - -class StoryFactory - class FakeStory < OpenStruct - def headline - title[0, 50] - end - - def source - feed.name - end - - def as_fever_json - { - id: id, - feed_id: feed_id, - title: title, - author: source, - html: body, - url: permalink, - is_saved: is_starred ? 1 : 0, - is_read: is_read ? 1 : 0, - created_on_time: published.to_i - } - end - end - - def self.build(params = {}) - default_params = { - id: rand(100), - title: Faker::Lorem.sentence, - permalink: Faker::Internet.url, - body: Faker::Lorem.paragraph, - feed: FeedFactory.build, - is_read: false, - is_starred: false, - published: Time.now - } - FakeStory.new(default_params.merge(params)) - end -end diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 7d643fbe2..8f9a57c3f 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -9,8 +9,8 @@ def app end let(:api_key) { "apisecretkey" } - let(:story_one) { StoryFactory.build } - let(:story_two) { StoryFactory.build } + let(:story_one) { build(:story) } + let(:story_two) { build(:story) } let(:group) { build(:group) } let(:feed) { FeedFactory.build(group_id: group.id) } let(:stories) { [story_one, story_two] } diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb index 84cf4a0c8..47ebafcec 100644 --- a/spec/support/factory_bot.rb +++ b/spec/support/factory_bot.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "factory_bot" +require "support/active_record" module FactoryCache def self.user From cd32ec3294b1306cf4812f496509d22651a95575 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 17:41:09 -0800 Subject: [PATCH 212/779] Factories: replace FeedFactory with FactoryBot (#739) --- .rubocop_todo.yml | 13 ---------- spec/commands/feeds/add_new_feed_spec.rb | 2 +- spec/commands/feeds/export_to_opml_spec.rb | 4 ++-- spec/controllers/feeds_controller_spec.rb | 6 ++--- spec/factories.rb | 1 - spec/factories/feed_factory.rb | 28 ---------------------- spec/fever_api_spec.rb | 2 +- spec/tasks/fetch_feeds_spec.rb | 2 +- 8 files changed, 8 insertions(+), 50 deletions(-) delete mode 100644 spec/factories/feed_factory.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0f666e620..96b279aad 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,7 +21,6 @@ Lint/NumberConversion: - 'app/models/feed.rb' - 'app/models/story.rb' - 'app/repositories/story_repository.rb' - - 'spec/factories/feed_factory.rb' - 'spec/models/feed_spec.rb' - 'spec/models/story_spec.rb' @@ -626,7 +625,6 @@ Rails/TimeZone: - 'app/tasks/remove_old_stories.rb' - 'app/utils/sample_story.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/factories/feed_factory.rb' - 'spec/fever_api_spec.rb' - 'spec/integration/feed_importing_spec.rb' - 'spec/models/story_spec.rb' @@ -794,7 +792,6 @@ Style/FrozenStringLiteralComment: - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/factories.rb' - - 'spec/factories/feed_factory.rb' - 'spec/factories/feeds.rb' - 'spec/factories/groups.rb' - 'spec/factories/stories.rb' @@ -858,7 +855,6 @@ Style/HashSyntax: - 'app/models/story.rb' - 'app/repositories/story_repository.rb' - 'app/utils/sample_story.rb' - - 'spec/factories/feed_factory.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' - 'spec/fever_api/read_groups_spec.rb' @@ -949,7 +945,6 @@ Style/NumericLiterals: Style/OpenStructUse: Exclude: - 'app.rb' - - 'spec/factories/feed_factory.rb' # Offense count: 28 # Configuration parameters: SuspiciousParamNames, Allowlist. @@ -968,7 +963,6 @@ Style/OptionHash: - 'app/fever_api/write_mark_feed.rb' - 'app/fever_api/write_mark_group.rb' - 'app/fever_api/write_mark_item.rb' - - 'spec/factories/feed_factory.rb' - 'spec/factories/feeds.rb' - 'spec/factories/groups.rb' @@ -1016,13 +1010,6 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Mode. -Style/StringConcatenation: - Exclude: - - 'spec/factories/feed_factory.rb' - # Offense count: 19 # This cop supports unsafe autocorrection (--autocorrect-all). Style/StringHashKeys: diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 3cc19ee65..52545fab2 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -17,7 +17,7 @@ let(:feed_url) { "http://feed.com/atom.xml" } let(:feed_result) { double(title: feed.name, feed_url: feed.url) } let(:discoverer) { double(discover: feed_result) } - let(:feed) { FeedFactory.build } + let(:feed) { build(:feed) } let(:repo) { double } it "parses and creates the feed if discovered" do diff --git a/spec/commands/feeds/export_to_opml_spec.rb b/spec/commands/feeds/export_to_opml_spec.rb index cb4c231db..259fa09e7 100644 --- a/spec/commands/feeds/export_to_opml_spec.rb +++ b/spec/commands/feeds/export_to_opml_spec.rb @@ -4,8 +4,8 @@ describe ExportToOpml do describe "#to_xml" do - let(:feed_one) { FeedFactory.build } - let(:feed_two) { FeedFactory.build } + let(:feed_one) { build(:feed) } + let(:feed_two) { build(:feed) } let(:feeds) { [feed_one, feed_two] } it "returns OPML XML" do diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 170cb3373..574f3c729 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -3,7 +3,7 @@ app_require "controllers/feeds_controller" describe "FeedsController" do - let(:feeds) { [FeedFactory.build, FeedFactory.build] } + let(:feeds) { build_pair(:feed) } describe "GET /feeds" do it "renders a list of feeds" do @@ -60,7 +60,7 @@ def params(feed, **overrides) describe "PUT /feeds/:feed_id" do it "updates a feed given the id" do - feed = FeedFactory.build(url: "example.com/atom", id: "12", group_id: nil) + feed = build(:feed, url: "example.com/atom", id: "12", group_id: nil) mock_feed(feed, "Test", "example.com/feed") feed_url = "example.com/feed" @@ -70,7 +70,7 @@ def params(feed, **overrides) end it "updates a feed group given the id" do - feed = FeedFactory.build(url: "example.com/atom") + feed = build(:feed, url: "example.com/atom") mock_feed(feed, feed.name, feed.url, "321") put "/feeds/123", **params(feed, feed_id: "123", group_id: "321") diff --git a/spec/factories.rb b/spec/factories.rb index e7de0de90..eb39ac32f 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,4 +1,3 @@ -require_relative "factories/feed_factory" require_relative "factories/feeds" require_relative "factories/groups" require_relative "factories/stories" diff --git a/spec/factories/feed_factory.rb b/spec/factories/feed_factory.rb deleted file mode 100644 index b649894a6..000000000 --- a/spec/factories/feed_factory.rb +++ /dev/null @@ -1,28 +0,0 @@ -class FeedFactory - class FakeFeed < OpenStruct - def as_fever_json - { - id: id, - favicon_id: 0, - title: name, - url: url, - site_url: url, - is_spark: 0, - last_updated_on_time: last_fetched.to_i - } - end - end - - def self.build(params = {}) - FakeFeed.new( - id: rand(100), - group_id: rand(100), - name: Faker::Name.name + " on Software", - url: Faker::Internet.url, - last_fetched: Time.now, - stories: [], - unread_stories: [], - **params - ) - end -end diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 8f9a57c3f..914f4bc5e 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -12,7 +12,7 @@ def app let(:story_one) { build(:story) } let(:story_two) { build(:story) } let(:group) { build(:group) } - let(:feed) { FeedFactory.build(group_id: group.id) } + let(:feed) { build(:feed, group: group) } let(:stories) { [story_one, story_two] } let(:standard_answer) do { api_version: 3, auth: 1, last_refreshed_on_time: 123456789 } diff --git a/spec/tasks/fetch_feeds_spec.rb b/spec/tasks/fetch_feeds_spec.rb index d3ba07b18..7b66229ad 100644 --- a/spec/tasks/fetch_feeds_spec.rb +++ b/spec/tasks/fetch_feeds_spec.rb @@ -3,7 +3,7 @@ describe FetchFeeds do describe "#fetch_all" do - let(:feeds) { [FeedFactory.build, FeedFactory.build] } + let(:feeds) { build_pair(:feed) } let(:fetcher_one) { instance_double(FetchFeed) } let(:fetcher_two) { instance_double(FetchFeed) } let(:pool) { double } From 2a96941f21fd3fcbebd8023d3ab3192d67519fd3 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 20 Dec 2022 17:47:50 -0800 Subject: [PATCH 213/779] Factories: remove Factories module (#740) --- spec/factories.rb | 7 ------- spec/spec_helper.rb | 1 - 2 files changed, 8 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index eb39ac32f..49b48b372 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -2,10 +2,3 @@ require_relative "factories/groups" require_relative "factories/stories" require_relative "factories/users" - -module Factories - def next_id - @next_id ||= 0 - @next_id += 1 - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6bfd9b0b5..6873a783f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,7 +35,6 @@ def custom_request(method, path, params = {}, env = {}, &) RSpec.configure do |config| config.include Rack::Test::Methods config.include RSpecHtmlMatchers - config.include Factories end def app_require(file) From 5dd4011d2d23000de9fbb0b0a34809349546e41b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 27 Dec 2022 20:41:01 -0800 Subject: [PATCH 214/779] Update all Bundler dependencies (2022-12-26) (#742) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a8c143966..4c244265e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,11 +83,11 @@ GEM xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.1.10) - coveralls_reborn (0.25.0) - simplecov (>= 0.18.1, < 0.22.0) - term-ansicolor (~> 1.6) - thor (>= 0.20.3, < 2.0) - tins (~> 1.16) + coveralls_reborn (0.26.0) + simplecov (~> 0.22.0) + term-ansicolor (~> 1.7) + thor (~> 1.2) + tins (~> 1.32) crass (1.0.6) date (3.3.3) delayed_job (4.1.11) @@ -97,14 +97,14 @@ GEM delayed_job (>= 3.0, < 5) diff-lcs (1.5.0) docile (1.4.0) - erubi (1.11.0) + erubi (1.12.0) execjs (2.8.1) factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (3.0.0) + faker (3.1.0) i18n (>= 1.8.11, < 2) feedbag (1.0.0) nokogiri (~> 1.8, >= 1.8.2) @@ -135,13 +135,13 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) mini_mime (1.1.2) - mini_portile2 (2.8.0) + mini_portile2 (2.8.1) minitest (5.16.3) multi_json (1.15.0) multi_xml (0.6.0) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - net-imap (0.3.2) + net-imap (0.3.4) date net-protocol net-pop (0.1.2) @@ -165,9 +165,9 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) public_suffix (5.0.1) - puma (6.0.0) + puma (6.0.1) nio4r (~> 2.0) - racc (1.6.1) + racc (1.6.2) rack (2.2.4) rack-protection (3.0.5) rack @@ -235,7 +235,7 @@ GEM rspec-mocks (~> 3.11) rspec-support (~> 3.11) rspec-support (3.12.0) - rubocop (1.40.0) + rubocop (1.41.1) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) @@ -247,7 +247,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.24.0) parser (>= 3.1.1.0) - rubocop-rails (2.17.3) + rubocop-rails (2.17.4) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -265,7 +265,7 @@ GEM sax-machine (1.3.2) shotgun (0.9.2) rack (>= 1.0) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) @@ -287,9 +287,9 @@ GEM tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) - sprockets (4.1.1) + sprockets (4.2.0) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + rack (>= 2.2.4, < 4) sprockets-helpers (1.4.0) sprockets (>= 2.2) sync (0.5.0) From 96e28976a7cab7e317a2097ae56d57762104c843 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Wed, 28 Dec 2022 14:11:23 -0800 Subject: [PATCH 215/779] RuboCop: switch WordArray rule (#745) Sticking with brackets for consistency. --- .rubocop.yml | 2 ++ .rubocop_todo.yml | 13 ------------- app/helpers/authentication_helpers.rb | 2 +- app/helpers/url_helpers.rb | 2 +- config/asset_pipeline.rb | 2 +- spec/controllers/stories_controller_spec.rb | 2 +- spec/fever_api/read_items_spec.rb | 2 +- spec/helpers/authentications_helper_spec.rb | 4 ++-- spec/helpers/url_helpers_spec.rb | 2 +- spec/javascript/test_controller.rb | 20 ++++++++++---------- 10 files changed, 20 insertions(+), 31 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 824da5e97..84149d247 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,8 @@ Style/StringLiterals: { EnforcedStyle: double_quotes } # want to enable these, but they don't work right when using `.rubocop_todo.yml` Style/DocumentationMethod: { Enabled: false } Style/Documentation: { Enabled: false } +Style/SymbolArray: { EnforcedStyle: brackets } +Style/WordArray: { EnforcedStyle: brackets } ################################################################################ # diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 96b279aad..24626f36f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -966,19 +966,6 @@ Style/OptionHash: - 'spec/factories/feeds.rb' - 'spec/factories/groups.rb' -# Offense count: 12 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Exclude: - - 'app/helpers/authentication_helpers.rb' - - 'app/helpers/url_helpers.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/helpers/authentications_helper_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - - 'spec/javascript/test_controller.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/app/helpers/authentication_helpers.rb b/app/helpers/authentication_helpers.rb index cb70a94f5..93e0eb364 100644 --- a/app/helpers/authentication_helpers.rb +++ b/app/helpers/authentication_helpers.rb @@ -10,7 +10,7 @@ def authenticated? def needs_authentication?(path) return false unless UserRepository.setup_complete? - return false if %w(/login /logout /heroku).include?(path) + return false if ["/login", "/logout", "/heroku"].include?(path) return false if path =~ /css|js|img/ true diff --git a/app/helpers/url_helpers.rb b/app/helpers/url_helpers.rb index 0be9dd386..b9e0121f9 100644 --- a/app/helpers/url_helpers.rb +++ b/app/helpers/url_helpers.rb @@ -7,7 +7,7 @@ module UrlHelpers def expand_absolute_urls(content, base_url) doc = Nokogiri::HTML.fragment(content) - [%w(a href), %w(img src), %w(video src)].each do |tag, attr| + [["a", "href"], ["img", "src"], ["video", "src"]].each do |tag, attr| doc.css("#{tag}[#{attr}]").each do |node| url = node.get_attribute(attr) next if url =~ ABS_RE diff --git a/config/asset_pipeline.rb b/config/asset_pipeline.rb index 32f2b2a83..59b009e36 100644 --- a/config/asset_pipeline.rb +++ b/config/asset_pipeline.rb @@ -2,7 +2,7 @@ module AssetPipeline def registered(app) app.set :sprockets, Sprockets::Environment.new(app.root) - %w[assets stylesheets javascripts].each do |path| + ["assets", "stylesheets", "javascripts"].each do |path| app.get "/#{path}/*" do env["PATH_INFO"].sub!(%r{^/#{path}}, "") settings.sprockets.call(env) diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 88e4a42fc..0fcf3fa24 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -154,7 +154,7 @@ it "marks all unread stories as read and reload the page" do expect_any_instance_of(MarkAllAsRead).to receive(:mark_as_read).once - post "/stories/mark_all_as_read", story_ids: %w(1 2 3) + post "/stories/mark_all_as_read", story_ids: ["1", "2", "3"] expect(last_response.status).to be 302 expect(URI.parse(last_response.location).path).to eq "/news" diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index fef8e3131..b56eca152 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -54,7 +54,7 @@ double("story", as_fever_json: { id: 11 }) ] expect(story_repository) - .to receive(:fetch_by_ids).with(%w(5 11)).twice.and_return(stories) + .to receive(:fetch_by_ids).with(["5", "11"]).twice.and_return(stories) expect(subject.call("items" => nil, with_ids: "5,11")).to eq( items: [ diff --git a/spec/helpers/authentications_helper_spec.rb b/spec/helpers/authentications_helper_spec.rb index e66496e00..7d77141df 100644 --- a/spec/helpers/authentications_helper_spec.rb +++ b/spec/helpers/authentications_helper_spec.rb @@ -23,7 +23,7 @@ end end - %w(/login /logout /heroku).each do |path| + ["/login", "/logout", "/heroku"].each do |path| context "when `path` is '#{path}'" do it "returns false" do expect(helper.needs_authentication?(path)).to be(false) @@ -31,7 +31,7 @@ end end - %w(css js img).each do |path| + ["css", "js", "img"].each do |path| context "when `path` contains '#{path}'" do it "returns false" do expect(helper.needs_authentication?("/#{path}/file.ext")).to be(false) diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index 7a422d2ee..edcb36d63 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -77,7 +77,7 @@ describe "#normalize_url" do it "resolves scheme-less urls" do - %w(http https).each do |scheme| + ["http", "https"].each do |scheme| feed_url = "#{scheme}://blog.golang.org/feed.atom" url = helper.normalize_url("//blog.golang.org/context", feed_url) diff --git a/spec/javascript/test_controller.rb b/spec/javascript/test_controller.rb index 97c62a491..cb6025913 100644 --- a/spec/javascript/test_controller.rb +++ b/spec/javascript/test_controller.rb @@ -23,26 +23,26 @@ def self.test_path(*chunks) private def vendor_js_files - %w( - mocha.js - sinon.js - chai.js - chai-changes.js - chai-backbone.js - sinon-chai.js - ).map do |name| + [ + "mocha.js", + "sinon.js", + "chai.js", + "chai-changes.js", + "chai-backbone.js", + "sinon-chai.js" + ].map do |name| File.join "vendor", "js", name end end def vendor_css_files - %w(mocha.css).map do |name| + ["mocha.css"].map do |name| File.join "vendor", "css", name end end def js_helper_files - %w(spec_helper.js).map do |name| + ["spec_helper.js"].map do |name| File.join "spec", name end end From c92b43d3ad69d5459e488893c071d7bb5fd1c1d8 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Wed, 28 Dec 2022 14:53:00 -0800 Subject: [PATCH 216/779] Fix: handle feeds that are missing a title (#746) Use the URL in its place. Fixes #744. --- .rubocop_todo.yml | 1 + app/commands/feeds/add_new_feed.rb | 8 +++----- app/controllers/feeds_controller.rb | 4 ++++ spec/commands/feeds/add_new_feed_spec.rb | 11 +++++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 24626f36f..fc8c0b673 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -216,6 +216,7 @@ RSpec/EmptyLineAfterHook: # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: + - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/feeds/export_to_opml_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' diff --git a/app/commands/feeds/add_new_feed.rb b/app/commands/feeds/add_new_feed.rb index 5fa5810db..0b13f2eb8 100644 --- a/app/commands/feeds/add_new_feed.rb +++ b/app/commands/feeds/add_new_feed.rb @@ -9,10 +9,8 @@ def self.add(url, discoverer = FeedDiscovery.new, repo = Feed) result = discoverer.discover(url) return false unless result - repo.create( - name: ContentSanitizer.sanitize(result.title), - url: result.feed_url, - last_fetched: Time.now - ONE_DAY - ) + name = ContentSanitizer.sanitize(result.title.presence || result.feed_url) + + repo.create(name:, url: result.feed_url, last_fetched: Time.now - ONE_DAY) end end diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 0f1488707..298cea139 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +require_relative "../repositories/feed_repository" +require_relative "../commands/feeds/add_new_feed" +require_relative "../commands/feeds/export_to_opml" + class FeedsController < ApplicationController def index @feeds = FeedRepository.list diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 52545fab2..2c0c77d93 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -45,5 +45,16 @@ end end end + + it "uses feed_url as name when title is not present" do + feed_url = "https://protomen.com/news/feed" + result = instance_double(Feedjira::Parser::RSS, title: nil, feed_url:) + discoverer = instance_double(FeedDiscovery, discover: result) + + expect { AddNewFeed.add(feed_url, discoverer) } + .to change(Feed, :count).by(1) + + expect(Feed.last.name).to eq(feed_url) + end end end From 147db851d4f276c8f2dffe147cf6a535def21df5 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 14:59:15 -0800 Subject: [PATCH 217/779] RuboCop: disable StringHashKeys cop (#747) As much as I might prefer consistency, this one seems hard to enforce safely. --- .rubocop.yml | 1 + .rubocop_todo.yml | 20 -------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 84149d247..52d907f21 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -44,3 +44,4 @@ Style/InlineComment: { Enabled: false } Style/MissingElse: { Enabled: false } Style/RequireOrder: { Enabled: false } Style/SafeNavigation: { Enabled: false } +Style/StringHashKeys: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fc8c0b673..1561a2104 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -998,26 +998,6 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' -# Offense count: 19 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/StringHashKeys: - Exclude: - - 'app/helpers/controller_helpers.rb' - - 'fever_api.rb' - - 'spec/app_spec.rb' - - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/imports_controller_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - - 'spec/fever_api/read_favicons_spec.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/read_links_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinSize. From 9a249e18bfc437649bf8aa77d8fa27e7285f3849 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 15:26:44 -0800 Subject: [PATCH 218/779] RuboCop: inspect blocks for RedundantLineBreak (#748) --- .rubocop.yml | 1 + app/commands/feeds/export_to_opml.rb | 4 +--- app/fever_api/write_mark_item.rb | 4 +--- app/utils/feed_discovery.rb | 4 +--- spec/commands/find_new_stories_spec.rb | 4 +--- spec/factories/groups.rb | 4 +--- spec/fever_api/read_feeds_groups_spec.rb | 4 +--- spec/fever_api/read_feeds_spec.rb | 8 ++------ spec/fever_api/read_items_spec.rb | 4 +--- spec/fever_api/write_mark_feed_spec.rb | 4 +--- spec/fever_api/write_mark_group_spec.rb | 4 +--- spec/fever_api/write_mark_item_spec.rb | 4 +--- spec/fever_api_spec.rb | 4 +--- spec/integration/feed_importing_spec.rb | 8 ++------ spec/javascript/test_controller.rb | 8 ++------ spec/repositories/story_repository_spec.rb | 4 +--- 16 files changed, 19 insertions(+), 54 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 52d907f21..0dbf283c5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,6 +12,7 @@ AllCops: - 'vendor/**/*' Layout/LineLength: { Max: 80 } +Layout/RedundantLineBreak: { InspectBlocks: true } Metrics/BlockLength: { Exclude: ['spec/**/*_spec.rb'] } Style/MethodCallWithArgsParentheses: AllowedMethods: diff --git a/app/commands/feeds/export_to_opml.rb b/app/commands/feeds/export_to_opml.rb index c6e37810c..a8e6e457e 100644 --- a/app/commands/feeds/export_to_opml.rb +++ b/app/commands/feeds/export_to_opml.rb @@ -9,9 +9,7 @@ def to_xml builder = Nokogiri::XML::Builder.new do |xml| xml.opml(version: "1.0") do - xml.head do - xml.title "Feeds from Stringer" - end + xml.head { xml.title "Feeds from Stringer" } xml.body do @feeds.each do |feed| xml.outline( diff --git a/app/fever_api/write_mark_item.rb b/app/fever_api/write_mark_item.rb index fe18a78b4..7d35e31db 100644 --- a/app/fever_api/write_mark_item.rb +++ b/app/fever_api/write_mark_item.rb @@ -8,9 +8,7 @@ class WriteMarkItem def initialize(options = {}) @read_marker_class = options.fetch(:read_marker_class) { MarkAsRead } @unread_marker_class = - options.fetch(:unread_marker_class) do - MarkAsUnread - end + options.fetch(:unread_marker_class) { MarkAsUnread } @starred_marker_class = options.fetch(:starred_marker_class) { MarkAsStarred } @unstarred_marker_class = diff --git a/app/utils/feed_discovery.rb b/app/utils/feed_discovery.rb index c55ad3484..83f4d5a53 100644 --- a/app/utils/feed_discovery.rb +++ b/app/utils/feed_discovery.rb @@ -8,9 +8,7 @@ def discover(url, finder = Feedbag, parser = Feedjira, client = HTTParty) urls = finder.find(url) return false if urls.empty? - get_feed_for_url(urls.first, parser, client) do - return false - end + get_feed_for_url(urls.first, parser, client) { return false } end end diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index c0992e592..c6d542a30 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -6,9 +6,7 @@ describe FindNewStories do describe "#new_stories" do context "the feed contains no new stories" do - before do - allow(StoryRepository).to receive(:exists?).and_return(true) - end + before { allow(StoryRepository).to receive(:exists?).and_return(true) } it "should find zero new stories" do story1 = double(published: nil, id: "story1") diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb index 3feda95ef..21306b6bb 100644 --- a/spec/factories/groups.rb +++ b/spec/factories/groups.rb @@ -1,3 +1 @@ -FactoryBot.define do - factory(:group) -end +FactoryBot.define { factory(:group) } diff --git a/spec/fever_api/read_feeds_groups_spec.rb b/spec/fever_api/read_feeds_groups_spec.rb index 81204fc3a..6540503dd 100644 --- a/spec/fever_api/read_feeds_groups_spec.rb +++ b/spec/fever_api/read_feeds_groups_spec.rb @@ -7,9 +7,7 @@ let(:feeds) { feed_ids.map { |id| double("feed", id: id, group_id: 1) } } let(:feed_repository) { double("repo") } - subject do - FeverAPI::ReadFeedsGroups.new(feed_repository: feed_repository) - end + subject { FeverAPI::ReadFeedsGroups.new(feed_repository: feed_repository) } it "returns a list of groups requested through feeds" do allow(feed_repository) diff --git a/spec/fever_api/read_feeds_spec.rb b/spec/fever_api/read_feeds_spec.rb index 3b0c36998..5ab15483c 100644 --- a/spec/fever_api/read_feeds_spec.rb +++ b/spec/fever_api/read_feeds_spec.rb @@ -5,15 +5,11 @@ describe FeverAPI::ReadFeeds do let(:feed_ids) { [5, 7, 11] } let(:feeds) do - feed_ids.map do |id| - double("feed", id: id, as_fever_json: { id: id }) - end + feed_ids.map { |id| double("feed", id: id, as_fever_json: { id: id }) } end let(:feed_repository) { double("repo") } - subject do - FeverAPI::ReadFeeds.new(feed_repository: feed_repository) - end + subject { FeverAPI::ReadFeeds.new(feed_repository: feed_repository) } it "returns a list of feeds" do expect(feed_repository).to receive(:list).and_return(feeds) diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index b56eca152..d146af044 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -5,9 +5,7 @@ describe FeverAPI::ReadItems do let(:story_repository) { double("repo") } - subject do - FeverAPI::ReadItems.new(story_repository: story_repository) - end + subject { FeverAPI::ReadItems.new(story_repository: story_repository) } it "returns a list of unread items including total count" do stories = [ diff --git a/spec/fever_api/write_mark_feed_spec.rb b/spec/fever_api/write_mark_feed_spec.rb index 65efde1d8..719b9ed65 100644 --- a/spec/fever_api/write_mark_feed_spec.rb +++ b/spec/fever_api/write_mark_feed_spec.rb @@ -6,9 +6,7 @@ let(:feed_marker) { double("feed marker") } let(:marker_class) { double("marker class") } - subject do - FeverAPI::WriteMarkFeed.new(marker_class: marker_class) - end + subject { FeverAPI::WriteMarkFeed.new(marker_class: marker_class) } it "instantiates a feed marker and calls mark_feed_as_read if requested" do expect(marker_class) diff --git a/spec/fever_api/write_mark_group_spec.rb b/spec/fever_api/write_mark_group_spec.rb index 91044ea56..9eaa6ee6a 100644 --- a/spec/fever_api/write_mark_group_spec.rb +++ b/spec/fever_api/write_mark_group_spec.rb @@ -6,9 +6,7 @@ let(:group_marker) { double("group marker") } let(:marker_class) { double("marker class") } - subject do - FeverAPI::WriteMarkGroup.new(marker_class: marker_class) - end + subject { FeverAPI::WriteMarkGroup.new(marker_class: marker_class) } it "instantiates a group marker and calls mark_group_as_read if requested" do expect(marker_class) diff --git a/spec/fever_api/write_mark_item_spec.rb b/spec/fever_api/write_mark_item_spec.rb index 483d2eba9..9efd634cc 100644 --- a/spec/fever_api/write_mark_item_spec.rb +++ b/spec/fever_api/write_mark_item_spec.rb @@ -7,9 +7,7 @@ let(:marker_class) { double("marker class") } describe "as read" do - subject do - FeverAPI::WriteMarkItem.new(read_marker_class: marker_class) - end + subject { FeverAPI::WriteMarkItem.new(read_marker_class: marker_class) } it "calls mark_item_as_read if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 914f4bc5e..9f656ed3e 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -17,9 +17,7 @@ def app let(:standard_answer) do { api_version: 3, auth: 1, last_refreshed_on_time: 123456789 } end - let(:cannot_auth) do - { api_version: 3, auth: 0 } - end + let(:cannot_auth) { { api_version: 3, auth: 0 } } let(:headers) { { api_key: api_key } } before do diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index f7d99df80..200e0bb3d 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -7,9 +7,7 @@ app_require "tasks/fetch_feed" describe "Feed importing" do - before(:all) do - @server = FeedServer.new - end + before(:all) { @server = FeedServer.new } let(:feed) do Feed.create( @@ -57,9 +55,7 @@ end describe "Feed with incorrect pubdates" do - before(:all) do - Timecop.freeze Time.parse("2014-08-12T17:30:00Z") - end + before(:all) { Timecop.freeze Time.parse("2014-08-12T17:30:00Z") } context "has been fetched before" do it "imports all new stories" do diff --git a/spec/javascript/test_controller.rb b/spec/javascript/test_controller.rb index cb6025913..84a5f6b59 100644 --- a/spec/javascript/test_controller.rb +++ b/spec/javascript/test_controller.rb @@ -36,15 +36,11 @@ def vendor_js_files end def vendor_css_files - ["mocha.css"].map do |name| - File.join "vendor", "css", name - end + ["mocha.css"].map { |name| File.join "vendor", "css", name } end def js_helper_files - ["spec_helper.js"].map do |name| - File.join "spec", name - end + ["spec_helper.js"].map { |name| File.join "spec", name } end def js_lib_files diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 816bedb6a..bc8f96949 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -6,9 +6,7 @@ describe StoryRepository do describe ".add" do let(:feed) { double(url: "http://blog.golang.org/feed.atom") } - before do - allow(Story).to receive(:create) - end + before { allow(Story).to receive(:create) } it "normalizes story urls" do entry = double( From c056f3f017c8dcddd32f747596a43e447cf9b621 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 15:39:29 -0800 Subject: [PATCH 219/779] RuboCop: refactor FeedsController#create (#749) --- .rubocop_todo.yml | 6 ------ app/controllers/feeds_controller.rb | 17 ++++++++--------- config/locales/de.yml | 8 ++++---- config/locales/el-GR.yml | 8 ++++---- config/locales/en.yml | 8 ++++---- config/locales/eo.yml | 8 ++++---- config/locales/es.yml | 8 ++++---- config/locales/fr.yml | 8 ++++---- config/locales/he.yml | 8 ++++---- config/locales/it.yml | 8 ++++---- config/locales/ja.yml | 8 ++++---- config/locales/nl.yml | 8 ++++---- config/locales/pt-BR.yml | 8 ++++---- config/locales/pt.yml | 8 ++++---- config/locales/ru.yml | 8 ++++---- config/locales/sv.yml | 8 ++++---- config/locales/tr.yml | 8 ++++---- config/locales/zh-CN.yml | 8 ++++---- config/locales/zh-TW.yml | 8 ++++---- 19 files changed, 76 insertions(+), 83 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1561a2104..f4cfe9195 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -24,12 +24,6 @@ Lint/NumberConversion: - 'spec/models/feed_spec.rb' - 'spec/models/story_spec.rb' -# Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes, Max. -Metrics/AbcSize: - Exclude: - - 'app/controllers/feeds_controller.rb' - # Offense count: 15 # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. Metrics/MethodLength: diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 298cea139..0073914a4 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -21,18 +21,17 @@ def create @feed_url = params[:feed_url] feed = AddNewFeed.add(@feed_url) - if feed && feed.valid? - FetchFeeds.enqueue([feed]) + unless feed && feed.valid? + flash.now[:error] = feed ? t(".already_subscribed") : t(".feed_not_found") - flash[:success] = t("feeds.add.flash.added_successfully") - redirect_to("/") - elsif feed - flash.now[:error] = t("feeds.add.flash.already_subscribed_error") - render(:new) - else - flash.now[:error] = t("feeds.add.flash.feed_not_found_error") render(:new) + return end + + FetchFeeds.enqueue([feed]) + + flash[:success] = t(".success") + redirect_to("/") end def update diff --git a/config/locales/de.yml b/config/locales/de.yml index bef897ecb..7eb5b516c 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -25,11 +25,11 @@ de: fields: feed_url: Feed URL submit: Hinzufügen - flash: - added_successfully: Wir haben deinen Feed hinzugefügt. Schau ein bisschen später wieder vorbei. - already_subscribed_error: Du hast diesen Feed bereits abonniert... - feed_not_found_error: Wir konnten diesen Feed nicht finden. Probiere es noch einmal title: Benötigst du neue Geschichten? + create: + success: Wir haben deinen Feed hinzugefügt. Schau ein bisschen später wieder vorbei. + already_subscribed: Du hast diesen Feed bereits abonniert... + feed_not_found: Wir konnten diesen Feed nicht finden. Probiere es noch einmal edit: fields: feed_name: Feed-Name diff --git a/config/locales/el-GR.yml b/config/locales/el-GR.yml index 79f70e364..5e7851c4a 100644 --- a/config/locales/el-GR.yml +++ b/config/locales/el-GR.yml @@ -25,11 +25,11 @@ el-GR: fields: feed_url: Διεύθυνση submit: Προσθήκη - flash: - added_successfully: Το καινούριο σας Ιστολόγιο προστέθηκε. Ελέγξτε παλι αργότερα. - already_subscribed_error: Είστε ήδη εγγεγραμενος σ' αυτο το ιστολόγιο... - feed_not_found_error: Δεν μπορέσαμε να βρούμε αυτο το ιστολόγιο. Προσπαθήστε ξανά. title: Όρεξη για καινούριες ειδήσεις? + create: + success: Το καινούριο σας Ιστολόγιο προστέθηκε. Ελέγξτε παλι αργότερα. + already_subscribed: Είστε ήδη εγγεγραμενος σ' αυτο το ιστολόγιο... + feed_not_found: Δεν μπορέσαμε να βρούμε αυτο το ιστολόγιο. Προσπαθήστε ξανά. edit: fields: feed_name: diff --git a/config/locales/en.yml b/config/locales/en.yml index 8eb38af8d..1fe5263c7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -25,11 +25,11 @@ en: fields: feed_url: Feed URL submit: Add - flash: - added_successfully: We've added your new feed. Check back in a bit. - already_subscribed_error: You are already subscribed to this feed... - feed_not_found_error: We couldn't find that feed. Try again. title: Need new stories? + create: + success: We've added your new feed. Check back in a bit. + already_subscribed: You are already subscribed to this feed... + feed_not_found: We couldn't find that feed. Try again. edit: fields: feed_name: Feed Name diff --git a/config/locales/eo.yml b/config/locales/eo.yml index 4dd73b787..a779bff14 100644 --- a/config/locales/eo.yml +++ b/config/locales/eo.yml @@ -25,11 +25,11 @@ eo: fields: feed_url: URL de fluo submit: Aldoni - flash: - added_successfully: Ni aldonis vian nova fluon. Revenu pli poste. - already_subscribed_error: Vi abonis tiun fluon jam... - feed_not_found_error: Ni ne eblas trovi tion fluon. Reprovu. title: Ĉu vi bezonas novajn rakontojn? + create: + success: Ni aldonis vian nova fluon. Revenu pli poste. + already_subscribed: Vi abonis tiun fluon jam... + feed_not_found: Ni ne eblas trovi tion fluon. Reprovu. edit: fields: feed_name: Nomo de fluo diff --git a/config/locales/es.yml b/config/locales/es.yml index 6f7a21446..353c8dae8 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -25,11 +25,11 @@ es: fields: feed_url: URL de la feed submit: Añadir - flash: - added_successfully: Hemos agregado tu nueva feed. Regresa en un ratito. - already_subscribed_error: Ya te suscribiste a esta feed... - feed_not_found_error: No pudimos encontrar esa feed. Inténtalo de vuelta. title: ¿Necesitas nuevas historias? + create: + success: Hemos agregado tu nueva feed. Regresa en un ratito. + already_subscribed: Ya te suscribiste a esta feed... + feed_not_found: No pudimos encontrar esa feed. Inténtalo de vuelta. edit: fields: feed_name: Nombre fuente diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 172e6328a..fd927a3a6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -25,11 +25,11 @@ fr: fields: feed_url: URL du flux submit: Ajouter - flash: - added_successfully: Le nouveau flux a été ajouté. Patientez quelques instants. - already_subscribed_error: Vous suivez déjà ce flux... - feed_not_found_error: Nous n'avons pas pu trouver ce flux. Essayez de nouveau. title: Besoin de nouveaux articles ? + create: + success: Le nouveau flux a été ajouté. Patientez quelques instants. + already_subscribed: Vous suivez déjà ce flux... + feed_not_found: Nous n'avons pas pu trouver ce flux. Essayez de nouveau. edit: fields: feed_name: diff --git a/config/locales/he.yml b/config/locales/he.yml index 9e6d2c96d..7bb881c9f 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -25,11 +25,11 @@ he: fields: feed_url: כתובת של הפיד submit: להוסיף - flash: - added_successfully: אנחנו הוספנו את הפיד החדש. עוד מעט תקבל עידכונים. - already_subscribed_error: הפיד הנ"ל כבר נמצא במעקב. - feed_not_found_error: לא הצלחנו למצוא את הפיד. נסה שוב. title: מחפש מה לקרוא? + create: + success: אנחנו הוספנו את הפיד החדש. עוד מעט תקבל עידכונים. + already_subscribed: הפיד הנ"ל כבר נמצא במעקב. + feed_not_found: לא הצלחנו למצוא את הפיד. נסה שוב. edit: fields: feed_name: diff --git a/config/locales/it.yml b/config/locales/it.yml index d0b4cbaea..0e4277039 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -25,11 +25,11 @@ it: fields: feed_url: URL del feed submit: Aggiungi - flash: - added_successfully: Abbiamo aggiunto il tuo nuovo feed. Ripassa tra qualche istante. - already_subscribed_error: Sei già sottoscritto a questo feed... - feed_not_found_error: Non siamo riusciti a trovare il feed. Riprova. title: Bisogno di nuove storie? + create: + success: Abbiamo aggiunto il tuo nuovo feed. Ripassa tra qualche istante. + already_subscribed: Sei già sottoscritto a questo feed... + feed_not_found: Non siamo riusciti a trovare il feed. Riprova. edit: fields: feed_name: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 4f30eb756..9597207a2 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -25,11 +25,11 @@ ja: fields: feed_url: フィードURL submit: 追加 - flash: - added_successfully: 新しいフィードを追加しました、少し経ってから確認して下さい - already_subscribed_error: このフィードは既に登録されてます - feed_not_found_error: フィードを見つけられませんでした、もう一度試して下さい title: 新しいストーリーが必要ですか? + create: + success: 新しいフィードを追加しました、少し経ってから確認して下さい + already_subscribed: このフィードは既に登録されてます + feed_not_found: フィードを見つけられませんでした、もう一度試して下さい edit: fields: feed_name: フィード名 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 115a908e4..dc32a0f62 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -25,11 +25,11 @@ nl: fields: feed_url: Feed-URL submit: Toevoegen - flash: - added_successfully: We hebben je nieuwe feed toegevoegd. Kijk over een tijdje nog eens. - already_subscribed_error: Je bent al geabonneerd op deze feed... - feed_not_found_error: Die feed konden we niet vinden. Probeer het opnieuw. title: Nieuwe artikelen nodig? + create: + success: We hebben je nieuwe feed toegevoegd. Kijk over een tijdje nog eens. + already_subscribed: Je bent al geabonneerd op deze feed... + feed_not_found: Die feed konden we niet vinden. Probeer het opnieuw. edit: fields: feed_name: Feednaam diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 0a18bfe00..7942b68e4 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -25,11 +25,11 @@ pt-BR: fields: feed_url: URL do Feed submit: Adicionar - flash: - added_successfully: Nós estamos adicionando um novo feed. Volte daqui a pouco. - already_subscribed_error: Você já está inscrito neste feed... - feed_not_found_error: Não conseguimos achar este feed. Tente novamente. title: Precisa de novas histórias? + create: + success: Nós estamos adicionando um novo feed. Volte daqui a pouco. + already_subscribed: Você já está inscrito neste feed... + feed_not_found: Não conseguimos achar este feed. Tente novamente. edit: fields: feed_name: diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 054b19bb8..45a5424d2 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -25,11 +25,11 @@ pt: fields: feed_url: URL da Feed submit: Adicionar - flash: - added_successfully: Adicionamos a sua nova feed. Verifique novamente mais tarde. - already_subscribed_error: Você já subscreveu esta feed... - feed_not_found_error: Não foi possível encontrar a feed. Tente novamente. title: Precisa de novas histórias? + create: + success: Adicionamos a sua nova feed. Verifique novamente mais tarde. + already_subscribed: Você já subscreveu esta feed... + feed_not_found: Não foi possível encontrar a feed. Tente novamente. edit: fields: feed_name: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 30299b1ab..a111fcf8e 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -25,11 +25,11 @@ ru: fields: feed_url: URL фида submit: Добавить - flash: - added_successfully: Мы добавили новый фид. Скоро информация обновится. - already_subscribed_error: Вы уже подписаны на этот фид... - feed_not_found_error: Мы не смогли найти этот фид. Попробуйте еще раз. title: Нужны новые истории? + create: + success: Мы добавили новый фид. Скоро информация обновится. + already_subscribed: Вы уже подписаны на этот фид... + feed_not_found: Мы не смогли найти этот фид. Попробуйте еще раз. edit: fields: feed_name: diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 12487e118..0067e9205 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -25,11 +25,11 @@ sv: fields: feed_url: Feedens URL submit: Lägg till - flash: - added_successfully: Vi har lagt till din nya feed. Kom tillbaks om en stund. - already_subscribed_error: Du prenumererar redan på den här feeden... - feed_not_found_error: Vi kunde inte hitta feeden. Prova igen. title: Behöver du nya berättelser? + create: + success: Vi har lagt till din nya feed. Kom tillbaks om en stund. + already_subscribed: Du prenumererar redan på den här feeden... + feed_not_found: Vi kunde inte hitta feeden. Prova igen. edit: fields: feed_name: Feednamn diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 26523682f..27ce5ecb9 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -25,11 +25,11 @@ tr: fields: feed_url: Besleme URL'si submit: Ekle - flash: - added_successfully: Yeni besleme eklenmistir. Sonra kontrol edin. - already_subscribed_error: Bu beslemeye zaten kayitlisiniz... - feed_not_found_error: Bu beslemeyi bulamadik. Tekrar deneyiniz. title: Yeni hikayelere mi ihtiyaciniz var? + create: + success: Yeni besleme eklenmistir. Sonra kontrol edin. + already_subscribed: Bu beslemeye zaten kayitlisiniz... + feed_not_found: Bu beslemeyi bulamadik. Tekrar deneyiniz. edit: fields: feed_name: diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 275dee1ad..4fd5432f3 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -25,11 +25,11 @@ zh-CN: fields: feed_url: 供稿地址 submit: 添加 - flash: - added_successfully: 你的订阅已经添加完毕,稍等一段时间就可以阅读啦 - already_subscribed_error: 你已经订阅过这个供稿了哟... - feed_not_found_error: 呃,我们无法识别这个供稿地址。麻烦你检查后再试一次。 title: 想要添加新内容? + create: + success: 你的订阅已经添加完毕,稍等一段时间就可以阅读啦 + already_subscribed: 你已经订阅过这个供稿了哟... + feed_not_found: 呃,我们无法识别这个供稿地址。麻烦你检查后再试一次。 edit: fields: feed_name: diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 9eef85581..1cba21e32 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -25,11 +25,11 @@ zh-TW: fields: feed_url: RSS 訊息來源 submit: 新增 - flash: - added_successfully: 你的訂閱已經新增完畢,請稍等一段時間再回來查看 - already_subscribed_error: 你已經訂閱過這個訊息來源了 - feed_not_found_error: 我們找不到這個訊息來源,麻煩檢查並稍後後再試一次 title: 想要新增新內容? + create: + success: 你的訂閱已經新增完畢,請稍等一段時間再回來查看 + already_subscribed: 你已經訂閱過這個訊息來源了 + feed_not_found: 我們找不到這個訊息來源,麻煩檢查並稍後後再試一次 edit: fields: feed_name: 訊息來源名稱 From 86a8f098c1665c1f687b476ee711194f80fabc3f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 15:54:33 -0800 Subject: [PATCH 220/779] RuboCop: configure a handful of rules (#750) --- .rubocop.yml | 8 ++- .rubocop_todo.yml | 139 ++++++---------------------------------------- 2 files changed, 24 insertions(+), 123 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0dbf283c5..fe813b383 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,18 +14,20 @@ AllCops: Layout/LineLength: { Max: 80 } Layout/RedundantLineBreak: { InspectBlocks: true } Metrics/BlockLength: { Exclude: ['spec/**/*_spec.rb'] } +RSpec/MessageExpectation: { EnforcedStyle: expect } +RSpec/MessageSpies: { EnforcedStyle: receive } Style/MethodCallWithArgsParentheses: AllowedMethods: - to - not_to - describe Style/StringLiterals: { EnforcedStyle: double_quotes } +Style/SymbolArray: { EnforcedStyle: brackets } +Style/WordArray: { EnforcedStyle: brackets } # want to enable these, but they don't work right when using `.rubocop_todo.yml` Style/DocumentationMethod: { Enabled: false } Style/Documentation: { Enabled: false } -Style/SymbolArray: { EnforcedStyle: brackets } -Style/WordArray: { EnforcedStyle: brackets } ################################################################################ # @@ -37,6 +39,8 @@ Bundler/GemComment: { Enabled: false } Bundler/GemVersion: { Enabled: false } Layout/SingleLineBlockChain: { Enabled: false } Lint/ConstantResolution: { Enabled: false } +RSpec/AlignLeftLetBrace: { Enabled: false } +RSpec/AlignRightLetBrace: { Enabled: false } RSpec/StubbedMock: { Enabled: false } Rails/SchemaComment: { Enabled: false } Style/ConstantVisibility: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f4cfe9195..24a4969be 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` -# on 2022-12-19 07:00:21 UTC using RuboCop version 1.40.0. +# on 2022-12-20 23:41:09 UTC using RuboCop version 1.40.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 12 +# Offense count: 10 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, IgnoredClasses. # AllowedMethods: ago, from_now, second, seconds, minute, minutes, hour, hours, day, days, week, weeks, fortnight, fortnights, in_milliseconds @@ -24,12 +24,11 @@ Lint/NumberConversion: - 'spec/models/feed_spec.rb' - 'spec/models/story_spec.rb' -# Offense count: 15 +# Offense count: 12 # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. Metrics/MethodLength: Exclude: - 'app/commands/feeds/export_to_opml.rb' - - 'app/controllers/feeds_controller.rb' - 'app/fever_api/read_items.rb' - 'app/helpers/url_helpers.rb' - 'app/models/story.rb' @@ -59,52 +58,6 @@ Naming/PredicateName: Exclude: - 'app/utils/sample_story.rb' -# Offense count: 31 -# This cop supports safe autocorrection (--autocorrect). -RSpec/AlignLeftLetBrace: - Exclude: - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/feeds/export_to_opml_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - - 'spec/fever_api_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' - -# Offense count: 35 -# This cop supports safe autocorrection (--autocorrect). -RSpec/AlignRightLetBrace: - Exclude: - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - - 'spec/fever_api_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' - # Offense count: 5 RSpec/AnyInstance: Exclude: @@ -286,12 +239,6 @@ RSpec/LeadingSubject: - 'spec/fever_api/write_mark_feed_spec.rb' - 'spec/fever_api/write_mark_group_spec.rb' -# Offense count: 2 -RSpec/LeakyConstantDeclaration: - Exclude: - - 'spec/helpers/authentications_helper_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). RSpec/LetBeforeExamples: @@ -304,75 +251,34 @@ RSpec/MessageChain: - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api_spec.rb' -# Offense count: 106 +# Offense count: 53 # Configuration parameters: EnforcedStyle. # SupportedStyles: allow, expect RSpec/MessageExpectation: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' + - 'spec/commands/find_new_stories_spec.rb' + - 'spec/controllers/debug_controller_spec.rb' + - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/imports_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - - 'spec/fever_api/authentication_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - 'spec/fever_api_spec.rb' - - 'spec/jobs/fetch_feed_job_spec.rb' + - 'spec/helpers/authentications_helper_spec.rb' + - 'spec/models/migration_status_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - 'spec/repositories/story_repository_spec.rb' - - 'spec/tasks/change_password_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' - 'spec/tasks/fetch_feeds_spec.rb' - 'spec/tasks/remove_old_stories_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/i18n_support_spec.rb' -# Offense count: 111 +# Offense count: 1 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/imports_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/fever_api/authentication_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - - 'spec/fever_api_spec.rb' - - 'spec/jobs/fetch_feed_job_spec.rb' - - 'spec/repositories/feed_repository_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/tasks/change_password_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - - 'spec/tasks/remove_old_stories_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' # Offense count: 96 # Configuration parameters: Max. @@ -607,7 +513,7 @@ Rails/SkipsModelValidations: - 'db/migrate/20140421224454_fix_invalid_unicode.rb' - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' -# Offense count: 26 +# Offense count: 24 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible @@ -673,7 +579,7 @@ Style/FetchEnvVar: Exclude: - 'Rakefile' -# Offense count: 153 +# Offense count: 149 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -829,7 +735,7 @@ Style/FrozenStringLiteralComment: - 'spec/utils/i18n_support_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 91 +# Offense count: 86 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -867,7 +773,7 @@ Style/HashSyntax: - 'spec/tasks/change_password_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' -# Offense count: 185 +# Offense count: 184 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses @@ -936,12 +842,12 @@ Style/NumericLiterals: - 'spec/fever_api/write_mark_group_spec.rb' - 'spec/fever_api_spec.rb' -# Offense count: 6 +# Offense count: 2 Style/OpenStructUse: Exclude: - 'app.rb' -# Offense count: 28 +# Offense count: 21 # Configuration parameters: SuspiciousParamNames, Allowlist. # SuspiciousParamNames: options, opts, args, params, parameters Style/OptionHash: @@ -958,8 +864,6 @@ Style/OptionHash: - 'app/fever_api/write_mark_feed.rb' - 'app/fever_api/write_mark_group.rb' - 'app/fever_api/write_mark_item.rb' - - 'spec/factories/feeds.rb' - - 'spec/factories/groups.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -992,13 +896,6 @@ Style/StaticClass: - 'app/utils/api_key.rb' - 'app/utils/content_sanitizer.rb' -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinSize. -# SupportedStyles: percent, brackets -Style/SymbolArray: - EnforcedStyle: brackets - # Offense count: 6 Style/TopLevelMethodDefinition: Exclude: From f801344068e2f77ff12bb8bd9a19f472f58af943 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 16:01:45 -0800 Subject: [PATCH 221/779] RuboCop: enable FrozenStringLiteralComment cop (#751) --- .rubocop_todo.yml | 156 ------------------ Gemfile | 2 + Rakefile | 2 + app.rb | 2 + app/commands/feeds/add_new_feed.rb | 2 + app/commands/feeds/export_to_opml.rb | 2 + app/commands/feeds/find_new_stories.rb | 2 + app/commands/feeds/import_from_opml.rb | 2 + app/commands/stories/mark_all_as_read.rb | 2 + app/commands/stories/mark_as_read.rb | 2 + app/commands/stories/mark_as_starred.rb | 2 + app/commands/stories/mark_as_unread.rb | 2 + app/commands/stories/mark_as_unstarred.rb | 2 + app/commands/stories/mark_feed_as_read.rb | 2 + app/commands/stories/mark_group_as_read.rb | 2 + app/commands/users/change_user_password.rb | 2 + app/commands/users/complete_setup.rb | 2 + app/commands/users/create_user.rb | 2 + app/commands/users/sign_in_user.rb | 2 + app/controllers/debug_controller.rb | 2 + .../sinatra/first_run_controller.rb | 2 + .../sinatra/sessions_controller.rb | 2 + app/controllers/sinatra/stories_controller.rb | 2 + app/fever_api/authentication.rb | 2 + app/fever_api/read_favicons.rb | 4 +- app/fever_api/read_feeds.rb | 2 + app/fever_api/read_feeds_groups.rb | 2 + app/fever_api/read_groups.rb | 2 + app/fever_api/read_items.rb | 2 + app/fever_api/read_links.rb | 2 + app/fever_api/response.rb | 2 + app/fever_api/sync_saved_item_ids.rb | 2 + app/fever_api/sync_unread_item_ids.rb | 2 + app/fever_api/write_mark_feed.rb | 2 + app/fever_api/write_mark_group.rb | 2 + app/fever_api/write_mark_item.rb | 2 + app/helpers/authentication_helpers.rb | 2 + app/helpers/url_helpers.rb | 2 + app/jobs/fetch_feed_job.rb | 2 + app/models/application_record.rb | 2 + app/models/feed.rb | 2 + app/models/group.rb | 2 + app/models/migration_status.rb | 2 + app/models/story.rb | 4 +- app/models/user.rb | 2 + app/repositories/feed_repository.rb | 2 + app/repositories/group_repository.rb | 2 + app/repositories/story_repository.rb | 2 + app/repositories/user_repository.rb | 2 + app/tasks/change_password.rb | 2 + app/tasks/fetch_feed.rb | 2 + app/tasks/fetch_feeds.rb | 2 + app/tasks/remove_old_stories.rb | 2 + app/utils/api_key.rb | 2 + app/utils/content_sanitizer.rb | 2 + app/utils/feed_discovery.rb | 2 + app/utils/opml_parser.rb | 2 + app/utils/sample_story.rb | 4 +- config.ru | 2 + config/asset_pipeline.rb | 2 + config/puma.rb | 2 + db/migrate/20130409010818_create_feeds.rb | 2 + db/migrate/20130409010826_create_stories.rb | 2 + ...0130412185253_add_new_fields_to_stories.rb | 2 + db/migrate/20130418221144_add_user_model.rb | 2 + .../20130423001740_drop_email_from_user.rb | 2 + ...130423180446_remove_author_from_stories.rb | 2 + ...130425211008_add_setup_complete_to_user.rb | 2 + db/migrate/20130425222157_add_delayed_job.rb | 2 + .../20130429232127_add_status_to_feeds.rb | 2 + db/migrate/20130504005816_text_url.rb | 2 + ...504022615_change_story_permalink_column.rb | 2 + .../20130509131045_add_unique_constraints.rb | 2 + ...130513025939_add_keep_unread_to_stories.rb | 2 + ...44029_add_is_starred_status_for_stories.rb | 2 + .../20130522014405_add_api_key_to_user.rb | 2 + .../20130730120312_add_entry_id_to_stories.rb | 2 + ...13712_update_stories_unique_constraints.rb | 2 + .../20130821020313_update_nil_entry_ids.rb | 2 + ...se_text_datatype_for_title_and_entry_id.rb | 2 + ..._groups_table_and_foreign_keys_to_feeds.rb | 2 + .../20140421224454_fix_invalid_unicode.rb | 2 + ...nvalid_titles_with_unicode_line_endings.rb | 2 + fever_api.rb | 2 + spec/app_spec.rb | 2 + spec/commands/feeds/add_new_feed_spec.rb | 2 + spec/commands/feeds/export_to_opml_spec.rb | 2 + spec/commands/feeds/import_from_opml_spec.rb | 2 + spec/commands/find_new_stories_spec.rb | 2 + .../commands/stories/mark_all_as_read_spec.rb | 2 + spec/commands/stories/mark_as_read_spec.rb | 2 + spec/commands/stories/mark_as_starred_spec.rb | 2 + spec/commands/stories/mark_as_unread_spec.rb | 2 + .../stories/mark_as_unstarred_spec.rb | 2 + .../stories/mark_feed_as_read_spec.rb | 2 + .../stories/mark_group_as_read_spec.rb | 2 + .../users/change_user_password_spec.rb | 2 + spec/commands/users/complete_setup_spec.rb | 2 + spec/commands/users/create_user_spec.rb | 2 + spec/commands/users/sign_in_user_spec.rb | 2 + spec/config/asset_pipeline_spec.rb | 2 + spec/controllers/debug_controller_spec.rb | 2 + spec/controllers/exports_controller_spec.rb | 2 + spec/controllers/feeds_controller_spec.rb | 2 + spec/controllers/first_run_controller_spec.rb | 2 + spec/controllers/imports_controller_spec.rb | 2 + spec/controllers/sessions_controller_spec.rb | 2 + spec/controllers/stories_controller_spec.rb | 2 + spec/factories.rb | 2 + spec/factories/feeds.rb | 2 + spec/factories/groups.rb | 2 + spec/factories/stories.rb | 2 + spec/factories/users.rb | 2 + spec/fever_api/authentication_spec.rb | 2 + spec/fever_api/read_favicons_spec.rb | 2 + spec/fever_api/read_feeds_groups_spec.rb | 2 + spec/fever_api/read_feeds_spec.rb | 2 + spec/fever_api/read_groups_spec.rb | 2 + spec/fever_api/read_items_spec.rb | 2 + spec/fever_api/read_links_spec.rb | 2 + spec/fever_api/sync_saved_item_ids_spec.rb | 2 + spec/fever_api/sync_unread_item_ids_spec.rb | 2 + spec/fever_api/write_mark_feed_spec.rb | 2 + spec/fever_api/write_mark_group_spec.rb | 2 + spec/fever_api/write_mark_item_spec.rb | 2 + spec/fever_api_spec.rb | 2 + spec/helpers/authentications_helper_spec.rb | 2 + spec/helpers/url_helpers_spec.rb | 2 + spec/integration/feed_importing_spec.rb | 2 + spec/javascript/test_controller.rb | 2 + spec/models/feed_spec.rb | 2 + spec/models/group_spec.rb | 2 + spec/models/migration_status_spec.rb | 2 + spec/models/story_spec.rb | 2 + spec/repositories/feed_repository_spec.rb | 2 + spec/repositories/group_repository_spec.rb | 2 + spec/repositories/story_repository_spec.rb | 2 + spec/repositories/user_repository_spec.rb | 2 + spec/spec_helper.rb | 2 + spec/support/active_record.rb | 2 + spec/support/coverage.rb | 2 + spec/support/feed_server.rb | 2 + spec/tasks/change_password_spec.rb | 2 + spec/tasks/fetch_feed_spec.rb | 2 + spec/tasks/fetch_feeds_spec.rb | 2 + spec/tasks/remove_old_stories_spec.rb | 2 + spec/utils/content_sanitizer_spec.rb | 2 + spec/utils/feed_discovery_spec.rb | 2 + spec/utils/i18n_support_spec.rb | 2 + spec/utils/opml_parser_spec.rb | 2 + 150 files changed, 301 insertions(+), 159 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 24a4969be..6c1b22b50 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -579,162 +579,6 @@ Style/FetchEnvVar: Exclude: - 'Rakefile' -# Offense count: 149 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Exclude: - - 'Gemfile' - - 'Rakefile' - - 'app.rb' - - 'app/commands/feeds/add_new_feed.rb' - - 'app/commands/feeds/export_to_opml.rb' - - 'app/commands/feeds/find_new_stories.rb' - - 'app/commands/feeds/import_from_opml.rb' - - 'app/commands/stories/mark_all_as_read.rb' - - 'app/commands/stories/mark_as_read.rb' - - 'app/commands/stories/mark_as_starred.rb' - - 'app/commands/stories/mark_as_unread.rb' - - 'app/commands/stories/mark_as_unstarred.rb' - - 'app/commands/stories/mark_feed_as_read.rb' - - 'app/commands/stories/mark_group_as_read.rb' - - 'app/commands/users/change_user_password.rb' - - 'app/commands/users/complete_setup.rb' - - 'app/commands/users/create_user.rb' - - 'app/commands/users/sign_in_user.rb' - - 'app/controllers/debug_controller.rb' - - 'app/controllers/sinatra/first_run_controller.rb' - - 'app/controllers/sinatra/sessions_controller.rb' - - 'app/controllers/sinatra/stories_controller.rb' - - 'app/fever_api/authentication.rb' - - 'app/fever_api/read_favicons.rb' - - 'app/fever_api/read_feeds.rb' - - 'app/fever_api/read_feeds_groups.rb' - - 'app/fever_api/read_groups.rb' - - 'app/fever_api/read_items.rb' - - 'app/fever_api/read_links.rb' - - 'app/fever_api/response.rb' - - 'app/fever_api/sync_saved_item_ids.rb' - - 'app/fever_api/sync_unread_item_ids.rb' - - 'app/fever_api/write_mark_feed.rb' - - 'app/fever_api/write_mark_group.rb' - - 'app/fever_api/write_mark_item.rb' - - 'app/helpers/authentication_helpers.rb' - - 'app/helpers/url_helpers.rb' - - 'app/jobs/fetch_feed_job.rb' - - 'app/models/application_record.rb' - - 'app/models/feed.rb' - - 'app/models/group.rb' - - 'app/models/migration_status.rb' - - 'app/models/story.rb' - - 'app/models/user.rb' - - 'app/repositories/feed_repository.rb' - - 'app/repositories/group_repository.rb' - - 'app/repositories/story_repository.rb' - - 'app/repositories/user_repository.rb' - - 'app/tasks/change_password.rb' - - 'app/tasks/fetch_feed.rb' - - 'app/tasks/fetch_feeds.rb' - - 'app/tasks/remove_old_stories.rb' - - 'app/utils/api_key.rb' - - 'app/utils/content_sanitizer.rb' - - 'app/utils/feed_discovery.rb' - - 'app/utils/opml_parser.rb' - - 'app/utils/sample_story.rb' - - 'config.ru' - - 'config/asset_pipeline.rb' - - 'config/puma.rb' - - 'db/migrate/20130409010818_create_feeds.rb' - - 'db/migrate/20130409010826_create_stories.rb' - - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' - - 'db/migrate/20130418221144_add_user_model.rb' - - 'db/migrate/20130423001740_drop_email_from_user.rb' - - 'db/migrate/20130423180446_remove_author_from_stories.rb' - - 'db/migrate/20130425211008_add_setup_complete_to_user.rb' - - 'db/migrate/20130425222157_add_delayed_job.rb' - - 'db/migrate/20130429232127_add_status_to_feeds.rb' - - 'db/migrate/20130504005816_text_url.rb' - - 'db/migrate/20130504022615_change_story_permalink_column.rb' - - 'db/migrate/20130509131045_add_unique_constraints.rb' - - 'db/migrate/20130513025939_add_keep_unread_to_stories.rb' - - 'db/migrate/20130513044029_add_is_starred_status_for_stories.rb' - - 'db/migrate/20130522014405_add_api_key_to_user.rb' - - 'db/migrate/20130730120312_add_entry_id_to_stories.rb' - - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' - - 'db/migrate/20130821020313_update_nil_entry_ids.rb' - - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' - - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' - - 'db/migrate/20140421224454_fix_invalid_unicode.rb' - - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' - - 'fever_api.rb' - - 'spec/app_spec.rb' - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/feeds/export_to_opml_spec.rb' - - 'spec/commands/feeds/import_from_opml_spec.rb' - - 'spec/commands/find_new_stories_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_as_read_spec.rb' - - 'spec/commands/stories/mark_as_starred_spec.rb' - - 'spec/commands/stories/mark_as_unread_spec.rb' - - 'spec/commands/stories/mark_as_unstarred_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/commands/users/create_user_spec.rb' - - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/config/asset_pipeline_spec.rb' - - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/exports_controller_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/imports_controller_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/factories.rb' - - 'spec/factories/feeds.rb' - - 'spec/factories/groups.rb' - - 'spec/factories/stories.rb' - - 'spec/factories/users.rb' - - 'spec/fever_api/authentication_spec.rb' - - 'spec/fever_api/read_favicons_spec.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/read_links_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - - 'spec/fever_api_spec.rb' - - 'spec/helpers/authentications_helper_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - - 'spec/integration/feed_importing_spec.rb' - - 'spec/javascript/test_controller.rb' - - 'spec/models/feed_spec.rb' - - 'spec/models/group_spec.rb' - - 'spec/models/migration_status_spec.rb' - - 'spec/models/story_spec.rb' - - 'spec/repositories/feed_repository_spec.rb' - - 'spec/repositories/group_repository_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/repositories/user_repository_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/support/active_record.rb' - - 'spec/support/coverage.rb' - - 'spec/support/feed_server.rb' - - 'spec/tasks/change_password_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - - 'spec/tasks/remove_old_stories_spec.rb' - - 'spec/utils/content_sanitizer_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' - - 'spec/utils/i18n_support_spec.rb' - - 'spec/utils/opml_parser_spec.rb' - # Offense count: 86 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. diff --git a/Gemfile b/Gemfile index 18c1bba94..4153f7c03 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ruby_version_file = File.expand_path(".ruby-version", __dir__) ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file) source "https://rubygems.org" diff --git a/Rakefile b/Rakefile index 4e4a44a3e..4bc059263 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "bundler" Bundler.setup diff --git a/app.rb b/app.rb index 4baa6c30a..87db2d0c4 100644 --- a/app.rb +++ b/app.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "action_pack" require "action_view" require "action_controller" diff --git a/app/commands/feeds/add_new_feed.rb b/app/commands/feeds/add_new_feed.rb index 0b13f2eb8..ab0a56348 100644 --- a/app/commands/feeds/add_new_feed.rb +++ b/app/commands/feeds/add_new_feed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../models/feed" require_relative "../../utils/content_sanitizer" require_relative "../../utils/feed_discovery" diff --git a/app/commands/feeds/export_to_opml.rb b/app/commands/feeds/export_to_opml.rb index a8e6e457e..b6a859089 100644 --- a/app/commands/feeds/export_to_opml.rb +++ b/app/commands/feeds/export_to_opml.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "nokogiri" class ExportToOpml diff --git a/app/commands/feeds/find_new_stories.rb b/app/commands/feeds/find_new_stories.rb index 0aabad8f9..90798d694 100644 --- a/app/commands/feeds/find_new_stories.rb +++ b/app/commands/feeds/find_new_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class FindNewStories diff --git a/app/commands/feeds/import_from_opml.rb b/app/commands/feeds/import_from_opml.rb index a0d911cc8..bfec71658 100644 --- a/app/commands/feeds/import_from_opml.rb +++ b/app/commands/feeds/import_from_opml.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../models/feed" require_relative "../../models/group" require_relative "../../utils/opml_parser" diff --git a/app/commands/stories/mark_all_as_read.rb b/app/commands/stories/mark_all_as_read.rb index e458c1f02..a74dceaf9 100644 --- a/app/commands/stories/mark_all_as_read.rb +++ b/app/commands/stories/mark_all_as_read.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class MarkAllAsRead diff --git a/app/commands/stories/mark_as_read.rb b/app/commands/stories/mark_as_read.rb index a2ddb121a..065ae1de5 100644 --- a/app/commands/stories/mark_as_read.rb +++ b/app/commands/stories/mark_as_read.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class MarkAsRead diff --git a/app/commands/stories/mark_as_starred.rb b/app/commands/stories/mark_as_starred.rb index e20ba4f0a..6f23c01ce 100644 --- a/app/commands/stories/mark_as_starred.rb +++ b/app/commands/stories/mark_as_starred.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class MarkAsStarred diff --git a/app/commands/stories/mark_as_unread.rb b/app/commands/stories/mark_as_unread.rb index a16791501..b03b45d90 100644 --- a/app/commands/stories/mark_as_unread.rb +++ b/app/commands/stories/mark_as_unread.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class MarkAsUnread diff --git a/app/commands/stories/mark_as_unstarred.rb b/app/commands/stories/mark_as_unstarred.rb index 4a616a25a..22cb666a3 100644 --- a/app/commands/stories/mark_as_unstarred.rb +++ b/app/commands/stories/mark_as_unstarred.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class MarkAsUnstarred diff --git a/app/commands/stories/mark_feed_as_read.rb b/app/commands/stories/mark_feed_as_read.rb index 8c28b8dbe..f65c6ba66 100644 --- a/app/commands/stories/mark_feed_as_read.rb +++ b/app/commands/stories/mark_feed_as_read.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class MarkFeedAsRead diff --git a/app/commands/stories/mark_group_as_read.rb b/app/commands/stories/mark_group_as_read.rb index c177e49b6..9364b3271 100644 --- a/app/commands/stories/mark_group_as_read.rb +++ b/app/commands/stories/mark_group_as_read.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" class MarkGroupAsRead diff --git a/app/commands/users/change_user_password.rb b/app/commands/users/change_user_password.rb index a818aea13..38c57d904 100644 --- a/app/commands/users/change_user_password.rb +++ b/app/commands/users/change_user_password.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/user_repository" require_relative "../../utils/api_key" diff --git a/app/commands/users/complete_setup.rb b/app/commands/users/complete_setup.rb index e37cb80bf..37576c1ce 100644 --- a/app/commands/users/complete_setup.rb +++ b/app/commands/users/complete_setup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CompleteSetup def self.complete(user) user.setup_complete = true diff --git a/app/commands/users/create_user.rb b/app/commands/users/create_user.rb index c295500f1..b51d6eddb 100644 --- a/app/commands/users/create_user.rb +++ b/app/commands/users/create_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../utils/api_key" class CreateUser diff --git a/app/commands/users/sign_in_user.rb b/app/commands/users/sign_in_user.rb index f41ad2e98..a0cb5aea2 100644 --- a/app/commands/users/sign_in_user.rb +++ b/app/commands/users/sign_in_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../models/user" class SignInUser diff --git a/app/controllers/debug_controller.rb b/app/controllers/debug_controller.rb index feece9b69..44a82b01f 100644 --- a/app/controllers/debug_controller.rb +++ b/app/controllers/debug_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../models/migration_status" class DebugController < ApplicationController diff --git a/app/controllers/sinatra/first_run_controller.rb b/app/controllers/sinatra/first_run_controller.rb index 79eb8f58d..78e5bf5df 100644 --- a/app/controllers/sinatra/first_run_controller.rb +++ b/app/controllers/sinatra/first_run_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../commands/feeds/import_from_opml" require_relative "../../commands/users/create_user" require_relative "../../commands/users/complete_setup" diff --git a/app/controllers/sinatra/sessions_controller.rb b/app/controllers/sinatra/sessions_controller.rb index bd305b390..e8c16a869 100644 --- a/app/controllers/sinatra/sessions_controller.rb +++ b/app/controllers/sinatra/sessions_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../commands/users/sign_in_user" class Stringer < Sinatra::Base diff --git a/app/controllers/sinatra/stories_controller.rb b/app/controllers/sinatra/stories_controller.rb index bf9cb3049..9614f86d1 100644 --- a/app/controllers/sinatra/stories_controller.rb +++ b/app/controllers/sinatra/stories_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../../repositories/story_repository" require_relative "../../commands/stories/mark_all_as_read" diff --git a/app/fever_api/authentication.rb b/app/fever_api/authentication.rb index 819eb07eb..05f55056a 100644 --- a/app/fever_api/authentication.rb +++ b/app/fever_api/authentication.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FeverAPI class Authentication def initialize(options = {}) diff --git a/app/fever_api/read_favicons.rb b/app/fever_api/read_favicons.rb index c924b7cfd..6b5a8dc58 100644 --- a/app/fever_api/read_favicons.rb +++ b/app/fever_api/read_favicons.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + module FeverAPI class ReadFavicons - ICON = "R0lGODlhAQABAIAAAObm5gAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==".freeze + ICON = "R0lGODlhAQABAIAAAObm5gAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" def call(params = {}) if params.keys.include?("favicons") diff --git a/app/fever_api/read_feeds.rb b/app/fever_api/read_feeds.rb index a00a4b60d..cabba321f 100644 --- a/app/fever_api/read_feeds.rb +++ b/app/fever_api/read_feeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../repositories/feed_repository" module FeverAPI diff --git a/app/fever_api/read_feeds_groups.rb b/app/fever_api/read_feeds_groups.rb index 13cec3b93..d6597a293 100644 --- a/app/fever_api/read_feeds_groups.rb +++ b/app/fever_api/read_feeds_groups.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../repositories/feed_repository" module FeverAPI diff --git a/app/fever_api/read_groups.rb b/app/fever_api/read_groups.rb index 2709e6648..2540195f1 100644 --- a/app/fever_api/read_groups.rb +++ b/app/fever_api/read_groups.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../repositories/group_repository" module FeverAPI diff --git a/app/fever_api/read_items.rb b/app/fever_api/read_items.rb index ca26d04b9..4d65ba4f7 100644 --- a/app/fever_api/read_items.rb +++ b/app/fever_api/read_items.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../repositories/story_repository" module FeverAPI diff --git a/app/fever_api/read_links.rb b/app/fever_api/read_links.rb index 595343c9a..1377b5b15 100644 --- a/app/fever_api/read_links.rb +++ b/app/fever_api/read_links.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FeverAPI class ReadLinks def call(params = {}) diff --git a/app/fever_api/response.rb b/app/fever_api/response.rb index 31336b5f4..327c40f55 100644 --- a/app/fever_api/response.rb +++ b/app/fever_api/response.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "authentication" require_relative "read_groups" diff --git a/app/fever_api/sync_saved_item_ids.rb b/app/fever_api/sync_saved_item_ids.rb index 9e4ff9dde..e169a1c5e 100644 --- a/app/fever_api/sync_saved_item_ids.rb +++ b/app/fever_api/sync_saved_item_ids.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../repositories/story_repository" module FeverAPI diff --git a/app/fever_api/sync_unread_item_ids.rb b/app/fever_api/sync_unread_item_ids.rb index 7d469d73b..84a043a83 100644 --- a/app/fever_api/sync_unread_item_ids.rb +++ b/app/fever_api/sync_unread_item_ids.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../repositories/story_repository" module FeverAPI diff --git a/app/fever_api/write_mark_feed.rb b/app/fever_api/write_mark_feed.rb index b4b582e6b..b6bd4347a 100644 --- a/app/fever_api/write_mark_feed.rb +++ b/app/fever_api/write_mark_feed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../commands/stories/mark_feed_as_read" module FeverAPI diff --git a/app/fever_api/write_mark_group.rb b/app/fever_api/write_mark_group.rb index 7ccbe127b..773cfc4f2 100644 --- a/app/fever_api/write_mark_group.rb +++ b/app/fever_api/write_mark_group.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../commands/stories/mark_group_as_read" module FeverAPI diff --git a/app/fever_api/write_mark_item.rb b/app/fever_api/write_mark_item.rb index 7d35e31db..058da471c 100644 --- a/app/fever_api/write_mark_item.rb +++ b/app/fever_api/write_mark_item.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../commands/stories/mark_as_read" require_relative "../commands/stories/mark_as_unread" require_relative "../commands/stories/mark_as_starred" diff --git a/app/helpers/authentication_helpers.rb b/app/helpers/authentication_helpers.rb index 93e0eb364..9fa9705a9 100644 --- a/app/helpers/authentication_helpers.rb +++ b/app/helpers/authentication_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "sinatra/base" require_relative "../repositories/user_repository" diff --git a/app/helpers/url_helpers.rb b/app/helpers/url_helpers.rb index b9e0121f9..3bcd0348a 100644 --- a/app/helpers/url_helpers.rb +++ b/app/helpers/url_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "nokogiri" require "uri" diff --git a/app/jobs/fetch_feed_job.rb b/app/jobs/fetch_feed_job.rb index 77bedc4d1..88294c3d7 100644 --- a/app/jobs/fetch_feed_job.rb +++ b/app/jobs/fetch_feed_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FetchFeedJob = Struct.new(:feed_id) do def perform diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba84..71fbba5b3 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/app/models/feed.rb b/app/models/feed.rb index 1f7913c4f..3e4716405 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "./application_record" class Feed < ApplicationRecord diff --git a/app/models/group.rb b/app/models/group.rb index e8d8ee22b..3dbcf1b96 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "./application_record" class Group < ApplicationRecord diff --git a/app/models/migration_status.rb b/app/models/migration_status.rb index a358ad49d..bda127c81 100644 --- a/app/models/migration_status.rb +++ b/app/models/migration_status.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MigrationStatus attr_reader :migrator diff --git a/app/models/story.rb b/app/models/story.rb index ae346ef2a..ea3055e79 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "./application_record" require_relative "./feed" @@ -6,7 +8,7 @@ class Story < ApplicationRecord validates_uniqueness_of :entry_id, scope: :feed_id - UNTITLED = "[untitled]".freeze + UNTITLED = "[untitled]" def headline title.nil? ? UNTITLED : strip_html(title)[0, 50] diff --git a/app/models/user.rb b/app/models/user.rb index dcbec3ad5..4b45e352c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "./application_record" class User < ApplicationRecord diff --git a/app/repositories/feed_repository.rb b/app/repositories/feed_repository.rb index 5deee8e22..d453fa61f 100644 --- a/app/repositories/feed_repository.rb +++ b/app/repositories/feed_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../models/feed" class FeedRepository diff --git a/app/repositories/group_repository.rb b/app/repositories/group_repository.rb index b827dd199..95bd01570 100644 --- a/app/repositories/group_repository.rb +++ b/app/repositories/group_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../models/group" class GroupRepository diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index b6d8a7e47..606ba003a 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../helpers/url_helpers" require_relative "../models/story" require_relative "../utils/content_sanitizer" diff --git a/app/repositories/user_repository.rb b/app/repositories/user_repository.rb index 029f26b85..a0292dd07 100644 --- a/app/repositories/user_repository.rb +++ b/app/repositories/user_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../models/user" class UserRepository diff --git a/app/tasks/change_password.rb b/app/tasks/change_password.rb index 0a16acbfe..b59e6fb30 100644 --- a/app/tasks/change_password.rb +++ b/app/tasks/change_password.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "io/console" require_relative "../commands/users/change_user_password" diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index aed06a496..5278f1423 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "feedjira" require "httparty" diff --git a/app/tasks/fetch_feeds.rb b/app/tasks/fetch_feeds.rb index bb7867525..8a45c01c9 100644 --- a/app/tasks/fetch_feeds.rb +++ b/app/tasks/fetch_feeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "thread/pool" require_relative "fetch_feed" diff --git a/app/tasks/remove_old_stories.rb b/app/tasks/remove_old_stories.rb index d766b49bd..4fd1f43fb 100644 --- a/app/tasks/remove_old_stories.rb +++ b/app/tasks/remove_old_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveOldStories def self.remove!(number_of_days) stories = old_stories(number_of_days) diff --git a/app/utils/api_key.rb b/app/utils/api_key.rb index 6f0f52c4c..397563b6e 100644 --- a/app/utils/api_key.rb +++ b/app/utils/api_key.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "digest/md5" class ApiKey diff --git a/app/utils/content_sanitizer.rb b/app/utils/content_sanitizer.rb index 87886c688..e0bf75b8d 100644 --- a/app/utils/content_sanitizer.rb +++ b/app/utils/content_sanitizer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ContentSanitizer def self.sanitize(content) Loofah.fragment(content.gsub(//i, "")) diff --git a/app/utils/feed_discovery.rb b/app/utils/feed_discovery.rb index 83f4d5a53..cb1baadaa 100644 --- a/app/utils/feed_discovery.rb +++ b/app/utils/feed_discovery.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "feedbag" require "feedjira" require "httparty" diff --git a/app/utils/opml_parser.rb b/app/utils/opml_parser.rb index e99d45938..6b197380e 100644 --- a/app/utils/opml_parser.rb +++ b/app/utils/opml_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "nokogiri" class OpmlParser diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 469465990..6b67f6fbe 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -1,4 +1,6 @@ -SAMPLE_BODY = <<~EOS.freeze +# frozen_string_literal: true + +SAMPLE_BODY = <<~EOS

    Tofu shoreditch intelligentsia umami, fashion axe photo booth try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee diff --git a/config.ru b/config.ru index a45d484f3..d4aa7984e 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rubygems" require "bundler" diff --git a/config/asset_pipeline.rb b/config/asset_pipeline.rb index 59b009e36..569219604 100644 --- a/config/asset_pipeline.rb +++ b/config/asset_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AssetPipeline def registered(app) app.set :sprockets, Sprockets::Environment.new(app.root) diff --git a/config/puma.rb b/config/puma.rb index dd0037c77..e439e2ca5 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + workers workers Integer(ENV.fetch("WEB_CONCURRENCY", 1)) threads_count = Integer(ENV.fetch("MAX_THREADS", 2)) threads threads_count, threads_count diff --git a/db/migrate/20130409010818_create_feeds.rb b/db/migrate/20130409010818_create_feeds.rb index 628400da3..26b2ca2e0 100644 --- a/db/migrate/20130409010818_create_feeds.rb +++ b/db/migrate/20130409010818_create_feeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateFeeds < ActiveRecord::Migration[4.2] def change create_table :feeds do |t| diff --git a/db/migrate/20130409010826_create_stories.rb b/db/migrate/20130409010826_create_stories.rb index 8df287917..73b494077 100644 --- a/db/migrate/20130409010826_create_stories.rb +++ b/db/migrate/20130409010826_create_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateStories < ActiveRecord::Migration[4.2] def change create_table :stories do |t| diff --git a/db/migrate/20130412185253_add_new_fields_to_stories.rb b/db/migrate/20130412185253_add_new_fields_to_stories.rb index 00beff1cc..e3c95eda9 100644 --- a/db/migrate/20130412185253_add_new_fields_to_stories.rb +++ b/db/migrate/20130412185253_add_new_fields_to_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddNewFieldsToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :published, :timestamp diff --git a/db/migrate/20130418221144_add_user_model.rb b/db/migrate/20130418221144_add_user_model.rb index 5adc4fc3b..6c8ccb858 100644 --- a/db/migrate/20130418221144_add_user_model.rb +++ b/db/migrate/20130418221144_add_user_model.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUserModel < ActiveRecord::Migration[4.2] def change create_table :users do |t| diff --git a/db/migrate/20130423001740_drop_email_from_user.rb b/db/migrate/20130423001740_drop_email_from_user.rb index f40b8a62c..9579bdfa7 100644 --- a/db/migrate/20130423001740_drop_email_from_user.rb +++ b/db/migrate/20130423001740_drop_email_from_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DropEmailFromUser < ActiveRecord::Migration[4.2] def up remove_column :users, :email diff --git a/db/migrate/20130423180446_remove_author_from_stories.rb b/db/migrate/20130423180446_remove_author_from_stories.rb index 47b630d0f..37061a611 100644 --- a/db/migrate/20130423180446_remove_author_from_stories.rb +++ b/db/migrate/20130423180446_remove_author_from_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveAuthorFromStories < ActiveRecord::Migration[4.2] def up remove_column :stories, :author diff --git a/db/migrate/20130425211008_add_setup_complete_to_user.rb b/db/migrate/20130425211008_add_setup_complete_to_user.rb index d98aa7a1c..39f29aacb 100644 --- a/db/migrate/20130425211008_add_setup_complete_to_user.rb +++ b/db/migrate/20130425211008_add_setup_complete_to_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSetupCompleteToUser < ActiveRecord::Migration[4.2] def change add_column :users, :setup_complete, :boolean diff --git a/db/migrate/20130425222157_add_delayed_job.rb b/db/migrate/20130425222157_add_delayed_job.rb index 60736b629..d4afefab8 100644 --- a/db/migrate/20130425222157_add_delayed_job.rb +++ b/db/migrate/20130425222157_add_delayed_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDelayedJob < ActiveRecord::Migration[4.2] def self.up create_table :delayed_jobs, force: true do |table| diff --git a/db/migrate/20130429232127_add_status_to_feeds.rb b/db/migrate/20130429232127_add_status_to_feeds.rb index 9bb84a23f..a458e8528 100644 --- a/db/migrate/20130429232127_add_status_to_feeds.rb +++ b/db/migrate/20130429232127_add_status_to_feeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddStatusToFeeds < ActiveRecord::Migration[4.2] def change add_column :feeds, :status, :int diff --git a/db/migrate/20130504005816_text_url.rb b/db/migrate/20130504005816_text_url.rb index 5f3c1ea7a..57e02d5cb 100644 --- a/db/migrate/20130504005816_text_url.rb +++ b/db/migrate/20130504005816_text_url.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TextUrl < ActiveRecord::Migration[4.2] def up change_column :feeds, :url, :text diff --git a/db/migrate/20130504022615_change_story_permalink_column.rb b/db/migrate/20130504022615_change_story_permalink_column.rb index db8d8b924..503a2dbd9 100644 --- a/db/migrate/20130504022615_change_story_permalink_column.rb +++ b/db/migrate/20130504022615_change_story_permalink_column.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeStoryPermalinkColumn < ActiveRecord::Migration[4.2] def up change_column :stories, :permalink, :text diff --git a/db/migrate/20130509131045_add_unique_constraints.rb b/db/migrate/20130509131045_add_unique_constraints.rb index f04989164..270dde2ba 100644 --- a/db/migrate/20130509131045_add_unique_constraints.rb +++ b/db/migrate/20130509131045_add_unique_constraints.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUniqueConstraints < ActiveRecord::Migration[4.2] def change add_index :stories, [:permalink, :feed_id], unique: true diff --git a/db/migrate/20130513025939_add_keep_unread_to_stories.rb b/db/migrate/20130513025939_add_keep_unread_to_stories.rb index 76742a0de..98b42cdf1 100644 --- a/db/migrate/20130513025939_add_keep_unread_to_stories.rb +++ b/db/migrate/20130513025939_add_keep_unread_to_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddKeepUnreadToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :keep_unread, :boolean, default: false diff --git a/db/migrate/20130513044029_add_is_starred_status_for_stories.rb b/db/migrate/20130513044029_add_is_starred_status_for_stories.rb index 8333225a0..4d64c1b19 100644 --- a/db/migrate/20130513044029_add_is_starred_status_for_stories.rb +++ b/db/migrate/20130513044029_add_is_starred_status_for_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIsStarredStatusForStories < ActiveRecord::Migration[4.2] def change add_column :stories, :is_starred, :boolean, default: false diff --git a/db/migrate/20130522014405_add_api_key_to_user.rb b/db/migrate/20130522014405_add_api_key_to_user.rb index b52aae725..a193761da 100644 --- a/db/migrate/20130522014405_add_api_key_to_user.rb +++ b/db/migrate/20130522014405_add_api_key_to_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddApiKeyToUser < ActiveRecord::Migration[4.2] def change add_column :users, :api_key, :string diff --git a/db/migrate/20130730120312_add_entry_id_to_stories.rb b/db/migrate/20130730120312_add_entry_id_to_stories.rb index f160a6d9d..fe25c77ed 100644 --- a/db/migrate/20130730120312_add_entry_id_to_stories.rb +++ b/db/migrate/20130730120312_add_entry_id_to_stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddEntryIdToStories < ActiveRecord::Migration[4.2] def change add_column :stories, :entry_id, :string diff --git a/db/migrate/20130805113712_update_stories_unique_constraints.rb b/db/migrate/20130805113712_update_stories_unique_constraints.rb index 2c320babb..326049b16 100644 --- a/db/migrate/20130805113712_update_stories_unique_constraints.rb +++ b/db/migrate/20130805113712_update_stories_unique_constraints.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UpdateStoriesUniqueConstraints < ActiveRecord::Migration[4.2] def up remove_index :stories, [:permalink, :feed_id] diff --git a/db/migrate/20130821020313_update_nil_entry_ids.rb b/db/migrate/20130821020313_update_nil_entry_ids.rb index 2b5624910..1f3a90416 100644 --- a/db/migrate/20130821020313_update_nil_entry_ids.rb +++ b/db/migrate/20130821020313_update_nil_entry_ids.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UpdateNilEntryIds < ActiveRecord::Migration[4.2] def up Story.where(entry_id: nil).each do |story| diff --git a/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb b/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb index 0d847e58c..b2ad28328 100644 --- a/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb +++ b/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UseTextDatatypeForTitleAndEntryId < ActiveRecord::Migration[4.2] def up change_column :stories, :title, :text diff --git a/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb b/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb index 149e3f77b..d862f5972 100644 --- a/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb +++ b/db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddGroupsTableAndForeignKeysToFeeds < ActiveRecord::Migration[4.2] def up create_table :groups do |t| diff --git a/db/migrate/20140421224454_fix_invalid_unicode.rb b/db/migrate/20140421224454_fix_invalid_unicode.rb index 902e311d2..2f556a154 100644 --- a/db/migrate/20140421224454_fix_invalid_unicode.rb +++ b/db/migrate/20140421224454_fix_invalid_unicode.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FixInvalidUnicode < ActiveRecord::Migration[4.2] def up Story.find_each do |story| diff --git a/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb b/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb index 5d0fa90d4..bea9b1a2f 100644 --- a/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb +++ b/db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FixInvalidTitlesWithUnicodeLineEndings < ActiveRecord::Migration[4.2] def up Story.find_each do |story| diff --git a/fever_api.rb b/fever_api.rb index e3d7f7cf4..2c639ff12 100644 --- a/fever_api.rb +++ b/fever_api.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "sinatra/base" require "sinatra/activerecord" diff --git a/spec/app_spec.rb b/spec/app_spec.rb index 0d79af4cf..2f8616302 100644 --- a/spec/app_spec.rb +++ b/spec/app_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 2c0c77d93..e0eb8d39d 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "/commands/feeds/add_new_feed" diff --git a/spec/commands/feeds/export_to_opml_spec.rb b/spec/commands/feeds/export_to_opml_spec.rb index 259fa09e7..1ed1ec622 100644 --- a/spec/commands/feeds/export_to_opml_spec.rb +++ b/spec/commands/feeds/export_to_opml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/feeds/export_to_opml" diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 8a3386b1d..0b4a08643 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/feeds/import_from_opml" diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index c6d542a30..8f4af7c98 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "repositories/story_repository" diff --git a/spec/commands/stories/mark_all_as_read_spec.rb b/spec/commands/stories/mark_all_as_read_spec.rb index b72c75b78..656302f9c 100644 --- a/spec/commands/stories/mark_all_as_read_spec.rb +++ b/spec/commands/stories/mark_all_as_read_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/stories/mark_all_as_read" diff --git a/spec/commands/stories/mark_as_read_spec.rb b/spec/commands/stories/mark_as_read_spec.rb index 7d10291ff..603e99e13 100644 --- a/spec/commands/stories/mark_as_read_spec.rb +++ b/spec/commands/stories/mark_as_read_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/stories/mark_as_read" diff --git a/spec/commands/stories/mark_as_starred_spec.rb b/spec/commands/stories/mark_as_starred_spec.rb index 5413d80dd..150d78fe1 100644 --- a/spec/commands/stories/mark_as_starred_spec.rb +++ b/spec/commands/stories/mark_as_starred_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/stories/mark_as_starred" diff --git a/spec/commands/stories/mark_as_unread_spec.rb b/spec/commands/stories/mark_as_unread_spec.rb index 0971ceb63..c5d72427b 100644 --- a/spec/commands/stories/mark_as_unread_spec.rb +++ b/spec/commands/stories/mark_as_unread_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/stories/mark_as_unread" diff --git a/spec/commands/stories/mark_as_unstarred_spec.rb b/spec/commands/stories/mark_as_unstarred_spec.rb index b1d06be36..5802c752f 100644 --- a/spec/commands/stories/mark_as_unstarred_spec.rb +++ b/spec/commands/stories/mark_as_unstarred_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/stories/mark_as_unstarred" diff --git a/spec/commands/stories/mark_feed_as_read_spec.rb b/spec/commands/stories/mark_feed_as_read_spec.rb index 00e5dff69..72d586e87 100644 --- a/spec/commands/stories/mark_feed_as_read_spec.rb +++ b/spec/commands/stories/mark_feed_as_read_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/stories/mark_feed_as_read" diff --git a/spec/commands/stories/mark_group_as_read_spec.rb b/spec/commands/stories/mark_group_as_read_spec.rb index 452b2446d..570e19127 100644 --- a/spec/commands/stories/mark_group_as_read_spec.rb +++ b/spec/commands/stories/mark_group_as_read_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/stories/mark_group_as_read" diff --git a/spec/commands/users/change_user_password_spec.rb b/spec/commands/users/change_user_password_spec.rb index caae4e3ee..61a208e76 100644 --- a/spec/commands/users/change_user_password_spec.rb +++ b/spec/commands/users/change_user_password_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/commands/users/complete_setup_spec.rb b/spec/commands/users/complete_setup_spec.rb index cc938a7e1..98fca9f1a 100644 --- a/spec/commands/users/complete_setup_spec.rb +++ b/spec/commands/users/complete_setup_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/users/complete_setup" diff --git a/spec/commands/users/create_user_spec.rb b/spec/commands/users/create_user_spec.rb index 189f44900..6c93c7f4f 100644 --- a/spec/commands/users/create_user_spec.rb +++ b/spec/commands/users/create_user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/users/create_user" diff --git a/spec/commands/users/sign_in_user_spec.rb b/spec/commands/users/sign_in_user_spec.rb index f3f921810..7132a70e3 100644 --- a/spec/commands/users/sign_in_user_spec.rb +++ b/spec/commands/users/sign_in_user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "commands/users/sign_in_user" diff --git a/spec/config/asset_pipeline_spec.rb b/spec/config/asset_pipeline_spec.rb index 4eb814211..fbd08855c 100644 --- a/spec/config/asset_pipeline_spec.rb +++ b/spec/config/asset_pipeline_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe "AssetPipeline" do diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index d5cae8cbc..f0c7dd4b7 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb index f94891239..07285e56f 100644 --- a/spec/controllers/exports_controller_spec.rb +++ b/spec/controllers/exports_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "controllers/exports_controller" diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 574f3c729..bbc28e605 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "controllers/feeds_controller" diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index baf706c92..14c8e62d7 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb index b62500cd4..2b052246e 100644 --- a/spec/controllers/imports_controller_spec.rb +++ b/spec/controllers/imports_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "controllers/imports_controller" diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 85eda0ade..93216b5a7 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "controllers/sinatra/sessions_controller" diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 0fcf3fa24..c06ba3702 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "will_paginate/array" diff --git a/spec/factories.rb b/spec/factories.rb index 49b48b372..57a1c15c9 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "factories/feeds" require_relative "factories/groups" require_relative "factories/stories" diff --git a/spec/factories/feeds.rb b/spec/factories/feeds.rb index a74858e7e..f722a6617 100644 --- a/spec/factories/feeds.rb +++ b/spec/factories/feeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory(:feed) do sequence(:name, 100) { |n| "Feed #{n}" } diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb index 21306b6bb..d51bca922 100644 --- a/spec/factories/groups.rb +++ b/spec/factories/groups.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + FactoryBot.define { factory(:group) } diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb index 22859cbb1..dbf19d7f1 100644 --- a/spec/factories/stories.rb +++ b/spec/factories/stories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory(:story) do feed diff --git a/spec/factories/users.rb b/spec/factories/users.rb index a3192ad95..53518a80a 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory(:user) do password { "super-secret" } diff --git a/spec/fever_api/authentication_spec.rb b/spec/fever_api/authentication_spec.rb index 0c96932eb..4cfd295dc 100644 --- a/spec/fever_api/authentication_spec.rb +++ b/spec/fever_api/authentication_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/authentication" diff --git a/spec/fever_api/read_favicons_spec.rb b/spec/fever_api/read_favicons_spec.rb index 93bb4efa1..19ce8a94b 100644 --- a/spec/fever_api/read_favicons_spec.rb +++ b/spec/fever_api/read_favicons_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/read_favicons" diff --git a/spec/fever_api/read_feeds_groups_spec.rb b/spec/fever_api/read_feeds_groups_spec.rb index 6540503dd..4df971b5f 100644 --- a/spec/fever_api/read_feeds_groups_spec.rb +++ b/spec/fever_api/read_feeds_groups_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/read_feeds_groups" diff --git a/spec/fever_api/read_feeds_spec.rb b/spec/fever_api/read_feeds_spec.rb index 5ab15483c..40732e031 100644 --- a/spec/fever_api/read_feeds_spec.rb +++ b/spec/fever_api/read_feeds_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/read_feeds" diff --git a/spec/fever_api/read_groups_spec.rb b/spec/fever_api/read_groups_spec.rb index 6adc080ff..2b7b5951d 100644 --- a/spec/fever_api/read_groups_spec.rb +++ b/spec/fever_api/read_groups_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/read_groups" diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index d146af044..a44a316f0 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/read_items" diff --git a/spec/fever_api/read_links_spec.rb b/spec/fever_api/read_links_spec.rb index 895123de0..3f279179d 100644 --- a/spec/fever_api/read_links_spec.rb +++ b/spec/fever_api/read_links_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/read_links" diff --git a/spec/fever_api/sync_saved_item_ids_spec.rb b/spec/fever_api/sync_saved_item_ids_spec.rb index 5907df49a..6b8afc0f9 100644 --- a/spec/fever_api/sync_saved_item_ids_spec.rb +++ b/spec/fever_api/sync_saved_item_ids_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/sync_saved_item_ids" diff --git a/spec/fever_api/sync_unread_item_ids_spec.rb b/spec/fever_api/sync_unread_item_ids_spec.rb index e7f98e9c8..8bb197dbc 100644 --- a/spec/fever_api/sync_unread_item_ids_spec.rb +++ b/spec/fever_api/sync_unread_item_ids_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/sync_unread_item_ids" diff --git a/spec/fever_api/write_mark_feed_spec.rb b/spec/fever_api/write_mark_feed_spec.rb index 719b9ed65..2a6c252e4 100644 --- a/spec/fever_api/write_mark_feed_spec.rb +++ b/spec/fever_api/write_mark_feed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/write_mark_feed" diff --git a/spec/fever_api/write_mark_group_spec.rb b/spec/fever_api/write_mark_group_spec.rb index 9eaa6ee6a..b86b42f98 100644 --- a/spec/fever_api/write_mark_group_spec.rb +++ b/spec/fever_api/write_mark_group_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/write_mark_group" diff --git a/spec/fever_api/write_mark_item_spec.rb b/spec/fever_api/write_mark_item_spec.rb index 9efd634cc..3edb48802 100644 --- a/spec/fever_api/write_mark_item_spec.rb +++ b/spec/fever_api/write_mark_item_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "fever_api/write_mark_item" diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 9f656ed3e..aa99b0df5 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "./fever_api" diff --git a/spec/helpers/authentications_helper_spec.rb b/spec/helpers/authentications_helper_spec.rb index 7d77141df..180082dc1 100644 --- a/spec/helpers/authentications_helper_spec.rb +++ b/spec/helpers/authentications_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "helpers/authentication_helpers" diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index edcb36d63..4c8561efd 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "helpers/url_helpers" diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index 200e0bb3d..1831528db 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "time" require "support/active_record" diff --git a/spec/javascript/test_controller.rb b/spec/javascript/test_controller.rb index 84a5f6b59..470757949 100644 --- a/spec/javascript/test_controller.rb +++ b/spec/javascript/test_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Stringer < Sinatra::Base def self.test_path(*chunks) File.expand_path(File.join("..", *chunks), __FILE__) diff --git a/spec/models/feed_spec.rb b/spec/models/feed_spec.rb index e7e3b4c57..7acdc0501 100644 --- a/spec/models/feed_spec.rb +++ b/spec/models/feed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 14b3285ca..6556e076b 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/models/migration_status_spec.rb b/spec/models/migration_status_spec.rb index d32f79683..9335c56eb 100644 --- a/spec/models/migration_status_spec.rb +++ b/spec/models/migration_status_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 27fb71ac0..cc6729698 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/repositories/feed_repository_spec.rb b/spec/repositories/feed_repository_spec.rb index 2f2dac5d4..1bd31867c 100644 --- a/spec/repositories/feed_repository_spec.rb +++ b/spec/repositories/feed_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/repositories/group_repository_spec.rb b/spec/repositories/group_repository_spec.rb index fd119fa27..2f6a5a827 100644 --- a/spec/repositories/group_repository_spec.rb +++ b/spec/repositories/group_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index bc8f96949..98aa3fada 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/repositories/user_repository_spec.rb b/spec/repositories/user_repository_spec.rb index 2e969b000..8e51de51b 100644 --- a/spec/repositories/user_repository_spec.rb +++ b/spec/repositories/user_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6873a783f..9688013bb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV["RACK_ENV"] = "test" ENV["ENFORCE_SSL"] = "true" diff --git a/spec/support/active_record.rb b/spec/support/active_record.rb index 724b89aa0..92ac0b8f6 100644 --- a/spec/support/active_record.rb +++ b/spec/support/active_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_record" db_config = YAML.safe_load(File.read("config/database.yml")) diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb index 2f2a2b83b..6c914f365 100644 --- a/spec/support/coverage.rb +++ b/spec/support/coverage.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "simplecov" if ENV["CI"] diff --git a/spec/support/feed_server.rb b/spec/support/feed_server.rb index 502c9b338..0fd60f524 100644 --- a/spec/support/feed_server.rb +++ b/spec/support/feed_server.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FeedServer attr_writer :response diff --git a/spec/tasks/change_password_spec.rb b/spec/tasks/change_password_spec.rb index 168f5401a..648a64858 100644 --- a/spec/tasks/change_password_spec.rb +++ b/spec/tasks/change_password_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "tasks/change_password" diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index a5bc4d88b..0a07c6df0 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "tasks/fetch_feed" diff --git a/spec/tasks/fetch_feeds_spec.rb b/spec/tasks/fetch_feeds_spec.rb index 7b66229ad..055b394f6 100644 --- a/spec/tasks/fetch_feeds_spec.rb +++ b/spec/tasks/fetch_feeds_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" require "support/active_record" diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index 2bba7bc47..7680edd23 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "tasks/remove_old_stories" diff --git a/spec/utils/content_sanitizer_spec.rb b/spec/utils/content_sanitizer_spec.rb index a5056fb12..7d4a598f1 100644 --- a/spec/utils/content_sanitizer_spec.rb +++ b/spec/utils/content_sanitizer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "utils/content_sanitizer" diff --git a/spec/utils/feed_discovery_spec.rb b/spec/utils/feed_discovery_spec.rb index ccb475948..4266d3ec1 100644 --- a/spec/utils/feed_discovery_spec.rb +++ b/spec/utils/feed_discovery_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "utils/feed_discovery" diff --git a/spec/utils/i18n_support_spec.rb b/spec/utils/i18n_support_spec.rb index e60e77b2d..65bdd3196 100644 --- a/spec/utils/i18n_support_spec.rb +++ b/spec/utils/i18n_support_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe "i18n" do diff --git a/spec/utils/opml_parser_spec.rb b/spec/utils/opml_parser_spec.rb index ea844b3e8..0939a0267 100644 --- a/spec/utils/opml_parser_spec.rb +++ b/spec/utils/opml_parser_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" app_require "utils/opml_parser" From 6da0bcc96b58f457ea49614aaa7333a0ccb4f543 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 16:06:57 -0800 Subject: [PATCH 222/779] RuboCop: add parens for controller specs (#752) --- .rubocop_todo.yml | 8 -------- spec/controllers/debug_controller_spec.rb | 6 +++--- spec/controllers/exports_controller_spec.rb | 4 ++-- spec/controllers/feeds_controller_spec.rb | 4 ++-- spec/controllers/first_run_controller_spec.rb | 16 ++++++++-------- spec/controllers/imports_controller_spec.rb | 4 ++-- spec/controllers/sessions_controller_spec.rb | 12 ++++++------ spec/controllers/stories_controller_spec.rb | 16 ++++++++-------- spec/javascript/test_controller.rb | 6 +++--- 9 files changed, 34 insertions(+), 42 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6c1b22b50..f3b4539f9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -656,17 +656,9 @@ Style/MethodCallWithArgsParentheses: - 'spec/commands/find_new_stories_spec.rb' - 'spec/commands/users/change_user_password_spec.rb' - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/exports_controller_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/imports_controller_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api_spec.rb' - 'spec/helpers/url_helpers_spec.rb' - 'spec/integration/feed_importing_spec.rb' - - 'spec/javascript/test_controller.rb' - 'spec/models/story_spec.rb' - 'spec/repositories/feed_repository_spec.rb' - 'spec/repositories/story_repository_spec.rb' diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index f0c7dd4b7..dc8a2fb62 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -8,15 +8,15 @@ describe DebugController do describe "GET /debug" do before do - delayed_job = double "Delayed::Job" + delayed_job = double("Delayed::Job") allow(delayed_job).to receive(:count).and_return(42) stub_const("Delayed::Job", delayed_job) - migration_status_instance = double "migration_status_instance" + migration_status_instance = double("migration_status_instance") allow(migration_status_instance) .to receive(:pending_migrations) .and_return(["Migration B - 2", "Migration C - 3"]) - migration_status = double "MigrationStatus" + migration_status = double("MigrationStatus") allow(migration_status) .to receive(:new).and_return(migration_status_instance) stub_const("MigrationStatus", migration_status) diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb index 07285e56f..7e2d2efeb 100644 --- a/spec/controllers/exports_controller_spec.rb +++ b/spec/controllers/exports_controller_spec.rb @@ -19,7 +19,7 @@ def mock_export get "/feeds/export" - expect(last_response.body).to eq some_xml + expect(last_response.body).to eq(some_xml) end it "responds with xml content type" do @@ -27,7 +27,7 @@ def mock_export get "/feeds/export" - expect(last_response.header["Content-Type"]).to include "application/xml" + expect(last_response.header["Content-Type"]).to include("application/xml") end it "responds with disposition attachment" do diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index bbc28e605..32b715b10 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -110,8 +110,8 @@ def params(feed, **overrides) post("/feeds", feed_url:) - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/") end end diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 14c8e62d7..418132b54 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -44,8 +44,8 @@ post "/setup/password", password: "foo", password_confirmation: "foo" - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/feeds/import" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/feeds/import") end end @@ -81,16 +81,16 @@ session = { "rack.session" => { user_id: user.id } } get "/", {}, session - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/news" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/news") get "/setup/password", {}, session - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/news" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/news") get "/setup/tutorial", {}, session - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/news" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/news") end end end diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb index 2b052246e..d2ea96841 100644 --- a/spec/controllers/imports_controller_spec.rb +++ b/spec/controllers/imports_controller_spec.rb @@ -28,8 +28,8 @@ post "/feeds/import", "opml_file" => opml_file - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/setup/tutorial" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/setup/tutorial") end end end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 93216b5a7..bfa5eef35 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -30,10 +30,10 @@ post "/login", password: "the-password" - expect(session[:user_id]).to eq 1 + expect(session[:user_id]).to eq(1) - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/") end it "redirects to the previous path when present" do @@ -43,7 +43,7 @@ post "/login", params, "rack.session" => { redirect_to: "/archive" } expect(session[:redirect_to]).to be_nil - expect(URI.parse(last_response.location).path).to eq "/archive" + expect(URI.parse(last_response.location).path).to eq("/archive") end end @@ -53,8 +53,8 @@ expect(session[:user_id]).to be_nil - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/") end end end diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index c06ba3702..758d4a6a2 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -100,7 +100,7 @@ put "/stories/#{story_one.id}", { is_read: true }.to_json - expect(story_one.is_read).to be true + expect(story_one.is_read).to be(true) end end @@ -110,7 +110,7 @@ put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json - expect(story_one.is_read).to be true + expect(story_one.is_read).to be(true) end end end @@ -120,7 +120,7 @@ it "marks a story as permanently unread" do put "/stories/#{story_one.id}", { keep_unread: false }.to_json - expect(story_one.keep_unread).to be false + expect(story_one.keep_unread).to be(false) end end @@ -128,7 +128,7 @@ it "marks a story as permanently unread" do put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json - expect(story_one.keep_unread).to be true + expect(story_one.keep_unread).to be(true) end end end @@ -138,7 +138,7 @@ it "marks a story as permanently starred" do put "/stories/#{story_one.id}", { is_starred: true }.to_json - expect(story_one.is_starred).to be true + expect(story_one.is_starred).to be(true) end end @@ -146,7 +146,7 @@ it "marks a story as permanently starred" do put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json - expect(story_one.is_starred).to be true + expect(story_one.is_starred).to be(true) end end end @@ -158,8 +158,8 @@ post "/stories/mark_all_as_read", story_ids: ["1", "2", "3"] - expect(last_response.status).to be 302 - expect(URI.parse(last_response.location).path).to eq "/news" + expect(last_response.status).to be(302) + expect(URI.parse(last_response.location).path).to eq("/news") end end diff --git a/spec/javascript/test_controller.rb b/spec/javascript/test_controller.rb index 470757949..3b1a7358d 100644 --- a/spec/javascript/test_controller.rb +++ b/spec/javascript/test_controller.rb @@ -33,16 +33,16 @@ def vendor_js_files "chai-backbone.js", "sinon-chai.js" ].map do |name| - File.join "vendor", "js", name + File.join("vendor", "js", name) end end def vendor_css_files - ["mocha.css"].map { |name| File.join "vendor", "css", name } + ["mocha.css"].map { |name| File.join("vendor", "css", name) } end def js_helper_files - ["spec_helper.js"].map { |name| File.join "spec", name } + ["spec_helper.js"].map { |name| File.join("spec", name) } end def js_lib_files From dd335211dd230fd08744545ab05504c85522e5e0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 16:28:06 -0800 Subject: [PATCH 223/779] RuboCop: fix lints for ExportsController (#753) --- .rubocop_todo.yml | 3 --- spec/controllers/exports_controller_spec.rb | 24 ++++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f3b4539f9..531cfbe43 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -61,7 +61,6 @@ Naming/PredicateName: # Offense count: 5 RSpec/AnyInstance: Exclude: - - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' @@ -147,7 +146,6 @@ RSpec/EmptyLineAfterFinalLet: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/models/story_spec.rb' - 'spec/repositories/story_repository_spec.rb' @@ -259,7 +257,6 @@ RSpec/MessageExpectation: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/exports_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' diff --git a/spec/controllers/exports_controller_spec.rb b/spec/controllers/exports_controller_spec.rb index 7e2d2efeb..66be986e9 100644 --- a/spec/controllers/exports_controller_spec.rb +++ b/spec/controllers/exports_controller_spec.rb @@ -6,33 +6,31 @@ describe ExportsController do describe "GET /feeds/export" do - let(:some_xml) { "some dummy opml" } - before { allow(Feed).to receive(:all) } - - def mock_export - expect_any_instance_of(ExportToOpml) - .to receive(:to_xml).and_return(some_xml) + def expected_xml + <<~XML + + + + Feeds from Stringer + + + + XML end it "returns an OPML file" do - mock_export - get "/feeds/export" - expect(last_response.body).to eq(some_xml) + expect(last_response.body).to eq(expected_xml) end it "responds with xml content type" do - mock_export - get "/feeds/export" expect(last_response.header["Content-Type"]).to include("application/xml") end it "responds with disposition attachment" do - mock_export - get "/feeds/export" expected = From a6b168906880adf751e01143f64b44ba433007e2 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 16:38:04 -0800 Subject: [PATCH 224/779] RuboCop: fix VerifiedDouble offenses in controller specs (#754) --- .rubocop_todo.yml | 4 ---- spec/controllers/debug_controller_spec.rb | 10 +++------- spec/controllers/feeds_controller_spec.rb | 4 ++-- spec/controllers/first_run_controller_spec.rb | 7 ++++--- spec/controllers/sessions_controller_spec.rb | 10 +++++----- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 531cfbe43..883752c0c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -387,10 +387,6 @@ RSpec/VerifiedDoubles: - 'spec/commands/stories/mark_all_as_read_spec.rb' - 'spec/commands/stories/mark_feed_as_read_spec.rb' - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/controllers/debug_controller_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - 'spec/fever_api/authentication_spec.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index dc8a2fb62..f325f0936 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -8,18 +8,14 @@ describe DebugController do describe "GET /debug" do before do - delayed_job = double("Delayed::Job") - allow(delayed_job).to receive(:count).and_return(42) - stub_const("Delayed::Job", delayed_job) + allow(Delayed::Job).to receive(:count).and_return(42) - migration_status_instance = double("migration_status_instance") + migration_status_instance = instance_double(MigrationStatus) allow(migration_status_instance) .to receive(:pending_migrations) .and_return(["Migration B - 2", "Migration C - 3"]) - migration_status = double("MigrationStatus") - allow(migration_status) + allow(MigrationStatus) .to receive(:new).and_return(migration_status_instance) - stub_const("MigrationStatus", migration_status) end it "displays the current Ruby version" do diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 32b715b10..6ac77e2ae 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -102,7 +102,7 @@ def params(feed, **overrides) describe "POST /feeds" do context "when the feed url is valid" do let(:feed_url) { "http://example.com/" } - let(:feed) { double(valid?: true) } + let(:feed) { instance_double(Feed, valid?: true) } it "adds the feed and queues it to be fetched" do expect(AddNewFeed).to receive(:add).with(feed_url).and_return(feed) @@ -130,7 +130,7 @@ def params(feed, **overrides) context "when the feed url is one we already subscribe to" do let(:feed_url) { "http://example.com/" } - let(:invalid_feed) { double(valid?: false) } + let(:invalid_feed) { instance_double(Feed, valid?: false) } it "adds the feed and queues it to be fetched" do expect(AddNewFeed) diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 418132b54..7afc00764 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -39,8 +39,9 @@ end it "accepts confirmed passwords and redirects to next step" do + user = instance_double(User, id: 1) expect_any_instance_of(CreateUser) - .to receive(:create).with("foo").and_return(double(id: 1)) + .to receive(:create).with("foo").and_return(user) post "/setup/password", password: "foo", password_confirmation: "foo" @@ -50,8 +51,8 @@ end describe "GET /setup/tutorial" do - let(:user) { double } - let(:feeds) { [double, double] } + let(:user) { instance_double(User) } + let(:feeds) { [instance_double(Feed), instance_double(Feed)] } before do allow(UserRepository).to receive(:fetch).and_return(user) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index bfa5eef35..589009797 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -26,20 +26,20 @@ end it "allows access when password is correct" do - allow(SignInUser).to receive(:sign_in).and_return(double(id: 1)) + user = create(:user) - post "/login", password: "the-password" + post "/login", password: user.password - expect(session[:user_id]).to eq(1) + expect(session[:user_id]).to eq(user.id) expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/") end it "redirects to the previous path when present" do - allow(SignInUser).to receive(:sign_in).and_return(double(id: 1)) + user = create(:user) - params = { password: "the-password" } + params = { password: user.password } post "/login", params, "rack.session" => { redirect_to: "/archive" } expect(session[:redirect_to]).to be_nil From 18a5e8628523513582890726c941b6a811d7e5a7 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 16:57:46 -0800 Subject: [PATCH 225/779] RuboCop: fix SaveBang offenses in controllers (#755) --- .rubocop_todo.yml | 2 -- app/commands/users/create_user.rb | 2 +- app/controllers/sinatra/first_run_controller.rb | 2 +- app/controllers/sinatra/stories_controller.rb | 2 +- app/repositories/story_repository.rb | 4 ---- spec/commands/users/create_user_spec.rb | 2 +- spec/controllers/first_run_controller_spec.rb | 2 +- spec/controllers/stories_controller_spec.rb | 4 ++-- 8 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 883752c0c..874e186f0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -488,8 +488,6 @@ Rails/SaveBang: - 'app/commands/users/change_user_password.rb' - 'app/commands/users/complete_setup.rb' - 'app/commands/users/create_user.rb' - - 'app/controllers/sinatra/first_run_controller.rb' - - 'app/controllers/sinatra/stories_controller.rb' - 'app/repositories/feed_repository.rb' - 'app/repositories/story_repository.rb' - 'app/repositories/user_repository.rb' diff --git a/app/commands/users/create_user.rb b/app/commands/users/create_user.rb index b51d6eddb..46db7e891 100644 --- a/app/commands/users/create_user.rb +++ b/app/commands/users/create_user.rb @@ -7,7 +7,7 @@ def initialize(repository = User) @repo = repository end - def create(password) + def call(password) @repo.delete_all @repo.create( password: password, diff --git a/app/controllers/sinatra/first_run_controller.rb b/app/controllers/sinatra/first_run_controller.rb index 78e5bf5df..37f6f19d3 100644 --- a/app/controllers/sinatra/first_run_controller.rb +++ b/app/controllers/sinatra/first_run_controller.rb @@ -22,7 +22,7 @@ class Stringer < Sinatra::Base flash.now[:error] = t("first_run.password.flash.passwords_dont_match") erb :"first_run/password" else - user = CreateUser.new.create(params[:password]) + user = CreateUser.new.call(params[:password]) session[:user_id] = user.id redirect to("/feeds/import") diff --git a/app/controllers/sinatra/stories_controller.rb b/app/controllers/sinatra/stories_controller.rb index 9614f86d1..064e97709 100644 --- a/app/controllers/sinatra/stories_controller.rb +++ b/app/controllers/sinatra/stories_controller.rb @@ -39,7 +39,7 @@ class Stringer < Sinatra::Base story.keep_unread = !!json_params[:keep_unread] story.is_starred = !!json_params[:is_starred] - StoryRepository.save(story) + story.save! end post "/stories/mark_all_as_read" do diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 606ba003a..a2c1032c0 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -48,10 +48,6 @@ def self.fetch_unread_for_feed_by_timestamp(feed_id, timestamp) .where("created_at < ? AND is_read = ?", timestamp, false) end - def self.save(story) - story.save - end - def self.exists?(id, feed_id) Story.exists?(entry_id: id, feed_id: feed_id) end diff --git a/spec/commands/users/create_user_spec.rb b/spec/commands/users/create_user_spec.rb index 6c93c7f4f..82fee8f90 100644 --- a/spec/commands/users/create_user_spec.rb +++ b/spec/commands/users/create_user_spec.rb @@ -14,7 +14,7 @@ expect(repo).to receive(:create) expect(repo).to receive(:delete_all) - command.create("password") + command.call("password") end end end diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 7afc00764..934e4c113 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -41,7 +41,7 @@ it "accepts confirmed passwords and redirects to next step" do user = instance_double(User, id: 1) expect_any_instance_of(CreateUser) - .to receive(:create).with("foo").and_return(user) + .to receive(:call).with("foo").and_return(user) post "/setup/password", password: "foo", password_confirmation: "foo" diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 758d4a6a2..39bd868b1 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -96,7 +96,7 @@ context "is_read parameter" do context "when it is not malformed" do it "marks a story as read" do - expect(StoryRepository).to receive(:save).once + expect(story_one).to receive(:save!).once put "/stories/#{story_one.id}", { is_read: true }.to_json @@ -106,7 +106,7 @@ context "when it is malformed" do it "marks a story as read" do - expect(StoryRepository).to receive(:save).once + expect(story_one).to receive(:save!).once put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json From 740988bd0c6c1b9ccbe1cf91a0cb36ef12860763 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Thu, 29 Dec 2022 23:11:44 -0800 Subject: [PATCH 226/779] Create CODE_OF_CONDUCT.md (#758) --- CODE_OF_CONDUCT.md | 128 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..fa581a793 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +robert@boon.gl. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. From 3d4dbe0e31856453b0bc57858b7580e3274a8d9b Mon Sep 17 00:00:00 2001 From: ilakast Date: Sat, 31 Dec 2022 20:25:09 +0000 Subject: [PATCH 227/779] Update README.md (#760) updated info about Heroku plans not being free anymore --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 5f5b44196..f4dc1f2fc 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Stringer is a Ruby app based on Sinatra, ActiveRecord, PostgreSQL, Backbone.js a [![Deploy to Heroku](https://cdn.herokuapp.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/stringer-rss/stringer) -Stringer will run just fine on the Heroku free plan. +Stringer will run just fine on the Eco/Basic Heroku plans. Instructions are provided for deploying to [Heroku manually](/docs/Heroku.md), to any Ruby compatible [Linux-based VPS](/docs/VPS.md), to [Docker](docs/docker.md) and to [OpenShift](/docs/OpenShift.md). @@ -79,9 +79,6 @@ If you would like to translate Stringer to your preferred language, please use [ ### Clean up old read stories on Heroku -If you are on the Heroku free plan, there is a 10k row limit so you will -eventually run out of space. - You can clean up old stories by running: `rake cleanup_old_stories` By default, this removes read stories that are more than 30 days old (that From 460ee12983abfb8f1d602cecf43f212f2455a4ad Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 15:35:18 -0800 Subject: [PATCH 228/779] RuboCop: fix AnyInstance offenses in controllers (#757) --- .rubocop_todo.yml | 2 -- app/commands/stories/mark_all_as_read.rb | 6 +++++- app/commands/users/create_user.rb | 4 ++++ app/controllers/sinatra/first_run_controller.rb | 2 +- app/controllers/sinatra/stories_controller.rb | 2 +- spec/commands/stories/mark_all_as_read_spec.rb | 6 +++--- spec/commands/users/create_user_spec.rb | 12 ++++-------- spec/controllers/first_run_controller_spec.rb | 3 +-- spec/controllers/stories_controller_spec.rb | 2 +- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 874e186f0..6353fdab8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -61,8 +61,6 @@ Naming/PredicateName: # Offense count: 5 RSpec/AnyInstance: Exclude: - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' # Offense count: 4 diff --git a/app/commands/stories/mark_all_as_read.rb b/app/commands/stories/mark_all_as_read.rb index a74dceaf9..c13d3aa76 100644 --- a/app/commands/stories/mark_all_as_read.rb +++ b/app/commands/stories/mark_all_as_read.rb @@ -8,7 +8,11 @@ def initialize(story_ids, repository = StoryRepository) @repo = repository end - def mark_as_read + def self.call(*args) + new(*args).call + end + + def call @repo.fetch_by_ids(@story_ids).update_all(is_read: true) end end diff --git a/app/commands/users/create_user.rb b/app/commands/users/create_user.rb index 46db7e891..955d615de 100644 --- a/app/commands/users/create_user.rb +++ b/app/commands/users/create_user.rb @@ -7,6 +7,10 @@ def initialize(repository = User) @repo = repository end + def self.call(password) + new.call(password) + end + def call(password) @repo.delete_all @repo.create( diff --git a/app/controllers/sinatra/first_run_controller.rb b/app/controllers/sinatra/first_run_controller.rb index 37f6f19d3..8556addc6 100644 --- a/app/controllers/sinatra/first_run_controller.rb +++ b/app/controllers/sinatra/first_run_controller.rb @@ -22,7 +22,7 @@ class Stringer < Sinatra::Base flash.now[:error] = t("first_run.password.flash.passwords_dont_match") erb :"first_run/password" else - user = CreateUser.new.call(params[:password]) + user = CreateUser.call(params[:password]) session[:user_id] = user.id redirect to("/feeds/import") diff --git a/app/controllers/sinatra/stories_controller.rb b/app/controllers/sinatra/stories_controller.rb index 064e97709..c36ce0573 100644 --- a/app/controllers/sinatra/stories_controller.rb +++ b/app/controllers/sinatra/stories_controller.rb @@ -43,7 +43,7 @@ class Stringer < Sinatra::Base end post "/stories/mark_all_as_read" do - MarkAllAsRead.new(params[:story_ids]).mark_as_read + MarkAllAsRead.call(params[:story_ids]) redirect to("/news") end diff --git a/spec/commands/stories/mark_all_as_read_spec.rb b/spec/commands/stories/mark_all_as_read_spec.rb index 656302f9c..b9880759e 100644 --- a/spec/commands/stories/mark_all_as_read_spec.rb +++ b/spec/commands/stories/mark_all_as_read_spec.rb @@ -5,14 +5,14 @@ app_require "commands/stories/mark_all_as_read" describe MarkAllAsRead do - describe "#mark_as_read" do + describe "#call" do let(:stories) { double } let(:repo) { double(fetch_by_ids: stories) } it "marks all stories as read" do - command = MarkAllAsRead.new([1, 2], repo) expect(stories).to receive(:update_all).with(is_read: true) - command.mark_as_read + + MarkAllAsRead.call([1, 2], repo) end end end diff --git a/spec/commands/users/create_user_spec.rb b/spec/commands/users/create_user_spec.rb index 82fee8f90..c8a2fde8e 100644 --- a/spec/commands/users/create_user_spec.rb +++ b/spec/commands/users/create_user_spec.rb @@ -5,16 +5,12 @@ app_require "commands/users/create_user" describe CreateUser do - let(:repo) { double } - - describe "#create" do + describe "#call" do it "removes existing users and create a user with the password supplied" do - command = CreateUser.new(repo) - - expect(repo).to receive(:create) - expect(repo).to receive(:delete_all) + expect(User).to receive(:create) + expect(User).to receive(:delete_all) - command.call("password") + described_class.call("password") end end end diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 934e4c113..454b76011 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -40,8 +40,7 @@ it "accepts confirmed passwords and redirects to next step" do user = instance_double(User, id: 1) - expect_any_instance_of(CreateUser) - .to receive(:call).with("foo").and_return(user) + expect(CreateUser).to receive(:call).with("foo").and_return(user) post "/setup/password", password: "foo", password_confirmation: "foo" diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 39bd868b1..2446daa10 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -154,7 +154,7 @@ describe "POST /stories/mark_all_as_read" do it "marks all unread stories as read and reload the page" do - expect_any_instance_of(MarkAllAsRead).to receive(:mark_as_read).once + expect(MarkAllAsRead).to receive(:call).once post "/stories/mark_all_as_read", story_ids: ["1", "2", "3"] From ab10806a26d45c50df0984a41bb9a0a26bc99ec6 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:03:45 -0800 Subject: [PATCH 229/779] Dev: remove racksh (#761) It currently [doesn't work with Ruby 3.2][r3]. For our purposes, we can instead replace it with a small rake task. [r3]: https://github.com/sickill/racksh/pull/15 --- Gemfile | 1 - Gemfile.lock | 4 ---- Procfile | 1 - README.md | 2 +- Rakefile | 5 +++++ docs/VPS.md | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 4153f7c03..c08b3cea2 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,6 @@ gem "feedjira" gem "httparty" gem "pg" gem "puma", "~> 6.0" -gem "racksh" gem "rack-ssl" gem "sass" gem "sinatra" diff --git a/Gemfile.lock b/Gemfile.lock index 4c244265e..1f48fefc0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -175,9 +175,6 @@ GEM rack rack-test (2.0.2) rack (>= 1.3) - racksh (1.0.0) - rack (>= 1.0) - rack-test (>= 0.5) rails (7.0.4) actioncable (= 7.0.4) actionmailbox (= 7.0.4) @@ -333,7 +330,6 @@ DEPENDENCIES pry-byebug puma (~> 6.0) rack-ssl - racksh rails (~> 7.0.1) rspec rspec-html-matchers diff --git a/Procfile b/Procfile index cceb33ddf..4a7ea7b92 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1 @@ web: bundle exec puma -p $PORT -C ./config/puma.rb -console: bundle exec racksh diff --git a/README.md b/README.md index f4dc1f2fc..9818718ff 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ foreman start The application will be running on port `5000`. -You can launch an interactive console (a la `rails c`) using `racksh`. +You can launch an interactive console (a la `rails c`) using `rake console`. ## Acknowledgments diff --git a/Rakefile b/Rakefile index 4bc059263..87fc524b4 100644 --- a/Rakefile +++ b/Rakefile @@ -19,6 +19,11 @@ require_relative "./app/tasks/fetch_feeds" require_relative "./app/tasks/change_password" require_relative "./app/tasks/remove_old_stories" +desc "Open an irb session preloaded with the app" +task :console do + sh "irb -r ./app.rb" +end + desc "Fetch all feeds." task :fetch_feeds do FetchFeeds.new(Feed.all).fetch_all diff --git a/docs/VPS.md b/docs/VPS.md index 9c05452d2..51b61d3b2 100644 --- a/docs/VPS.md +++ b/docs/VPS.md @@ -130,7 +130,7 @@ Logout stringer user, install systemd services: As stringer user, close existing Stringer instance: - exit # exit racksh and app + exit # exit app Start app as a systemd service and make app run at startup From 91d35a3826068d1d4775d53cabfe84bdd18b214d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:09:05 -0800 Subject: [PATCH 230/779] RuboCop: fix NestedGroups offenses in stories controller spec (#762) --- .rubocop_todo.yml | 1 - spec/controllers/stories_controller_spec.rb | 52 ++++++++------------- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6353fdab8..8e1c263ac 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -343,7 +343,6 @@ RSpec/NamedSubject: RSpec/NestedGroups: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - 'spec/integration/feed_importing_spec.rb' # Offense count: 2 diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 2446daa10..b261c5d74 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -94,60 +94,48 @@ describe "PUT /stories/:id" do before { allow(StoryRepository).to receive(:fetch).and_return(story_one) } context "is_read parameter" do - context "when it is not malformed" do - it "marks a story as read" do - expect(story_one).to receive(:save!).once + it "marks a story as read when it is not malformed" do + expect(story_one).to receive(:save!).once - put "/stories/#{story_one.id}", { is_read: true }.to_json + put "/stories/#{story_one.id}", { is_read: true }.to_json - expect(story_one.is_read).to be(true) - end + expect(story_one.is_read).to be(true) end - context "when it is malformed" do - it "marks a story as read" do - expect(story_one).to receive(:save!).once + it "marks a story as read when it is malformed" do + expect(story_one).to receive(:save!).once - put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json + put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json - expect(story_one.is_read).to be(true) - end + expect(story_one.is_read).to be(true) end end context "keep_unread parameter" do - context "when it is not malformed" do - it "marks a story as permanently unread" do - put "/stories/#{story_one.id}", { keep_unread: false }.to_json + it "marks a story as permanently unread when it is not malformed" do + put "/stories/#{story_one.id}", { keep_unread: false }.to_json - expect(story_one.keep_unread).to be(false) - end + expect(story_one.keep_unread).to be(false) end - context "when it is malformed" do - it "marks a story as permanently unread" do - put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json + it "marks a story as permanently unread when it is malformed" do + put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json - expect(story_one.keep_unread).to be(true) - end + expect(story_one.keep_unread).to be(true) end end context "is_starred parameter" do - context "when it is not malformed" do - it "marks a story as permanently starred" do - put "/stories/#{story_one.id}", { is_starred: true }.to_json + it "marks a story as permanently starred when it is not malformed" do + put "/stories/#{story_one.id}", { is_starred: true }.to_json - expect(story_one.is_starred).to be(true) - end + expect(story_one.is_starred).to be(true) end - context "when it is malformed" do - it "marks a story as permanently starred" do - put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json + it "marks a story as permanently starred when it is malformed" do + put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json - expect(story_one.is_starred).to be(true) - end + expect(story_one.is_starred).to be(true) end end end From 85aa590a8abe0d82d715d673052db3391fec9953 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sat, 31 Dec 2022 16:09:13 -0800 Subject: [PATCH 231/779] Update Ruby to version 3.2.0 (#743) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- .circleci/config.yml | 2 +- .ruby-version | 2 +- .tool-versions | 2 +- Dockerfile | 2 +- Gemfile.lock | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c8e2edd9..e79700049 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: build: parallelism: 1 docker: - - image: cimg/ruby:3.1.3-browsers + - image: cimg/ruby:3.2.0-browsers environment: BUNDLE_JOBS: 3 BUNDLE_RETRY: 3 diff --git a/.ruby-version b/.ruby-version index ff365e06b..944880fa1 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.3 +3.2.0 diff --git a/.tool-versions b/.tool-versions index ddf26c264..e57b760fc 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -ruby 3.1.3 +ruby 3.2.0 bundler 2.3.25 postgres 14.6 diff --git a/Dockerfile b/Dockerfile index 307350dfb..7dde75564 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.1.3 +FROM ruby:3.2.0 ENV RACK_ENV=production ENV PORT=8080 diff --git a/Gemfile.lock b/Gemfile.lock index 1f48fefc0..6e7319853 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -353,7 +353,7 @@ DEPENDENCIES will_paginate RUBY VERSION - ruby 3.1.3 + ruby 3.2.0 BUNDLED WITH 2.3.25 From 22426adfe7929937ae5438041819a685a3e0366b Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:23:38 -0800 Subject: [PATCH 232/779] Deps: update Nokogiri version (#764) The current release version [does not support Ruby 3.2][r3]. [r3]: https://github.com/sparklemotion/nokogiri/discussions/2747 --- Gemfile | 1 + Gemfile.lock | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c08b3cea2..2f91f7809 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ gem "delayed_job_active_record" gem "feedbag" gem "feedjira" gem "httparty" +gem "nokogiri", "~> 1.14.0.rc1" gem "pg" gem "puma", "~> 6.0" gem "rack-ssl" diff --git a/Gemfile.lock b/Gemfile.lock index 6e7319853..5b64567b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -151,7 +151,7 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.8) - nokogiri (1.13.10) + nokogiri (1.14.0.rc1) mini_portile2 (~> 2.8.0) racc (~> 1.4) parallel (1.22.1) @@ -326,6 +326,7 @@ DEPENDENCIES feedbag feedjira httparty + nokogiri (~> 1.14.0.rc1) pg pry-byebug puma (~> 6.0) From 6fa346c3c9b22158cd5372a63d14e1293194c3bb Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:23:49 -0800 Subject: [PATCH 233/779] RuboCop: fix CollectionMethods offenses (#763) --- .rubocop_todo.yml | 9 --------- app/controllers/sinatra/stories_controller.rb | 2 +- app/fever_api/response.rb | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8e1c263ac..f0b4eb1a2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -543,15 +543,6 @@ Rails/WhereNot: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. -# MethodsAcceptingSymbol: inject, reduce -Style/CollectionMethods: - Exclude: - - 'app/controllers/sinatra/stories_controller.rb' - - 'app/fever_api/response.rb' - # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. diff --git a/app/controllers/sinatra/stories_controller.rb b/app/controllers/sinatra/stories_controller.rb index c36ce0573..d67ba7775 100644 --- a/app/controllers/sinatra/stories_controller.rb +++ b/app/controllers/sinatra/stories_controller.rb @@ -14,7 +14,7 @@ class Stringer < Sinatra::Base @feed = FeedRepository.fetch(params[:feed_id]) @stories = StoryRepository.feed(params[:feed_id]) - @unread_stories = @stories.find_all { |story| !story.is_read } + @unread_stories = @stories.reject(&:is_read) erb :feed end diff --git a/app/fever_api/response.rb b/app/fever_api/response.rb index 327c40f55..19c1e324a 100644 --- a/app/fever_api/response.rb +++ b/app/fever_api/response.rb @@ -45,7 +45,7 @@ def initialize(params) def to_json(*_args) base_response = { api_version: API_VERSION } ACTIONS - .inject(base_response) { |a, e| a.merge!(e.new.call(@params)) } + .reduce(base_response) { |a, e| a.merge!(e.new.call(@params)) } .to_json end end From fcc671c9bbd6ab8ff28dcf8baff7d001745bafb0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:28:10 -0800 Subject: [PATCH 234/779] RuboCop: fix DoubleNegation offense (#765) --- .rubocop_todo.yml | 8 -------- app/controllers/sinatra/stories_controller.rb | 6 +----- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f0b4eb1a2..b09ce42f4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -543,14 +543,6 @@ Rails/WhereNot: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: allowed_in_returns, forbidden -Style/DoubleNegation: - Exclude: - - 'app/controllers/sinatra/stories_controller.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedVars. diff --git a/app/controllers/sinatra/stories_controller.rb b/app/controllers/sinatra/stories_controller.rb index d67ba7775..29b5bc272 100644 --- a/app/controllers/sinatra/stories_controller.rb +++ b/app/controllers/sinatra/stories_controller.rb @@ -35,11 +35,7 @@ class Stringer < Sinatra::Base json_params = JSON.parse(request.body.read, symbolize_names: true) story = StoryRepository.fetch(params[:id]) - story.is_read = !!json_params[:is_read] - story.keep_unread = !!json_params[:keep_unread] - story.is_starred = !!json_params[:is_starred] - - story.save! + story.update!(json_params.slice(:is_read, :is_starred, :keep_unread)) end post "/stories/mark_all_as_read" do From 3ebfa9ec1ed6f8c37759ff37a006028072c83da0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:33:08 -0800 Subject: [PATCH 235/779] RuboCop: fix EmptyLine offenses (#766) --- .rubocop_todo.yml | 17 ----------------- spec/commands/feeds/add_new_feed_spec.rb | 1 + spec/commands/users/complete_setup_spec.rb | 1 + spec/controllers/stories_controller_spec.rb | 3 +++ spec/models/story_spec.rb | 1 + spec/repositories/story_repository_spec.rb | 1 + 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b09ce42f4..69a89a078 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -138,23 +138,6 @@ RSpec/DescribedClass: - 'spec/utils/feed_discovery_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterFinalLet: - Exclude: - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/models/story_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterHook: - Exclude: - - 'spec/controllers/stories_controller_spec.rb' - # Offense count: 63 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index e0eb8d39d..8893f5434 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -8,6 +8,7 @@ describe "#add" do context "feed cannot be discovered" do let(:discoverer) { double(discover: false) } + it "returns false if cant discover any feeds" do result = AddNewFeed.add("http://not-a-feed.com", discoverer) diff --git a/spec/commands/users/complete_setup_spec.rb b/spec/commands/users/complete_setup_spec.rb index 98fca9f1a..5c1ad2a88 100644 --- a/spec/commands/users/complete_setup_spec.rb +++ b/spec/commands/users/complete_setup_spec.rb @@ -6,6 +6,7 @@ describe CompleteSetup do let(:user) { build(:user) } + it "marks setup as complete" do expect(user).to receive(:save).once diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index b261c5d74..1801fee0f 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -65,6 +65,7 @@ let(:read_one) { build(:story, :read) } let(:read_two) { build(:story, :read) } let(:stories) { [read_one, read_two].paginate } + before { allow(StoryRepository).to receive(:read).and_return(stories) } it "displays the list of read stories with pagination" do @@ -80,6 +81,7 @@ let(:starred_one) { build(:story, :starred) } let(:starred_two) { build(:story, :starred) } let(:stories) { [starred_one, starred_two].paginate } + before { allow(StoryRepository).to receive(:starred).and_return(stories) } it "displays the list of starred stories with pagination" do @@ -93,6 +95,7 @@ describe "PUT /stories/:id" do before { allow(StoryRepository).to receive(:fetch).and_return(story_one) } + context "is_read parameter" do it "marks a story as read when it is not malformed" do expect(story_one).to receive(:save!).once diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index cc6729698..e015054c9 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -42,6 +42,7 @@ describe "#source" do let(:feed) { Feed.new(name: "Superfeed") } + before { story.feed = feed } it "returns the feeds name" do diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 98aa3fada..6b4abc5ad 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -8,6 +8,7 @@ describe StoryRepository do describe ".add" do let(:feed) { double(url: "http://blog.golang.org/feed.atom") } + before { allow(Story).to receive(:create) } it "normalizes story urls" do From 7cf31ffd9b60c9a03c71681eb92b3a0dbba7b102 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:50:12 -0800 Subject: [PATCH 236/779] RuboCop: fix ExampleWording offenses (#767) --- .rubocop_todo.yml | 14 -------------- spec/commands/find_new_stories_spec.rb | 8 ++++---- spec/controllers/first_run_controller_spec.rb | 2 +- spec/controllers/stories_controller_spec.rb | 2 +- spec/tasks/fetch_feed_spec.rb | 8 ++++---- spec/tasks/remove_old_stories_spec.rb | 8 ++++---- spec/utils/i18n_support_spec.rb | 6 +++--- spec/utils/opml_parser_spec.rb | 2 +- 8 files changed, 18 insertions(+), 32 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 69a89a078..8e5048161 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -165,20 +165,6 @@ RSpec/ExampleLength: - 'spec/utils/feed_discovery_spec.rb' - 'spec/utils/opml_parser_spec.rb' -# Offense count: 18 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. -# DisallowedExamples: works -RSpec/ExampleWording: - Exclude: - - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/remove_old_stories_spec.rb' - - 'spec/utils/i18n_support_spec.rb' - - 'spec/utils/opml_parser_spec.rb' - # Offense count: 2 RSpec/ExpectInHook: Exclude: diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index 8f4af7c98..5f2f45c63 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -10,7 +10,7 @@ context "the feed contains no new stories" do before { allow(StoryRepository).to receive(:exists?).and_return(true) } - it "should find zero new stories" do + it "finds zero new stories" do story1 = double(published: nil, id: "story1") story2 = double(published: nil, id: "story2") feed = double(entries: [story1, story2]) @@ -21,7 +21,7 @@ end context "the feed contains new stories" do - it "should return stories that are not found in the database" do + it "returns stories that are not found in the database" do story1 = double(published: nil, id: "story1") story2 = double(published: nil, id: "story2") feed = double(entries: [story1, story2]) @@ -36,7 +36,7 @@ end end - it "should scan until matching the last story id" do + it "scans until matching the last story id" do new_story = double(published: nil, id: "new-story") old_story = double(published: nil, id: "old-story") feed = double(last_modified: nil, entries: [new_story, old_story]) @@ -50,7 +50,7 @@ expect(result).to eq [new_story] end - it "should ignore stories older than 3 days" do + it "ignores stories older than 3 days" do new_stories = [ double(published: 1.hour.ago, id: "new-story"), double(published: 2.days.ago, id: "new-story") diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 454b76011..b449ea83b 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -76,7 +76,7 @@ end context "when a user has been setup" do - it "should redirect any requests to first run stuff" do + it "redirects any requests to first run stuff" do user = create(:user, :setup_complete) session = { "rack.session" => { user_id: user.id } } diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 1801fee0f..c4fdda94e 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -40,7 +40,7 @@ expect(last_response.body).to have_tag("#add-feed") end - it "should have correct footer links" do + it "has correct footer links" do get "/news" page = last_response.body diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 0a07c6df0..457d80e0b 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -21,7 +21,7 @@ end context "when feed has not been modified" do - it "should not try to fetch posts" do + it "does not try to fetch posts" do client = class_spy(HTTParty) parser = class_double(Feedjira, parse: 304) @@ -53,7 +53,7 @@ end context "when no new posts have been added" do - it "should not add any new posts" do + it "does not add any new posts" do fake_feed = double(last_modified: Time.new(2012, 12, 31)) client = class_spy(HTTParty) parser = class_double(Feedjira, parse: fake_feed) @@ -83,7 +83,7 @@ .to receive(:new_stories).and_return([new_story]) end - it "should only add posts that are new" do + it "only adds posts that are new" do expect(StoryRepository).to receive(:add).with( new_story, daring_fireball @@ -98,7 +98,7 @@ ).fetch end - it "should update the last fetched time for the feed" do + it "updates the last fetched time for the feed" do expect(FeedRepository).to receive(:update_last_fetched) .with(daring_fireball, now) diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index 7680edd23..08a36df7f 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -11,7 +11,7 @@ stories end - it "should pass along the number of days to the story repository query" do + it "passes along the number of days to the story repository query" do allow(RemoveOldStories).to receive(:pruned_feeds) { [] } expect(StoryRepository).to receive(:unstarred_read_stories_older_than) @@ -20,7 +20,7 @@ RemoveOldStories.remove!(7) end - it "should request deletion of all old stories" do + it "requests deletion of all old stories" do allow(RemoveOldStories).to receive(:pruned_feeds) { [] } allow(StoryRepository) .to receive(:unstarred_read_stories_older_than) { stories_mock } @@ -30,7 +30,7 @@ RemoveOldStories.remove!(11) end - it "should fetch affected feeds by id" do + it "fetches affected feeds by id" do allow(RemoveOldStories).to receive(:old_stories) do stories = [double("story", feed_id: 3), double("story", feed_id: 5)] allow(stories).to receive(:delete_all) @@ -43,7 +43,7 @@ RemoveOldStories.remove!(13) end - it "should update last_fetched on affected feeds" do + it "updates last_fetched on affected feeds" do feeds = [double("feed a"), double("feed b")] allow(RemoveOldStories).to receive(:pruned_feeds) { feeds } allow(RemoveOldStories).to receive(:old_stories) { stories_mock } diff --git a/spec/utils/i18n_support_spec.rb b/spec/utils/i18n_support_spec.rb index 65bdd3196..d469036a7 100644 --- a/spec/utils/i18n_support_spec.rb +++ b/spec/utils/i18n_support_spec.rb @@ -12,7 +12,7 @@ context "when no locale was set" do let(:locale) { nil } - it "should load default locale" do + it "loads default locale" do expect(I18n.locale.to_s).to eq "en" expect(I18n.locale.to_s).not_to be_nil end @@ -21,7 +21,7 @@ context "when locale was set" do let(:locale) { "en" } - it "should load default locale" do + it "loads default locale" do expect(I18n.locale.to_s).to eq "en" expect(I18n.t("layout.title")).to eq "stringer | your rss buddy" end @@ -30,7 +30,7 @@ context "when a missing locale was set" do let(:locale) { "xx" } - it "should not find localization strings" do + it "does not find localization strings" do expect(I18n.t("layout.title", locale: ENV["LOCALE"].to_sym)) .not_to eq "stringer | your rss buddy" end diff --git a/spec/utils/opml_parser_spec.rb b/spec/utils/opml_parser_spec.rb index 0939a0267..afdf21fad 100644 --- a/spec/utils/opml_parser_spec.rb +++ b/spec/utils/opml_parser_spec.rb @@ -8,7 +8,7 @@ let(:parser) { OpmlParser.new } describe "#parse_feeds" do - it "it returns a hash of feed details from an OPML file" do + it "returns a hash of feed details from an OPML file" do result = parser.parse_feeds(<<-EOS) From ddbebcbe57491cd857d3849fa3f91b6ad273d4e3 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 31 Dec 2022 16:59:18 -0800 Subject: [PATCH 237/779] RuboCop: clean up StoriesController contexts (#768) --- .rubocop_todo.yml | 1 - spec/controllers/stories_controller_spec.rb | 52 +++++++++------------ 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8e5048161..f76e21a7b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -82,7 +82,6 @@ RSpec/ContextWording: - 'spec/commands/feeds/import_from_opml_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - 'spec/commands/stories/mark_group_as_read_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - 'spec/helpers/authentications_helper_spec.rb' - 'spec/integration/feed_importing_spec.rb' - 'spec/tasks/fetch_feed_spec.rb' diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index c4fdda94e..fb7e7af4b 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -96,50 +96,44 @@ describe "PUT /stories/:id" do before { allow(StoryRepository).to receive(:fetch).and_return(story_one) } - context "is_read parameter" do - it "marks a story as read when it is not malformed" do - expect(story_one).to receive(:save!).once + it "marks a story as read when it is_read not malformed" do + expect(story_one).to receive(:save!).once - put "/stories/#{story_one.id}", { is_read: true }.to_json + put "/stories/#{story_one.id}", { is_read: true }.to_json - expect(story_one.is_read).to be(true) - end + expect(story_one.is_read).to be(true) + end - it "marks a story as read when it is malformed" do - expect(story_one).to receive(:save!).once + it "marks a story as read when is_read is malformed" do + expect(story_one).to receive(:save!).once - put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json + put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json - expect(story_one.is_read).to be(true) - end + expect(story_one.is_read).to be(true) end - context "keep_unread parameter" do - it "marks a story as permanently unread when it is not malformed" do - put "/stories/#{story_one.id}", { keep_unread: false }.to_json + it "marks a story as keep unread when it keep_unread not malformed" do + put "/stories/#{story_one.id}", { keep_unread: false }.to_json - expect(story_one.keep_unread).to be(false) - end + expect(story_one.keep_unread).to be(false) + end - it "marks a story as permanently unread when it is malformed" do - put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json + it "marks a story as keep unread when keep_unread is malformed" do + put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json - expect(story_one.keep_unread).to be(true) - end + expect(story_one.keep_unread).to be(true) end - context "is_starred parameter" do - it "marks a story as permanently starred when it is not malformed" do - put "/stories/#{story_one.id}", { is_starred: true }.to_json + it "marks a story as starred when is_starred is not malformed" do + put "/stories/#{story_one.id}", { is_starred: true }.to_json - expect(story_one.is_starred).to be(true) - end + expect(story_one.is_starred).to be(true) + end - it "marks a story as permanently starred when it is malformed" do - put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json + it "marks a story as starred when is_starred is malformed" do + put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json - expect(story_one.is_starred).to be(true) - end + expect(story_one.is_starred).to be(true) end end From dd9dcf8928b0f673013c8185546c42c9f063eb9f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 1 Jan 2023 21:40:46 -0800 Subject: [PATCH 238/779] RuboCop: shorten examples for FirstRunController (#769) --- .rubocop_todo.yml | 1 - spec/controllers/first_run_controller_spec.rb | 19 +++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f76e21a7b..bdf9e8f6c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -144,7 +144,6 @@ RSpec/ExampleLength: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/feeds/export_to_opml_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/read_favicons_spec.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index b449ea83b..7b7a85a59 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -19,7 +19,6 @@ expect(page).to have_tag("form#password_setup") expect(page).to have_tag("input#password") expect(page).to have_tag("input#password-confirmation") - expect(page).to have_tag("input#submit") end end @@ -66,29 +65,25 @@ page = last_response.body expect(page).to have_tag("#mark-all-instruction") - expect(page).to have_tag("#refresh-instruction") - expect(page).to have_tag("#feeds-instruction") - expect(page).to have_tag("#add-feed-instruction") - expect(page).to have_tag("#story-instruction") - expect(page).to have_tag("#start") end end end context "when a user has been setup" do - it "redirects any requests to first run stuff" do + it "redirects tutorial path to /news" do user = create(:user, :setup_complete) session = { "rack.session" => { user_id: user.id } } - get "/", {}, session + get "/setup/tutorial", {}, session expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/news") + end - get "/setup/password", {}, session - expect(last_response.status).to be(302) - expect(URI.parse(last_response.location).path).to eq("/news") + it "redirects root path to /news" do + user = create(:user, :setup_complete) + session = { "rack.session" => { user_id: user.id } } - get "/setup/tutorial", {}, session + get "/", {}, session expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/news") end From 3a5838f6cf29fe19acbdad0c01baa72fc88c4491 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 1 Jan 2023 21:54:05 -0800 Subject: [PATCH 239/779] RuboCop: clean up specs for StoriesController (#770) The latter example wasn't actually testing anything, as the `have_tag` matcher ignores the `class:` option. It's effectively only looking for `li`. There description can't really be tested via controller tests, as the stories are rendered via backbone. --- .rubocop_todo.yml | 1 - spec/controllers/stories_controller_spec.rb | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bdf9e8f6c..1272e7d1b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -144,7 +144,6 @@ RSpec/ExampleLength: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/feeds/export_to_opml_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/read_favicons_spec.rb' - 'spec/fever_api/read_feeds_groups_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index fb7e7af4b..dad032850 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -46,10 +46,6 @@ page = last_response.body expect(page).to have_tag("a", with: { href: "/feeds/export" }) expect(page).to have_tag("a", with: { href: "/logout" }) - expect(page).to have_tag( - "a", - with: { href: "https://github.com/stringer-rss/stringer" } - ) end it "displays a zen-like message when there are no unread stories" do @@ -166,18 +162,5 @@ expect(last_response.body).to have_tag("#stories") end - - it "differentiates between read and unread" do - allow(FeedRepository).to receive(:fetch).and_return(story_one.feed) - allow(StoryRepository).to receive(:feed).and_return(stories) - - story_one.is_read = false - story_two.is_read = true - - get "/feed/#{story_one.feed.id}" - - expect(last_response.body).to have_tag("li", class: "story") - expect(last_response.body).to have_tag("li", class: "unread") - end end end From 2c77e1cda9141754670d912f71cb004e27c160d9 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 2 Jan 2023 13:29:22 -0800 Subject: [PATCH 240/779] RuboCop: adjust specs for DebugController (#771) --- .rubocop_todo.yml | 1 - spec/controllers/debug_controller_spec.rb | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1272e7d1b..671f95cec 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -220,7 +220,6 @@ RSpec/MessageExpectation: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/debug_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index f325f0936..3d2652a23 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -7,18 +7,20 @@ describe DebugController do describe "GET /debug" do - before do - allow(Delayed::Job).to receive(:count).and_return(42) + def setup + expect(Delayed::Job).to receive(:count).and_return(42) migration_status_instance = instance_double(MigrationStatus) - allow(migration_status_instance) + expect(migration_status_instance) .to receive(:pending_migrations) .and_return(["Migration B - 2", "Migration C - 3"]) - allow(MigrationStatus) + expect(MigrationStatus) .to receive(:new).and_return(migration_status_instance) end it "displays the current Ruby version" do + setup + get "/debug" page = last_response.body @@ -26,6 +28,8 @@ end it "displays the user agent" do + setup + get "/debug", {}, "HTTP_USER_AGENT" => "test" page = last_response.body @@ -33,6 +37,8 @@ end it "displays the delayed job count" do + setup + get "/debug" page = last_response.body @@ -40,6 +46,8 @@ end it "displays pending migrations" do + setup + get "/debug" page = last_response.body From 647a48ae98e334e9d7c7ccace4aacb603ce1839a Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 2 Jan 2023 14:16:12 -0800 Subject: [PATCH 241/779] RuboCop: refactor FirstRunController specs (#773) --- .rubocop_todo.yml | 1 - spec/controllers/first_run_controller_spec.rb | 24 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 671f95cec..3a2059f58 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -220,7 +220,6 @@ RSpec/MessageExpectation: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api_spec.rb' diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 7b7a85a59..25b5840e9 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -7,23 +7,27 @@ describe "FirstRunController" do context "when a user has not been setup" do - before do - allow(UserRepository).to receive(:setup_complete?).and_return(false) + def setup + expect(UserRepository) + .to receive(:setup_complete?).twice.and_return(false) end describe "GET /setup/password" do it "displays a form to enter your password" do + setup + get "/setup/password" page = last_response.body expect(page).to have_tag("form#password_setup") expect(page).to have_tag("input#password") - expect(page).to have_tag("input#password-confirmation") end end describe "POST /setup/password" do it "rejects empty passwords" do + setup + post "/setup/password" page = last_response.body @@ -31,6 +35,8 @@ end it "rejects when password isn't confirmed" do + setup + post "/setup/password", password: "foo", password_confirmation: "bar" page = last_response.body @@ -38,12 +44,12 @@ end it "accepts confirmed passwords and redirects to next step" do + setup user = instance_double(User, id: 1) expect(CreateUser).to receive(:call).with("foo").and_return(user) post "/setup/password", password: "foo", password_confirmation: "foo" - expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/feeds/import") end end @@ -52,16 +58,10 @@ let(:user) { instance_double(User) } let(:feeds) { [instance_double(Feed), instance_double(Feed)] } - before do - allow(UserRepository).to receive(:fetch).and_return(user) - allow(Feed).to receive(:all).and_return(feeds) - end - it "displays the tutorial and completes setup" do - expect(CompleteSetup).to receive(:complete).with(user).once - expect(FetchFeeds).to receive(:enqueue).with(feeds).once + user = create(:user) - get "/setup/tutorial" + get "/setup/tutorial", {}, { "rack.session" => { user_id: user.id } } page = last_response.body expect(page).to have_tag("#mark-all-instruction") From cc83dbe8ce0100f3e5696a0ea51d005ca8123696 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 2 Jan 2023 15:22:52 -0800 Subject: [PATCH 242/779] RuboCop: expect in SessionsController spec (#774) --- .rubocop_todo.yml | 1 - spec/controllers/sessions_controller_spec.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3a2059f58..e9b66019c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -220,7 +220,6 @@ RSpec/MessageExpectation: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api_spec.rb' - 'spec/helpers/authentications_helper_spec.rb' diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 589009797..b5e92e5a2 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -17,7 +17,7 @@ describe "POST /login" do it "denies access when password is incorrect" do - allow(SignInUser).to receive(:sign_in).and_return(nil) + expect(SignInUser).to receive(:sign_in).and_return(nil) post "/login", password: "not-the-password" From 5aa103b90f0deb7d3038075a3647071a5dcc4722 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Mon, 2 Jan 2023 15:35:58 -0800 Subject: [PATCH 243/779] RuboCop: clean up StoriesController spec (#775) --- .rubocop_todo.yml | 1 - spec/controllers/stories_controller_spec.rb | 41 ++++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e9b66019c..bbc72ca15 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -220,7 +220,6 @@ RSpec/MessageExpectation: Exclude: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/commands/find_new_stories_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api_spec.rb' - 'spec/helpers/authentications_helper_spec.rb' - 'spec/models/migration_status_spec.rb' diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index dad032850..595806394 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -11,19 +11,21 @@ let(:stories) { [story_one, story_two] } describe "GET /news" do - before do - allow(StoryRepository).to receive(:unread).and_return(stories) - allow(UserRepository).to receive(:fetch).and_return(double) + def setup + expect(StoryRepository).to receive(:unread).and_return(stories) + expect(UserRepository).to receive(:fetch).twice.and_return(double) end it "display list of unread stories" do + setup + get "/news" expect(last_response.body).to have_tag("#stories") end it "displays the blog title and article title" do - expect(StoryRepository).to receive(:unread).and_return([story_one]) + setup get "/news" @@ -32,15 +34,18 @@ end it "displays all user actions" do + setup + get "/news" expect(last_response.body).to have_tag("#mark-all") expect(last_response.body).to have_tag("#refresh") expect(last_response.body).to have_tag("#feeds") - expect(last_response.body).to have_tag("#add-feed") end it "has correct footer links" do + setup + get "/news" page = last_response.body @@ -49,7 +54,7 @@ end it "displays a zen-like message when there are no unread stories" do - allow(StoryRepository).to receive(:unread).and_return([]) + expect(StoryRepository).to receive(:unread).and_return([]) get "/news" @@ -62,9 +67,9 @@ let(:read_two) { build(:story, :read) } let(:stories) { [read_one, read_two].paginate } - before { allow(StoryRepository).to receive(:read).and_return(stories) } - it "displays the list of read stories with pagination" do + expect(StoryRepository).to receive(:read).and_return(stories) + get "/archive" page = last_response.body @@ -78,9 +83,9 @@ let(:starred_two) { build(:story, :starred) } let(:stories) { [starred_one, starred_two].paginate } - before { allow(StoryRepository).to receive(:starred).and_return(stories) } - it "displays the list of starred stories with pagination" do + expect(StoryRepository).to receive(:starred).and_return(stories) + get "/starred" page = last_response.body @@ -90,9 +95,8 @@ end describe "PUT /stories/:id" do - before { allow(StoryRepository).to receive(:fetch).and_return(story_one) } - it "marks a story as read when it is_read not malformed" do + expect(StoryRepository).to receive(:fetch).and_return(story_one) expect(story_one).to receive(:save!).once put "/stories/#{story_one.id}", { is_read: true }.to_json @@ -101,6 +105,7 @@ end it "marks a story as read when is_read is malformed" do + expect(StoryRepository).to receive(:fetch).and_return(story_one) expect(story_one).to receive(:save!).once put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json @@ -109,24 +114,32 @@ end it "marks a story as keep unread when it keep_unread not malformed" do + expect(StoryRepository).to receive(:fetch).and_return(story_one) + put "/stories/#{story_one.id}", { keep_unread: false }.to_json expect(story_one.keep_unread).to be(false) end it "marks a story as keep unread when keep_unread is malformed" do + expect(StoryRepository).to receive(:fetch).and_return(story_one) + put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json expect(story_one.keep_unread).to be(true) end it "marks a story as starred when is_starred is not malformed" do + expect(StoryRepository).to receive(:fetch).and_return(story_one) + put "/stories/#{story_one.id}", { is_starred: true }.to_json expect(story_one.is_starred).to be(true) end it "marks a story as starred when is_starred is malformed" do + expect(StoryRepository).to receive(:fetch).and_return(story_one) + put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json expect(story_one.is_starred).to be(true) @@ -155,8 +168,8 @@ end it "displays a list of stories" do - allow(FeedRepository).to receive(:fetch).and_return(story_one.feed) - allow(StoryRepository).to receive(:feed).and_return(stories) + expect(FeedRepository).to receive(:fetch).and_return(story_one.feed) + expect(StoryRepository).to receive(:feed).and_return(stories) get "/feed/#{story_one.feed.id}" From 0892124fce23ee9f4e4f7ba294b92a7310b9ac06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 08:04:09 -0800 Subject: [PATCH 244/779] Bump httparty from 0.20.0 to 0.21.0 (#776) Bumps [httparty](https://github.com/jnunemaker/httparty) from 0.20.0 to 0.21.0. - [Release notes](https://github.com/jnunemaker/httparty/releases) - [Changelog](https://github.com/jnunemaker/httparty/blob/master/Changelog.md) - [Commits](https://github.com/jnunemaker/httparty/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: httparty dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5b64567b3..ab25f3644 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -114,8 +114,8 @@ GEM ffi (1.15.5) globalid (1.0.0) activesupport (>= 5.0) - httparty (0.20.0) - mime-types (~> 3.0) + httparty (0.21.0) + mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) i18n (1.12.0) concurrent-ruby (~> 1.0) @@ -131,9 +131,6 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) mini_mime (1.1.2) mini_portile2 (2.8.1) minitest (5.16.3) From 209fb677805a04231152fec274839944c1bf2b3f Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:08:43 -0800 Subject: [PATCH 245/779] RuboCop: refactor in DebugController spec (#777) --- .rubocop.yml | 1 + .rubocop_todo.yml | 1 - spec/controllers/debug_controller_spec.rb | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fe813b383..de898a51e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,6 +18,7 @@ RSpec/MessageExpectation: { EnforcedStyle: expect } RSpec/MessageSpies: { EnforcedStyle: receive } Style/MethodCallWithArgsParentheses: AllowedMethods: + - and - to - not_to - describe diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bbc72ca15..4674c8902 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -249,7 +249,6 @@ RSpec/MultipleExpectations: - 'spec/commands/users/change_user_password_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/debug_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/imports_controller_spec.rb' diff --git a/spec/controllers/debug_controller_spec.rb b/spec/controllers/debug_controller_spec.rb index 3d2652a23..f2fafc359 100644 --- a/spec/controllers/debug_controller_spec.rb +++ b/spec/controllers/debug_controller_spec.rb @@ -50,9 +50,9 @@ def setup get "/debug" - page = last_response.body - expect(page).to have_tag("li", text: /Migration B - 2/) - expect(page).to have_tag("li", text: /Migration C - 3/) + rendered = Capybara.string(last_response.body) + expect(rendered).to have_selector("li", text: /Migration B - 2/) + .and have_selector("li", text: /Migration C - 3/) end end From 7515fb2eeea1fa8cbeb567fca68b3fa362a2bda9 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:12:59 -0800 Subject: [PATCH 246/779] Specs: set up Webmock (#778) Prevent network connections. It's really easily to accidentally invoke the `FeedDiscovery` class, which hits the network, so this will make sure we don't forget. --- Gemfile | 1 + Gemfile.lock | 8 ++++++++ spec/spec_helper.rb | 1 + spec/support/webmock.rb | 8 ++++++++ 4 files changed, 18 insertions(+) create mode 100644 spec/support/webmock.rb diff --git a/Gemfile b/Gemfile index 2f91f7809..246d875eb 100644 --- a/Gemfile +++ b/Gemfile @@ -46,4 +46,5 @@ group :development, :test do gem "shotgun" gem "simplecov" gem "timecop" + gem "webmock", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index ab25f3644..4f0243833 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,8 @@ GEM term-ansicolor (~> 1.7) thor (~> 1.2) tins (~> 1.32) + crack (0.4.5) + rexml crass (1.0.6) date (3.3.3) delayed_job (4.1.11) @@ -114,6 +116,7 @@ GEM ffi (1.15.5) globalid (1.0.0) activesupport (>= 5.0) + hashdiff (1.0.1) httparty (0.21.0) mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) @@ -301,6 +304,10 @@ GEM uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.3.0) + webmock (3.18.1) + 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) @@ -348,6 +355,7 @@ DEPENDENCIES thread timecop uglifier + webmock will_paginate RUBY VERSION diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9688013bb..66d5bbe7f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,6 +15,7 @@ require_relative "support/coverage" require_relative "support/factory_bot" +require_relative "support/webmock" require_relative "factories" require "./app" diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb new file mode 100644 index 000000000..4e0581096 --- /dev/null +++ b/spec/support/webmock.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require "webmock/rspec" + +WebMock.disable_net_connect!( + allow_localhost: true, + allow: [/geckodriver/, /chromedriver/] +) From 5ff04603a4df81c0dd78e8ae770a9b552edf35f6 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:19:43 -0800 Subject: [PATCH 247/779] RuboCop: use shorter hash syntax (#779) --- .rubocop_todo.yml | 38 --------------------- app.rb | 4 +-- app/commands/users/create_user.rb | 2 +- app/fever_api/read_favicons.rb | 2 +- app/fever_api/read_feeds.rb | 2 +- app/fever_api/read_feeds_groups.rb | 4 +-- app/fever_api/read_groups.rb | 2 +- app/fever_api/read_links.rb | 2 +- app/fever_api/sync_saved_item_ids.rb | 2 +- app/fever_api/sync_unread_item_ids.rb | 2 +- app/models/feed.rb | 4 +-- app/models/group.rb | 2 +- app/models/story.rb | 6 ++-- app/repositories/story_repository.rb | 10 +++--- app/utils/sample_story.rb | 20 +++++------ spec/fever_api/read_feeds_groups_spec.rb | 4 +-- spec/fever_api/read_feeds_spec.rb | 4 +-- spec/fever_api/read_groups_spec.rb | 2 +- spec/fever_api/read_items_spec.rb | 2 +- spec/fever_api/sync_saved_item_ids_spec.rb | 6 ++-- spec/fever_api/sync_unread_item_ids_spec.rb | 6 ++-- spec/fever_api/write_mark_feed_spec.rb | 2 +- spec/fever_api/write_mark_group_spec.rb | 2 +- spec/fever_api_spec.rb | 6 ++-- spec/integration/feed_importing_spec.rb | 2 +- spec/javascript/test_controller.rb | 4 +-- spec/models/feed_spec.rb | 2 +- spec/models/story_spec.rb | 8 ++--- spec/repositories/story_repository_spec.rb | 26 +++++++------- spec/tasks/change_password_spec.rb | 4 +-- spec/tasks/fetch_feed_spec.rb | 32 ++++------------- 31 files changed, 76 insertions(+), 138 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4674c8902..ab63311fc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -511,44 +511,6 @@ Style/FetchEnvVar: Exclude: - 'Rakefile' -# Offense count: 86 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Exclude: - - 'app.rb' - - 'app/commands/users/create_user.rb' - - 'app/fever_api/read_favicons.rb' - - 'app/fever_api/read_feeds.rb' - - 'app/fever_api/read_feeds_groups.rb' - - 'app/fever_api/read_groups.rb' - - 'app/fever_api/read_links.rb' - - 'app/fever_api/sync_saved_item_ids.rb' - - 'app/fever_api/sync_unread_item_ids.rb' - - 'app/models/feed.rb' - - 'app/models/group.rb' - - 'app/models/story.rb' - - 'app/repositories/story_repository.rb' - - 'app/utils/sample_story.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api_spec.rb' - - 'spec/integration/feed_importing_spec.rb' - - 'spec/javascript/test_controller.rb' - - 'spec/models/feed_spec.rb' - - 'spec/models/story_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/tasks/change_password_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - # Offense count: 184 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. diff --git a/app.rb b/app.rb index 87db2d0c4..24225afb0 100644 --- a/app.rb +++ b/app.rb @@ -69,7 +69,7 @@ class Stringer < Sinatra::Base include Sinatra::AuthenticationHelpers def render_partial(name, locals = {}) - erb "partials/_#{name}".to_sym, layout: false, locals: locals + erb "partials/_#{name}".to_sym, layout: false, locals: end def render_js_template(name) @@ -77,7 +77,7 @@ def render_js_template(name) end def render_js(name, locals = {}) - erb "js/#{name}.js".to_sym, layout: false, locals: locals + erb "js/#{name}.js".to_sym, layout: false, locals: end def t(*args, **kwargs) diff --git a/app/commands/users/create_user.rb b/app/commands/users/create_user.rb index 955d615de..cb1765ff7 100644 --- a/app/commands/users/create_user.rb +++ b/app/commands/users/create_user.rb @@ -14,7 +14,7 @@ def self.call(password) def call(password) @repo.delete_all @repo.create( - password: password, + password:, password_confirmation: password, setup_complete: false, api_key: ApiKey.compute(password) diff --git a/app/fever_api/read_favicons.rb b/app/fever_api/read_favicons.rb index 6b5a8dc58..1f5de9166 100644 --- a/app/fever_api/read_favicons.rb +++ b/app/fever_api/read_favicons.rb @@ -6,7 +6,7 @@ class ReadFavicons def call(params = {}) if params.keys.include?("favicons") - { favicons: favicons } + { favicons: } else {} end diff --git a/app/fever_api/read_feeds.rb b/app/fever_api/read_feeds.rb index cabba321f..aab68c452 100644 --- a/app/fever_api/read_feeds.rb +++ b/app/fever_api/read_feeds.rb @@ -10,7 +10,7 @@ def initialize(options = {}) def call(params = {}) if params.keys.include?("feeds") - { feeds: feeds } + { feeds: } else {} end diff --git a/app/fever_api/read_feeds_groups.rb b/app/fever_api/read_feeds_groups.rb index d6597a293..d13a8fbd8 100644 --- a/app/fever_api/read_feeds_groups.rb +++ b/app/fever_api/read_feeds_groups.rb @@ -10,7 +10,7 @@ def initialize(options = {}) def call(params = {}) if params.keys.include?("feeds") || params.keys.include?("groups") - { feeds_groups: feeds_groups } + { feeds_groups: } else {} end @@ -23,7 +23,7 @@ def feeds_groups @feed_repository.in_group.order("LOWER(name)").group_by(&:group_id) grouped_feeds.map do |group_id, feeds| { - group_id: group_id, + group_id:, feed_ids: feeds.map(&:id).join(",") } end diff --git a/app/fever_api/read_groups.rb b/app/fever_api/read_groups.rb index 2540195f1..b5d7d343e 100644 --- a/app/fever_api/read_groups.rb +++ b/app/fever_api/read_groups.rb @@ -10,7 +10,7 @@ def initialize(options = {}) def call(params = {}) if params.keys.include?("groups") - { groups: groups } + { groups: } else {} end diff --git a/app/fever_api/read_links.rb b/app/fever_api/read_links.rb index 1377b5b15..8ba078604 100644 --- a/app/fever_api/read_links.rb +++ b/app/fever_api/read_links.rb @@ -4,7 +4,7 @@ module FeverAPI class ReadLinks def call(params = {}) if params.keys.include?("links") - { links: links } + { links: } else {} end diff --git a/app/fever_api/sync_saved_item_ids.rb b/app/fever_api/sync_saved_item_ids.rb index e169a1c5e..610f80ce0 100644 --- a/app/fever_api/sync_saved_item_ids.rb +++ b/app/fever_api/sync_saved_item_ids.rb @@ -10,7 +10,7 @@ def initialize(options = {}) def call(params = {}) if params.keys.include?("saved_item_ids") - { saved_item_ids: saved_item_ids } + { saved_item_ids: } else {} end diff --git a/app/fever_api/sync_unread_item_ids.rb b/app/fever_api/sync_unread_item_ids.rb index 84a043a83..1e06f10cb 100644 --- a/app/fever_api/sync_unread_item_ids.rb +++ b/app/fever_api/sync_unread_item_ids.rb @@ -10,7 +10,7 @@ def initialize(options = {}) def call(params = {}) if params.keys.include?("unread_item_ids") - { unread_item_ids: unread_item_ids } + { unread_item_ids: } else {} end diff --git a/app/models/feed.rb b/app/models/feed.rb index 3e4716405..266bd32e2 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -22,10 +22,10 @@ def unread_stories def as_fever_json { - id: id, + id:, favicon_id: 0, title: name, - url: url, + url:, site_url: url, is_spark: 0, last_updated_on_time: last_fetched.to_i diff --git a/app/models/group.rb b/app/models/group.rb index 3dbcf1b96..0976ce6b6 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -6,6 +6,6 @@ class Group < ApplicationRecord has_many :feeds def as_fever_json - { id: id, title: name } + { id:, title: name } end end diff --git a/app/models/story.rb b/app/models/story.rb index ea3055e79..18784be7f 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -32,9 +32,9 @@ def as_json(_options = {}) def as_fever_json { - id: id, - feed_id: feed_id, - title: title, + id:, + feed_id:, + title:, author: source, html: body, url: permalink, diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index a2c1032c0..1380b7045 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -11,10 +11,10 @@ class StoryRepository def self.add(entry, feed) enclosure_url = entry.enclosure_url if entry.respond_to?(:enclosure_url) Story.create( - feed: feed, + feed:, title: extract_title(entry), permalink: extract_url(entry, feed), - enclosure_url: enclosure_url, + enclosure_url:, body: extract_content(entry), is_read: false, is_starred: false, @@ -38,18 +38,18 @@ def self.fetch_unread_by_timestamp(timestamp) def self.fetch_unread_by_timestamp_and_group(timestamp, group_id) fetch_unread_by_timestamp(timestamp) - .joins(:feed).where(feeds: { group_id: group_id }) + .joins(:feed).where(feeds: { group_id: }) end def self.fetch_unread_for_feed_by_timestamp(feed_id, timestamp) timestamp = Time.at(timestamp.to_i) Story - .where(feed_id: feed_id) + .where(feed_id:) .where("created_at < ? AND is_read = ?", timestamp, false) end def self.exists?(id, feed_id) - Story.exists?(entry_id: id, feed_id: feed_id) + Story.exists?(entry_id: id, feed_id:) end def self.unread diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 6b67f6fbe..1bde2143d 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -61,17 +61,17 @@ def published def as_json(_options = {}) { - id: id, - headline: headline, - lead: lead, - source: source, - title: title, + id:, + headline:, + lead:, + source:, + title:, pretty_date: published.strftime("%A, %B %d"), - body: body, - permalink: permalink, - is_read: is_read, - is_starred: is_starred, - keep_unread: keep_unread + body:, + permalink:, + is_read:, + is_starred:, + keep_unread: } end end diff --git a/spec/fever_api/read_feeds_groups_spec.rb b/spec/fever_api/read_feeds_groups_spec.rb index 4df971b5f..e4004fd20 100644 --- a/spec/fever_api/read_feeds_groups_spec.rb +++ b/spec/fever_api/read_feeds_groups_spec.rb @@ -6,10 +6,10 @@ describe FeverAPI::ReadFeedsGroups do let(:feed_ids) { [5, 7, 11] } - let(:feeds) { feed_ids.map { |id| double("feed", id: id, group_id: 1) } } + let(:feeds) { feed_ids.map { |id| double("feed", id:, group_id: 1) } } let(:feed_repository) { double("repo") } - subject { FeverAPI::ReadFeedsGroups.new(feed_repository: feed_repository) } + subject { FeverAPI::ReadFeedsGroups.new(feed_repository:) } it "returns a list of groups requested through feeds" do allow(feed_repository) diff --git a/spec/fever_api/read_feeds_spec.rb b/spec/fever_api/read_feeds_spec.rb index 40732e031..f429153d4 100644 --- a/spec/fever_api/read_feeds_spec.rb +++ b/spec/fever_api/read_feeds_spec.rb @@ -7,11 +7,11 @@ describe FeverAPI::ReadFeeds do let(:feed_ids) { [5, 7, 11] } let(:feeds) do - feed_ids.map { |id| double("feed", id: id, as_fever_json: { id: id }) } + feed_ids.map { |id| double("feed", id:, as_fever_json: { id: }) } end let(:feed_repository) { double("repo") } - subject { FeverAPI::ReadFeeds.new(feed_repository: feed_repository) } + subject { FeverAPI::ReadFeeds.new(feed_repository:) } it "returns a list of feeds" do expect(feed_repository).to receive(:list).and_return(feeds) diff --git a/spec/fever_api/read_groups_spec.rb b/spec/fever_api/read_groups_spec.rb index 2b7b5951d..d36002995 100644 --- a/spec/fever_api/read_groups_spec.rb +++ b/spec/fever_api/read_groups_spec.rb @@ -11,7 +11,7 @@ end let(:group_repository) { double("repo") } - subject { FeverAPI::ReadGroups.new(group_repository: group_repository) } + subject { FeverAPI::ReadGroups.new(group_repository:) } it "returns a group list if requested" do expect(group_repository).to receive(:list).and_return([group1, group2]) diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index a44a316f0..caa375f44 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -7,7 +7,7 @@ describe FeverAPI::ReadItems do let(:story_repository) { double("repo") } - subject { FeverAPI::ReadItems.new(story_repository: story_repository) } + subject { FeverAPI::ReadItems.new(story_repository:) } it "returns a list of unread items including total count" do stories = [ diff --git a/spec/fever_api/sync_saved_item_ids_spec.rb b/spec/fever_api/sync_saved_item_ids_spec.rb index 6b8afc0f9..6acfe5e0a 100644 --- a/spec/fever_api/sync_saved_item_ids_spec.rb +++ b/spec/fever_api/sync_saved_item_ids_spec.rb @@ -6,12 +6,10 @@ describe FeverAPI::SyncSavedItemIds do let(:story_ids) { [5, 7, 11] } - let(:stories) { story_ids.map { |id| double("story", id: id) } } + let(:stories) { story_ids.map { |id| double("story", id:) } } let(:story_repository) { double("repo") } - subject do - FeverAPI::SyncSavedItemIds.new(story_repository: story_repository) - end + subject { FeverAPI::SyncSavedItemIds.new(story_repository:) } it "returns a list of starred items if requested" do expect(story_repository).to receive(:all_starred).and_return(stories) diff --git a/spec/fever_api/sync_unread_item_ids_spec.rb b/spec/fever_api/sync_unread_item_ids_spec.rb index 8bb197dbc..f84c22ac4 100644 --- a/spec/fever_api/sync_unread_item_ids_spec.rb +++ b/spec/fever_api/sync_unread_item_ids_spec.rb @@ -6,12 +6,10 @@ describe FeverAPI::SyncUnreadItemIds do let(:story_ids) { [5, 7, 11] } - let(:stories) { story_ids.map { |id| double("story", id: id) } } + let(:stories) { story_ids.map { |id| double("story", id:) } } let(:story_repository) { double("repo") } - subject do - FeverAPI::SyncUnreadItemIds.new(story_repository: story_repository) - end + subject { FeverAPI::SyncUnreadItemIds.new(story_repository:) } it "returns a list of unread items if requested" do expect(story_repository).to receive(:unread).and_return(stories) diff --git a/spec/fever_api/write_mark_feed_spec.rb b/spec/fever_api/write_mark_feed_spec.rb index 2a6c252e4..2ff1e4546 100644 --- a/spec/fever_api/write_mark_feed_spec.rb +++ b/spec/fever_api/write_mark_feed_spec.rb @@ -8,7 +8,7 @@ let(:feed_marker) { double("feed marker") } let(:marker_class) { double("marker class") } - subject { FeverAPI::WriteMarkFeed.new(marker_class: marker_class) } + subject { FeverAPI::WriteMarkFeed.new(marker_class:) } it "instantiates a feed marker and calls mark_feed_as_read if requested" do expect(marker_class) diff --git a/spec/fever_api/write_mark_group_spec.rb b/spec/fever_api/write_mark_group_spec.rb index b86b42f98..0713f19c4 100644 --- a/spec/fever_api/write_mark_group_spec.rb +++ b/spec/fever_api/write_mark_group_spec.rb @@ -8,7 +8,7 @@ let(:group_marker) { double("group marker") } let(:marker_class) { double("marker class") } - subject { FeverAPI::WriteMarkGroup.new(marker_class: marker_class) } + subject { FeverAPI::WriteMarkGroup.new(marker_class:) } it "instantiates a group marker and calls mark_group_as_read if requested" do expect(marker_class) diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index aa99b0df5..88df51341 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -14,16 +14,16 @@ def app let(:story_one) { build(:story) } let(:story_two) { build(:story) } let(:group) { build(:group) } - let(:feed) { build(:feed, group: group) } + let(:feed) { build(:feed, group:) } let(:stories) { [story_one, story_two] } let(:standard_answer) do { api_version: 3, auth: 1, last_refreshed_on_time: 123456789 } end let(:cannot_auth) { { api_version: 3, auth: 0 } } - let(:headers) { { api_key: api_key } } + let(:headers) { { api_key: } } before do - user = double(api_key: api_key) + user = double(api_key:) allow(User).to receive(:first) { user } allow(Time).to receive(:now) { Time.at(123456789) } diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index 1831528db..d3b09acea 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -88,5 +88,5 @@ def fetch_feed(feed) logger = Logger.new($stdout) logger.level = Logger::DEBUG - FetchFeed.new(feed, logger: logger).fetch + FetchFeed.new(feed, logger:).fetch end diff --git a/spec/javascript/test_controller.rb b/spec/javascript/test_controller.rb index 3b1a7358d..014976308 100644 --- a/spec/javascript/test_controller.rb +++ b/spec/javascript/test_controller.rb @@ -9,8 +9,8 @@ def self.test_path(*chunks) erb File.read(self.class.test_path("support", "views", "index.erb")), layout: false, locals: { - js_files: js_files, - js_templates: js_templates + js_files:, + js_templates: } end diff --git a/spec/models/feed_spec.rb b/spec/models/feed_spec.rb index 7acdc0501..e116c6e38 100644 --- a/spec/models/feed_spec.rb +++ b/spec/models/feed_spec.rb @@ -62,7 +62,7 @@ id: 52, name: "chicken feed", url: "wat url", - last_fetched: last_fetched + last_fetched: ) expect(feed.as_fever_json).to eq( diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index e015054c9..262f0ba34 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -74,16 +74,16 @@ story = create( :story, body: "story body", - created_at: created_at, + created_at:, entry_id: 5, - feed: feed, + feed:, is_read: true, is_starred: false, keep_unread: true, permalink: "www.exampoo.com/perma", published: published_at, title: "the story title", - updated_at: updated_at + updated_at: ) expect(story.as_json).to eq( @@ -116,7 +116,7 @@ published_at = 1.day.ago story = create( :story, - feed: feed, + feed:, title: "the story title", body: "story body", permalink: "www.exampoo.com/perma", diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index 6b4abc5ad..b3c806901 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -121,7 +121,7 @@ describe ".fetch_unread_by_timestamp_and_group" do it "returns unread stories before timestamp for group_id" do feed = create(:feed, group_id: 52) - story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -131,7 +131,7 @@ it "does not return read stories before timestamp for group_id" do feed = create(:feed, group_id: 52) - create(:story, feed: feed, created_at: 5.minutes.ago) + create(:story, feed:, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -141,7 +141,7 @@ it "does not return unread stories after timestamp for group_id" do feed = create(:feed, group_id: 52) - create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed:, created_at: 5.minutes.ago) time = 6.minutes.ago stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -151,7 +151,7 @@ it "does not return stories before timestamp for other group_id" do feed = create(:feed, group_id: 52) - create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 55) @@ -161,7 +161,7 @@ it "does not return stories with no group_id before timestamp" do feed = create(:feed) - create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) @@ -171,7 +171,7 @@ it "returns unread stories before timestamp for nil group_id" do feed = create(:feed) - story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, nil) @@ -183,7 +183,7 @@ describe ".fetch_unread_for_feed_by_timestamp" do it "returns unread stories for the feed before timestamp" do feed = create(:feed) - story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed:, created_at: 5.minutes.ago) time = 4.minutes.ago stories = @@ -194,7 +194,7 @@ it "returns unread stories for the feed before string timestamp" do feed = create(:feed) - story = create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + story = create(:story, :unread, feed:, created_at: 5.minutes.ago) timestamp = Integer(4.minutes.ago).to_s stories = @@ -205,7 +205,7 @@ it "does not return read stories for the feed before timestamp" do feed = create(:feed) - create(:story, feed: feed, created_at: 5.minutes.ago) + create(:story, feed:, created_at: 5.minutes.ago) time = 4.minutes.ago stories = @@ -216,7 +216,7 @@ it "does not return unread stories for the feed after timestamp" do feed = create(:feed) - create(:story, :unread, feed: feed, created_at: 5.minutes.ago) + create(:story, :unread, feed:, created_at: 5.minutes.ago) time = 6.minutes.ago stories = @@ -279,15 +279,15 @@ describe ".feed" do it "returns stories for the given feed id" do feed = create(:feed) - story = create(:story, feed: feed) + story = create(:story, feed:) expect(StoryRepository.feed(feed.id)).to eq([story]) end it "sorts stories by published" do feed = create(:feed) - story1 = create(:story, feed: feed, published: 1.day.ago) - story2 = create(:story, feed: feed, published: 1.hour.ago) + story1 = create(:story, feed:, published: 1.day.ago) + story2 = create(:story, feed:, published: 1.hour.ago) expect(StoryRepository.feed(feed.id)).to eq([story2, story1]) end diff --git a/spec/tasks/change_password_spec.rb b/spec/tasks/change_password_spec.rb index 648a64858..ef6a5e08b 100644 --- a/spec/tasks/change_password_spec.rb +++ b/spec/tasks/change_password_spec.rb @@ -11,7 +11,7 @@ it "invokes command with confirmed password" do output = StringIO.new input = StringIO.new("new-pw\nnew-pw\n") - task = ChangePassword.new(command, output: output, input: input) + task = ChangePassword.new(command, output:, input:) expect(command).to receive(:change_user_password).with("new-pw") @@ -21,7 +21,7 @@ it "repeats until a matching confirmation" do output = StringIO.new input = StringIO.new("woops\nnope\nnew-pw\nnew-pw\n") - task = ChangePassword.new(command, output: output, input: input) + task = ChangePassword.new(command, output:, input:) expect(command).to receive(:change_user_password).with("new-pw") diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 457d80e0b..532a69166 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -27,12 +27,7 @@ expect(StoryRepository).not_to receive(:add) - FetchFeed.new( - daring_fireball, - parser: parser, - client: client, - logger: nil - ).fetch + FetchFeed.new(daring_fireball, parser:, client:, logger: nil).fetch end it "logs a message" do @@ -41,12 +36,7 @@ output = StringIO.new logger = Logger.new(output) - FetchFeed.new( - daring_fireball, - parser: parser, - client: client, - logger: - ).fetch + FetchFeed.new(daring_fireball, parser:, client:, logger:).fetch expect(output.string).to include("has not been modified") end @@ -63,7 +53,7 @@ expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser: parser, client: client).fetch + FetchFeed.new(daring_fireball, parser:, client:).fetch end end @@ -119,7 +109,7 @@ expect(FeedRepository).to receive(:set_status) .with(:green, daring_fireball) - FetchFeed.new(daring_fireball, parser: parser, client: client).fetch + FetchFeed.new(daring_fireball, parser:, client:).fetch end it "sets the status to red if things go wrong" do @@ -129,12 +119,7 @@ expect(FeedRepository).to receive(:set_status) .with(:red, daring_fireball) - FetchFeed.new( - daring_fireball, - parser: parser, - client: client, - logger: nil - ).fetch + FetchFeed.new(daring_fireball, parser:, client:, logger: nil).fetch end it "outputs a message when things go wrong" do @@ -143,12 +128,7 @@ output = StringIO.new logger = Logger.new(output) - FetchFeed.new( - daring_fireball, - parser: parser, - client: client, - logger: logger - ).fetch + FetchFeed.new(daring_fireball, parser:, client:, logger:).fetch expect(output.string).to include("Something went wrong") end From 145f37aa0110920c0e8d6fff12e4daced0ed201e Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:28:00 -0800 Subject: [PATCH 248/779] RuboCop: reduce expectations in feeds controller spec (#780) --- .rubocop_todo.yml | 1 - spec/controllers/feeds_controller_spec.rb | 51 ++++++++++------------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ab63311fc..b1530a98c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -249,7 +249,6 @@ RSpec/MultipleExpectations: - 'spec/commands/users/change_user_password_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 6ac77e2ae..b4e7ac780 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -5,22 +5,17 @@ app_require "controllers/feeds_controller" describe "FeedsController" do - let(:feeds) { build_pair(:feed) } - describe "GET /feeds" do it "renders a list of feeds" do - expect(FeedRepository).to receive(:list).and_return(feeds) + create_pair(:feed) get "/feeds" - page = last_response.body - expect(page).to have_tag("ul#feed-list") - expect(page).to have_tag("li.feed", count: 2) + rendered = Capybara.string(last_response.body) + expect(rendered).to have_selector("li.feed", count: 2) end it "displays message to add feeds if there are none" do - expect(FeedRepository).to receive(:list).and_return([]) - get "/feeds" page = last_response.body @@ -29,14 +24,13 @@ end describe "GET /feeds/:feed_id/edit" do - it "fetches a feed given the id" do - feed = Feed.new(name: "Rainbows and unicorns", url: "example.com/feed") - expect(FeedRepository).to receive(:fetch).with("123").and_return(feed) + it "displays the feed edit form" do + feed = create(:feed, name: "Rainbows/unicorns", url: "example.com/feed") - get "/feeds/123/edit" + get "/feeds/#{feed.id}/edit" - expect(last_response.body).to include("Rainbows and unicorns") - expect(last_response.body).to include("example.com/feed") + rendered = Capybara.string(last_response.body) + expect(rendered).to have_field("feed_name", with: "Rainbows/unicorns") end end @@ -90,37 +84,37 @@ def params(feed, **overrides) end describe "GET /feeds/new" do - it "displays a form and submit button" do + it "displays a new feed form" do get "/feeds/new" page = last_response.body expect(page).to have_tag("form#add-feed-setup") - expect(page).to have_tag("input#submit") end end describe "POST /feeds" do context "when the feed url is valid" do let(:feed_url) { "http://example.com/" } - let(:feed) { instance_double(Feed, valid?: true) } it "adds the feed and queues it to be fetched" do - expect(AddNewFeed).to receive(:add).with(feed_url).and_return(feed) - expect(FetchFeeds).to receive(:enqueue).with([feed]) + stub_request(:get, feed_url).to_return(status: 200, body: "") - post("/feeds", feed_url:) + expect { post("/feeds", feed_url:) }.to change(Feed, :count).by(1) + end - expect(last_response.status).to be(302) - expect(URI.parse(last_response.location).path).to eq("/") + it "queues the feed to be fetched" do + stub_request(:get, feed_url).to_return(status: 200, body: "") + expect(FetchFeeds).to receive(:enqueue).with([instance_of(Feed)]) + + post("/feeds", feed_url:) end end context "when the feed url is invalid" do let(:feed_url) { "http://not-a-valid-feed.com/" } - it "adds the feed and queues it to be fetched" do - expect(AddNewFeed).to receive(:add).with(feed_url).and_return(false) - + it "does not add the feed" do + stub_request(:get, feed_url).to_return(status: 404) post("/feeds", feed_url:) page = last_response.body @@ -130,11 +124,10 @@ def params(feed, **overrides) context "when the feed url is one we already subscribe to" do let(:feed_url) { "http://example.com/" } - let(:invalid_feed) { instance_double(Feed, valid?: false) } - it "adds the feed and queues it to be fetched" do - expect(AddNewFeed) - .to receive(:add).with(feed_url).and_return(invalid_feed) + it "does not add the feed" do + create(:feed, url: feed_url) + stub_request(:get, feed_url).to_return(status: 200, body: "") post("/feeds", feed_url:) From 4ef7b1923b2a795c80f5f4d2e0a6ceb1c41a8bca Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:35:18 -0800 Subject: [PATCH 249/779] RuboCop: reduce expects in FirstRunController specs (#781) --- .rubocop_todo.yml | 1 - spec/controllers/first_run_controller_spec.rb | 7 ------- 2 files changed, 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b1530a98c..624b73fcb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -249,7 +249,6 @@ RSpec/MultipleExpectations: - 'spec/commands/users/change_user_password_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index 25b5840e9..bf9e4465a 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -20,7 +20,6 @@ def setup page = last_response.body expect(page).to have_tag("form#password_setup") - expect(page).to have_tag("input#password") end end @@ -44,10 +43,6 @@ def setup end it "accepts confirmed passwords and redirects to next step" do - setup - user = instance_double(User, id: 1) - expect(CreateUser).to receive(:call).with("foo").and_return(user) - post "/setup/password", password: "foo", password_confirmation: "foo" expect(URI.parse(last_response.location).path).to eq("/feeds/import") @@ -75,7 +70,6 @@ def setup session = { "rack.session" => { user_id: user.id } } get "/setup/tutorial", {}, session - expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/news") end @@ -84,7 +78,6 @@ def setup session = { "rack.session" => { user_id: user.id } } get "/", {}, session - expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/news") end end From 440d689d58a4d012046518f4690f1c72fda56879 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:40:13 -0800 Subject: [PATCH 250/779] RuboCop: reduce expects in ImportsController specs (#782) --- .rubocop_todo.yml | 1 - spec/controllers/imports_controller_spec.rb | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 624b73fcb..e218ae5b9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -249,7 +249,6 @@ RSpec/MultipleExpectations: - 'spec/commands/users/change_user_password_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/authentication_spec.rb' diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb index d2ea96841..9ae906fa7 100644 --- a/spec/controllers/imports_controller_spec.rb +++ b/spec/controllers/imports_controller_spec.rb @@ -11,7 +11,6 @@ page = last_response.body expect(page).to have_tag("input#opml_file") - expect(page).to have_tag("a#skip") end end @@ -23,13 +22,10 @@ ) end - it "parse OPML and starts fetching" do + it "parses OPML and starts fetching" do expect(ImportFromOpml).to receive(:import).once post "/feeds/import", "opml_file" => opml_file - - expect(last_response.status).to be(302) - expect(URI.parse(last_response.location).path).to eq("/setup/tutorial") end end end From 4236f2bacda8810558ffdba458266ff7c1979b20 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:44:28 -0800 Subject: [PATCH 251/779] RuboCop: reduce expects in SessionsController specs (#783) --- .rubocop_todo.yml | 1 - spec/controllers/sessions_controller_spec.rb | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e218ae5b9..f675bd3e8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -249,7 +249,6 @@ RSpec/MultipleExpectations: - 'spec/commands/users/change_user_password_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/authentication_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index b5e92e5a2..e80e95cf5 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -11,14 +11,12 @@ page = last_response.body expect(page).to have_tag("input#password") - expect(page).to have_tag("#login") end end describe "POST /login" do it "denies access when password is incorrect" do - expect(SignInUser).to receive(:sign_in).and_return(nil) - + create(:user) post "/login", password: "not-the-password" page = last_response.body @@ -31,8 +29,13 @@ post "/login", password: user.password expect(session[:user_id]).to eq(user.id) + end + + it "redirects to the root page" do + user = create(:user) + + post "/login", password: user.password - expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/") end @@ -42,18 +45,20 @@ params = { password: user.password } post "/login", params, "rack.session" => { redirect_to: "/archive" } - expect(session[:redirect_to]).to be_nil expect(URI.parse(last_response.location).path).to eq("/archive") end end describe "GET /logout" do - it "clears the session and redirects" do + it "clears the session" do get "/logout", {}, "rack.session" => { userid: 1 } expect(session[:user_id]).to be_nil + end + + it "redirects to the root page" do + get "/logout", {}, "rack.session" => { userid: 1 } - expect(last_response.status).to be(302) expect(URI.parse(last_response.location).path).to eq("/") end end From 5bbb775bc4bb81d21626ee4e364dbc51625f4c5c Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:49:44 -0800 Subject: [PATCH 252/779] RuboCop: reduce expectations in StoriesController specs (#784) --- .rubocop_todo.yml | 1 - spec/controllers/stories_controller_spec.rb | 71 ++++----------------- 2 files changed, 14 insertions(+), 58 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f675bd3e8..ae1b604e5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -249,7 +249,6 @@ RSpec/MultipleExpectations: - 'spec/commands/users/change_user_password_spec.rb' - 'spec/commands/users/complete_setup_spec.rb' - 'spec/commands/users/create_user_spec.rb' - - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api/authentication_spec.rb' - 'spec/fever_api/read_feeds_spec.rb' - 'spec/fever_api/read_groups_spec.rb' diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 595806394..a0c066e88 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -30,7 +30,6 @@ def setup get "/news" expect(last_response.body).to include(story_one.headline) - expect(last_response.body).to include(story_one.source) end it "displays all user actions" do @@ -39,8 +38,6 @@ def setup get "/news" expect(last_response.body).to have_tag("#mark-all") - expect(last_response.body).to have_tag("#refresh") - expect(last_response.body).to have_tag("#feeds") end it "has correct footer links" do @@ -48,14 +45,11 @@ def setup get "/news" - page = last_response.body - expect(page).to have_tag("a", with: { href: "/feeds/export" }) - expect(page).to have_tag("a", with: { href: "/logout" }) + rendered = Capybara.string(last_response.body) + expect(rendered).to have_link("Export").and have_link("Logout") end it "displays a zen-like message when there are no unread stories" do - expect(StoryRepository).to receive(:unread).and_return([]) - get "/news" expect(last_response.body).to have_tag("#zen") @@ -63,114 +57,77 @@ def setup end describe "GET /archive" do - let(:read_one) { build(:story, :read) } - let(:read_two) { build(:story, :read) } - let(:stories) { [read_one, read_two].paginate } - it "displays the list of read stories with pagination" do - expect(StoryRepository).to receive(:read).and_return(stories) + create(:story, :read) get "/archive" page = last_response.body expect(page).to have_tag("#stories") - expect(page).to have_tag("div#pagination") end end describe "GET /starred" do - let(:starred_one) { build(:story, :starred) } - let(:starred_two) { build(:story, :starred) } - let(:stories) { [starred_one, starred_two].paginate } - - it "displays the list of starred stories with pagination" do - expect(StoryRepository).to receive(:starred).and_return(stories) + it "displays the list of starred stories" do + create(:story, :starred) get "/starred" page = last_response.body expect(page).to have_tag("#stories") - expect(page).to have_tag("div#pagination") end end describe "PUT /stories/:id" do it "marks a story as read when it is_read not malformed" do - expect(StoryRepository).to receive(:fetch).and_return(story_one) - expect(story_one).to receive(:save!).once - put "/stories/#{story_one.id}", { is_read: true }.to_json - expect(story_one.is_read).to be(true) + expect(story_one.reload.is_read).to be(true) end it "marks a story as read when is_read is malformed" do - expect(StoryRepository).to receive(:fetch).and_return(story_one) - expect(story_one).to receive(:save!).once - put "/stories/#{story_one.id}", { is_read: "malformed" }.to_json - expect(story_one.is_read).to be(true) + expect(story_one.reload.is_read).to be(true) end it "marks a story as keep unread when it keep_unread not malformed" do - expect(StoryRepository).to receive(:fetch).and_return(story_one) - put "/stories/#{story_one.id}", { keep_unread: false }.to_json - expect(story_one.keep_unread).to be(false) + expect(story_one.reload.keep_unread).to be(false) end it "marks a story as keep unread when keep_unread is malformed" do - expect(StoryRepository).to receive(:fetch).and_return(story_one) - put "/stories/#{story_one.id}", { keep_unread: "malformed" }.to_json - expect(story_one.keep_unread).to be(true) + expect(story_one.reload.keep_unread).to be(true) end it "marks a story as starred when is_starred is not malformed" do - expect(StoryRepository).to receive(:fetch).and_return(story_one) - put "/stories/#{story_one.id}", { is_starred: true }.to_json - expect(story_one.is_starred).to be(true) + expect(story_one.reload.is_starred).to be(true) end it "marks a story as starred when is_starred is malformed" do - expect(StoryRepository).to receive(:fetch).and_return(story_one) - put "/stories/#{story_one.id}", { is_starred: "malformed" }.to_json - expect(story_one.is_starred).to be(true) + expect(story_one.reload.is_starred).to be(true) end end describe "POST /stories/mark_all_as_read" do it "marks all unread stories as read and reload the page" do - expect(MarkAllAsRead).to receive(:call).once + stories = create_pair(:story) - post "/stories/mark_all_as_read", story_ids: ["1", "2", "3"] + post "/stories/mark_all_as_read", story_ids: stories.map(&:id) - expect(last_response.status).to be(302) - expect(URI.parse(last_response.location).path).to eq("/news") + expect(stories.map(&:reload).map(&:is_read)).to all(be(true)) end end describe "GET /feed/:feed_id" do - it "looks for a particular feed" do - expect(FeedRepository).to receive(:fetch) - .with(story_one.feed.id.to_s).and_return(story_one.feed) - expect(StoryRepository) - .to receive(:feed).with(story_one.feed.id.to_s).and_return([story_one]) - - get "/feed/#{story_one.feed.id}" - end - it "displays a list of stories" do - expect(FeedRepository).to receive(:fetch).and_return(story_one.feed) - expect(StoryRepository).to receive(:feed).and_return(stories) - get "/feed/#{story_one.feed.id}" expect(last_response.body).to have_tag("#stories") From f079e8753c2b3015c57de5946d1abab475dc85c9 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:54:09 -0800 Subject: [PATCH 253/779] RuboCop: enable HeredocDelimiterNaming (#785) --- .rubocop_todo.yml | 9 --------- app/utils/sample_story.rb | 4 ++-- spec/helpers/url_helpers_spec.rb | 16 ++++++++-------- spec/utils/opml_parser_spec.rb | 16 ++++++++-------- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ae1b604e5..3a6bb7ec8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -39,15 +39,6 @@ Metrics/MethodLength: - 'config/asset_pipeline.rb' - 'db/migrate/20130425222157_add_delayed_job.rb' -# Offense count: 9 -# Configuration parameters: ForbiddenDelimiters. -# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) -Naming/HeredocDelimiterNaming: - Exclude: - - 'app/utils/sample_story.rb' - - 'spec/helpers/url_helpers_spec.rb' - - 'spec/utils/opml_parser_spec.rb' - # Offense count: 2 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. # NamePrefix: is_, has_, have_ diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 1bde2143d..16c0bd1b4 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -SAMPLE_BODY = <<~EOS +SAMPLE_BODY = <<~HTML

    Tofu shoreditch intelligentsia umami, fashion axe photo booth try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee @@ -19,7 +19,7 @@ Single-origin coffee direct trade retro biodiesel, truffaut fanny pack portland blue bottle scenester bushwick. Skateboard squid fanny pack bushwick, photo booth vice literally.

    -EOS +HTML SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index 4c8561efd..8e8a7a5b3 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -18,23 +18,23 @@ end it "replaces relative urls in a, img and video tags" do - content = <<~EOS + content = <<~HTML
    tee
    - EOS + HTML result = helper.expand_absolute_urls(content, "http://oodl.io/d/") - expect(result.delete("\n")).to eq <<~EOS.delete("\n") + expect(result.delete("\n")).to eq <<~HTML.delete("\n")
    tee
    - EOS + HTML end it "handles empty body" do @@ -42,22 +42,22 @@ end it "doesn't modify tags that do not have url attributes" do - content = <<~EOS + content = <<~HTML
    - EOS + HTML result = helper.expand_absolute_urls(content, "http://oodl.io/d/") - expect(result.delete("\n")).to eq <<~EOS.delete("\n") + expect(result.delete("\n")).to eq <<~HTML.delete("\n")
    - EOS + HTML end it "leaves the url as-is if it cannot be parsed" do diff --git a/spec/utils/opml_parser_spec.rb b/spec/utils/opml_parser_spec.rb index afdf21fad..0db3f6781 100644 --- a/spec/utils/opml_parser_spec.rb +++ b/spec/utils/opml_parser_spec.rb @@ -9,7 +9,7 @@ describe "#parse_feeds" do it "returns a hash of feed details from an OPML file" do - result = parser.parse_feeds(<<-EOS) + result = parser.parse_feeds(<<-XML) @@ -22,7 +22,7 @@ xmlUrl="http://mdswanson.com/atom.xml" htmlUrl="http://mdswanson.com/"/> - EOS + XML resulted_values = result.values.flatten expect(resulted_values.size).to eq 2 @@ -35,7 +35,7 @@ end it "handles nested groups of feeds" do - result = parser.parse_feeds(<<-EOS) + result = parser.parse_feeds(<<-XML) @@ -48,7 +48,7 @@ - EOS + XML resulted_values = result.values.flatten expect(resulted_values.count).to eq 1 @@ -58,7 +58,7 @@ end it "doesn't explode when there are no feeds" do - result = parser.parse_feeds(<<-EOS) + result = parser.parse_feeds(<<-XML) @@ -67,13 +67,13 @@ - EOS + XML expect(result).to be_empty end it "handles Feedly's exported OPML (missing :title)" do - result = parser.parse_feeds(<<-EOS) + result = parser.parse_feeds(<<-XML) @@ -84,7 +84,7 @@ xmlUrl="http://feeds.feedburner.com/foobar" htmlUrl="http://www.example.org/"/> - EOS + XML resulted_values = result.values.flatten expect(resulted_values.count).to eq 1 From f2cf11e34effc3c1fad78cd7c98048902a3e8982 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 15:58:17 -0800 Subject: [PATCH 254/779] RuboCop: enable BeforeAfterAll cop (#786) --- .rubocop_todo.yml | 5 ----- spec/integration/feed_importing_spec.rb | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3a6bb7ec8..2645be3e1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -59,11 +59,6 @@ RSpec/Be: Exclude: - 'spec/commands/feeds/import_from_opml_spec.rb' -# Offense count: 3 -RSpec/BeforeAfterAll: - Exclude: - - 'spec/integration/feed_importing_spec.rb' - # Offense count: 18 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index d3b09acea..291d93dda 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -9,7 +9,7 @@ app_require "tasks/fetch_feed" describe "Feed importing" do - before(:all) { @server = FeedServer.new } + before { @server = FeedServer.new } let(:feed) do Feed.create( @@ -20,7 +20,7 @@ end describe "Valid feed" do - before(:all) do + before do # articles older than 3 days are ignored, so freeze time within # applicable range of the stories in the sample feed Timecop.freeze Time.parse("2014-08-15T17:30:00Z") @@ -57,7 +57,7 @@ end describe "Feed with incorrect pubdates" do - before(:all) { Timecop.freeze Time.parse("2014-08-12T17:30:00Z") } + before { Timecop.freeze Time.parse("2014-08-12T17:30:00Z") } context "has been fetched before" do it "imports all new stories" do From da3413b714ae5474923a5f91fd0679b11f61a610 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:02:48 -0800 Subject: [PATCH 255/779] RuboCop: enable RSpec/DescribedClass cop (#787) --- .rubocop_todo.yml | 43 ------- spec/commands/feeds/add_new_feed_spec.rb | 8 +- spec/commands/feeds/export_to_opml_spec.rb | 6 +- spec/commands/find_new_stories_spec.rb | 8 +- .../commands/stories/mark_all_as_read_spec.rb | 2 +- spec/commands/stories/mark_as_read_spec.rb | 2 +- spec/commands/stories/mark_as_starred_spec.rb | 2 +- spec/commands/stories/mark_as_unread_spec.rb | 2 +- .../stories/mark_as_unstarred_spec.rb | 2 +- .../stories/mark_feed_as_read_spec.rb | 2 +- .../users/change_user_password_spec.rb | 4 +- spec/commands/users/complete_setup_spec.rb | 2 +- spec/commands/users/sign_in_user_spec.rb | 4 +- spec/fever_api/authentication_spec.rb | 2 +- spec/fever_api/read_favicons_spec.rb | 2 +- spec/fever_api/read_feeds_groups_spec.rb | 2 +- spec/fever_api/read_feeds_spec.rb | 2 +- spec/fever_api/read_groups_spec.rb | 2 +- spec/fever_api/read_items_spec.rb | 2 +- spec/fever_api/read_links_spec.rb | 2 +- spec/fever_api/sync_saved_item_ids_spec.rb | 2 +- spec/fever_api/sync_unread_item_ids_spec.rb | 2 +- spec/fever_api/write_mark_feed_spec.rb | 2 +- spec/fever_api/write_mark_group_spec.rb | 2 +- spec/fever_api/write_mark_item_spec.rb | 14 +- spec/models/group_spec.rb | 2 +- spec/repositories/feed_repository_spec.rb | 29 +++-- spec/repositories/group_repository_spec.rb | 2 +- spec/repositories/story_repository_spec.rb | 120 +++++++++--------- spec/repositories/user_repository_spec.rb | 16 +-- spec/tasks/change_password_spec.rb | 4 +- spec/tasks/fetch_feed_spec.rb | 26 ++-- spec/tasks/fetch_feeds_spec.rb | 9 +- spec/tasks/remove_old_stories_spec.rb | 18 +-- spec/utils/feed_discovery_spec.rb | 8 +- spec/utils/opml_parser_spec.rb | 2 +- 36 files changed, 161 insertions(+), 198 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2645be3e1..eead9e7dd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -80,49 +80,6 @@ RSpec/DescribeClass: - 'spec/integration/feed_importing_spec.rb' - 'spec/utils/i18n_support_spec.rb' -# Offense count: 149 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: SkipBlocks, EnforcedStyle. -# SupportedStyles: described_class, explicit -RSpec/DescribedClass: - Exclude: - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/feeds/export_to_opml_spec.rb' - - 'spec/commands/find_new_stories_spec.rb' - - 'spec/commands/stories/mark_all_as_read_spec.rb' - - 'spec/commands/stories/mark_as_read_spec.rb' - - 'spec/commands/stories/mark_as_starred_spec.rb' - - 'spec/commands/stories/mark_as_unread_spec.rb' - - 'spec/commands/stories/mark_as_unstarred_spec.rb' - - 'spec/commands/stories/mark_feed_as_read_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/complete_setup_spec.rb' - - 'spec/commands/users/create_user_spec.rb' - - 'spec/commands/users/sign_in_user_spec.rb' - - 'spec/fever_api/authentication_spec.rb' - - 'spec/fever_api/read_favicons_spec.rb' - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/read_links_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - - 'spec/fever_api/write_mark_item_spec.rb' - - 'spec/models/group_spec.rb' - - 'spec/repositories/feed_repository_spec.rb' - - 'spec/repositories/group_repository_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/repositories/user_repository_spec.rb' - - 'spec/tasks/change_password_spec.rb' - - 'spec/tasks/fetch_feed_spec.rb' - - 'spec/tasks/fetch_feeds_spec.rb' - - 'spec/tasks/remove_old_stories_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' - - 'spec/utils/opml_parser_spec.rb' - # Offense count: 63 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index 8893f5434..dc2df8187 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -10,7 +10,7 @@ let(:discoverer) { double(discover: false) } it "returns false if cant discover any feeds" do - result = AddNewFeed.add("http://not-a-feed.com", discoverer) + result = described_class.add("http://not-a-feed.com", discoverer) expect(result).to be(false) end @@ -26,7 +26,7 @@ it "parses and creates the feed if discovered" do expect(repo).to receive(:create).and_return(feed) - result = AddNewFeed.add("http://feed.com", discoverer, repo) + result = described_class.add("http://feed.com", discoverer, repo) expect(result).to be feed end @@ -42,7 +42,7 @@ it "deletes the script tag from the title" do allow(repo).to receive(:create) - AddNewFeed.add("http://feed.com", discoverer, repo) + described_class.add("http://feed.com", discoverer, repo) expect(repo).to have_received(:create).with(include(name: "foobar")) end @@ -54,7 +54,7 @@ result = instance_double(Feedjira::Parser::RSS, title: nil, feed_url:) discoverer = instance_double(FeedDiscovery, discover: result) - expect { AddNewFeed.add(feed_url, discoverer) } + expect { described_class.add(feed_url, discoverer) } .to change(Feed, :count).by(1) expect(Feed.last.name).to eq(feed_url) diff --git a/spec/commands/feeds/export_to_opml_spec.rb b/spec/commands/feeds/export_to_opml_spec.rb index 1ed1ec622..01c89a82e 100644 --- a/spec/commands/feeds/export_to_opml_spec.rb +++ b/spec/commands/feeds/export_to_opml_spec.rb @@ -11,7 +11,7 @@ let(:feeds) { [feed_one, feed_two] } it "returns OPML XML" do - result = ExportToOpml.new(feeds).to_xml + result = described_class.new(feeds).to_xml outlines = Nokogiri.XML(result).xpath("//body//outline") expect(outlines.size).to eq(2) @@ -22,14 +22,14 @@ end it "handles empty feeds" do - result = ExportToOpml.new([]).to_xml + result = described_class.new([]).to_xml outlines = Nokogiri.XML(result).xpath("//body//outline") expect(outlines).to be_empty end it "has a proper title" do - result = ExportToOpml.new(feeds).to_xml + result = described_class.new(feeds).to_xml title = Nokogiri.XML(result).xpath("//head//title").first expect(title.content).to eq "Feeds from Stringer" diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index 5f2f45c63..903c3447f 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -15,7 +15,7 @@ story2 = double(published: nil, id: "story2") feed = double(entries: [story1, story2]) - result = FindNewStories.new(feed, 1, Time.new(2013, 1, 2)).new_stories + result = described_class.new(feed, 1, Time.new(2013, 1, 2)).new_stories expect(result).to be_empty end end @@ -31,7 +31,7 @@ allow(StoryRepository) .to receive(:exists?).with("story2", 1).and_return(false) - result = FindNewStories.new(feed, 1, Time.new(2013, 1, 2)).new_stories + result = described_class.new(feed, 1, Time.new(2013, 1, 2)).new_stories expect(result).to eq [story2] end end @@ -41,7 +41,7 @@ old_story = double(published: nil, id: "old-story") feed = double(last_modified: nil, entries: [new_story, old_story]) - result = FindNewStories.new( + result = described_class.new( feed, 1, Time.new(2013, 1, 3), @@ -66,7 +66,7 @@ entries: new_stories + stories_older_than_3_days ) - result = FindNewStories.new(feed, 1, nil, nil).new_stories + result = described_class.new(feed, 1, nil, nil).new_stories expect(result).not_to include(stories_older_than_3_days) end end diff --git a/spec/commands/stories/mark_all_as_read_spec.rb b/spec/commands/stories/mark_all_as_read_spec.rb index b9880759e..e9555a794 100644 --- a/spec/commands/stories/mark_all_as_read_spec.rb +++ b/spec/commands/stories/mark_all_as_read_spec.rb @@ -12,7 +12,7 @@ it "marks all stories as read" do expect(stories).to receive(:update_all).with(is_read: true) - MarkAllAsRead.call([1, 2], repo) + described_class.call([1, 2], repo) end end end diff --git a/spec/commands/stories/mark_as_read_spec.rb b/spec/commands/stories/mark_as_read_spec.rb index 603e99e13..814aac756 100644 --- a/spec/commands/stories/mark_as_read_spec.rb +++ b/spec/commands/stories/mark_as_read_spec.rb @@ -9,7 +9,7 @@ let(:story) { create(:story, is_read: false) } it "marks a story as read" do - expect { MarkAsRead.new(story.id).mark_as_read } + expect { described_class.new(story.id).mark_as_read } .to change { Story.find(story.id).is_read } .to(true) end diff --git a/spec/commands/stories/mark_as_starred_spec.rb b/spec/commands/stories/mark_as_starred_spec.rb index 150d78fe1..c5ece86d4 100644 --- a/spec/commands/stories/mark_as_starred_spec.rb +++ b/spec/commands/stories/mark_as_starred_spec.rb @@ -9,7 +9,7 @@ let(:story) { create(:story, is_starred: false) } it "marks a story as starred" do - expect { MarkAsStarred.new(story.id).mark_as_starred } + expect { described_class.new(story.id).mark_as_starred } .to change { Story.find(story.id).is_starred } .to(true) end diff --git a/spec/commands/stories/mark_as_unread_spec.rb b/spec/commands/stories/mark_as_unread_spec.rb index c5d72427b..ed113691c 100644 --- a/spec/commands/stories/mark_as_unread_spec.rb +++ b/spec/commands/stories/mark_as_unread_spec.rb @@ -9,7 +9,7 @@ let(:story) { create(:story, is_read: true) } it "marks a story as unread" do - expect { MarkAsUnread.new(story.id).mark_as_unread } + expect { described_class.new(story.id).mark_as_unread } .to change { Story.find(story.id).is_read } .to(false) end diff --git a/spec/commands/stories/mark_as_unstarred_spec.rb b/spec/commands/stories/mark_as_unstarred_spec.rb index 5802c752f..a0dbcd167 100644 --- a/spec/commands/stories/mark_as_unstarred_spec.rb +++ b/spec/commands/stories/mark_as_unstarred_spec.rb @@ -9,7 +9,7 @@ let(:story) { create(:story, is_starred: true) } it "marks a story as unstarred" do - expect { MarkAsUnstarred.new(story.id).mark_as_unstarred } + expect { described_class.new(story.id).mark_as_unstarred } .to change { Story.find(story.id).is_starred } .to(false) end diff --git a/spec/commands/stories/mark_feed_as_read_spec.rb b/spec/commands/stories/mark_feed_as_read_spec.rb index 72d586e87..63a7dec3b 100644 --- a/spec/commands/stories/mark_feed_as_read_spec.rb +++ b/spec/commands/stories/mark_feed_as_read_spec.rb @@ -10,7 +10,7 @@ let(:repo) { double(fetch_unread_for_feed_by_timestamp: stories) } it "marks feed 1 as read" do - command = MarkFeedAsRead.new(1, Time.now.to_i, repo) + command = described_class.new(1, Time.now.to_i, repo) expect(stories).to receive(:update_all).with(is_read: true) command.mark_feed_as_read end diff --git a/spec/commands/users/change_user_password_spec.rb b/spec/commands/users/change_user_password_spec.rb index 61a208e76..f109d666b 100644 --- a/spec/commands/users/change_user_password_spec.rb +++ b/spec/commands/users/change_user_password_spec.rb @@ -17,7 +17,7 @@ expect(repo).to receive(:first).and_return(user) expect(repo).to receive(:save) - command = ChangeUserPassword.new(repo) + command = described_class.new(repo) result = command.change_user_password(new_password) expect(BCrypt::Password.new(result.password_digest)).to eq new_password @@ -27,7 +27,7 @@ expect(repo).to receive(:first).and_return(user) expect(repo).to receive(:save) - command = ChangeUserPassword.new(repo) + command = described_class.new(repo) result = command.change_user_password(new_password) expect(result.api_key).to eq ApiKey.compute(new_password) diff --git a/spec/commands/users/complete_setup_spec.rb b/spec/commands/users/complete_setup_spec.rb index 5c1ad2a88..6e07fc86d 100644 --- a/spec/commands/users/complete_setup_spec.rb +++ b/spec/commands/users/complete_setup_spec.rb @@ -10,7 +10,7 @@ it "marks setup as complete" do expect(user).to receive(:save).once - result = CompleteSetup.complete(user) + result = described_class.complete(user) expect(result.setup_complete).to be(true) end end diff --git a/spec/commands/users/sign_in_user_spec.rb b/spec/commands/users/sign_in_user_spec.rb index 7132a70e3..e5dbc0137 100644 --- a/spec/commands/users/sign_in_user_spec.rb +++ b/spec/commands/users/sign_in_user_spec.rb @@ -14,13 +14,13 @@ describe "#sign_in" do it "returns the user if the password is valid" do - result = SignInUser.sign_in(valid_password, repo) + result = described_class.sign_in(valid_password, repo) expect(result.id).to eq 1 end it "returns nil if password is invalid" do - result = SignInUser.sign_in("not-the-pw", repo) + result = described_class.sign_in("not-the-pw", repo) expect(result).to be_nil end diff --git a/spec/fever_api/authentication_spec.rb b/spec/fever_api/authentication_spec.rb index 4cfd295dc..18cca061f 100644 --- a/spec/fever_api/authentication_spec.rb +++ b/spec/fever_api/authentication_spec.rb @@ -8,7 +8,7 @@ it "returns a hash with keys :auth and :last_refreshed_on_time" do fake_clock = double("clock") expect(fake_clock).to receive(:now).and_return(1234567890) - result = FeverAPI::Authentication.new(clock: fake_clock).call(double) + result = described_class.new(clock: fake_clock).call(double) expect(result).to eq(auth: 1, last_refreshed_on_time: 1234567890) end end diff --git a/spec/fever_api/read_favicons_spec.rb b/spec/fever_api/read_favicons_spec.rb index 19ce8a94b..26f5afbda 100644 --- a/spec/fever_api/read_favicons_spec.rb +++ b/spec/fever_api/read_favicons_spec.rb @@ -5,7 +5,7 @@ app_require "fever_api/read_favicons" describe FeverAPI::ReadFavicons do - subject { FeverAPI::ReadFavicons.new } + subject { described_class.new } it "returns a fixed icon list if requested" do expect(subject.call("favicons" => nil)).to eq( diff --git a/spec/fever_api/read_feeds_groups_spec.rb b/spec/fever_api/read_feeds_groups_spec.rb index e4004fd20..ce98c876f 100644 --- a/spec/fever_api/read_feeds_groups_spec.rb +++ b/spec/fever_api/read_feeds_groups_spec.rb @@ -9,7 +9,7 @@ let(:feeds) { feed_ids.map { |id| double("feed", id:, group_id: 1) } } let(:feed_repository) { double("repo") } - subject { FeverAPI::ReadFeedsGroups.new(feed_repository:) } + subject { described_class.new(feed_repository:) } it "returns a list of groups requested through feeds" do allow(feed_repository) diff --git a/spec/fever_api/read_feeds_spec.rb b/spec/fever_api/read_feeds_spec.rb index f429153d4..a49766d98 100644 --- a/spec/fever_api/read_feeds_spec.rb +++ b/spec/fever_api/read_feeds_spec.rb @@ -11,7 +11,7 @@ end let(:feed_repository) { double("repo") } - subject { FeverAPI::ReadFeeds.new(feed_repository:) } + subject { described_class.new(feed_repository:) } it "returns a list of feeds" do expect(feed_repository).to receive(:list).and_return(feeds) diff --git a/spec/fever_api/read_groups_spec.rb b/spec/fever_api/read_groups_spec.rb index d36002995..176429b41 100644 --- a/spec/fever_api/read_groups_spec.rb +++ b/spec/fever_api/read_groups_spec.rb @@ -11,7 +11,7 @@ end let(:group_repository) { double("repo") } - subject { FeverAPI::ReadGroups.new(group_repository:) } + subject { described_class.new(group_repository:) } it "returns a group list if requested" do expect(group_repository).to receive(:list).and_return([group1, group2]) diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index caa375f44..cd71d5511 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -7,7 +7,7 @@ describe FeverAPI::ReadItems do let(:story_repository) { double("repo") } - subject { FeverAPI::ReadItems.new(story_repository:) } + subject { described_class.new(story_repository:) } it "returns a list of unread items including total count" do stories = [ diff --git a/spec/fever_api/read_links_spec.rb b/spec/fever_api/read_links_spec.rb index 3f279179d..837c2ac38 100644 --- a/spec/fever_api/read_links_spec.rb +++ b/spec/fever_api/read_links_spec.rb @@ -5,7 +5,7 @@ app_require "fever_api/read_links" describe FeverAPI::ReadLinks do - subject { FeverAPI::ReadLinks.new } + subject { described_class.new } it "returns a fixed link list if requested" do expect(subject.call("links" => nil)).to eq(links: []) diff --git a/spec/fever_api/sync_saved_item_ids_spec.rb b/spec/fever_api/sync_saved_item_ids_spec.rb index 6acfe5e0a..daef8ce43 100644 --- a/spec/fever_api/sync_saved_item_ids_spec.rb +++ b/spec/fever_api/sync_saved_item_ids_spec.rb @@ -9,7 +9,7 @@ let(:stories) { story_ids.map { |id| double("story", id:) } } let(:story_repository) { double("repo") } - subject { FeverAPI::SyncSavedItemIds.new(story_repository:) } + subject { described_class.new(story_repository:) } it "returns a list of starred items if requested" do expect(story_repository).to receive(:all_starred).and_return(stories) diff --git a/spec/fever_api/sync_unread_item_ids_spec.rb b/spec/fever_api/sync_unread_item_ids_spec.rb index f84c22ac4..f46b7ff39 100644 --- a/spec/fever_api/sync_unread_item_ids_spec.rb +++ b/spec/fever_api/sync_unread_item_ids_spec.rb @@ -9,7 +9,7 @@ let(:stories) { story_ids.map { |id| double("story", id:) } } let(:story_repository) { double("repo") } - subject { FeverAPI::SyncUnreadItemIds.new(story_repository:) } + subject { described_class.new(story_repository:) } it "returns a list of unread items if requested" do expect(story_repository).to receive(:unread).and_return(stories) diff --git a/spec/fever_api/write_mark_feed_spec.rb b/spec/fever_api/write_mark_feed_spec.rb index 2ff1e4546..ee7c13842 100644 --- a/spec/fever_api/write_mark_feed_spec.rb +++ b/spec/fever_api/write_mark_feed_spec.rb @@ -8,7 +8,7 @@ let(:feed_marker) { double("feed marker") } let(:marker_class) { double("marker class") } - subject { FeverAPI::WriteMarkFeed.new(marker_class:) } + subject { described_class.new(marker_class:) } it "instantiates a feed marker and calls mark_feed_as_read if requested" do expect(marker_class) diff --git a/spec/fever_api/write_mark_group_spec.rb b/spec/fever_api/write_mark_group_spec.rb index 0713f19c4..16a955cfa 100644 --- a/spec/fever_api/write_mark_group_spec.rb +++ b/spec/fever_api/write_mark_group_spec.rb @@ -8,7 +8,7 @@ let(:group_marker) { double("group marker") } let(:marker_class) { double("marker class") } - subject { FeverAPI::WriteMarkGroup.new(marker_class:) } + subject { described_class.new(marker_class:) } it "instantiates a group marker and calls mark_group_as_read if requested" do expect(marker_class) diff --git a/spec/fever_api/write_mark_item_spec.rb b/spec/fever_api/write_mark_item_spec.rb index 3edb48802..0bd98cf06 100644 --- a/spec/fever_api/write_mark_item_spec.rb +++ b/spec/fever_api/write_mark_item_spec.rb @@ -9,7 +9,7 @@ let(:marker_class) { double("marker class") } describe "as read" do - subject { FeverAPI::WriteMarkItem.new(read_marker_class: marker_class) } + subject { described_class.new(read_marker_class: marker_class) } it "calls mark_item_as_read if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) @@ -19,9 +19,7 @@ end describe "as unread" do - subject do - FeverAPI::WriteMarkItem.new(unread_marker_class: marker_class) - end + subject { described_class.new(unread_marker_class: marker_class) } it "calls mark_item_as_unread if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) @@ -31,9 +29,7 @@ end describe "as starred" do - subject do - FeverAPI::WriteMarkItem.new(starred_marker_class: marker_class) - end + subject { described_class.new(starred_marker_class: marker_class) } it "calls mark_item_as_starred if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) @@ -43,9 +39,7 @@ end describe "as unstarred" do - subject do - FeverAPI::WriteMarkItem.new(unstarred_marker_class: marker_class) - end + subject { described_class.new(unstarred_marker_class: marker_class) } it "calls marks_item_as_unstarred if requested" do expect(marker_class).to receive(:new).with(5).and_return(item_marker) diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 6556e076b..e34ac3363 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Group do describe "#as_fever_json" do it "returns a hash of the group in fever format" do - group = Group.new(id: 5, name: "wat group") + group = described_class.new(id: 5, name: "wat group") expect(group.as_fever_json).to eq(id: 5, title: "wat group") end diff --git a/spec/repositories/feed_repository_spec.rb b/spec/repositories/feed_repository_spec.rb index 1bd31867c..f9da37222 100644 --- a/spec/repositories/feed_repository_spec.rb +++ b/spec/repositories/feed_repository_spec.rb @@ -11,13 +11,13 @@ it "finds by id" do expect(Feed).to receive(:find).with(feed.id).and_return(feed) - FeedRepository.fetch(feed.id) + described_class.fetch(feed.id) end it "returns found feed" do allow(Feed).to receive(:find).with(feed.id).and_return(feed) - result = FeedRepository.fetch(feed.id) + result = described_class.fetch(feed.id) expect(result).to eq feed end @@ -27,13 +27,14 @@ it "finds all feeds by id" do feeds = create_pair(:feed) - expect(FeedRepository.fetch_by_ids(feeds.map(&:id))).to match_array(feeds) + expect(described_class.fetch_by_ids(feeds.map(&:id))) + .to match_array(feeds) end it "does not find other feeds" do feed1, = create_pair(:feed) - expect(FeedRepository.fetch_by_ids(feed1.id)).to eq([feed1]) + expect(described_class.fetch_by_ids(feed1.id)).to eq([feed1]) end end @@ -41,7 +42,7 @@ it "saves the name and url" do feed = Feed.new - FeedRepository.update_feed(feed, "Test Feed", "example.com/feed") + described_class.update_feed(feed, "Test Feed", "example.com/feed") expect(feed.name).to eq "Test Feed" expect(feed.url).to eq "example.com/feed" @@ -54,7 +55,7 @@ it "saves the last_fetched timestamp" do feed = Feed.new - FeedRepository.update_last_fetched(feed, timestamp) + described_class.update_last_fetched(feed, timestamp) expect(feed.last_fetched).to eq timestamp end @@ -64,7 +65,7 @@ it "rejects weird timestamps" do feed = Feed.new(last_fetched: timestamp) - FeedRepository.update_last_fetched(feed, weird_timestamp) + described_class.update_last_fetched(feed, weird_timestamp) expect(feed.last_fetched).to eq timestamp end @@ -72,7 +73,7 @@ it "doesn't update if timestamp is nil" do feed = Feed.new(last_fetched: timestamp) - FeedRepository.update_last_fetched(feed, nil) + described_class.update_last_fetched(feed, nil) expect(feed.last_fetched).to eq timestamp end @@ -81,7 +82,7 @@ feed = Feed.new(last_fetched: timestamp) one_week_ago = timestamp - 1.week - FeedRepository.update_last_fetched(feed, one_week_ago) + described_class.update_last_fetched(feed, one_week_ago) expect(feed.last_fetched).to eq timestamp end @@ -91,7 +92,7 @@ it "deletes the feed by id" do feed = create(:feed) - FeedRepository.delete(feed.id) + described_class.delete(feed.id) expect(Feed.unscoped.find_by(id: feed.id)).to be_nil end @@ -99,7 +100,7 @@ it "does not delete other feeds" do feed1, feed2 = create_pair(:feed) - FeedRepository.delete(feed1.id) + described_class.delete(feed1.id) expect(Feed.unscoped.find_by(id: feed2.id)).to eq(feed2) end @@ -112,7 +113,7 @@ feed3 = create(:feed, name: "Zooby") feed4 = create(:feed, name: "zabby") - expect(FeedRepository.list).to eq([feed2, feed1, feed4, feed3]) + expect(described_class.list).to eq([feed2, feed1, feed4, feed3]) end end @@ -121,13 +122,13 @@ feed1 = create(:feed, group_id: 5) feed2 = create(:feed, group_id: 6) - expect(FeedRepository.in_group).to match_array([feed1, feed2]) + expect(described_class.in_group).to match_array([feed1, feed2]) end it "does not return feeds that are not in a group" do create_pair(:feed) - expect(FeedRepository.in_group).to be_empty + expect(described_class.in_group).to be_empty end end end diff --git a/spec/repositories/group_repository_spec.rb b/spec/repositories/group_repository_spec.rb index 2f6a5a827..48c7e600b 100644 --- a/spec/repositories/group_repository_spec.rb +++ b/spec/repositories/group_repository_spec.rb @@ -14,7 +14,7 @@ group4 = create(:group, name: "Babba") expected_groups = [group4, group3, group1, group2] - expect(GroupRepository.list).to eq(expected_groups) + expect(described_class.list).to eq(expected_groups) end end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index b3c806901..cc50b3046 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -17,29 +17,29 @@ title: "", content: "" ).as_null_object - expect(StoryRepository) + expect(described_class) .to receive(:normalize_url).with(entry.url, feed.url) - StoryRepository.add(entry, feed) + described_class.add(entry, feed) end it "deletes line and paragraph separator characters from titles" do entry = double(title: "n\u2028\u2029", content: "").as_null_object - allow(StoryRepository).to receive(:normalize_url) + allow(described_class).to receive(:normalize_url) expect(Story).to receive(:create).with(hash_including(title: "n")) - StoryRepository.add(entry, feed) + described_class.add(entry, feed) end it "deletes script tags from titles" do entry = double(title: "n", content: "") .as_null_object - allow(StoryRepository).to receive(:normalize_url) + allow(described_class).to receive(:normalize_url) expect(Story).to receive(:create).with(hash_including(title: "n")) - StoryRepository.add(entry, feed) + described_class.add(entry, feed) end it "sets the enclosure url when present" do @@ -50,11 +50,11 @@ summary: "", content: "" ).as_null_object - allow(StoryRepository).to receive(:normalize_url) + allow(described_class).to receive(:normalize_url) expect(Story).to receive(:create).with(hash_including(enclosure_url: "http://example.com/audio.mp3")) - StoryRepository.add(entry, feed) + described_class.add(entry, feed) end it "does not set the enclosure url when not present" do @@ -64,11 +64,11 @@ summary: "", content: "" ).as_null_object - allow(StoryRepository).to receive(:normalize_url) + allow(described_class).to receive(:normalize_url) expect(Story).to receive(:create).with(hash_including(enclosure_url: nil)) - StoryRepository.add(entry, feed) + described_class.add(entry, feed) end end @@ -76,7 +76,7 @@ it "finds the story by id" do story = create(:story) - expect(StoryRepository.fetch(story.id)).to eq(story) + expect(described_class.fetch(story.id)).to eq(story) end end @@ -86,7 +86,7 @@ story2 = create(:story) expected_stories = [story1, story2] - actual_stories = StoryRepository.fetch_by_ids(expected_stories.map(&:id)) + actual_stories = described_class.fetch_by_ids(expected_stories.map(&:id)) expect(actual_stories).to match_array(expected_stories) end @@ -96,7 +96,7 @@ it "returns unread stories from before the timestamp" do story = create(:story, created_at: 1.week.ago, is_read: false) - actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) + actual_stories = described_class.fetch_unread_by_timestamp(4.days.ago) expect(actual_stories).to eq([story]) end @@ -104,7 +104,7 @@ it "does not return unread stories from after the timestamp" do create(:story, created_at: 3.days.ago, is_read: false) - actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) + actual_stories = described_class.fetch_unread_by_timestamp(4.days.ago) expect(actual_stories).to be_empty end @@ -112,7 +112,7 @@ it "does not return read stories from before the timestamp" do create(:story, created_at: 1.week.ago, is_read: true) - actual_stories = StoryRepository.fetch_unread_by_timestamp(4.days.ago) + actual_stories = described_class.fetch_unread_by_timestamp(4.days.ago) expect(actual_stories).to be_empty end @@ -124,7 +124,7 @@ story = create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now - stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + stories = described_class.fetch_unread_by_timestamp_and_group(time, 52) expect(stories).to eq([story]) end @@ -134,7 +134,7 @@ create(:story, feed:, created_at: 5.minutes.ago) time = Time.now - stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + stories = described_class.fetch_unread_by_timestamp_and_group(time, 52) expect(stories).to be_empty end @@ -144,7 +144,7 @@ create(:story, :unread, feed:, created_at: 5.minutes.ago) time = 6.minutes.ago - stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + stories = described_class.fetch_unread_by_timestamp_and_group(time, 52) expect(stories).to be_empty end @@ -154,7 +154,7 @@ create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now - stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 55) + stories = described_class.fetch_unread_by_timestamp_and_group(time, 55) expect(stories).to be_empty end @@ -164,7 +164,7 @@ create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now - stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, 52) + stories = described_class.fetch_unread_by_timestamp_and_group(time, 52) expect(stories).to be_empty end @@ -174,7 +174,7 @@ story = create(:story, :unread, feed:, created_at: 5.minutes.ago) time = Time.now - stories = StoryRepository.fetch_unread_by_timestamp_and_group(time, nil) + stories = described_class.fetch_unread_by_timestamp_and_group(time, nil) expect(stories).to eq([story]) end @@ -187,7 +187,7 @@ time = 4.minutes.ago stories = - StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + described_class.fetch_unread_for_feed_by_timestamp(feed.id, time) expect(stories).to eq([story]) end @@ -198,7 +198,7 @@ timestamp = Integer(4.minutes.ago).to_s stories = - StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, timestamp) + described_class.fetch_unread_for_feed_by_timestamp(feed.id, timestamp) expect(stories).to eq([story]) end @@ -209,7 +209,7 @@ time = 4.minutes.ago stories = - StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + described_class.fetch_unread_for_feed_by_timestamp(feed.id, time) expect(stories).to be_empty end @@ -220,7 +220,7 @@ time = 6.minutes.ago stories = - StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + described_class.fetch_unread_for_feed_by_timestamp(feed.id, time) expect(stories).to be_empty end @@ -231,7 +231,7 @@ time = 4.minutes.ago stories = - StoryRepository.fetch_unread_for_feed_by_timestamp(feed.id, time) + described_class.fetch_unread_for_feed_by_timestamp(feed.id, time) expect(stories).to be_empty end @@ -242,14 +242,14 @@ story1 = create(:story, :unread, published: 5.minutes.ago) story2 = create(:story, :unread, published: 4.minutes.ago) - expect(StoryRepository.unread).to eq([story2, story1]) + expect(described_class.unread).to eq([story2, story1]) end it "does not return read stories" do create(:story, published: 5.minutes.ago) create(:story, published: 4.minutes.ago) - expect(StoryRepository.unread).to be_empty + expect(described_class.unread).to be_empty end end @@ -258,21 +258,21 @@ story1 = create(:story, :unread) story2 = create(:story, :unread) - expect(StoryRepository.unread_since_id(story1.id)).to eq([story2]) + expect(described_class.unread_since_id(story1.id)).to eq([story2]) end it "does not return read stories with id greater than given id" do story1 = create(:story, :unread) create(:story) - expect(StoryRepository.unread_since_id(story1.id)).to be_empty + expect(described_class.unread_since_id(story1.id)).to be_empty end it "does not return unread stories with id less than given id" do create(:story, :unread) story2 = create(:story, :unread) - expect(StoryRepository.unread_since_id(story2.id)).to be_empty + expect(described_class.unread_since_id(story2.id)).to be_empty end end @@ -281,7 +281,7 @@ feed = create(:feed) story = create(:story, feed:) - expect(StoryRepository.feed(feed.id)).to eq([story]) + expect(described_class.feed(feed.id)).to eq([story]) end it "sorts stories by published" do @@ -289,14 +289,14 @@ story1 = create(:story, feed:, published: 1.day.ago) story2 = create(:story, feed:, published: 1.hour.ago) - expect(StoryRepository.feed(feed.id)).to eq([story2, story1]) + expect(described_class.feed(feed.id)).to eq([story2, story1]) end it "does not return stories for other feeds" do feed = create(:feed) create(:story) - expect(StoryRepository.feed(feed.id)).to be_empty + expect(described_class.feed(feed.id)).to be_empty end end @@ -304,28 +304,28 @@ it "returns read stories" do story = create(:story, :read) - expect(StoryRepository.read).to eq([story]) + expect(described_class.read).to eq([story]) end it "sorts stories by published" do story1 = create(:story, :read, published: 1.day.ago) story2 = create(:story, :read, published: 1.hour.ago) - expect(StoryRepository.read).to eq([story2, story1]) + expect(described_class.read).to eq([story2, story1]) end it "does not return unread stories" do create(:story, :unread) - expect(StoryRepository.read).to be_empty + expect(described_class.read).to be_empty end it "paginates results" do stories = 21.times.map { |num| create(:story, :read, published: num.days.ago) } - expect(StoryRepository.read).to eq(stories[0...20]) - expect(StoryRepository.read(2)).to eq([stories.last]) + expect(described_class.read).to eq(stories[0...20]) + expect(described_class.read(2)).to eq([stories.last]) end end @@ -333,28 +333,28 @@ it "returns starred stories" do story = create(:story, :starred) - expect(StoryRepository.starred).to eq([story]) + expect(described_class.starred).to eq([story]) end it "sorts stories by published" do story1 = create(:story, :starred, published: 1.day.ago) story2 = create(:story, :starred, published: 1.hour.ago) - expect(StoryRepository.starred).to eq([story2, story1]) + expect(described_class.starred).to eq([story2, story1]) end it "does not return unstarred stories" do create(:story) - expect(StoryRepository.starred).to be_empty + expect(described_class.starred).to be_empty end it "paginates results" do stories = 21.times.map { |num| create(:story, :starred, published: num.days.ago) } - expect(StoryRepository.starred).to eq(stories[0...20]) - expect(StoryRepository.starred(2)).to eq([stories.last]) + expect(described_class.starred).to eq(stories[0...20]) + expect(described_class.starred(2)).to eq([stories.last]) end end @@ -362,26 +362,26 @@ it "returns unstarred read stories older than given number of days" do story = create(:story, :read, published: 6.days.ago) - expect(StoryRepository.unstarred_read_stories_older_than(5)) + expect(described_class.unstarred_read_stories_older_than(5)) .to eq([story]) end it "does not return starred stories older than the given number of days" do create(:story, :read, :starred, published: 6.days.ago) - expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty + expect(described_class.unstarred_read_stories_older_than(5)).to be_empty end it "does not return unread stories older than the given number of days" do create(:story, :unread, published: 6.days.ago) - expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty + expect(described_class.unstarred_read_stories_older_than(5)).to be_empty end it "does not return stories newer than given number of days" do create(:story, :read, published: 4.days.ago) - expect(StoryRepository.unstarred_read_stories_older_than(5)).to be_empty + expect(described_class.unstarred_read_stories_older_than(5)).to be_empty end end @@ -391,13 +391,13 @@ create(:story, :read) create(:story, :read) - expect(StoryRepository.read_count).to eq(3) + expect(described_class.read_count).to eq(3) end it "does not count unread stories" do create_list(:story, 3, :unread) - expect(StoryRepository.read_count).to eq(0) + expect(described_class.read_count).to eq(0) end end @@ -406,21 +406,21 @@ feed = double(url: "http://github.com") entry = double(url: "https://github.com/stringer-rss/stringer") - expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" + expect(described_class.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" end it "returns the enclosure_url when the url is nil" do feed = double(url: "http://github.com") entry = double(url: nil, enclosure_url: "https://github.com/stringer-rss/stringer") - expect(StoryRepository.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" + expect(described_class.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" end it "does not crash if url is nil but enclosure_url does not exist" do feed = double(url: "http://github.com") entry = double(url: nil) - expect(StoryRepository.extract_url(entry, feed)).to be_nil + expect(described_class.extract_url(entry, feed)).to be_nil end end @@ -428,13 +428,13 @@ it "returns the title if there is a title" do entry = double(title: "title", summary: "summary") - expect(StoryRepository.extract_title(entry)).to eq "title" + expect(described_class.extract_title(entry)).to eq "title" end it "returns the summary if there isn't a title" do entry = double(title: "", summary: "summary") - expect(StoryRepository.extract_title(entry)).to eq "summary" + expect(described_class.extract_title(entry)).to eq "summary" end end @@ -455,18 +455,18 @@ end it "sanitizes content" do - expect(StoryRepository.extract_content(entry)).to eq "Some test content" + expect(described_class.extract_content(entry)).to eq "Some test content" end it "falls back to summary if there is no content" do - expect(StoryRepository.extract_content(summary_only)) + expect(described_class.extract_content(summary_only)) .to eq "Dumb publisher" end it "returns empty string if there is no content or summary" do entry = double(url: "http://mdswanson.com", content: nil, summary: nil) - expect(StoryRepository.extract_content(entry)).to eq "" + expect(described_class.extract_content(entry)).to eq "" end it "expands urls" do @@ -476,7 +476,7 @@ summary: "Page" ) - expect(StoryRepository.extract_content(entry)) + expect(described_class.extract_content(entry)) .to eq "Page" end @@ -484,7 +484,7 @@ entry = double(url: nil, content: nil, summary: "Page") - expect(StoryRepository.extract_content(entry)) + expect(described_class.extract_content(entry)) .to eq "Page" end end diff --git a/spec/repositories/user_repository_spec.rb b/spec/repositories/user_repository_spec.rb index 8e51de51b..b5b56b4fe 100644 --- a/spec/repositories/user_repository_spec.rb +++ b/spec/repositories/user_repository_spec.rb @@ -8,31 +8,31 @@ describe UserRepository do describe ".fetch" do it "returns nil when given id is nil" do - expect(UserRepository.fetch(nil)).to be_nil + expect(described_class.fetch(nil)).to be_nil end it "returns the user for the given id" do user = create(:user) - expect(UserRepository.fetch(user.id)).to eq(user) + expect(described_class.fetch(user.id)).to eq(user) end end describe ".setup_complete?" do it "returns false when there are no users" do - expect(UserRepository.setup_complete?).to be(false) + expect(described_class.setup_complete?).to be(false) end it "returns false when user has not completed setup" do create(:user) - expect(UserRepository.setup_complete?).to be(false) + expect(described_class.setup_complete?).to be(false) end it "returns true when user has completed setup" do create(:user, :setup_complete) - expect(UserRepository.setup_complete?).to be(true) + expect(described_class.setup_complete?).to be(true) end end @@ -40,14 +40,14 @@ it "saves the given user" do user = build(:user) - expect { UserRepository.save(user) } + expect { described_class.save(user) } .to change(user, :persisted?).from(false).to(true) end it "returns the given user" do user = User.new - expect(UserRepository.save(user)).to eq(user) + expect(described_class.save(user)).to eq(user) end end @@ -56,7 +56,7 @@ user = create(:user) create(:user) - expect(UserRepository.first).to eq(user) + expect(described_class.first).to eq(user) end end end diff --git a/spec/tasks/change_password_spec.rb b/spec/tasks/change_password_spec.rb index ef6a5e08b..d93463769 100644 --- a/spec/tasks/change_password_spec.rb +++ b/spec/tasks/change_password_spec.rb @@ -11,7 +11,7 @@ it "invokes command with confirmed password" do output = StringIO.new input = StringIO.new("new-pw\nnew-pw\n") - task = ChangePassword.new(command, output:, input:) + task = described_class.new(command, output:, input:) expect(command).to receive(:change_user_password).with("new-pw") @@ -21,7 +21,7 @@ it "repeats until a matching confirmation" do output = StringIO.new input = StringIO.new("woops\nnope\nnew-pw\nnew-pw\n") - task = ChangePassword.new(command, output:, input:) + task = described_class.new(command, output:, input:) expect(command).to receive(:change_user_password).with("new-pw") diff --git a/spec/tasks/fetch_feed_spec.rb b/spec/tasks/fetch_feed_spec.rb index 532a69166..47e3ec0fc 100644 --- a/spec/tasks/fetch_feed_spec.rb +++ b/spec/tasks/fetch_feed_spec.rb @@ -27,7 +27,12 @@ expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser:, client:, logger: nil).fetch + described_class.new( + daring_fireball, + parser:, + client:, + logger: nil + ).fetch end it "logs a message" do @@ -36,7 +41,7 @@ output = StringIO.new logger = Logger.new(output) - FetchFeed.new(daring_fireball, parser:, client:, logger:).fetch + described_class.new(daring_fireball, parser:, client:, logger:).fetch expect(output.string).to include("has not been modified") end @@ -53,7 +58,7 @@ expect(StoryRepository).not_to receive(:add) - FetchFeed.new(daring_fireball, parser:, client:).fetch + described_class.new(daring_fireball, parser:, client:).fetch end end @@ -81,7 +86,7 @@ expect(StoryRepository) .not_to receive(:add).with(old_story, daring_fireball) - FetchFeed.new( + described_class.new( daring_fireball, parser: fake_parser, client: fake_client @@ -92,7 +97,7 @@ expect(FeedRepository).to receive(:update_last_fetched) .with(daring_fireball, now) - FetchFeed.new( + described_class.new( daring_fireball, parser: fake_parser, client: fake_client @@ -109,7 +114,7 @@ expect(FeedRepository).to receive(:set_status) .with(:green, daring_fireball) - FetchFeed.new(daring_fireball, parser:, client:).fetch + described_class.new(daring_fireball, parser:, client:).fetch end it "sets the status to red if things go wrong" do @@ -119,7 +124,12 @@ expect(FeedRepository).to receive(:set_status) .with(:red, daring_fireball) - FetchFeed.new(daring_fireball, parser:, client:, logger: nil).fetch + described_class.new( + daring_fireball, + parser:, + client:, + logger: nil + ).fetch end it "outputs a message when things go wrong" do @@ -128,7 +138,7 @@ output = StringIO.new logger = Logger.new(output) - FetchFeed.new(daring_fireball, parser:, client:, logger:).fetch + described_class.new(daring_fireball, parser:, client:, logger:).fetch expect(output.string).to include("Something went wrong") end diff --git a/spec/tasks/fetch_feeds_spec.rb b/spec/tasks/fetch_feeds_spec.rb index 055b394f6..e16f44723 100644 --- a/spec/tasks/fetch_feeds_spec.rb +++ b/spec/tasks/fetch_feeds_spec.rb @@ -19,7 +19,7 @@ expect(pool).to receive(:shutdown) - FetchFeeds.new(feeds, pool).fetch_all + described_class.new(feeds, pool).fetch_all end it "finds feeds when run after a delay" do @@ -32,7 +32,7 @@ expect(pool).to receive(:shutdown) - FetchFeeds.new(feeds, pool).prepare_to_delay.fetch_all + described_class.new(feeds, pool).prepare_to_delay.fetch_all end end @@ -40,7 +40,7 @@ it "serializes the instance for backgrounding" do feeds = create_pair(:feed) feeds_ids = feeds.map(&:id) - fetch_feeds = FetchFeeds.new(feeds) + fetch_feeds = described_class.new(feeds) fetch_feeds.prepare_to_delay @@ -54,7 +54,8 @@ feeds = create_pair(:feed) feeds_ids = feeds.map(&:id) - expect { FetchFeeds.enqueue(feeds) }.to change(Delayed::Job, :count).by(1) + expect { described_class.enqueue(feeds) } + .to change(Delayed::Job, :count).by(1) job_object = Delayed::Job.last.payload_object.object expect(job_object.instance_variable_get(:@feeds_ids)).to eq(feeds_ids) diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index 08a36df7f..3ba94dde0 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -12,26 +12,26 @@ end it "passes along the number of days to the story repository query" do - allow(RemoveOldStories).to receive(:pruned_feeds) { [] } + allow(described_class).to receive(:pruned_feeds) { [] } expect(StoryRepository).to receive(:unstarred_read_stories_older_than) .with(7).and_return(stories_mock) - RemoveOldStories.remove!(7) + described_class.remove!(7) end it "requests deletion of all old stories" do - allow(RemoveOldStories).to receive(:pruned_feeds) { [] } + allow(described_class).to receive(:pruned_feeds) { [] } allow(StoryRepository) .to receive(:unstarred_read_stories_older_than) { stories_mock } expect(stories_mock).to receive(:delete_all) - RemoveOldStories.remove!(11) + described_class.remove!(11) end it "fetches affected feeds by id" do - allow(RemoveOldStories).to receive(:old_stories) do + allow(described_class).to receive(:old_stories) do stories = [double("story", feed_id: 3), double("story", feed_id: 5)] allow(stories).to receive(:delete_all) stories @@ -40,20 +40,20 @@ expect(FeedRepository) .to receive(:fetch_by_ids).with([3, 5]).and_return([]) - RemoveOldStories.remove!(13) + described_class.remove!(13) end it "updates last_fetched on affected feeds" do feeds = [double("feed a"), double("feed b")] - allow(RemoveOldStories).to receive(:pruned_feeds) { feeds } - allow(RemoveOldStories).to receive(:old_stories) { stories_mock } + allow(described_class).to receive(:pruned_feeds) { feeds } + allow(described_class).to receive(:old_stories) { stories_mock } expect(FeedRepository) .to receive(:update_last_fetched).with(feeds.first, anything) expect(FeedRepository) .to receive(:update_last_fetched).with(feeds.last, anything) - RemoveOldStories.remove!(13) + described_class.remove!(13) end end end diff --git a/spec/utils/feed_discovery_spec.rb b/spec/utils/feed_discovery_spec.rb index 4266d3ec1..fbf381b04 100644 --- a/spec/utils/feed_discovery_spec.rb +++ b/spec/utils/feed_discovery_spec.rb @@ -20,7 +20,7 @@ expect(parser).to receive(:parse).and_raise(StandardError) expect(finder).to receive(:find).and_return([]) - result = FeedDiscovery.new.discover(url, finder, parser, client) + result = described_class.new.discover(url, finder, parser, client) expect(result).to be(false) end @@ -29,7 +29,7 @@ expect(client).to receive(:get).with(url) expect(parser).to receive(:parse).and_return(feed) - result = FeedDiscovery.new.discover(url, finder, parser, client) + result = described_class.new.discover(url, finder, parser, client) expect(result).to eq feed end @@ -43,7 +43,7 @@ expect(client).to receive(:get).with(invalid_discovered_url) expect(parser).to receive(:parse).and_raise(StandardError) - result = FeedDiscovery.new.discover(url, finder, parser, client) + result = described_class.new.discover(url, finder, parser, client) expect(result).to be(false) end @@ -57,7 +57,7 @@ expect(client).to receive(:get).with(valid_discovered_url) expect(parser).to receive(:parse).and_return(feed) - result = FeedDiscovery.new.discover(url, finder, parser, client) + result = described_class.new.discover(url, finder, parser, client) expect(result).to eq feed end diff --git a/spec/utils/opml_parser_spec.rb b/spec/utils/opml_parser_spec.rb index 0db3f6781..4520a8a07 100644 --- a/spec/utils/opml_parser_spec.rb +++ b/spec/utils/opml_parser_spec.rb @@ -5,7 +5,7 @@ app_require "utils/opml_parser" describe OpmlParser do - let(:parser) { OpmlParser.new } + let(:parser) { described_class.new } describe "#parse_feeds" do it "returns a hash of feed details from an OPML file" do From c7cce410a3511865644027e5c4b5424945f18de4 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:07:28 -0800 Subject: [PATCH 256/779] RuboCop: enable RSpec/HookArgument cop (#788) --- .rubocop_todo.yml | 8 -------- spec/integration/feed_importing_spec.rb | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eead9e7dd..d400ec7f9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -117,14 +117,6 @@ RSpec/FilePath: Exclude: - 'spec/helpers/authentications_helper_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: implicit, each, example -RSpec/HookArgument: - Exclude: - - 'spec/integration/feed_importing_spec.rb' - # Offense count: 6 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index 291d93dda..8481e2558 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -34,7 +34,7 @@ end describe "Importing for the second time" do - before(:each) do + before do @server.response = sample_data("feeds/feed01_valid_feed/feed.xml") fetch_feed(feed) end From 8e3180a3b08a874cafe6d5606c04c0ee6851d690 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:11:51 -0800 Subject: [PATCH 257/779] RuboCop: enable RSpec/InstanceVariable cop (#789) --- .rubocop_todo.yml | 6 ------ spec/integration/feed_importing_spec.rb | 15 +++++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d400ec7f9..0badbc720 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -117,12 +117,6 @@ RSpec/FilePath: Exclude: - 'spec/helpers/authentications_helper_spec.rb' -# Offense count: 6 -# Configuration parameters: AssignmentOnly. -RSpec/InstanceVariable: - Exclude: - - 'spec/integration/feed_importing_spec.rb' - # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). RSpec/LeadingSubject: diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index 8481e2558..90c0f3771 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -9,13 +9,12 @@ app_require "tasks/fetch_feed" describe "Feed importing" do - before { @server = FeedServer.new } - + let(:server) { FeedServer.new } let(:feed) do Feed.create( name: "Example feed", last_fetched: Time.new(2014, 1, 1), - url: @server.url + url: server.url ) end @@ -28,27 +27,27 @@ describe "Importing for the first time" do it "imports all entries" do - @server.response = sample_data("feeds/feed01_valid_feed/feed.xml") + server.response = sample_data("feeds/feed01_valid_feed/feed.xml") expect { fetch_feed(feed) }.to change(feed.stories, :count).to(5) end end describe "Importing for the second time" do before do - @server.response = sample_data("feeds/feed01_valid_feed/feed.xml") + server.response = sample_data("feeds/feed01_valid_feed/feed.xml") fetch_feed(feed) end context "no new entries" do it "does not create new stories" do - @server.response = sample_data("feeds/feed01_valid_feed/feed.xml") + server.response = sample_data("feeds/feed01_valid_feed/feed.xml") expect { fetch_feed(feed) }.to_not change(feed.stories, :count) end end context "new entries" do it "creates new stories" do - @server.response = + server.response = sample_data("feeds/feed01_valid_feed/feed_updated.xml") expect { fetch_feed(feed) }.to change(feed.stories, :count).by(1) end @@ -71,7 +70,7 @@ # was published. feed.last_fetched = Time.parse("2014-08-12T00:01:00Z") - @server.response = + server.response = sample_data("feeds/feed02_invalid_published_dates/feed.xml") expect { fetch_feed(feed) }.to change { feed.stories.count }.by(1) From 55e91bf3933717150b302f4b6b0ec42def665134 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:24:47 -0800 Subject: [PATCH 258/779] RuboCop: enable RSpec/LeadingSubject cop (#790) --- .rubocop_todo.yml | 13 ------------- spec/fever_api/read_feeds_groups_spec.rb | 4 ++-- spec/fever_api/read_feeds_spec.rb | 4 ++-- spec/fever_api/read_groups_spec.rb | 4 ++-- spec/fever_api/read_items_spec.rb | 4 ++-- spec/fever_api/sync_saved_item_ids_spec.rb | 4 ++-- spec/fever_api/sync_unread_item_ids_spec.rb | 4 ++-- spec/fever_api/write_mark_feed_spec.rb | 4 ++-- spec/fever_api/write_mark_group_spec.rb | 4 ++-- 9 files changed, 16 insertions(+), 29 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0badbc720..59af1bc53 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -117,19 +117,6 @@ RSpec/FilePath: Exclude: - 'spec/helpers/authentications_helper_spec.rb' -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -RSpec/LeadingSubject: - Exclude: - - 'spec/fever_api/read_feeds_groups_spec.rb' - - 'spec/fever_api/read_feeds_spec.rb' - - 'spec/fever_api/read_groups_spec.rb' - - 'spec/fever_api/read_items_spec.rb' - - 'spec/fever_api/sync_saved_item_ids_spec.rb' - - 'spec/fever_api/sync_unread_item_ids_spec.rb' - - 'spec/fever_api/write_mark_feed_spec.rb' - - 'spec/fever_api/write_mark_group_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). RSpec/LetBeforeExamples: diff --git a/spec/fever_api/read_feeds_groups_spec.rb b/spec/fever_api/read_feeds_groups_spec.rb index ce98c876f..21b80bc8f 100644 --- a/spec/fever_api/read_feeds_groups_spec.rb +++ b/spec/fever_api/read_feeds_groups_spec.rb @@ -5,12 +5,12 @@ app_require "fever_api/read_feeds_groups" describe FeverAPI::ReadFeedsGroups do + subject { described_class.new(feed_repository:) } + let(:feed_ids) { [5, 7, 11] } let(:feeds) { feed_ids.map { |id| double("feed", id:, group_id: 1) } } let(:feed_repository) { double("repo") } - subject { described_class.new(feed_repository:) } - it "returns a list of groups requested through feeds" do allow(feed_repository) .to receive_message_chain(:in_group, :order).and_return(feeds) diff --git a/spec/fever_api/read_feeds_spec.rb b/spec/fever_api/read_feeds_spec.rb index a49766d98..3ab78665a 100644 --- a/spec/fever_api/read_feeds_spec.rb +++ b/spec/fever_api/read_feeds_spec.rb @@ -5,14 +5,14 @@ app_require "fever_api/read_feeds" describe FeverAPI::ReadFeeds do + subject { described_class.new(feed_repository:) } + let(:feed_ids) { [5, 7, 11] } let(:feeds) do feed_ids.map { |id| double("feed", id:, as_fever_json: { id: }) } end let(:feed_repository) { double("repo") } - subject { described_class.new(feed_repository:) } - it "returns a list of feeds" do expect(feed_repository).to receive(:list).and_return(feeds) expect(subject.call("feeds" => nil)).to eq( diff --git a/spec/fever_api/read_groups_spec.rb b/spec/fever_api/read_groups_spec.rb index 176429b41..198ecb881 100644 --- a/spec/fever_api/read_groups_spec.rb +++ b/spec/fever_api/read_groups_spec.rb @@ -5,14 +5,14 @@ app_require "fever_api/read_groups" describe FeverAPI::ReadGroups do + subject { described_class.new(group_repository:) } + let(:group1) { double("group1", as_fever_json: { id: 1, title: "IT news" }) } let(:group2) do double("group2", as_fever_json: { id: 2, title: "World news" }) end let(:group_repository) { double("repo") } - subject { described_class.new(group_repository:) } - it "returns a group list if requested" do expect(group_repository).to receive(:list).and_return([group1, group2]) expect(subject.call("groups" => nil)).to eq( diff --git a/spec/fever_api/read_items_spec.rb b/spec/fever_api/read_items_spec.rb index cd71d5511..89ad94741 100644 --- a/spec/fever_api/read_items_spec.rb +++ b/spec/fever_api/read_items_spec.rb @@ -5,10 +5,10 @@ app_require "fever_api/read_items" describe FeverAPI::ReadItems do - let(:story_repository) { double("repo") } - subject { described_class.new(story_repository:) } + let(:story_repository) { double("repo") } + it "returns a list of unread items including total count" do stories = [ double("story", as_fever_json: { id: 5 }), diff --git a/spec/fever_api/sync_saved_item_ids_spec.rb b/spec/fever_api/sync_saved_item_ids_spec.rb index daef8ce43..fad1b5b3c 100644 --- a/spec/fever_api/sync_saved_item_ids_spec.rb +++ b/spec/fever_api/sync_saved_item_ids_spec.rb @@ -5,12 +5,12 @@ app_require "fever_api/sync_saved_item_ids" describe FeverAPI::SyncSavedItemIds do + subject { described_class.new(story_repository:) } + let(:story_ids) { [5, 7, 11] } let(:stories) { story_ids.map { |id| double("story", id:) } } let(:story_repository) { double("repo") } - subject { described_class.new(story_repository:) } - it "returns a list of starred items if requested" do expect(story_repository).to receive(:all_starred).and_return(stories) expect(subject.call("saved_item_ids" => nil)) diff --git a/spec/fever_api/sync_unread_item_ids_spec.rb b/spec/fever_api/sync_unread_item_ids_spec.rb index f46b7ff39..bbdea8c6a 100644 --- a/spec/fever_api/sync_unread_item_ids_spec.rb +++ b/spec/fever_api/sync_unread_item_ids_spec.rb @@ -5,12 +5,12 @@ app_require "fever_api/sync_unread_item_ids" describe FeverAPI::SyncUnreadItemIds do + subject { described_class.new(story_repository:) } + let(:story_ids) { [5, 7, 11] } let(:stories) { story_ids.map { |id| double("story", id:) } } let(:story_repository) { double("repo") } - subject { described_class.new(story_repository:) } - it "returns a list of unread items if requested" do expect(story_repository).to receive(:unread).and_return(stories) expect(subject.call("unread_item_ids" => nil)) diff --git a/spec/fever_api/write_mark_feed_spec.rb b/spec/fever_api/write_mark_feed_spec.rb index ee7c13842..429b37512 100644 --- a/spec/fever_api/write_mark_feed_spec.rb +++ b/spec/fever_api/write_mark_feed_spec.rb @@ -5,11 +5,11 @@ app_require "fever_api/write_mark_feed" describe FeverAPI::WriteMarkFeed do + subject { described_class.new(marker_class:) } + let(:feed_marker) { double("feed marker") } let(:marker_class) { double("marker class") } - subject { described_class.new(marker_class:) } - it "instantiates a feed marker and calls mark_feed_as_read if requested" do expect(marker_class) .to receive(:new).with(5, 1234567890).and_return(feed_marker) diff --git a/spec/fever_api/write_mark_group_spec.rb b/spec/fever_api/write_mark_group_spec.rb index 16a955cfa..b0f209704 100644 --- a/spec/fever_api/write_mark_group_spec.rb +++ b/spec/fever_api/write_mark_group_spec.rb @@ -5,11 +5,11 @@ app_require "fever_api/write_mark_group" describe FeverAPI::WriteMarkGroup do + subject { described_class.new(marker_class:) } + let(:group_marker) { double("group marker") } let(:marker_class) { double("marker class") } - subject { described_class.new(marker_class:) } - it "instantiates a group marker and calls mark_group_as_read if requested" do expect(marker_class) .to receive(:new).with(5, 1234567890).and_return(group_marker) From c9b76bbe3eb31197d8c2559317f5da21fb9cfa90 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:30:31 -0800 Subject: [PATCH 259/779] RuboCop: enable RSpec/LetBeforeExamples cop (#791) --- .rubocop_todo.yml | 6 ------ spec/repositories/feed_repository_spec.rb | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 59af1bc53..9ba0bce1c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -117,12 +117,6 @@ RSpec/FilePath: Exclude: - 'spec/helpers/authentications_helper_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -RSpec/LetBeforeExamples: - Exclude: - - 'spec/repositories/feed_repository_spec.rb' - # Offense count: 4 RSpec/MessageChain: Exclude: diff --git a/spec/repositories/feed_repository_spec.rb b/spec/repositories/feed_repository_spec.rb index f9da37222..fbcbaef5d 100644 --- a/spec/repositories/feed_repository_spec.rb +++ b/spec/repositories/feed_repository_spec.rb @@ -60,9 +60,8 @@ expect(feed.last_fetched).to eq timestamp end - let(:weird_timestamp) { Time.parse("Mon, 01 Jan 0001 00:00:00 +0100") } - it "rejects weird timestamps" do + weird_timestamp = Time.parse("Mon, 01 Jan 0001 00:00:00 +0100") feed = Feed.new(last_fetched: timestamp) described_class.update_last_fetched(feed, weird_timestamp) From 02ea93052c26a59f84f19579d8ec20dd7adb2678 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:34:54 -0800 Subject: [PATCH 260/779] RuboCop: enable RSpec/NoExpectationExample cop (#792) --- .rubocop_todo.yml | 7 ------- spec/commands/stories/mark_group_as_read_spec.rb | 7 ++++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9ba0bce1c..f5d137377 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -211,13 +211,6 @@ RSpec/NestedGroups: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/integration/feed_importing_spec.rb' -# Offense count: 2 -# Configuration parameters: AllowedPatterns. -# AllowedPatterns: ^expect_, ^assert_ -RSpec/NoExpectationExample: - Exclude: - - 'spec/commands/stories/mark_group_as_read_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/spec/commands/stories/mark_group_as_read_spec.rb b/spec/commands/stories/mark_group_as_read_spec.rb index 570e19127..1f8f51d13 100644 --- a/spec/commands/stories/mark_group_as_read_spec.rb +++ b/spec/commands/stories/mark_group_as_read_spec.rb @@ -31,17 +31,18 @@ def run_command(group_id) end context "SPARKS_GROUP_ID and KINDLING_GROUP_ID" do - before do + it "marks as read all feeds when group is 0" do expect(stories).to receive(:update_all).with(is_read: true) expect(repo).to receive(:fetch_unread_by_timestamp).and_return(stories) - end - it "marks as read all feeds when group is 0" do command = run_command(0) command.mark_group_as_read end it "marks as read all feeds when group is -1" do + expect(stories).to receive(:update_all).with(is_read: true) + expect(repo).to receive(:fetch_unread_by_timestamp).and_return(stories) + command = run_command(-1) command.mark_group_as_read end From 85345368f3aa5d915bd6ef05b957a8fe8c190a4a Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:39:00 -0800 Subject: [PATCH 261/779] RuboCop: enable RSpec/NotToNot cop (#793) --- .rubocop_todo.yml | 8 -------- spec/integration/feed_importing_spec.rb | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f5d137377..f7df262a4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -211,14 +211,6 @@ RSpec/NestedGroups: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/integration/feed_importing_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: not_to, to_not -RSpec/NotToNot: - Exclude: - - 'spec/integration/feed_importing_spec.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index 90c0f3771..d6227295b 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -41,7 +41,7 @@ context "no new entries" do it "does not create new stories" do server.response = sample_data("feeds/feed01_valid_feed/feed.xml") - expect { fetch_feed(feed) }.to_not change(feed.stories, :count) + expect { fetch_feed(feed) }.not_to change(feed.stories, :count) end end From f62f0bcb8c2b4521693e1e05acdf54631b6781b4 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:43:27 -0800 Subject: [PATCH 262/779] RuboCop: enable RSpec/ReturnFromStub cop (#794) --- .rubocop_todo.yml | 8 -------- spec/tasks/remove_old_stories_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f7df262a4..a16d1ab06 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -211,14 +211,6 @@ RSpec/NestedGroups: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/integration/feed_importing_spec.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: and_return, block -RSpec/ReturnFromStub: - Exclude: - - 'spec/tasks/remove_old_stories_spec.rb' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredLet: diff --git a/spec/tasks/remove_old_stories_spec.rb b/spec/tasks/remove_old_stories_spec.rb index 3ba94dde0..960eedbf6 100644 --- a/spec/tasks/remove_old_stories_spec.rb +++ b/spec/tasks/remove_old_stories_spec.rb @@ -12,7 +12,7 @@ end it "passes along the number of days to the story repository query" do - allow(described_class).to receive(:pruned_feeds) { [] } + allow(described_class).to receive(:pruned_feeds).and_return([]) expect(StoryRepository).to receive(:unstarred_read_stories_older_than) .with(7).and_return(stories_mock) @@ -21,7 +21,7 @@ end it "requests deletion of all old stories" do - allow(described_class).to receive(:pruned_feeds) { [] } + allow(described_class).to receive(:pruned_feeds).and_return([]) allow(StoryRepository) .to receive(:unstarred_read_stories_older_than) { stories_mock } From 6d8d26feb1c84f409592e73bb2a0115c700ba429 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:47:54 -0800 Subject: [PATCH 263/779] RuboCop: enable RSpec/ScatteredLet cop (#795) --- .rubocop_todo.yml | 7 ------- spec/commands/feeds/import_from_opml_spec.rb | 5 ++--- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a16d1ab06..e763e1f3f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -211,13 +211,6 @@ RSpec/NestedGroups: - 'spec/commands/feeds/add_new_feed_spec.rb' - 'spec/integration/feed_importing_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -RSpec/ScatteredLet: - Exclude: - - 'spec/commands/feeds/import_from_opml_spec.rb' - - 'spec/repositories/feed_repository_spec.rb' - # Offense count: 94 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 0b4a08643..9e668ae30 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -13,6 +13,8 @@ ) ) end + let(:group1) { Group.find_by_name("Football News") } + let(:group2) { Group.find_by_name("RoR") } def import described_class.import(subscriptions) @@ -23,9 +25,6 @@ def import Group.delete_all end - let(:group1) { Group.find_by_name("Football News") } - let(:group2) { Group.find_by_name("RoR") } - context "adding group_id for existing feeds" do let!(:feed1) do Feed.create(name: "TMW Football Transfer News", url: "http://www.transfermarketweb.com/rss") From 2af578ebba2fb01ecb53389b567a2b773fa58015 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:52:09 -0800 Subject: [PATCH 264/779] RuboCop: disable Rails/BulkChangeTable cop (#796) --- .rubocop.yml | 1 + .rubocop_todo.yml | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index de898a51e..eb9f20122 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -40,6 +40,7 @@ Bundler/GemComment: { Enabled: false } Bundler/GemVersion: { Enabled: false } Layout/SingleLineBlockChain: { Enabled: false } Lint/ConstantResolution: { Enabled: false } +Rails/BulkChangeTable: { Enabled: false } RSpec/AlignLeftLetBrace: { Enabled: false } RSpec/AlignRightLetBrace: { Enabled: false } RSpec/StubbedMock: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e763e1f3f..c7fc51433 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -237,15 +237,6 @@ RSpec/VerifiedDoubles: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 2 -# Configuration parameters: Database, Include. -# SupportedDatabases: mysql, postgresql -# Include: db/migrate/*.rb -Rails/BulkChangeTable: - Exclude: - - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' - - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' - # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. From c9fbda3728e51b67870ed697a055220be7d1c06e Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 16:59:33 -0800 Subject: [PATCH 265/779] RuboCop: enable Rails/DynamicFindBy cop (#797) --- .rubocop_todo.yml | 10 ---------- spec/commands/feeds/import_from_opml_spec.rb | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c7fc51433..700657864 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -237,16 +237,6 @@ RSpec/VerifiedDoubles: - 'spec/tasks/remove_old_stories_spec.rb' - 'spec/utils/feed_discovery_spec.rb' -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. -# Whitelist: find_by_sql, find_by_token_for -# AllowedMethods: find_by_sql, find_by_token_for -# AllowedReceivers: Gem::Specification, page -Rails/DynamicFindBy: - Exclude: - - 'spec/commands/feeds/import_from_opml_spec.rb' - # Offense count: 1 # Configuration parameters: Include. # Include: app/models/**/*.rb diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 9e668ae30..2c6642826 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -13,8 +13,8 @@ ) ) end - let(:group1) { Group.find_by_name("Football News") } - let(:group2) { Group.find_by_name("RoR") } + let(:group1) { Group.find_by(name: "Football News") } + let(:group2) { Group.find_by(name: "RoR") } def import described_class.import(subscriptions) @@ -93,7 +93,7 @@ def import it "does not create empty group" do described_class.import(subscriptions) - expect(Group.find_by_name("Empty Group")).to be_nil + expect(Group.find_by(name: "Empty Group")).to be_nil end end From 25100c451e62c8df5889fbfa0350f136b4c180c0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 17:03:46 -0800 Subject: [PATCH 266/779] RuboCop: enable a couple of Rails/Where cops (#798) --- .rubocop_todo.yml | 13 ------------- app/models/feed.rb | 2 +- app/repositories/story_repository.rb | 2 +- spec/commands/feeds/import_from_opml_spec.rb | 2 +- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 700657864..12e098106 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -347,19 +347,6 @@ Rails/Validation: - 'app/models/feed.rb' - 'app/models/story.rb' -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -Rails/WhereEquals: - Exclude: - - 'app/models/feed.rb' - - 'app/repositories/story_repository.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/WhereNot: - Exclude: - - 'spec/commands/feeds/import_from_opml_spec.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedVars. diff --git a/app/models/feed.rb b/app/models/feed.rb index 266bd32e2..29ae94305 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -17,7 +17,7 @@ def status_bubble end def unread_stories - stories.where("is_read = ?", false) + stories.where(is_read: false) end def as_fever_json diff --git a/app/repositories/story_repository.rb b/app/repositories/story_repository.rb index 1380b7045..bee6f822d 100644 --- a/app/repositories/story_repository.rb +++ b/app/repositories/story_repository.rb @@ -61,7 +61,7 @@ def self.unread_since_id(since_id) end def self.feed(feed_id) - Story.where("feed_id = ?", feed_id).order("published desc").includes(:feed) + Story.where(feed_id:).order("published desc").includes(:feed) end def self.read(page = 1) diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 2c6642826..16d22d658 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -104,7 +104,7 @@ def import it "does not create any new group for feeds without group" do described_class.import(subscriptions) - expect(Group.where("id NOT IN (?)", [group1.id, group2.id]).count).to eq 0 + expect(Group.where.not(id: [group1.id, group2.id]).count).to eq 0 end it "creates feeds without group_id" do From 24f9cacd911b00d91ba00ff237d9e5eb0770b5af Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 17:03:53 -0800 Subject: [PATCH 267/779] Update all Bundler dependencies (2023-01-04) (#772) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 16 ++++++++-------- app/commands/stories/mark_all_as_read.rb | 8 ++++---- app/commands/users/create_user.rb | 8 ++++---- app/tasks/fetch_feeds.rb | 8 ++++---- app/utils/sample_story.rb | 2 +- .../20130821020313_update_nil_entry_ids.rb | 2 +- ...2_use_text_datatype_for_title_and_entry_id.rb | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4f0243833..9a1cbe79e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -136,7 +136,7 @@ GEM method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.1) - minitest (5.16.3) + minitest (5.17.0) multi_json (1.15.0) multi_xml (0.6.0) mustermann (3.0.0) @@ -155,7 +155,7 @@ GEM mini_portile2 (~> 2.8.0) racc (~> 1.4) parallel (1.22.1) - parser (3.1.3.0) + parser (3.2.0.0) ast (~> 2.4.1) pg (1.4.5) pry (0.14.1) @@ -165,10 +165,10 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) public_suffix (5.0.1) - puma (6.0.1) + puma (6.0.2) nio4r (~> 2.0) racc (1.6.2) - rack (2.2.4) + rack (2.2.5) rack-protection (3.0.5) rack rack-ssl (1.4.1) @@ -232,17 +232,17 @@ GEM rspec-mocks (~> 3.11) rspec-support (~> 3.11) rspec-support (3.12.0) - rubocop (1.41.1) + rubocop (1.42.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.23.0, < 2.0) + rubocop-ast (>= 1.24.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.24.0) + rubocop-ast (1.24.1) parser (>= 3.1.1.0) rubocop-rails (2.17.4) activesupport (>= 4.2.0) @@ -303,7 +303,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.3.0) + unicode-display_width (2.4.1) webmock (3.18.1) addressable (>= 2.8.0) crack (>= 0.3.2) diff --git a/app/commands/stories/mark_all_as_read.rb b/app/commands/stories/mark_all_as_read.rb index c13d3aa76..62d060a05 100644 --- a/app/commands/stories/mark_all_as_read.rb +++ b/app/commands/stories/mark_all_as_read.rb @@ -3,15 +3,15 @@ require_relative "../../repositories/story_repository" class MarkAllAsRead + def self.call(*args) + new(*args).call + end + def initialize(story_ids, repository = StoryRepository) @story_ids = story_ids @repo = repository end - def self.call(*args) - new(*args).call - end - def call @repo.fetch_by_ids(@story_ids).update_all(is_read: true) end diff --git a/app/commands/users/create_user.rb b/app/commands/users/create_user.rb index cb1765ff7..b183135ef 100644 --- a/app/commands/users/create_user.rb +++ b/app/commands/users/create_user.rb @@ -3,14 +3,14 @@ require_relative "../../utils/api_key" class CreateUser - def initialize(repository = User) - @repo = repository - end - def self.call(password) new.call(password) end + def initialize(repository = User) + @repo = repository + end + def call(password) @repo.delete_all @repo.create( diff --git a/app/tasks/fetch_feeds.rb b/app/tasks/fetch_feeds.rb index 8a45c01c9..b7d351551 100644 --- a/app/tasks/fetch_feeds.rb +++ b/app/tasks/fetch_feeds.rb @@ -7,6 +7,10 @@ require "delayed_job_active_record" class FetchFeeds + def self.enqueue(feeds) + new(feeds).prepare_to_delay.delay.fetch_all + end + def initialize(feeds, pool = nil) @pool = pool @feeds = feeds @@ -36,8 +40,4 @@ def prepare_to_delay @feeds = [] self end - - def self.enqueue(feeds) - new(feeds).prepare_to_delay.delay.fetch_all - end end diff --git a/app/utils/sample_story.rb b/app/utils/sample_story.rb index 16c0bd1b4..6db079814 100644 --- a/app/utils/sample_story.rb +++ b/app/utils/sample_story.rb @@ -24,7 +24,7 @@ SampleStory = Struct.new(:source, :title, :lead, :is_read, :published) do def id - -1 * rand(100) + rand(100) * -1 end def headline diff --git a/db/migrate/20130821020313_update_nil_entry_ids.rb b/db/migrate/20130821020313_update_nil_entry_ids.rb index 1f3a90416..f0f7729b5 100644 --- a/db/migrate/20130821020313_update_nil_entry_ids.rb +++ b/db/migrate/20130821020313_update_nil_entry_ids.rb @@ -8,7 +8,7 @@ def up end end - def self.down + def down # skip end end diff --git a/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb b/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb index b2ad28328..1d065d2b1 100644 --- a/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb +++ b/db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb @@ -6,7 +6,7 @@ def up change_column :stories, :entry_id, :text end - def self.down + def down change_column :stories, :title, :string change_column :stories, :entry_id, :string end From 4518995ed98c82776968fd444878f0d2f08ebdd3 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 17:13:11 -0800 Subject: [PATCH 268/779] RuboCop: add parens for Rakefile (#799) --- .rubocop.yml | 2 ++ .rubocop_todo.yml | 1 - Rakefile | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index eb9f20122..5e7e26fad 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,6 +22,8 @@ Style/MethodCallWithArgsParentheses: - to - not_to - describe + - require + - task Style/StringLiterals: { EnforcedStyle: double_quotes } Style/SymbolArray: { EnforcedStyle: brackets } Style/WordArray: { EnforcedStyle: brackets } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 12e098106..adcde89f8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -360,7 +360,6 @@ Style/FetchEnvVar: # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: Exclude: - - 'Rakefile' - 'app.rb' - 'app/commands/feeds/export_to_opml.rb' - 'app/models/feed.rb' diff --git a/Rakefile b/Rakefile index 87fc524b4..c15fe9554 100644 --- a/Rakefile +++ b/Rakefile @@ -37,7 +37,7 @@ task :lazy_fetch do end FeedRepository.list.each do |feed| - Delayed::Job.enqueue FetchFeedJob.new(feed.id) + Delayed::Job.enqueue(FetchFeedJob.new(feed.id)) end end From 67370f7c2477e16064dc0c60bf2e6fc3353cc8d7 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 17:17:52 -0800 Subject: [PATCH 269/779] RuboCop: add parens for app files (#800) --- .rubocop_todo.yml | 5 ----- app.rb | 6 +++--- app/commands/feeds/export_to_opml.rb | 2 +- app/models/feed.rb | 2 +- app/tasks/change_password.rb | 2 +- app/tasks/fetch_feed.rb | 4 ++-- 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index adcde89f8..ab8b2a03e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -360,11 +360,6 @@ Style/FetchEnvVar: # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: Exclude: - - 'app.rb' - - 'app/commands/feeds/export_to_opml.rb' - - 'app/models/feed.rb' - - 'app/tasks/change_password.rb' - - 'app/tasks/fetch_feed.rb' - 'config/asset_pipeline.rb' - 'config/puma.rb' - 'db/migrate/20130409010818_create_feeds.rb' diff --git a/app.rb b/app.rb index 24225afb0..d74d6df97 100644 --- a/app.rb +++ b/app.rb @@ -69,15 +69,15 @@ class Stringer < Sinatra::Base include Sinatra::AuthenticationHelpers def render_partial(name, locals = {}) - erb "partials/_#{name}".to_sym, layout: false, locals: + erb("partials/_#{name}".to_sym, layout: false, locals:) end def render_js_template(name) - erb "js/templates/_#{name}.js".to_sym, layout: false + erb("js/templates/_#{name}.js".to_sym, layout: false) end def render_js(name, locals = {}) - erb "js/#{name}.js".to_sym, layout: false, locals: + erb("js/#{name}.js".to_sym, layout: false, locals:) end def t(*args, **kwargs) diff --git a/app/commands/feeds/export_to_opml.rb b/app/commands/feeds/export_to_opml.rb index b6a859089..0ca5754eb 100644 --- a/app/commands/feeds/export_to_opml.rb +++ b/app/commands/feeds/export_to_opml.rb @@ -11,7 +11,7 @@ def to_xml builder = Nokogiri::XML::Builder.new do |xml| xml.opml(version: "1.0") do - xml.head { xml.title "Feeds from Stringer" } + xml.head { xml.title("Feeds from Stringer") } xml.body do @feeds.each do |feed| xml.outline( diff --git a/app/models/feed.rb b/app/models/feed.rb index 29ae94305..b214aba50 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -3,7 +3,7 @@ require_relative "./application_record" class Feed < ApplicationRecord - has_many :stories, -> { order "published desc" }, dependent: :delete_all + has_many :stories, -> { order("published desc") }, dependent: :delete_all belongs_to :group validates_uniqueness_of :url diff --git a/app/tasks/change_password.rb b/app/tasks/change_password.rb index b59e6fb30..c8445566d 100644 --- a/app/tasks/change_password.rb +++ b/app/tasks/change_password.rb @@ -17,7 +17,7 @@ def initialize( def change_password while (password = ask_password) != ask_confirmation - @output.puts I18n.t("first_run.flash.passwords_dont_match") + @output.puts(I18n.t("first_run.flash.passwords_dont_match")) end @command.change_user_password(password) end diff --git a/app/tasks/fetch_feed.rb b/app/tasks/fetch_feed.rb index 5278f1423..4d839884e 100644 --- a/app/tasks/fetch_feed.rb +++ b/app/tasks/fetch_feed.rb @@ -33,7 +33,7 @@ def fetch rescue StandardError => e FeedRepository.set_status(:red, @feed) - @logger&.error "Something went wrong when parsing #{@feed.url}: #{e}" + @logger&.error("Something went wrong when parsing #{@feed.url}: #{e}") end private @@ -44,7 +44,7 @@ def fetch_raw_feed end def feed_not_modified - @logger&.info "#{@feed.url} has not been modified since last fetch" + @logger&.info("#{@feed.url} has not been modified since last fetch") end def feed_modified(raw_feed) From e6dc80f0ab52c7daad8373d5c0fb7bad6a9600bd Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 17:24:00 -0800 Subject: [PATCH 270/779] RuboCop: add parens for command specs (#801) --- .rubocop_todo.yml | 6 ------ spec/commands/feeds/add_new_feed_spec.rb | 2 +- spec/commands/feeds/export_to_opml_spec.rb | 10 +++++----- spec/commands/feeds/import_from_opml_spec.rb | 10 +++++----- spec/commands/find_new_stories_spec.rb | 4 ++-- spec/commands/users/change_user_password_spec.rb | 4 ++-- spec/commands/users/sign_in_user_spec.rb | 2 +- 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ab8b2a03e..58db54f8f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -381,12 +381,6 @@ Style/MethodCallWithArgsParentheses: - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' - - 'spec/commands/feeds/add_new_feed_spec.rb' - - 'spec/commands/feeds/export_to_opml_spec.rb' - - 'spec/commands/feeds/import_from_opml_spec.rb' - - 'spec/commands/find_new_stories_spec.rb' - - 'spec/commands/users/change_user_password_spec.rb' - - 'spec/commands/users/sign_in_user_spec.rb' - 'spec/fever_api_spec.rb' - 'spec/helpers/url_helpers_spec.rb' - 'spec/integration/feed_importing_spec.rb' diff --git a/spec/commands/feeds/add_new_feed_spec.rb b/spec/commands/feeds/add_new_feed_spec.rb index dc2df8187..93a17e731 100644 --- a/spec/commands/feeds/add_new_feed_spec.rb +++ b/spec/commands/feeds/add_new_feed_spec.rb @@ -28,7 +28,7 @@ result = described_class.add("http://feed.com", discoverer, repo) - expect(result).to be feed + expect(result).to be(feed) end context "title includes a script tag" do diff --git a/spec/commands/feeds/export_to_opml_spec.rb b/spec/commands/feeds/export_to_opml_spec.rb index 01c89a82e..9d136f19a 100644 --- a/spec/commands/feeds/export_to_opml_spec.rb +++ b/spec/commands/feeds/export_to_opml_spec.rb @@ -15,10 +15,10 @@ outlines = Nokogiri.XML(result).xpath("//body//outline") expect(outlines.size).to eq(2) - expect(outlines.first["title"]).to eq feed_one.name - expect(outlines.first["xmlUrl"]).to eq feed_one.url - expect(outlines.last["title"]).to eq feed_two.name - expect(outlines.last["xmlUrl"]).to eq feed_two.url + expect(outlines.first["title"]).to eq(feed_one.name) + expect(outlines.first["xmlUrl"]).to eq(feed_one.url) + expect(outlines.last["title"]).to eq(feed_two.name) + expect(outlines.last["xmlUrl"]).to eq(feed_two.url) end it "handles empty feeds" do @@ -32,7 +32,7 @@ result = described_class.new(feeds).to_xml title = Nokogiri.XML(result).xpath("//head//title").first - expect(title.content).to eq "Feeds from Stringer" + expect(title.content).to eq("Feeds from Stringer") end end end diff --git a/spec/commands/feeds/import_from_opml_spec.rb b/spec/commands/feeds/import_from_opml_spec.rb index 16d22d658..00bb8722a 100644 --- a/spec/commands/feeds/import_from_opml_spec.rb +++ b/spec/commands/feeds/import_from_opml_spec.rb @@ -53,8 +53,8 @@ def import it "sets group_id for existing feeds" do described_class.import(subscriptions) - expect(feed1.reload.group).to eq group1 - expect(feed2.reload.group).to eq group2 + expect(feed1.reload.group).to eq(group1) + expect(feed2.reload.group).to eq(group2) end end @@ -86,8 +86,8 @@ def import it "sets group" do described_class.import(subscriptions) - expect(feed1.first.group).to eq group1 - expect(feed2.first.group).to eq group2 + expect(feed1.first.group).to eq(group1) + expect(feed2.first.group).to eq(group2) end it "does not create empty group" do @@ -104,7 +104,7 @@ def import it "does not create any new group for feeds without group" do described_class.import(subscriptions) - expect(Group.where.not(id: [group1.id, group2.id]).count).to eq 0 + expect(Group.where.not(id: [group1.id, group2.id]).count).to eq(0) end it "creates feeds without group_id" do diff --git a/spec/commands/find_new_stories_spec.rb b/spec/commands/find_new_stories_spec.rb index 903c3447f..4ae39085b 100644 --- a/spec/commands/find_new_stories_spec.rb +++ b/spec/commands/find_new_stories_spec.rb @@ -32,7 +32,7 @@ .to receive(:exists?).with("story2", 1).and_return(false) result = described_class.new(feed, 1, Time.new(2013, 1, 2)).new_stories - expect(result).to eq [story2] + expect(result).to eq([story2]) end end @@ -47,7 +47,7 @@ Time.new(2013, 1, 3), "old-story" ).new_stories - expect(result).to eq [new_story] + expect(result).to eq([new_story]) end it "ignores stories older than 3 days" do diff --git a/spec/commands/users/change_user_password_spec.rb b/spec/commands/users/change_user_password_spec.rb index f109d666b..6c89be12e 100644 --- a/spec/commands/users/change_user_password_spec.rb +++ b/spec/commands/users/change_user_password_spec.rb @@ -20,7 +20,7 @@ command = described_class.new(repo) result = command.change_user_password(new_password) - expect(BCrypt::Password.new(result.password_digest)).to eq new_password + expect(BCrypt::Password.new(result.password_digest)).to eq(new_password) end it "changes the API key of the user" do @@ -30,7 +30,7 @@ command = described_class.new(repo) result = command.change_user_password(new_password) - expect(result.api_key).to eq ApiKey.compute(new_password) + expect(result.api_key).to eq(ApiKey.compute(new_password)) end end end diff --git a/spec/commands/users/sign_in_user_spec.rb b/spec/commands/users/sign_in_user_spec.rb index e5dbc0137..e87cd515d 100644 --- a/spec/commands/users/sign_in_user_spec.rb +++ b/spec/commands/users/sign_in_user_spec.rb @@ -16,7 +16,7 @@ it "returns the user if the password is valid" do result = described_class.sign_in(valid_password, repo) - expect(result.id).to eq 1 + expect(result.id).to eq(1) end it "returns nil if password is invalid" do From bae43012ca329985f94128e82837dfc5ca3e6522 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 17:28:44 -0800 Subject: [PATCH 271/779] RuboCop: add parens for config files (#802) --- .rubocop_todo.yml | 2 -- config/asset_pipeline.rb | 36 ++++++++++++++++++++---------------- config/puma.rb | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 58db54f8f..886c90866 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -360,8 +360,6 @@ Style/FetchEnvVar: # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: Exclude: - - 'config/asset_pipeline.rb' - - 'config/puma.rb' - 'db/migrate/20130409010818_create_feeds.rb' - 'db/migrate/20130409010826_create_stories.rb' - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' diff --git a/config/asset_pipeline.rb b/config/asset_pipeline.rb index 569219604..406b79dd7 100644 --- a/config/asset_pipeline.rb +++ b/config/asset_pipeline.rb @@ -2,10 +2,10 @@ module AssetPipeline def registered(app) - app.set :sprockets, Sprockets::Environment.new(app.root) + app.set(:sprockets, Sprockets::Environment.new(app.root)) ["assets", "stylesheets", "javascripts"].each do |path| - app.get "/#{path}/*" do + app.get("/#{path}/*") do env["PATH_INFO"].sub!(%r{^/#{path}}, "") settings.sprockets.call(env) end @@ -20,29 +20,33 @@ def registered(app) private def append_paths(app) - app.sprockets.append_path File.join(app.root, "app", "assets") - app.sprockets.append_path File.join( - app.root, - "app", - "assets", - "stylesheets" + app.sprockets.append_path(File.join(app.root, "app", "assets")) + app.sprockets.append_path( + File.join( + app.root, + "app", + "assets", + "stylesheets" + ) ) - app.sprockets.append_path File.join( - app.root, - "app", - "assets", - "javascripts" + app.sprockets.append_path( + File.join( + app.root, + "app", + "assets", + "javascripts" + ) ) end def configure_development(app) - app.configure :development, :test do + app.configure(:development, :test) do app.sprockets.cache = Sprockets::Cache::FileStore.new("./tmp") end end def configure_production(app) - app.configure :production, :test do + app.configure(:production, :test) do app.sprockets.css_compressor = :scss app.sprockets.js_compressor = :uglify end @@ -56,7 +60,7 @@ def register_helpers(app) config.digest = true if app.production? end - app.helpers Sprockets::Helpers + app.helpers(Sprockets::Helpers) end module_function :registered, diff --git a/config/puma.rb b/config/puma.rb index e439e2ca5..c36d06d49 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -workers workers Integer(ENV.fetch("WEB_CONCURRENCY", 1)) +workers Integer(ENV.fetch("WEB_CONCURRENCY", 1)) threads_count = Integer(ENV.fetch("MAX_THREADS", 2)) threads threads_count, threads_count From 744c96bc9c7b1e32ac6faf6e87216a408f7b2c05 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 17:32:50 -0800 Subject: [PATCH 272/779] RuboCop: add parens for remaining specs (#803) --- .rubocop_todo.yml | 11 ---------- spec/fever_api_spec.rb | 4 ++-- spec/helpers/url_helpers_spec.rb | 14 ++++++------- spec/integration/feed_importing_spec.rb | 4 ++-- spec/models/story_spec.rb | 4 ++-- spec/repositories/feed_repository_spec.rb | 14 ++++++------- spec/repositories/story_repository_spec.rb | 18 ++++++++-------- spec/spec_helper.rb | 4 ++-- spec/utils/content_sanitizer_spec.rb | 8 ++++---- spec/utils/feed_discovery_spec.rb | 4 ++-- spec/utils/i18n_support_spec.rb | 8 ++++---- spec/utils/opml_parser_spec.rb | 24 +++++++++++----------- 12 files changed, 53 insertions(+), 64 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 886c90866..a7b450f66 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -379,17 +379,6 @@ Style/MethodCallWithArgsParentheses: - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' - - 'spec/fever_api_spec.rb' - - 'spec/helpers/url_helpers_spec.rb' - - 'spec/integration/feed_importing_spec.rb' - - 'spec/models/story_spec.rb' - - 'spec/repositories/feed_repository_spec.rb' - - 'spec/repositories/story_repository_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/utils/content_sanitizer_spec.rb' - - 'spec/utils/feed_discovery_spec.rb' - - 'spec/utils/i18n_support_spec.rb' - - 'spec/utils/opml_parser_spec.rb' # Offense count: 10 # This cop supports safe autocorrection (--autocorrect). diff --git a/spec/fever_api_spec.rb b/spec/fever_api_spec.rb index 88df51341..9d3715b6a 100644 --- a/spec/fever_api_spec.rb +++ b/spec/fever_api_spec.rb @@ -55,7 +55,7 @@ def last_response_as_object describe "#get" do def make_request(extra_headers = {}) - get "/", headers.merge(extra_headers) + get("/", headers.merge(extra_headers)) end it "returns standard answer" do @@ -191,7 +191,7 @@ def make_request(extra_headers = {}) describe "#post" do def make_request(extra_headers = {}) - post "/", headers.merge(extra_headers) + post("/", headers.merge(extra_headers)) end it "commands to mark story as read" do diff --git a/spec/helpers/url_helpers_spec.rb b/spec/helpers/url_helpers_spec.rb index 8e8a7a5b3..0c7024c30 100644 --- a/spec/helpers/url_helpers_spec.rb +++ b/spec/helpers/url_helpers_spec.rb @@ -14,7 +14,7 @@ it "preserves existing absolute urls" do content = 'bar' - expect(helper.expand_absolute_urls(content, nil)).to eq content + expect(helper.expand_absolute_urls(content, nil)).to eq(content) end it "replaces relative urls in a, img and video tags" do @@ -27,7 +27,7 @@ HTML result = helper.expand_absolute_urls(content, "http://oodl.io/d/") - expect(result.delete("\n")).to eq <<~HTML.delete("\n") + expect(result.delete("\n")).to eq(<<~HTML.delete("\n"))
    tee @@ -38,7 +38,7 @@ end it "handles empty body" do - expect(helper.expand_absolute_urls("", nil)).to eq "" + expect(helper.expand_absolute_urls("", nil)).to eq("") end it "doesn't modify tags that do not have url attributes" do @@ -51,7 +51,7 @@ HTML result = helper.expand_absolute_urls(content, "http://oodl.io/d/") - expect(result.delete("\n")).to eq <<~HTML.delete("\n") + expect(result.delete("\n")).to eq(<<~HTML.delete("\n"))
    @@ -84,7 +84,7 @@ url = helper.normalize_url("//blog.golang.org/context", feed_url) - expect(url).to eq "#{scheme}://blog.golang.org/context" + expect(url).to eq("#{scheme}://blog.golang.org/context") end end @@ -100,7 +100,7 @@ url = helper.normalize_url( "//blog.golang.org/context", "//blog.golang.org/feed.atom" ) - expect(url).to eq "http://blog.golang.org/context" + expect(url).to eq("http://blog.golang.org/context") end it "resolves relative urls" do @@ -108,7 +108,7 @@ "/progrium/dokku/releases/tag/v0.4.4", "https://github.com/progrium/dokku/releases.atom" ) - expect(url).to eq "https://github.com/progrium/dokku/releases/tag/v0.4.4" + expect(url).to eq("https://github.com/progrium/dokku/releases/tag/v0.4.4") end end end diff --git a/spec/integration/feed_importing_spec.rb b/spec/integration/feed_importing_spec.rb index d6227295b..cd4033906 100644 --- a/spec/integration/feed_importing_spec.rb +++ b/spec/integration/feed_importing_spec.rb @@ -22,7 +22,7 @@ before do # articles older than 3 days are ignored, so freeze time within # applicable range of the stories in the sample feed - Timecop.freeze Time.parse("2014-08-15T17:30:00Z") + Timecop.freeze(Time.parse("2014-08-15T17:30:00Z")) end describe "Importing for the first time" do @@ -56,7 +56,7 @@ end describe "Feed with incorrect pubdates" do - before { Timecop.freeze Time.parse("2014-08-12T17:30:00Z") } + before { Timecop.freeze(Time.parse("2014-08-12T17:30:00Z")) } context "has been fetched before" do it "imports all new stories" do diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index 262f0ba34..43f1b78d0 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -25,7 +25,7 @@ it "strips html out" do story.title = "Super cool stuff" - expect(story.headline).to eq "Super cool stuff" + expect(story.headline).to eq("Super cool stuff") end end @@ -36,7 +36,7 @@ it "strips html out" do story.body = "Yo dawg" - expect(story.lead).to eq "Yo dawg" + expect(story.lead).to eq("Yo dawg") end end diff --git a/spec/repositories/feed_repository_spec.rb b/spec/repositories/feed_repository_spec.rb index fbcbaef5d..fab1522bc 100644 --- a/spec/repositories/feed_repository_spec.rb +++ b/spec/repositories/feed_repository_spec.rb @@ -19,7 +19,7 @@ result = described_class.fetch(feed.id) - expect(result).to eq feed + expect(result).to eq(feed) end end @@ -44,8 +44,8 @@ described_class.update_feed(feed, "Test Feed", "example.com/feed") - expect(feed.name).to eq "Test Feed" - expect(feed.url).to eq "example.com/feed" + expect(feed.name).to eq("Test Feed") + expect(feed.url).to eq("example.com/feed") end end @@ -57,7 +57,7 @@ described_class.update_last_fetched(feed, timestamp) - expect(feed.last_fetched).to eq timestamp + expect(feed.last_fetched).to eq(timestamp) end it "rejects weird timestamps" do @@ -66,7 +66,7 @@ described_class.update_last_fetched(feed, weird_timestamp) - expect(feed.last_fetched).to eq timestamp + expect(feed.last_fetched).to eq(timestamp) end it "doesn't update if timestamp is nil" do @@ -74,7 +74,7 @@ described_class.update_last_fetched(feed, nil) - expect(feed.last_fetched).to eq timestamp + expect(feed.last_fetched).to eq(timestamp) end it "doesn't update if timestamp is older than the current value" do @@ -83,7 +83,7 @@ described_class.update_last_fetched(feed, one_week_ago) - expect(feed.last_fetched).to eq timestamp + expect(feed.last_fetched).to eq(timestamp) end end diff --git a/spec/repositories/story_repository_spec.rb b/spec/repositories/story_repository_spec.rb index cc50b3046..c03e787bb 100644 --- a/spec/repositories/story_repository_spec.rb +++ b/spec/repositories/story_repository_spec.rb @@ -406,14 +406,14 @@ feed = double(url: "http://github.com") entry = double(url: "https://github.com/stringer-rss/stringer") - expect(described_class.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" + expect(described_class.extract_url(entry, feed)).to eq("https://github.com/stringer-rss/stringer") end it "returns the enclosure_url when the url is nil" do feed = double(url: "http://github.com") entry = double(url: nil, enclosure_url: "https://github.com/stringer-rss/stringer") - expect(described_class.extract_url(entry, feed)).to eq "https://github.com/stringer-rss/stringer" + expect(described_class.extract_url(entry, feed)).to eq("https://github.com/stringer-rss/stringer") end it "does not crash if url is nil but enclosure_url does not exist" do @@ -428,13 +428,13 @@ it "returns the title if there is a title" do entry = double(title: "title", summary: "summary") - expect(described_class.extract_title(entry)).to eq "title" + expect(described_class.extract_title(entry)).to eq("title") end it "returns the summary if there isn't a title" do entry = double(title: "", summary: "summary") - expect(described_class.extract_title(entry)).to eq "summary" + expect(described_class.extract_title(entry)).to eq("summary") end end @@ -455,18 +455,18 @@ end it "sanitizes content" do - expect(described_class.extract_content(entry)).to eq "Some test content" + expect(described_class.extract_content(entry)).to eq("Some test content") end it "falls back to summary if there is no content" do expect(described_class.extract_content(summary_only)) - .to eq "Dumb publisher" + .to eq("Dumb publisher") end it "returns empty string if there is no content or summary" do entry = double(url: "http://mdswanson.com", content: nil, summary: nil) - expect(described_class.extract_content(entry)).to eq "" + expect(described_class.extract_content(entry)).to eq("") end it "expands urls" do @@ -477,7 +477,7 @@ ) expect(described_class.extract_content(entry)) - .to eq "Page" + .to eq("Page") end it "ignores URL expansion if entry url is nil" do @@ -485,7 +485,7 @@ double(url: nil, content: nil, summary: "Page") expect(described_class.extract_content(entry)) - .to eq "Page" + .to eq("Page") end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 66d5bbe7f..1b1ec9a32 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -36,8 +36,8 @@ def custom_request(method, path, params = {}, env = {}, &) end RSpec.configure do |config| - config.include Rack::Test::Methods - config.include RSpecHtmlMatchers + config.include(Rack::Test::Methods) + config.include(RSpecHtmlMatchers) end def app_require(file) diff --git a/spec/utils/content_sanitizer_spec.rb b/spec/utils/content_sanitizer_spec.rb index 7d4a598f1..03eda1ded 100644 --- a/spec/utils/content_sanitizer_spec.rb +++ b/spec/utils/content_sanitizer_spec.rb @@ -11,25 +11,25 @@ result = described_class.sanitize("WM_ERROR asdf") - expect(result).to eq "WM_ERROR asdf" + expect(result).to eq("WM_ERROR asdf") end it "handles
    tag properly" do result = described_class.sanitize("
    some code
    ") - expect(result).to eq "
    some code
    " + expect(result).to eq("
    some code
    ") end it "handles unprintable characters" do result = described_class.sanitize("n\u2028\u2029") - expect(result).to eq "n" + expect(result).to eq("n") end it "preserves line endings" do result = described_class.sanitize("test\r\ncase") - expect(result).to eq "test\r\ncase" + expect(result).to eq("test\r\ncase") end end end diff --git a/spec/utils/feed_discovery_spec.rb b/spec/utils/feed_discovery_spec.rb index fbf381b04..c6b27291f 100644 --- a/spec/utils/feed_discovery_spec.rb +++ b/spec/utils/feed_discovery_spec.rb @@ -31,7 +31,7 @@ result = described_class.new.discover(url, finder, parser, client) - expect(result).to eq feed + expect(result).to eq(feed) end it "returns false if the discovered feed is not parsable" do @@ -59,7 +59,7 @@ result = described_class.new.discover(url, finder, parser, client) - expect(result).to eq feed + expect(result).to eq(feed) end end end diff --git a/spec/utils/i18n_support_spec.rb b/spec/utils/i18n_support_spec.rb index d469036a7..791bcaa4c 100644 --- a/spec/utils/i18n_support_spec.rb +++ b/spec/utils/i18n_support_spec.rb @@ -13,7 +13,7 @@ let(:locale) { nil } it "loads default locale" do - expect(I18n.locale.to_s).to eq "en" + expect(I18n.locale.to_s).to eq("en") expect(I18n.locale.to_s).not_to be_nil end end @@ -22,8 +22,8 @@ let(:locale) { "en" } it "loads default locale" do - expect(I18n.locale.to_s).to eq "en" - expect(I18n.t("layout.title")).to eq "stringer | your rss buddy" + expect(I18n.locale.to_s).to eq("en") + expect(I18n.t("layout.title")).to eq("stringer | your rss buddy") end end @@ -32,7 +32,7 @@ it "does not find localization strings" do expect(I18n.t("layout.title", locale: ENV["LOCALE"].to_sym)) - .not_to eq "stringer | your rss buddy" + .not_to eq("stringer | your rss buddy") end end end diff --git a/spec/utils/opml_parser_spec.rb b/spec/utils/opml_parser_spec.rb index 4520a8a07..90e5afc55 100644 --- a/spec/utils/opml_parser_spec.rb +++ b/spec/utils/opml_parser_spec.rb @@ -25,13 +25,13 @@ XML resulted_values = result.values.flatten - expect(resulted_values.size).to eq 2 - expect(resulted_values.first[:name]).to eq "a sample feed" - expect(resulted_values.first[:url]).to eq "http://feeds.feedburner.com/foobar" + expect(resulted_values.size).to eq(2) + expect(resulted_values.first[:name]).to eq("a sample feed") + expect(resulted_values.first[:url]).to eq("http://feeds.feedburner.com/foobar") - expect(resulted_values.last[:name]).to eq "Matt's Blog" - expect(resulted_values.last[:url]).to eq "http://mdswanson.com/atom.xml" - expect(result.keys.first).to eq "Ungrouped" + expect(resulted_values.last[:name]).to eq("Matt's Blog") + expect(resulted_values.last[:url]).to eq("http://mdswanson.com/atom.xml") + expect(result.keys.first).to eq("Ungrouped") end it "handles nested groups of feeds" do @@ -51,10 +51,10 @@ XML resulted_values = result.values.flatten - expect(resulted_values.count).to eq 1 - expect(resulted_values.first[:name]).to eq "a sample feed" - expect(resulted_values.first[:url]).to eq "http://feeds.feedburner.com/foobar" - expect(result.keys.first).to eq "Technology News" + expect(resulted_values.count).to eq(1) + expect(resulted_values.first[:name]).to eq("a sample feed") + expect(resulted_values.first[:url]).to eq("http://feeds.feedburner.com/foobar") + expect(result.keys.first).to eq("Technology News") end it "doesn't explode when there are no feeds" do @@ -87,8 +87,8 @@ XML resulted_values = result.values.flatten - expect(resulted_values.count).to eq 1 - expect(resulted_values.first[:name]).to eq "a sample feed" + expect(resulted_values.count).to eq(1) + expect(resulted_values.first[:name]).to eq("a sample feed") end end end From 1667aae1971edb30fd5685b68ed4de33ac94218a Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 3 Jan 2023 17:37:55 -0800 Subject: [PATCH 273/779] RuboCop: exclude db directory for parens linter (#804) --- .rubocop.yml | 2 ++ .rubocop_todo.yml | 26 -------------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5e7e26fad..9e1bdc7db 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,6 +24,8 @@ Style/MethodCallWithArgsParentheses: - describe - require - task + Exclude: + - db/**/*.rb Style/StringLiterals: { EnforcedStyle: double_quotes } Style/SymbolArray: { EnforcedStyle: brackets } Style/WordArray: { EnforcedStyle: brackets } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a7b450f66..45b1bb5ea 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -354,32 +354,6 @@ Style/FetchEnvVar: Exclude: - 'Rakefile' -# Offense count: 184 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: IgnoreMacros, AllowedMethods, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. -# SupportedStyles: require_parentheses, omit_parentheses -Style/MethodCallWithArgsParentheses: - Exclude: - - 'db/migrate/20130409010818_create_feeds.rb' - - 'db/migrate/20130409010826_create_stories.rb' - - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' - - 'db/migrate/20130418221144_add_user_model.rb' - - 'db/migrate/20130423001740_drop_email_from_user.rb' - - 'db/migrate/20130423180446_remove_author_from_stories.rb' - - 'db/migrate/20130425211008_add_setup_complete_to_user.rb' - - 'db/migrate/20130425222157_add_delayed_job.rb' - - 'db/migrate/20130429232127_add_status_to_feeds.rb' - - 'db/migrate/20130504005816_text_url.rb' - - 'db/migrate/20130504022615_change_story_permalink_column.rb' - - 'db/migrate/20130509131045_add_unique_constraints.rb' - - 'db/migrate/20130513025939_add_keep_unread_to_stories.rb' - - 'db/migrate/20130513044029_add_is_starred_status_for_stories.rb' - - 'db/migrate/20130522014405_add_api_key_to_user.rb' - - 'db/migrate/20130730120312_add_entry_id_to_stories.rb' - - 'db/migrate/20130805113712_update_stories_unique_constraints.rb' - - 'db/migrate/20130905204142_use_text_datatype_for_title_and_entry_id.rb' - - 'db/migrate/20140413100725_add_groups_table_and_foreign_keys_to_feeds.rb' - # Offense count: 10 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinDigits, Strict, AllowedNumbers, AllowedPatterns. From 69be6f93b335dfcba01c4939220bff8bb28b2fd0 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sun, 8 Jan 2023 16:03:09 -0800 Subject: [PATCH 274/779] Rails: introduce config/routes.rb (#805) Move ActionController routes to file that more closely mimics Rails. --- app.rb | 16 +--------------- app/helpers/controller_helpers.rb | 18 ------------------ config/routes.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 33 deletions(-) delete mode 100644 app/helpers/controller_helpers.rb create mode 100644 config/routes.rb diff --git a/app.rb b/app.rb index d74d6df97..608ec2881 100644 --- a/app.rb +++ b/app.rb @@ -17,7 +17,6 @@ require "securerandom" require_relative "app/helpers/authentication_helpers" -require_relative "app/helpers/controller_helpers" require_relative "app/repositories/user_repository" require_relative "config/asset_pipeline" @@ -44,8 +43,6 @@ class Stringer < Sinatra::Base use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } end - extend Sinatra::ControllerHelpers - register Sinatra::ActiveRecordExtension register Sinatra::Flash register Sinatra::Contrib @@ -101,20 +98,9 @@ def t(*args, **kwargs) redirect to("/setup/password") end end - - rails_route(:get, "/debug", to: "debug#index") - rails_route(:get, "/heroku", to: "debug#heroku") - rails_route(:get, "/feeds", to: "feeds#index") - rails_route(:get, "/feeds/:id/edit", to: "feeds#edit") - rails_route(:put, "/feeds/:id", to: "feeds#update") - rails_route(:delete, "/feeds/:id", to: "feeds#destroy") - rails_route(:get, "/feeds/new", to: "feeds#new") - rails_route(:post, "/feeds", to: "feeds#create") - rails_route(:get, "/feeds/export", to: "exports#index") - rails_route(:get, "/feeds/import", to: "imports#new") - rails_route(:post, "/feeds/import", to: "imports#create") end require_relative "app/controllers/sinatra/stories_controller" require_relative "app/controllers/sinatra/first_run_controller" require_relative "app/controllers/sinatra/sessions_controller" +require_relative "config/routes" diff --git a/app/helpers/controller_helpers.rb b/app/helpers/controller_helpers.rb deleted file mode 100644 index 4070c9c0e..000000000 --- a/app/helpers/controller_helpers.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module Sinatra - module ControllerHelpers - def rails_route(method, path, options) - options = options.with_indifferent_access - to = options.delete(:to) - controller_name, action_name = to.split("#") - controller_klass = "#{controller_name.camelize}Controller".constantize - route(method.to_s.upcase, path, options) do - # Make sure that our parsed URL params are where Rack (and - # ActionDispatch) expect them - app = controller_klass.action(action_name) - app.call(request.env.merge("rack.request.query_hash" => params)) - end - end - end -end diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 000000000..c3f1d93bb --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class Stringer < Sinatra::Base + def self.match(path, to:, via:) + controller_name, action_name = to.split("#") + controller_klass = "#{controller_name.camelize}Controller".constantize + route(via.to_s.upcase, path) do + # Make sure that our parsed URL params are where Rack (and + # ActionDispatch) expect them + app = controller_klass.action(action_name) + app.call(request.env.merge("rack.request.query_hash" => params)) + end + end + + match("/debug", to: "debug#index", via: :get) + match("/heroku", to: "debug#heroku", via: :get) + match("/feeds", to: "feeds#index", via: :get) + match("/feeds/:id/edit", to: "feeds#edit", via: :get) + match("/feeds/:id", to: "feeds#update", via: :put) + match("/feeds/:id", to: "feeds#destroy", via: :delete) + match("/feeds/new", to: "feeds#new", via: :get) + match("/feeds", to: "feeds#create", via: :post) + match("/feeds/export", to: "exports#index", via: :get) + match("/feeds/import", to: "imports#new", via: :get) + match("/feeds/import", to: "imports#create", via: :post) +end From a076213c32576745cd07f189ae71d10cb69dcdbf Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 17:00:45 -0800 Subject: [PATCH 275/779] Update all Bundler dependencies (2023-01-09) (#806) Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9a1cbe79e..cbd0fd2d8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -214,13 +214,13 @@ GEM rspec-mocks (~> 3.12.0) rspec-core (3.12.0) rspec-support (~> 3.12.0) - rspec-expectations (3.12.1) + rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-html-matchers (0.10.0) nokogiri (~> 1) rspec (>= 3.0.0.a) - rspec-mocks (3.12.1) + rspec-mocks (3.12.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-rails (6.0.1) @@ -303,7 +303,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.4.1) + unicode-display_width (2.4.2) webmock (3.18.1) addressable (>= 2.8.0) crack (>= 0.3.2) From 30e50a3ea3cfa71976f4381dcefae3c44044468d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 14 Jan 2023 12:14:02 -0800 Subject: [PATCH 276/779] Rails: move password setup to new controller (#807) --- .rubocop_todo.yml | 1 + app.rb | 1 + app/controllers/passwords_controller.rb | 33 +++++++++++++ .../sinatra/first_run_controller.rb | 30 +----------- .../password.erb => passwords/new.html.erb} | 0 config/routes.rb | 2 + spec/controllers/first_run_controller_spec.rb | 42 ----------------- spec/controllers/passwords_controller_spec.rb | 47 +++++++++++++++++++ spec/support/coverage.rb | 2 +- 9 files changed, 86 insertions(+), 72 deletions(-) create mode 100644 app/controllers/passwords_controller.rb rename app/views/{first_run/password.erb => passwords/new.html.erb} (100%) create mode 100644 spec/controllers/passwords_controller_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 45b1bb5ea..7e3578342 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -255,6 +255,7 @@ Rails/HttpPositionalArguments: - 'spec/controllers/feeds_controller_spec.rb' - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/imports_controller_spec.rb' + - 'spec/controllers/passwords_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' - 'spec/fever_api_spec.rb' diff --git a/app.rb b/app.rb index 608ec2881..d7501492e 100644 --- a/app.rb +++ b/app.rb @@ -25,6 +25,7 @@ require_relative "app/controllers/feeds_controller" require_relative "app/controllers/exports_controller" require_relative "app/controllers/imports_controller" +require_relative "app/controllers/passwords_controller" module Rails def self.application diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb new file mode 100644 index 000000000..c71936bd1 --- /dev/null +++ b/app/controllers/passwords_controller.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class PasswordsController < ApplicationController + before_action :redirect_if_setup_complete + + def new; end + + def create + if no_password(params) || password_mismatch?(params) + flash.now[:error] = t("first_run.password.flash.passwords_dont_match") + render(:new) + else + user = CreateUser.call(params[:password]) + session[:user_id] = user.id + + redirect_to("/feeds/import") + end + end + + private + + def no_password(params) + params[:password].nil? || params[:password] == "" + end + + def password_mismatch?(params) + params[:password] != params[:password_confirmation] + end + + def redirect_if_setup_complete + redirect_to("/news") if UserRepository.setup_complete? + end +end diff --git a/app/controllers/sinatra/first_run_controller.rb b/app/controllers/sinatra/first_run_controller.rb index 8556addc6..3ca3f5810 100644 --- a/app/controllers/sinatra/first_run_controller.rb +++ b/app/controllers/sinatra/first_run_controller.rb @@ -9,27 +9,9 @@ class Stringer < Sinatra::Base namespace "/setup" do - before do + get "/tutorial" do redirect to("/news") if UserRepository.setup_complete? - end - - get "/password" do - erb :"first_run/password" - end - - post "/password" do - if no_password(params) || password_mismatch?(params) - flash.now[:error] = t("first_run.password.flash.passwords_dont_match") - erb :"first_run/password" - else - user = CreateUser.call(params[:password]) - session[:user_id] = user.id - - redirect to("/feeds/import") - end - end - get "/tutorial" do FetchFeeds.enqueue(Feed.all) CompleteSetup.complete(current_user) @@ -37,14 +19,4 @@ class Stringer < Sinatra::Base erb :tutorial end end - - private - - def no_password(params) - params[:password].nil? || params[:password] == "" - end - - def password_mismatch?(params) - params[:password] != params[:password_confirmation] - end end diff --git a/app/views/first_run/password.erb b/app/views/passwords/new.html.erb similarity index 100% rename from app/views/first_run/password.erb rename to app/views/passwords/new.html.erb diff --git a/config/routes.rb b/config/routes.rb index c3f1d93bb..0ec5cb3a9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,4 +23,6 @@ def self.match(path, to:, via:) match("/feeds/export", to: "exports#index", via: :get) match("/feeds/import", to: "imports#new", via: :get) match("/feeds/import", to: "imports#create", via: :post) + match("/setup/password", to: "passwords#new", via: :get) + match("/setup/password", to: "passwords#create", via: :post) end diff --git a/spec/controllers/first_run_controller_spec.rb b/spec/controllers/first_run_controller_spec.rb index bf9e4465a..9ac408c0f 100644 --- a/spec/controllers/first_run_controller_spec.rb +++ b/spec/controllers/first_run_controller_spec.rb @@ -7,48 +7,6 @@ describe "FirstRunController" do context "when a user has not been setup" do - def setup - expect(UserRepository) - .to receive(:setup_complete?).twice.and_return(false) - end - - describe "GET /setup/password" do - it "displays a form to enter your password" do - setup - - get "/setup/password" - - page = last_response.body - expect(page).to have_tag("form#password_setup") - end - end - - describe "POST /setup/password" do - it "rejects empty passwords" do - setup - - post "/setup/password" - - page = last_response.body - expect(page).to have_tag("div.error") - end - - it "rejects when password isn't confirmed" do - setup - - post "/setup/password", password: "foo", password_confirmation: "bar" - - page = last_response.body - expect(page).to have_tag("div.error") - end - - it "accepts confirmed passwords and redirects to next step" do - post "/setup/password", password: "foo", password_confirmation: "foo" - - expect(URI.parse(last_response.location).path).to eq("/feeds/import") - end - end - describe "GET /setup/tutorial" do let(:user) { instance_double(User) } let(:feeds) { [instance_double(Feed), instance_double(Feed)] } diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb new file mode 100644 index 000000000..12e45d913 --- /dev/null +++ b/spec/controllers/passwords_controller_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require "spec_helper" +require "support/active_record" + +RSpec.describe PasswordsController do + def setup + expect(UserRepository).to receive(:setup_complete?).twice.and_return(false) + end + + describe "#new" do + it "displays a form to enter your password" do + setup + + get "/setup/password" + + page = last_response.body + expect(page).to have_tag("form#password_setup") + end + end + + describe "#create" do + it "rejects empty passwords" do + setup + + post "/setup/password" + + page = last_response.body + expect(page).to have_tag("div.error") + end + + it "rejects when password isn't confirmed" do + setup + + post "/setup/password", password: "foo", password_confirmation: "bar" + + page = last_response.body + expect(page).to have_tag("div.error") + end + + it "accepts confirmed passwords and redirects to next step" do + post "/setup/password", password: "foo", password_confirmation: "foo" + + expect(URI.parse(last_response.location).path).to eq("/feeds/import") + end + end +end diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb index 6c914f365..29cf4d5dc 100644 --- a/spec/support/coverage.rb +++ b/spec/support/coverage.rb @@ -15,4 +15,4 @@ add_group("Utils", "app/utils") enable_coverage :branch end -SimpleCov.minimum_coverage(line: 100, branch: 99) +SimpleCov.minimum_coverage(line: 100, branch: 98) From 1f78dc4f67fedd2d9e208eeb869c76c6ed458c64 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Sat, 14 Jan 2023 13:41:13 -0800 Subject: [PATCH 277/779] Rails: move tutorials to ApplicationController (#808) The newly added views are all copies of existing partials. The old ones will be removed when all of the references are gone. --- .rubocop_todo.yml | 2 +- app.rb | 7 ++- .../sinatra/first_run_controller.rb | 22 -------- app/controllers/tutorials_controller.rb | 15 ++++++ app/views/feeds/index.html.erb | 2 +- app/views/stories/_js.html.erb | 43 +++++++++++++++ .../stories/_mark_all_as_read_form.html.erb | 7 +++ app/views/stories/_templates.html.erb | 54 +++++++++++++++++++ .../_action_bar.html.erb} | 3 +- .../index.html.erb} | 4 +- config/routes.rb | 1 + spec/controllers/first_run_controller_spec.rb | 42 --------------- spec/controllers/tutorials_controller_spec.rb | 40 ++++++++++++++ 13 files changed, 171 insertions(+), 71 deletions(-) delete mode 100644 app/controllers/sinatra/first_run_controller.rb create mode 100644 app/controllers/tutorials_controller.rb create mode 100644 app/views/stories/_js.html.erb create mode 100644 app/views/stories/_mark_all_as_read_form.html.erb create mode 100644 app/views/stories/_templates.html.erb rename app/views/{partials/_tutorial_action_bar.erb => tutorials/_action_bar.html.erb} (87%) rename app/views/{tutorial.erb => tutorials/index.html.erb} (92%) delete mode 100644 spec/controllers/first_run_controller_spec.rb create mode 100644 spec/controllers/tutorials_controller_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7e3578342..4761ceaed 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -253,11 +253,11 @@ Rails/HttpPositionalArguments: - 'spec/app_spec.rb' - 'spec/controllers/debug_controller_spec.rb' - 'spec/controllers/feeds_controller_spec.rb' - - 'spec/controllers/first_run_controller_spec.rb' - 'spec/controllers/imports_controller_spec.rb' - 'spec/controllers/passwords_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' - 'spec/controllers/stories_controller_spec.rb' + - 'spec/controllers/tutorials_controller_spec.rb' - 'spec/fever_api_spec.rb' # Offense count: 1 diff --git a/app.rb b/app.rb index d7501492e..6fcda39b3 100644 --- a/app.rb +++ b/app.rb @@ -16,8 +16,13 @@ require "sprockets-helpers" require "securerandom" +require_relative "app/commands/feeds/import_from_opml" +require_relative "app/commands/users/complete_setup" +require_relative "app/commands/users/create_user" require_relative "app/helpers/authentication_helpers" +require_relative "app/repositories/story_repository" require_relative "app/repositories/user_repository" +require_relative "app/tasks/fetch_feeds" require_relative "config/asset_pipeline" require_relative "app/controllers/application_controller" @@ -26,6 +31,7 @@ require_relative "app/controllers/exports_controller" require_relative "app/controllers/imports_controller" require_relative "app/controllers/passwords_controller" +require_relative "app/controllers/tutorials_controller" module Rails def self.application @@ -102,6 +108,5 @@ def t(*args, **kwargs) end require_relative "app/controllers/sinatra/stories_controller" -require_relative "app/controllers/sinatra/first_run_controller" require_relative "app/controllers/sinatra/sessions_controller" require_relative "config/routes" diff --git a/app/controllers/sinatra/first_run_controller.rb b/app/controllers/sinatra/first_run_controller.rb deleted file mode 100644 index 3ca3f5810..000000000 --- a/app/controllers/sinatra/first_run_controller.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -require_relative "../../commands/feeds/import_from_opml" -require_relative "../../commands/users/create_user" -require_relative "../../commands/users/complete_setup" -require_relative "../../repositories/user_repository" -require_relative "../../repositories/story_repository" -require_relative "../../tasks/fetch_feeds" - -class Stringer < Sinatra::Base - namespace "/setup" do - get "/tutorial" do - redirect to("/news") if UserRepository.setup_complete? - - FetchFeeds.enqueue(Feed.all) - CompleteSetup.complete(current_user) - - @sample_stories = StoryRepository.samples - erb :tutorial - end - end -end diff --git a/app/controllers/tutorials_controller.rb b/app/controllers/tutorials_controller.rb new file mode 100644 index 000000000..ee68709ea --- /dev/null +++ b/app/controllers/tutorials_controller.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class TutorialsController < ApplicationController + def index + if UserRepository.setup_complete? + redirect_to("/news") + return + end + + FetchFeeds.enqueue(Feed.all) + CompleteSetup.complete(current_user) + + @sample_stories = StoryRepository.samples + end +end diff --git a/app/views/feeds/index.html.erb b/app/views/feeds/index.html.erb index 7709e4633..79025c862 100644 --- a/app/views/feeds/index.html.erb +++ b/app/views/feeds/index.html.erb @@ -12,7 +12,7 @@
    <% else %>
    -

    <%= t('feeds.index.add_some_feeds', :add => ''+t('feeds.index.add')+'') %>

    +

    <%= t('feeds.index.add_some_feeds', :add => ''+t('feeds.index.add')+'').html_safe %>

    <% end %> diff --git a/app/views/stories/_js.html.erb b/app/views/stories/_js.html.erb new file mode 100644 index 000000000..0ff6d1681 --- /dev/null +++ b/app/views/stories/_js.html.erb @@ -0,0 +1,43 @@ +<%= render 'stories/templates' %> + + diff --git a/app/views/stories/_mark_all_as_read_form.html.erb b/app/views/stories/_mark_all_as_read_form.html.erb new file mode 100644 index 000000000..2e4b3089e --- /dev/null +++ b/app/views/stories/_mark_all_as_read_form.html.erb @@ -0,0 +1,7 @@ +
    +
    + <% stories.each do |story| %> + + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/stories/_templates.html.erb b/app/views/stories/_templates.html.erb new file mode 100644 index 000000000..2c10c12fc --- /dev/null +++ b/app/views/stories/_templates.html.erb @@ -0,0 +1,54 @@ + diff --git a/app/views/partials/_tutorial_action_bar.erb b/app/views/tutorials/_action_bar.html.erb similarity index 87% rename from app/views/partials/_tutorial_action_bar.erb rename to app/views/tutorials/_action_bar.html.erb index f5ed6d893..7432d1135 100644 --- a/app/views/partials/_tutorial_action_bar.erb +++ b/app/views/tutorials/_action_bar.html.erb @@ -2,8 +2,7 @@
    - <%= render_partial :tutorial_action_bar, {stories: @sample_stories} %> + <%= render 'tutorials/action_bar', {stories: @sample_stories} %>
    -<%= render_js :stories, { stories: @sample_stories } %> +<%= render 'stories/js', { stories: @sample_stories } %>