Skip to content

Commit

Permalink
fix all the remaining lints
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Jan 13, 2022
1 parent e0eb289 commit 800d772
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@

/app/assets/builds/*
!/app/assets/builds/.keep

/spec/support/results.txt
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Lint/Env:
- "**/*.rb"
Exclude:
- "**/config/environments/**/*"
- "**/config/initializers/**/*"
- "**/config/application.rb"
- "**/config/environment.rb"
- "**/config/puma.rb"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PostsController < ApplicationController
def index
@feed = Feed.find_by_token(params[:feed_id])
@feed = Feed.find_by(token: params[:feed_id])
@posts = @feed.posts
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def sharing_meta_tags(title: "Feed Your Email")
tag.meta(property: "twitter:creator", content: "@indirect"),
# Icons
tag.link(rel: "icon", type: "image/svg+xml", href: "/favicon.svg"),
tag.link(rel: "alternate icon", href: "/favicon.ico"),
].join("\n").html_safe
tag.link(rel: "alternate icon", href: "/favicon.ico")
].join("\n").html_safe # rubocop:disable Rails/OutputSafety
end
end
4 changes: 3 additions & 1 deletion app/processors/email_processor.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class EmailProcessor
cattr_accessor :default_to_newest_feed, default: false

def initialize(email)
@email = email
end
Expand All @@ -11,7 +13,7 @@ def process(token: nil)

def feed
@feed ||= Feed.where(token: feed_token).first
@feed ||= Feed.order(:updated_at).last if Rails.env.development?
@feed ||= Feed.order(:updated_at).last if default_to_newest_feed
end

def feed_token
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
if Rails.root.join("tmp", "caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/email_processor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rails.application.config.to_prepare do
EmailProcessor.default_to_newest_feed = Rails.env.development?
end
4 changes: 2 additions & 2 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

Expand All @@ -15,7 +15,7 @@

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT", 3000)

# Specifies the `environment` that Puma will run in.
#
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20220111070447_add_token_to_post.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddTokenToPost < ActiveRecord::Migration[7.0]
def change
add_column :posts, :token, :citext, null: false, unique: true
add_column :posts, :token, :citext, null: false, unique: true, default: ""
end
end
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)

feed = Feed.find_or_create_by!(token: "somefeed", name: "Money Stuff")
Feed.find_or_create_by!(token: "somefeed", name: "Money Stuff")

json = JSON.parse(Rails.root.join("spec/support/body.json").read)
json = JSON.parse(Rails.root.join("spec", "support", "body.json").read)
params = Griddler::Postmark::Adapter.normalize_params(json.deep_symbolize_keys)
email = Griddler::Email.new(params)
EmailProcessor.new(email).process(token: "somepost")
8 changes: 4 additions & 4 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
require "spec_helper"
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../config/environment", __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
require "rspec/rails"
# Add additional requires below this line. Rails is not loaded until this point!

# Requires supporting ruby files with custom matchers and macros, etc, in
Expand Down
63 changes: 1 addition & 62 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,83 +14,22 @@
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end

# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
# have no way to turn it off -- the option exists only for backwards
# compatibility in RSpec 3). It causes shared context metadata to be
# inherited by the metadata hash of host groups and examples, rather than
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# This allows you to limit a spec run to individual examples or groups
# you care about by tagging them with `:focus` metadata. When nothing
# is tagged with `:focus`, all examples get run. RSpec also provides
# aliases for `it`, `describe`, and `context` that include `:focus`
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
config.filter_run_when_matching :focus
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
config.example_status_persistence_file_path = "spec/support/results.txt"
config.disable_monkey_patching!
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = "doc"
end

# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
=end
end

0 comments on commit 800d772

Please sign in to comment.