"
- @branch = GitBranchnameGenerator.new(username: @username, doc_path: @doc.path).branchname
+ @branch = GitBranchnameGenerator.new(username: @username, doc_path: @doc.path).branchname
set_title("Help Writing docs #{@doc.path} - #{@repo.full_name} #{@repo.language}")
- set_description("#{@doc.missing_docs? ? 'Write' : 'Read'} docs for #{@repo.name} starting with #{@doc.path}.")
+ set_description("#{@doc.missing_docs? ? "Write" : "Read"} docs for #{@repo.name} starting with #{@doc.path}.")
end
def click_method_redirect
- doc = DocMethod.find(params[:id])
- sub = RepoSubscription.where(user_id: params[:user_id], repo: doc.repo).first
+ doc = DocMethod.find(params[:id])
+ sub = RepoSubscription.where(user_id: params[:user_id], repo: doc.repo).first
assignment = DocAssignment.where(doc_method_id: doc.id, repo_subscription_id: sub.id).first
if assignment&.user&.id.to_s == params[:user_id]
@@ -34,8 +34,8 @@ def click_method_redirect
end
def click_source_redirect
- doc = DocMethod.find(params[:id])
- sub = RepoSubscription.find_by!(user_id: params[:user_id], repo: doc.repo)
+ doc = DocMethod.find(params[:id])
+ sub = RepoSubscription.find_by!(user_id: params[:user_id], repo: doc.repo)
assignment = DocAssignment.find_by!(doc_method_id: doc.id, repo_subscription_id: sub.id)
if assignment&.user&.id.to_s == params[:user_id]
diff --git a/app/controllers/issue_assignments_controller.rb b/app/controllers/issue_assignments_controller.rb
index 27d0eb474..30441ae9e 100644
--- a/app/controllers/issue_assignments_controller.rb
+++ b/app/controllers/issue_assignments_controller.rb
@@ -4,7 +4,7 @@ class IssueAssignmentsController < ApplicationController
def create
repo_sub = current_user.repo_subscriptions.find(params[:id])
SendSingleTriageEmailJob.perform_later(repo_sub.id)
- redirect_to repo_path(repo_sub.repo), notice: 'You will receive an email with your new issue shortly'
+ redirect_to repo_path(repo_sub.repo), notice: "You will receive an email with your new issue shortly"
end
# get "/issue_assignments/:id/users/:user_id/click/:created_at", to: "issue_assignments#click"
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 36f1a24ee..8a52dfaed 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -31,7 +31,7 @@ def index
@covid_repos = get_covid_repos
@repos = Repo.with_some_issues
- .select(:id, :updated_at, :issues_count, :language, :full_name, :name, :description)
+ .select(:id, :updated_at, :issues_count, :language, :full_name, :name, :description)
if (language = valid_params[:language] || current_user.try(:favorite_languages))
@repos = @repos.where(language: language)
end
@@ -45,8 +45,8 @@ def index
respond_to do |format|
format.html {}
format.json do
- htmlForPage = render_to_string(partial: "repos_with_pagination", locals: { repos: @repos }, formats: ['html'])
- render json: { html: htmlForPage }.to_json
+ html_for_page = render_to_string(partial: "repos_with_pagination", locals: {repos: @repos}, formats: ["html"])
+ render json: {html: html_for_page}.to_json
end
end
end
@@ -54,8 +54,8 @@ def index
private def description
Rails.cache.fetch("pages#index/description", expires_in: 1.hour) do
"Discover the easiest way to get started contributing to open source. " \
- "Over #{number_with_delimiter(User.count, delimiter: ',')} devs are " \
- "helping #{number_with_delimiter(Repo.count, delimiter: ',')} projects " \
+ "Over #{number_with_delimiter(User.count, delimiter: ",")} devs are " \
+ "helping #{number_with_delimiter(Repo.count, delimiter: ",")} projects " \
"with our free, community developed tools"
end
end
diff --git a/app/controllers/repo_based_controller.rb b/app/controllers/repo_based_controller.rb
index 315f553d0..c0ef7745f 100644
--- a/app/controllers/repo_based_controller.rb
+++ b/app/controllers/repo_based_controller.rb
@@ -4,7 +4,7 @@ class RepoBasedController < ApplicationController
protected
def name_from_params(options)
- [options[:name], options[:format]].compact.join('.')
+ [options[:name], options[:format]].compact.join(".")
end
def find_repo(options, only_active: true)
diff --git a/app/controllers/repo_subscriptions_controller.rb b/app/controllers/repo_subscriptions_controller.rb
index d1f0b7a87..278ed8b64 100644
--- a/app/controllers/repo_subscriptions_controller.rb
+++ b/app/controllers/repo_subscriptions_controller.rb
@@ -7,7 +7,7 @@ def create
@repo_subscription = create_or_update_subscription
if @repo_subscription.save
SendSingleTriageEmailJob.perform_later(@repo_subscription.id)
- redirect_to @repo_subscription.repo, notice: I18n.t('repo_subscriptions.subscribed')
+ redirect_to @repo_subscription.repo, notice: I18n.t("repo_subscriptions.subscribed")
else
flash[:error] = "Something went wrong"
redirect_to repo_path(@repo_subscription.try(:repo) || Repo.find(repo_subscription_params[:repo_id]))
diff --git a/app/controllers/repos_controller.rb b/app/controllers/repos_controller.rb
index 822892d99..0b88d3a7c 100644
--- a/app/controllers/repos_controller.rb
+++ b/app/controllers/repos_controller.rb
@@ -8,8 +8,8 @@ class ReposController < RepoBasedController
def new
@repo = Repo.new(user_name: params[:user_name], name: params[:name])
- @full_name = @repo.name && @repo.user_name ? +"#{@repo.user_name}/#{@repo.name}" : nil
- @full_name.prepend("https://github.com/") if @full_name
+ @full_name = (@repo.name && @repo.user_name) ? +"#{@repo.user_name}/#{@repo.name}" : nil
+ @full_name&.prepend("https://github.com/")
@repo_sub = RepoSubscription.new
end
@@ -18,16 +18,16 @@ def show
@repo = find_repo(params)
@issues = @repo.open_issues.select(:id, :title, :html_url).limit(record_count)
@issues = paginate(@issues, after: params[:issues_after],
- before: params[:issues_before])
+ before: params[:issues_before])
- @docs = @repo.doc_methods.select(:id, :doc_comments_count, :path).limit(record_count)
- @docs = paginate(@docs, after: params[:docs_after],
- before: params[:docs_before])
+ @docs = @repo.doc_methods.select(:id, :doc_comments_count, :path).limit(record_count)
+ @docs = paginate(@docs, after: params[:docs_after],
+ before: params[:docs_before])
- @repo_sub = current_user.repo_subscriptions_for(@repo.id).first if current_user
+ @repo_sub = current_user.repo_subscriptions_for(@repo.id).first if current_user
@subscribers = @repo.subscribers.select(:private, :avatar_url, :github).limit(27)
- @docs_pagination = params[:docs_after] || params[:docs_before]
+ @docs_pagination = params[:docs_after] || params[:docs_before]
@issues_pagination = params[:issues_after] || params[:issues_before]
set_title("Help Contribute to #{@repo.full_name} - #{@repo.language}")
@@ -39,7 +39,7 @@ def show
def create
parse_params_for_repo_info
- @repo = Repo.search_by(params[:repo][:name], params[:repo][:user_name]).first unless params_blank?
+ @repo = Repo.search_by(params[:repo][:name], params[:repo][:user_name]).first unless params_blank?
@repo ||= Repo.new(repo_params)
if @repo.save
@repo_sub = current_user.repo_subscriptions.create(repo: @repo)
@@ -70,12 +70,12 @@ def list
@repo = Repo.new(user_name: params[:user_name], name: name_from_params(params))
if user_signed_in?
case params[:show]
- when 'own'
- @repos = cached_repos 'repos', current_user.own_repos_json
- when 'starred'
- @repos = cached_repos 'starred', current_user.starred_repos_json
- when 'watched'
- @repos = cached_repos 'subscriptions', current_user.subscribed_repos_json
+ when "own"
+ @repos = cached_repos "repos", current_user.own_repos_json
+ when "starred"
+ @repos = cached_repos "starred", current_user.starred_repos_json
+ when "watched"
+ @repos = cached_repos "subscriptions", current_user.subscribed_repos_json
end
end
render layout: nil
@@ -111,7 +111,7 @@ def repo_params
:stars_count,
:language,
:description,
- :full_name,
+ :full_name
)
end
@@ -123,7 +123,7 @@ def parse_params_for_repo_info
params[:url].gsub!(/\?(.*)/, "")
url_array = params[:url].split("/")
- params[:repo][:name] = url_array.pop || ""
+ params[:repo][:name] = url_array.pop || ""
params[:repo][:user_name] = url_array.pop || ""
end
diff --git a/app/controllers/subscribers_controller.rb b/app/controllers/subscribers_controller.rb
index 70bf17aab..eeaf3677b 100644
--- a/app/controllers/subscribers_controller.rb
+++ b/app/controllers/subscribers_controller.rb
@@ -2,7 +2,7 @@
class SubscribersController < RepoBasedController
def show
- @repo = find_repo(params)
+ @repo = find_repo(params)
@subscribers = @repo.users.page(params[:page]).per_page(params[:per_page] || 50)
set_title("Code helpers for #{@repo.full_name} - #{@repo.language}")
end
diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb
index 222af5f44..10cb9b133 100644
--- a/app/controllers/topics_controller.rb
+++ b/app/controllers/topics_controller.rb
@@ -10,15 +10,15 @@ def show
label = Label.find_by(name: @topic)
@repos = Repo.with_some_issues
- .joins(:repo_labels)
- .where(repo_labels: { label_id: label.id })
- .select(:id, :issues_count, :language, :full_name, :name, :description)
+ .joins(:repo_labels)
+ .where(repo_labels: {label_id: label.id})
+ .select(:id, :issues_count, :language, :full_name, :name, :description)
@repos = @repos.order_by_issue_count.page(valid_params[:page]).per_page(valid_params[:per_page] || 50)
end
private def set_topic
- topic_name = valid_params['id'].downcase
+ topic_name = valid_params["id"].downcase
@topic = TOPICS.detect { |t| t == topic_name }
if @topic.blank?
diff --git a/app/controllers/university_controller.rb b/app/controllers/university_controller.rb
index 53f6c2060..d2a297d3f 100644
--- a/app/controllers/university_controller.rb
+++ b/app/controllers/university_controller.rb
@@ -13,27 +13,27 @@ def show
@page_title = "Please squash your commits"
set_title(@page_title)
set_description("What on earth does squashing commits mean and how do you do it? Find out the what, why, and how of git squashs here.")
- render 'squash'
+ render "squash"
when "rebase"
@page_title = "Please Rebase your commits"
set_title(@page_title)
set_description("What on earth does rebasing commits mean and how do you do it? Find out the what, why, and how of git rebases here.")
- render 'rebase'
+ render "rebase"
when "reproduction_code", "reproduction", "reproduction_case"
@page_title = "Please Provide Reproduction Code"
set_title(@page_title)
set_description("Get answers for your open source bug reports faster by providing a code that reproduces your problem. Find out how.")
- render 'reproduction_code'
- when 'example_app', 'example_apps', 'example-app', 'example-apps'
+ render "reproduction_code"
+ when "example_app", "example_apps", "example-app", "example-apps"
@page_title = "Please Provide an Example App"
set_title(@page_title)
set_description("Get answers for your open source bug reports faster by providing an example app. Find out how right here.")
- render 'example_app'
- when 'picking_a_repo'
+ render "example_app"
+ when "picking_a_repo"
@page_title = "Picking the Right Repo(s)"
set_title("Picking the Right Repo(s) to start your Open Source Contribution Journey")
set_description("One of the most important decisions you'll make when you start contributing is which open source libraries you contribute to. This guide will help you get started")
- render 'picking_a_repo'
+ render "picking_a_repo"
end
end
end
diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb
index 590ba345e..a1aaed60b 100644
--- a/app/controllers/users/omniauth_callbacks_controller.rb
+++ b/app/controllers/users/omniauth_callbacks_controller.rb
@@ -5,17 +5,19 @@ def github
@user = GitHubAuthenticator.authenticate(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = if @user.valid_email?
- I18n.t "devise.omniauth_callbacks.success", kind: "GitHub"
- else
- I18n.t "devise.omniauth_callbacks.bad_email_success", kind: "GitHub"
- end
+ I18n.t "devise.omniauth_callbacks.success", kind: "GitHub"
+ else
+ I18n.t "devise.omniauth_callbacks.bad_email_success", kind: "GitHub"
+ end
sign_in_and_redirect @user, event: :authentication
else
session["devise.github_data"] = request.env["omniauth.auth"].delete("extra")
- flash[:error] = no_email_error if request.env["omniauth.auth"].info.email.blank?
- flash[:notice] = I18n.t "devise.omniauth_callbacks.failure",
- kind: "GitHub", reason: "Invalid credentials" if flash[:error].blank?
+ flash[:error] = no_email_error if request.env["omniauth.auth"].info.email.blank?
+ if flash[:error].blank?
+ flash[:notice] = I18n.t "devise.omniauth_callbacks.failure",
+ kind: "GitHub", reason: "Invalid credentials"
+ end
redirect_to root_path
end
end
@@ -23,7 +25,7 @@ def github
private
def no_email_error
- msg = "You need a public email address on GitHub to sign up you can add"
+ msg = "You need a public email address on GitHub to sign up you can add"
msg << " an email, sign up for triage, then remove it from GitHub:
"
msg << "GitHub Profile"
msg.html_safe
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index d8af10eaf..f6327ce17 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -34,12 +34,12 @@ def update
begin
uparams = user_params
rescue ActionController::ParameterMissing
- uparams = { favorite_languages: [] }
+ uparams = {favorite_languages: []}
end
@user = current_user
if @user.update(uparams)
- redirect_to @user, flash: { success: 'User successfully updated' }
+ redirect_to @user, flash: {success: "User successfully updated"}
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index cb19f0c8f..7aeaac75b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,26 +1,26 @@
# frozen_string_literal: true
module ApplicationHelper
- WARNING_SVG = %Q{
+ WARNING_SVG = %(
-}.html_safe
+).html_safe
- STAR_SVG = %Q{
+ STAR_SVG = %(
- }.html_safe
+ ).html_safe
def flash_class(level)
case level
- when :notice then 'info'
- when :error then 'error'
- when :alert then 'warning'
+ when :notice then "info"
+ when :error then "error"
+ when :alert then "warning"
end
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 9750a785c..386ac3d89 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -2,6 +2,6 @@
module UsersHelper
def available_times_of_day
- (0...24).map { |hour| Time.utc(2000, 1, 1, hour, 00, 0) }
+ (0...24).map { |hour| Time.utc(2000, 1, 1, hour, 0o0, 0) }
end
end
diff --git a/app/jobs/populate_issues_job.rb b/app/jobs/populate_issues_job.rb
index 283fe4e9f..416e7aadc 100644
--- a/app/jobs/populate_issues_job.rb
+++ b/app/jobs/populate_issues_job.rb
@@ -47,8 +47,8 @@ def populate_issues(page_number)
upsert_mega_array = []
fetcher.as_json.each do |github_issue_hash|
- last_touched_at = github_issue_hash['updated_at'] ? DateTime.parse(github_issue_hash['updated_at']) : nil
- pr_attached = pr_attached_with_issue?(github_issue_hash['pull_request'])
+ last_touched_at = github_issue_hash["updated_at"] ? DateTime.parse(github_issue_hash["updated_at"]) : nil
+ pr_attached = pr_attached_with_issue?(github_issue_hash["pull_request"])
upsert_mega_array << {
repo_id: @repo.id,
@@ -56,11 +56,11 @@ def populate_issues(page_number)
last_touched_at: last_touched_at,
updated_at: @time_now,
created_at: @time_now,
- title: github_issue_hash['title'],
- url: github_issue_hash['url'],
- state: github_issue_hash['state'],
- html_url: github_issue_hash['html_url'],
- number: github_issue_hash['number']
+ title: github_issue_hash["title"],
+ url: github_issue_hash["url"],
+ state: github_issue_hash["state"],
+ html_url: github_issue_hash["html_url"],
+ number: github_issue_hash["number"]
}
end
diff --git a/app/jobs/repo_based_job.rb b/app/jobs/repo_based_job.rb
index b9a8af77d..ef0ec99b2 100644
--- a/app/jobs/repo_based_job.rb
+++ b/app/jobs/repo_based_job.rb
@@ -28,10 +28,10 @@
class RepoBasedJob < ApplicationJob
around_perform do |job, block|
repo_or_id = job.arguments[0]
- if repo_or_id.is_a?(Integer)
- repo = Repo.find(repo_or_id)
+ repo = if repo_or_id.is_a?(Integer)
+ Repo.find(repo_or_id)
else
- repo = repo_or_id
+ repo_or_id
end
job.arguments[0] = repo
ScoutApm::Context.add(repo_id: repo.id)
diff --git a/app/jobs/send_daily_triage_email_job.rb b/app/jobs/send_daily_triage_email_job.rb
index e01574d9f..d14ee0d95 100644
--- a/app/jobs/send_daily_triage_email_job.rb
+++ b/app/jobs/send_daily_triage_email_job.rb
@@ -10,11 +10,11 @@ def perform(user, force_send: false)
private
def reason_for_skip(user)
- return "Not time to send" if before_email_time_of_day?(user)
- return "No subscriptions" if user.repo_subscriptions.empty?
+ return "Not time to send" if before_email_time_of_day?(user)
+ return "No subscriptions" if user.repo_subscriptions.empty?
return "Sent email within 24 hours" if email_sent_today?(user)
- return "Email backoff" if skip_daily_email?(user)
- return false
+ return "Email backoff" if skip_daily_email?(user)
+ false
end
def skip?(user)
@@ -22,8 +22,8 @@ def skip?(user)
end
def send_daily_triage!(user)
- assignments = user.issue_assignments_to_deliver
- subscriptions = user.repo_subscriptions.order(Arel.sql('RANDOM()')).includes(:doc_assignments).load
+ assignments = user.issue_assignments_to_deliver
+ subscriptions = user.repo_subscriptions.order(Arel.sql("RANDOM()")).includes(:doc_assignments).load
docs = DocMailerMaker.new(user, subscriptions)
return if assignments.empty? && docs.empty?
@@ -62,7 +62,7 @@ def email_decider(user)
EmailRateLimit.new(user.days_since_last_clicked, minimum_frequency: user.email_frequency)
end
- DEFAULT_EMAIL_TIME_OF_DAY = Time.utc(2000, 1, 1, 17, 00, 0)
+ DEFAULT_EMAIL_TIME_OF_DAY = Time.utc(2000, 1, 1, 17, 0o0, 0)
def before_email_time_of_day?(user)
Time.current.change(year: 2000, month: 1, day: 1) < email_time_of_day_or_default(user)
diff --git a/app/jobs/send_single_triage_email_job.rb b/app/jobs/send_single_triage_email_job.rb
index a58ad88c5..52b721465 100644
--- a/app/jobs/send_single_triage_email_job.rb
+++ b/app/jobs/send_single_triage_email_job.rb
@@ -22,6 +22,6 @@ def perform(id, create: false)
def assignment(repo_sub = nil)
raise ArgumentError if repo_sub.nil? && @assignment.nil? # provide repo_sub first time
@assignment ||= repo_sub.user.issue_assignments.order(:created_at).eager_load(:repo_subscription)
- .where(repo_subscriptions: { repo_id: repo_sub.repo_id }).last
+ .where(repo_subscriptions: {repo_id: repo_sub.repo_id}).last
end
end
diff --git a/app/jobs/user_based_job.rb b/app/jobs/user_based_job.rb
index 71290eced..3b9cdb6dd 100644
--- a/app/jobs/user_based_job.rb
+++ b/app/jobs/user_based_job.rb
@@ -28,10 +28,10 @@
class UserBasedJob < ApplicationJob
around_perform do |job, block|
user_or_id = job.arguments[0]
- if user_or_id.is_a?(Integer)
- user = User.find(user_or_id)
+ user = if user_or_id.is_a?(Integer)
+ User.find(user_or_id)
else
- user = user_or_id
+ user_or_id
end
job.arguments[0] = user
ScoutApm::Context.add_user(github: user.github)
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index c10f257d5..16281ec78 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -11,12 +11,12 @@ class AbortDeliveryError < StandardError; end
rescue_from AbortDeliveryError, with: -> {}
def send_daily_triage(
- user_id:,
- assignment_ids:,
- email_at:,
- read_doc_ids: [],
- write_doc_ids: []
- )
+ user_id:,
+ assignment_ids:,
+ email_at:,
+ read_doc_ids: [],
+ write_doc_ids: []
+ )
user = User.find(user_id)
return unless set_and_check_user(user)
@@ -35,11 +35,11 @@ def send_daily_triage(
write_doc_ids: write_doc_ids
)
- subject = String.new
- if user.effective_streak_count.zero?
- subject << "[Start contributing today 💌]"
+ subject = +""
+ subject << if user.effective_streak_count.zero?
+ "[Start contributing today 💌]"
else
- subject << "[Grow your streak #{user. effective_streak_count} 💌]"
+ "[Grow your streak #{user.effective_streak_count} 💌]"
end
subject << " " unless subject.end_with?(" ")
@@ -61,9 +61,9 @@ def send_daily_triage(
def daily_docs(user:, write_docs:, read_docs:)
return unless set_and_check_user(user)
@write_docs = write_docs
- @read_docs = read_docs
- count = (@write_docs.try(:count) || 0) + (@read_docs.try(:count) || 0)
- subject = "Check out #{count} Open Source #{"Doc".pluralize(count)}"
+ @read_docs = read_docs
+ count = (@write_docs.try(:count) || 0) + (@read_docs.try(:count) || 0)
+ subject = "Check out #{count} Open Source #{"Doc".pluralize(count)}"
mail(to: @user.email, subject: subject)
end
@@ -82,8 +82,8 @@ def poke_inactive(user:, min_issue_count:, min_subscriber_count:)
query = Repo.active
query = repo.where(language: languages) if !languages.empty?
query = query
- .where("issues_count >= ?", min_issue_count)
- .where("subscribers_count >= ?", min_subscriber_count)
+ .where("issues_count >= ?", min_issue_count)
+ .where("subscribers_count >= ?", min_subscriber_count)
@repos = Random::CachedIdQuery.new(
query: query,
diff --git a/app/models/doc_class.rb b/app/models/doc_class.rb
index 4db14da00..e45bd1b5c 100644
--- a/app/models/doc_class.rb
+++ b/app/models/doc_class.rb
@@ -2,5 +2,5 @@
class DocClass < ActiveRecord::Base
belongs_to :repo
- has_many :doc_comments, dependent: :destroy
+ has_many :doc_comments, dependent: :destroy
end
diff --git a/app/models/doc_comment.rb b/app/models/doc_comment.rb
index c8a6d2aa6..0bf2d084b 100644
--- a/app/models/doc_comment.rb
+++ b/app/models/doc_comment.rb
@@ -4,8 +4,8 @@ class DocComment < ActiveRecord::Base
belongs_to :doc_method, counter_cache: true
belongs_to :doc_class, counter_cache: true
- validates :comment, uniqueness: { scope: [:doc_method_id, :doc_class_id] }
- validates :comment, presence: true
+ validates :comment, uniqueness: {scope: [:doc_method_id, :doc_class_id]}
+ validates :comment, presence: true
def doc_method?
doc_method_id.present?
@@ -13,7 +13,7 @@ def doc_method?
def md_safe_comment_block
md = comment
- md = DocMethod::NeedsDocs if md.blank?
+ md = DocMethod::NEEDS_DOCS if md.blank?
md
end
diff --git a/app/models/doc_mailer_maker.rb b/app/models/doc_mailer_maker.rb
index ce92e695e..acf07de95 100644
--- a/app/models/doc_mailer_maker.rb
+++ b/app/models/doc_mailer_maker.rb
@@ -8,15 +8,15 @@
#
# +#subs+ is an accessor for the collection of +Repo_Subscription+ objects pass to the class.
class DocMailerMaker
- attr_accessor :user, :subs, :write_docs, :read_docs
+ attr_accessor :user, :subs
- READY_FOR_NEXT_DEFAULT = Proc.new { |_s| true }
+ READY_FOR_NEXT_DEFAULT = proc { |_s| true }
def initialize(user, subs, _options = {}, &send_next)
- @user = user
- @subs = subs
+ @user = user
+ @subs = subs
@write_docs = []
- @read_docs = []
+ @read_docs = []
assign_docs(&(send_next || READY_FOR_NEXT_DEFAULT))
end
@@ -41,7 +41,7 @@ def assign_doc_to_subscription(doc, sub)
end
# Assigns documentation tasks to a subscription
- def assign_docs()
+ def assign_docs
subs.flat_map do |sub|
if !yield(sub)
Rails.logger.debug "Filtered: #{sub.inspect}"
@@ -52,7 +52,7 @@ def assign_docs()
# to the appropriate subscription queue.
if sub.read?
sub.unassigned_read_doc_methods.each do |doc|
- @read_docs << assign_doc_to_subscription(doc, sub)
+ @read_docs << assign_doc_to_subscription(doc, sub)
end
end
diff --git a/app/models/doc_method.rb b/app/models/doc_method.rb
index 33d937fca..29bdac4d9 100644
--- a/app/models/doc_method.rb
+++ b/app/models/doc_method.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
class DocMethod < ActiveRecord::Base
- NeedsDocs = "⚠ Needs Docs ⚠".freeze
+ NEEDS_DOCS = "⚠ Needs Docs ⚠"
belongs_to :repo
- has_many :doc_comments, dependent: :destroy, counter_cache: :doc_comments_count
+ has_many :doc_comments, dependent: :destroy, counter_cache: :doc_comments_count
validates :raw_file, :name, :path, presence: true
include ActiveRecord::CounterCache
def self.missing_docs
- where(doc_methods: { doc_comments_count: 0 })
+ where(doc_methods: {doc_comments_count: 0})
end
def self.active
@@ -33,7 +33,7 @@ def raw_file
def file
return nil if raw_file.blank?
_absolute, _match, relative = raw_file.partition(/(\/|^)#{repo.name}\//i)
- return relative
+ relative
end
# converts a doc method to a github path
diff --git a/app/models/email_rate_limit.rb b/app/models/email_rate_limit.rb
index afd2f16a9..47f899c2e 100644
--- a/app/models/email_rate_limit.rb
+++ b/app/models/email_rate_limit.rb
@@ -7,15 +7,15 @@
class EmailRateLimit
# USER_STATES = ["daily", "twice_a_week", "once_a_week", "once_a_month"]
USER_STATES_HASH = {}
- USER_STATES_HASH["daily"] = "Daily"
+ USER_STATES_HASH["daily"] = "Daily"
USER_STATES_HASH["twice_a_week"] = "Twice a week"
- USER_STATES_HASH["once_a_week"] = "Once a week"
+ USER_STATES_HASH["once_a_week"] = "Once a week"
USER_STATES_HASH["once_a_month"] = "Once a month"
USER_STATES = USER_STATES_HASH.keys
def initialize(last_clicked_days_ago, minimum_frequency: nil)
@last_clicked_days_ago = last_clicked_days_ago
- @minimum_frequency = minimum_frequency
+ @minimum_frequency = minimum_frequency
end
def skip?(last_sent_days_ago)
diff --git a/app/models/github_fetcher/commit_sha.rb b/app/models/github_fetcher/commit_sha.rb
index 9cce1a6a7..d598a6f65 100644
--- a/app/models/github_fetcher/commit_sha.rb
+++ b/app/models/github_fetcher/commit_sha.rb
@@ -4,17 +4,17 @@ module GithubFetcher
class CommitSha < Resource
def initialize(user_name:, name:, default_branch:)
@api_path = File.join(
- 'repos',
+ "repos",
user_name,
name,
- 'commits',
+ "commits",
default_branch || "master"
)
super({})
end
def commit_sha
- @commit_sha ||= as_json['sha']
+ @commit_sha ||= as_json["sha"]
end
end
end
diff --git a/app/models/github_fetcher/email.rb b/app/models/github_fetcher/email.rb
index 04b01e132..1b0284228 100644
--- a/app/models/github_fetcher/email.rb
+++ b/app/models/github_fetcher/email.rb
@@ -4,7 +4,7 @@ module GithubFetcher
class Email < Resource
def initialize(options)
super
- @api_path = '/user/emails'
+ @api_path = "/user/emails"
end
private
diff --git a/app/models/github_fetcher/issue.rb b/app/models/github_fetcher/issue.rb
index 9225435a9..83a989df8 100644
--- a/app/models/github_fetcher/issue.rb
+++ b/app/models/github_fetcher/issue.rb
@@ -4,10 +4,10 @@ module GithubFetcher
class Issue < Resource
def initialize(owner_name:, repo_name:, number:)
@api_path = File.join(
- 'repos',
+ "repos",
owner_name,
repo_name,
- 'issues',
+ "issues",
number.to_s
)
super({})
diff --git a/app/models/github_fetcher/issue_comments.rb b/app/models/github_fetcher/issue_comments.rb
index d3db95b4b..1735db613 100644
--- a/app/models/github_fetcher/issue_comments.rb
+++ b/app/models/github_fetcher/issue_comments.rb
@@ -4,12 +4,12 @@ module GithubFetcher
class IssueComments < Resource
def initialize(owner_name:, repo_name:, number:)
@api_path = File.join(
- 'repos',
+ "repos",
owner_name,
repo_name,
- 'issues',
+ "issues",
number.to_s,
- 'comments'
+ "comments"
)
super({})
end
diff --git a/app/models/github_fetcher/issues.rb b/app/models/github_fetcher/issues.rb
index 65b6ea28a..b19a4bb88 100644
--- a/app/models/github_fetcher/issues.rb
+++ b/app/models/github_fetcher/issues.rb
@@ -4,16 +4,16 @@ module GithubFetcher
class Issues < Resource
def initialize(options)
@api_path = File.join(
- 'repos',
+ "repos",
options.delete(:user_name),
options.delete(:name),
- 'issues'
+ "issues"
)
- options[:sort] ||= 'comments'
- options[:direction] ||= 'desc'
- options[:state] ||= 'open'
- options[:page] ||= 1
+ options[:sort] ||= "comments"
+ options[:direction] ||= "desc"
+ options[:state] ||= "open"
+ options[:page] ||= 1
super
end
diff --git a/app/models/github_fetcher/repo.rb b/app/models/github_fetcher/repo.rb
index 9b092b22d..6394a2579 100644
--- a/app/models/github_fetcher/repo.rb
+++ b/app/models/github_fetcher/repo.rb
@@ -4,15 +4,15 @@ module GithubFetcher
class Repo < Resource
def initialize(options)
@api_path = File.join(
- 'repos',
+ "repos",
options.delete(:user_name),
- options.delete(:name),
+ options.delete(:name)
)
super
end
def default_branch
- as_json['default_branch']
+ as_json["default_branch"]
end
# TODO - does this really belong here? Seems like it (and Repo#populate_docs!)
@@ -20,7 +20,7 @@ def default_branch
def clone
out = `cd #{dir} && git clone #{clone_url} 2>&1`
raise "Error executing git clone #{clone_url.inspect}: #{out.inspect}" unless $?.success?
- return dir
+ dir
end
private
diff --git a/app/models/github_fetcher/repos.rb b/app/models/github_fetcher/repos.rb
index e3fbd212d..72aba87ab 100644
--- a/app/models/github_fetcher/repos.rb
+++ b/app/models/github_fetcher/repos.rb
@@ -3,21 +3,21 @@
module GithubFetcher
class Repos < Resource
KINDS = [
- OWNED = 'repos',
- STARRED = 'starred',
- SUBSCRIBED = 'subscriptions'
+ OWNED = "repos",
+ STARRED = "starred",
+ SUBSCRIBED = "subscriptions"
]
def initialize(options)
unless options[:kind].in? KINDS
- raise TypeError.new("kind must be one of #{KINDS.join(', ')} (#{options[:kind]} invalid)")
+ raise TypeError.new("kind must be one of #{KINDS.join(", ")} (#{options[:kind]} invalid)")
end
- options[:type] = 'owner' if options[:kind] == OWNED
+ options[:type] = "owner" if options[:kind] == OWNED
@api_path = File.join(
- 'user',
- options.delete(:kind),
+ "user",
+ options.delete(:kind)
)
super
end
diff --git a/app/models/github_fetcher/resource.rb b/app/models/github_fetcher/resource.rb
index 560191f22..832c788b2 100644
--- a/app/models/github_fetcher/resource.rb
+++ b/app/models/github_fetcher/resource.rb
@@ -41,12 +41,12 @@ def as_json
# Generally not over-ridden
def response
@response ||= begin
- GitHubBub.get(api_path, options)
- rescue GitHubBub::RequestError => e
- @error = e
- @error_message = e.message
- null_response(e)
- end
+ GitHubBub.get(api_path, options)
+ rescue GitHubBub::RequestError => e
+ @error = e
+ @error_message = e.message
+ null_response(e)
+ end
end
def success?
@@ -57,7 +57,7 @@ def success?
end
def not_found?
- status == 404 ? true : false
+ status == 404
end
def bad_token?
diff --git a/app/models/github_fetcher/user.rb b/app/models/github_fetcher/user.rb
index d66a9830e..df07e7c93 100644
--- a/app/models/github_fetcher/user.rb
+++ b/app/models/github_fetcher/user.rb
@@ -3,16 +3,14 @@
module GithubFetcher
class User < Resource
def initialize(options)
- @api_path = '/user'
+ @api_path = "/user"
super
end
def valid?
- begin
- GitHubBub.valid_token?(@options[:token])
- rescue GitHubBub::RequestError
- false
- end
+ GitHubBub.valid_token?(@options[:token])
+ rescue GitHubBub::RequestError
+ false
end
end
end
diff --git a/app/models/github_url_from_base_path_line.rb b/app/models/github_url_from_base_path_line.rb
index 2ba88df35..af3d6be3e 100644
--- a/app/models/github_url_from_base_path_line.rb
+++ b/app/models/github_url_from_base_path_line.rb
@@ -10,6 +10,6 @@ def initialize(base, commit_sha, path, line)
# https://github.com/codetriage/docs_doctor/blob/f5dd91595d5cdad0a2348515c6f715ef19c51070/app/models/github_url_from_base_path_line.rb#L10
def to_github
- File.join(@base, 'blob', @commit_sha, @path, "#L#{@line}")
+ File.join(@base, "blob", @commit_sha, @path, "#L#{@line}")
end
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index d3edc842c..93461e64b 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
class Issue < ActiveRecord::Base
- OPEN = "open"
+ OPEN = "open"
CLOSED = "closed"
- validates :state, inclusion: { in: [OPEN, CLOSED] }
+ validates :state, inclusion: {in: [OPEN, CLOSED]}
validates :number, presence: true
belongs_to :repo
@@ -13,8 +13,8 @@ def valid_for_user?(user, can_access_network: !Rails.env.test?, repo: nil)
update_issue!(repo)
return false if commenting_users(repo).include?(user.github)
end
- return false if closed?
- return false if pr_attached? && user.skip_issues_with_pr?
+ return false if closed?
+ return false if pr_attached? && user.skip_issues_with_pr?
true
end
@@ -22,7 +22,7 @@ def fetcher(repo = nil)
@fetcher ||= GithubFetcher::Issue.new(
owner_name: repo.try(:user_name) || owner_name,
repo_name: repo.try(:name) || repo_name,
- number: number,
+ number: number
)
end
@@ -30,7 +30,7 @@ def comments_fetcher(repo = nil)
@comments_fetcher ||= GithubFetcher::IssueComments.new(
owner_name: repo.try(:user_name) || owner_name,
repo_name: repo.try(:name) || repo_name,
- number: number,
+ number: number
)
end
@@ -57,11 +57,11 @@ def open?
end
def repo_name
- self.repo.name
+ repo.name
end
def owner_name
- self.repo.user_name
+ repo.user_name
end
def public_url
@@ -75,36 +75,35 @@ def commenting_users(repo = nil)
end
def self.find_or_create_from_hash!(issue_hash, repo)
- issue = Issue.find_or_create_by(number: issue_hash['number'], repo: repo)
+ issue = Issue.find_or_create_by(number: issue_hash["number"], repo: repo)
issue.update_from_github_hash!(issue_hash)
end
def update_from_github_hash!(issue_hash)
- last_touched_at = issue_hash['updated_at'] ? DateTime.parse(issue_hash['updated_at']) : nil
-
- self.update!(title: issue_hash['title'],
- url: issue_hash['url'],
- last_touched_at: last_touched_at,
- state: issue_hash['state'],
- html_url: issue_hash['html_url'],
- number: issue_hash['number'],
- pr_attached: pr_attached_with_issue?(issue_hash['pull_request']))
+ last_touched_at = issue_hash["updated_at"] ? DateTime.parse(issue_hash["updated_at"]) : nil
+
+ update!(title: issue_hash["title"],
+ url: issue_hash["url"],
+ last_touched_at: last_touched_at,
+ state: issue_hash["state"],
+ html_url: issue_hash["html_url"],
+ number: issue_hash["number"],
+ pr_attached: pr_attached_with_issue?(issue_hash["pull_request"]))
rescue => e
raise e, "#{e.message} issue_id: #{id}, issue_hash: #{issue_hash.inspect}"
end
def self.create_from_github_hash!(issue_hash, repo:)
- last_touched_at = issue_hash['updated_at'] ? DateTime.parse(issue_hash['updated_at']) : nil
+ last_touched_at = issue_hash["updated_at"] ? DateTime.parse(issue_hash["updated_at"]) : nil
Issue.create!(repo_id: repo.id,
- title: issue_hash['title'],
- url: issue_hash['url'],
- last_touched_at: last_touched_at,
- state: issue_hash['state'],
- html_url: issue_hash['html_url'],
- number: issue_hash['number'],
- pr_attached: pr_attached_with_issue?(issue_hash['pull_request']))
-
+ title: issue_hash["title"],
+ url: issue_hash["url"],
+ last_touched_at: last_touched_at,
+ state: issue_hash["state"],
+ html_url: issue_hash["html_url"],
+ number: issue_hash["number"],
+ pr_attached: pr_attached_with_issue?(issue_hash["pull_request"]))
rescue => e
raise e, "#{e.message} issue_hash: #{issue_hash.inspect}"
end
@@ -114,8 +113,6 @@ def self.queue_mark_old_as_closed!
.update_all(state: CLOSED)
end
- private
-
def self.pr_attached_with_issue?(pull_request_hash)
# issue_hash['pull_request'] has following structure
# pull_request: {
@@ -128,7 +125,7 @@ def self.pr_attached_with_issue?(pull_request_hash)
pull_request_hash.values.uniq != [nil]
end
- def pr_attached_with_issue?(pull_request_hash)
+ private def pr_attached_with_issue?(pull_request_hash)
self.class.pr_attached_with_issue?(pull_request_hash)
end
end
diff --git a/app/models/issue_assigner.rb b/app/models/issue_assigner.rb
index 72c1ef39a..effbf3249 100644
--- a/app/models/issue_assigner.rb
+++ b/app/models/issue_assigner.rb
@@ -14,7 +14,7 @@ class IssueAssigner
attr_reader :user, :subscriptions
def initialize(user, subscriptions, can_access_network: !Rails.env.test?)
- @user = user
+ @user = user
@subscriptions = subscriptions
@assigned_count_hash = Hash.new { |hash, key| hash[key] = 0 }
@can_access_network = can_access_network
@@ -74,6 +74,6 @@ def assign!
LIMIT
:email_limit
SQL
- Issue.find_by_sql([sql, { sub_id: sub.id, issue_state: Issue::OPEN, repo_id: sub.repo_id, email_limit: sub.email_limit }]).first(sub.email_limit)
+ Issue.find_by_sql([sql, {sub_id: sub.id, issue_state: Issue::OPEN, repo_id: sub.repo_id, email_limit: sub.email_limit}]).first(sub.email_limit)
end
end
diff --git a/app/models/issue_assignment.rb b/app/models/issue_assignment.rb
index ac6df4c67..b85d1a821 100644
--- a/app/models/issue_assignment.rb
+++ b/app/models/issue_assignment.rb
@@ -2,9 +2,9 @@
class IssueAssignment < ActiveRecord::Base
belongs_to :repo_subscription
- has_one :user, through: :repo_subscription
- has_one :repo, through: :repo_subscription
+ has_one :user, through: :repo_subscription
+ has_one :repo, through: :repo_subscription
belongs_to :issue
- validates :repo_subscription_id, presence: true
- validates :issue_id, uniqueness: { scope: :repo_subscription_id }, presence: true
+ validates :repo_subscription_id, presence: true
+ validates :issue_id, uniqueness: {scope: :repo_subscription_id}, presence: true
end
diff --git a/app/models/mail_builder/grouped_issues_docs.rb b/app/models/mail_builder/grouped_issues_docs.rb
index 9efb7c189..5ec9a63c6 100644
--- a/app/models/mail_builder/grouped_issues_docs.rb
+++ b/app/models/mail_builder/grouped_issues_docs.rb
@@ -51,43 +51,43 @@ module MailBuilder
#
class GroupedIssuesDocs
def initialize(user_id:, assignment_ids: [], read_doc_ids: [], write_doc_ids: [], random_seed: Random.new_seed)
- @active = false
- @sub_hashes = {}
- @repo_id_to_sub = {}
+ @active = false
+ @sub_hashes = {}
+ @repo_id_to_sub = {}
@doc_comments_hash = {}
- @error_hash = Hash.new { raise "must call within each" }
- @active_hash = @error_hash
+ @error_hash = Hash.new { raise "must call within each" }
+ @active_hash = @error_hash
- @any_docs = read_doc_ids.present? || write_doc_ids.present?
+ @any_docs = read_doc_ids.present? || write_doc_ids.present?
@any_issues = assignment_ids.present?
## Issue assignments
assignments = IssueAssignment
- .where(id: assignment_ids)
- .includes(:issue)
- .select(:id, :repo_subscription_id, :issue_id)
+ .where(id: assignment_ids)
+ .includes(:issue)
+ .select(:id, :repo_subscription_id, :issue_id)
## Docs
docs = DocMethod
- .where(id: write_doc_ids + read_doc_ids)
- .select(:id, :repo_id, :line, :file, :path)
+ .where(id: write_doc_ids + read_doc_ids)
+ .select(:id, :repo_id, :line, :file, :path)
## Comments
doc_comments = DocComment
- .where(doc_method_id: docs.map(&:id).uniq)
- .select(:comment, :doc_method_id)
+ .where(doc_method_id: docs.map(&:id).uniq)
+ .select(:comment, :doc_method_id)
## Subscriptions
doc_repo_ids = docs.map(&:repo_id).uniq
subscriptions = RepoSubscription
- .joins("LEFT OUTER JOIN issue_assignments ON issue_assignments.repo_subscription_id = repo_subscriptions.id")
- .where("issue_assignments.id in (?) or repo_id in (?)", assignment_ids, doc_repo_ids)
- .where(user_id: user_id)
- .select(:id, :repo_id)
- .includes(:repo)
- .all
- .shuffle(random: Random.new(random_seed))
+ .joins("LEFT OUTER JOIN issue_assignments ON issue_assignments.repo_subscription_id = repo_subscriptions.id")
+ .where("issue_assignments.id in (?) or repo_id in (?)", assignment_ids, doc_repo_ids)
+ .where(user_id: user_id)
+ .select(:id, :repo_id)
+ .includes(:repo)
+ .all
+ .shuffle(random: Random.new(random_seed))
store_subscriptions!(subscriptions)
store_assignments!(assignments)
@@ -105,9 +105,8 @@ def store_subscriptions!(subscriptions)
@sub_hashes[sub.id] ||= {}
@sub_hashes[sub.id][:repo] = sub.repo
@sub_hashes[sub.id][:assignments] ||= []
- @sub_hashes[sub.id][:read_docs] ||= []
- @sub_hashes[sub.id][:write_docs] ||= []
- @sub_hashes
+ @sub_hashes[sub.id][:read_docs] ||= []
+ @sub_hashes[sub.id][:write_docs] ||= []
end
end
@@ -119,7 +118,7 @@ def store_assignments!(assignments)
def store_docs!(write_doc_ids:, docs:, doc_comments:)
write_docs = []
- read_docs = []
+ read_docs = []
docs.each do |doc|
if write_doc_ids.include?(doc.id)
write_docs << doc
@@ -145,10 +144,10 @@ def store_docs!(write_doc_ids:, docs:, doc_comments:)
def each
@sub_hashes.each do |_, hash|
- @active = true
+ @active = true
@active_hash = hash
yield self
- @active = false
+ @active = false
@active_hash = @error_hash
end
end
@@ -172,20 +171,20 @@ def write_docs
def any_docs
return @any_docs if !@active
- return read_docs.any? || write_docs.any?
+ read_docs.any? || write_docs.any?
end
def any_issues
return @any_issues if !@active
- return assignments.any?
+ assignments.any?
end
- alias :any_docs? :any_docs
- alias :any_issues? :any_issues
+ alias_method :any_docs?, :any_docs
+ alias_method :any_issues?, :any_issues
def actions(delimiter: "and")
- return "issues" if !self.any_docs
- return "docs" if !self.any_issues
+ return "issues" if !any_docs
+ return "docs" if !any_issues
"issues #{delimiter} docs"
end
diff --git a/app/models/repo.rb b/app/models/repo.rb
index 2adcc9baf..8ac9294fa 100644
--- a/app/models/repo.rb
+++ b/app/models/repo.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'docs_doctor/parsers/ruby/yard'
+require "docs_doctor/parsers/ruby/yard"
class Repo < ActiveRecord::Base
# Now done at the DB level # validates :name, uniqueness: {scope: :user_name, case_sensitive: false }
@@ -22,7 +22,7 @@ class Repo < ActiveRecord::Base
before_validation :set_full_name!, :downcase_name, :strip_whitespaces
after_create :background_populate_issues!, :update_repo_info!, :background_populate_docs!
- CLASS_FOR_DOC_LANGUAGE = { "ruby" => DocsDoctor::Parsers::Ruby::Yard }
+ CLASS_FOR_DOC_LANGUAGE = {"ruby" => DocsDoctor::Parsers::Ruby::Yard}
scope :archived, -> { where(archived: true) }
scope :not_archived, -> { where(archived: false) }
@@ -67,13 +67,13 @@ def populate_docs!(commit_sha: commit_sha_fetcher.commit_sha, location: nil, has
return "Skipped, no commit SHA" unless commit_sha
return "Skipped, no subscribers" unless has_subscribers
- self.update!(commit_sha: commit_sha)
+ update!(commit_sha: commit_sha)
location ||= fetcher.clone
parser = class_for_doc_language.new(location)
parser.process
parser.store(self)
- return :success
+ :success
end
def background_populate_issues!
@@ -85,7 +85,7 @@ def background_populate_docs!
end
def methods_missing_docs
- doc_methods.where(doc_methods: { doc_comments_count: 0 })
+ doc_methods.where(doc_methods: {doc_comments_count: 0})
end
def methods_with_docs
@@ -93,32 +93,32 @@ def methods_with_docs
end
def classes_missing_docs
- doc_classes.where(doc_classes: { doc_comments_count: 0 })
+ doc_classes.where(doc_classes: {doc_comments_count: 0})
end
def color
case weight
when "low"
- "5bb878".freeze
+ "5bb878"
when "medium"
- "eba117".freeze
+ "eba117"
when "high"
- "e25443".freeze
+ "e25443"
else
- "lightgrey".freeze
+ "lightgrey"
end
end
def weight
case issues_count
when 0..199
- "low".freeze
+ "low"
when 200..799
- "medium".freeze
+ "medium"
when 800..Float::INFINITY
- "high".freeze
+ "high"
else
- "".freeze
+ ""
end
end
@@ -151,8 +151,8 @@ def self.repos_needing_help_for_user(user)
end
def force_issues_count_sync!
- self.update!(
- issues_count: self.issues.where(state: "open").count,
+ update!(
+ issues_count: issues.where(state: "open").count,
docs_subscriber_count: query_docs_subscriber_count
)
end
@@ -162,7 +162,7 @@ def to_param
end
def self.order_by_issue_count
- self.order("issues_count DESC")
+ order("issues_count DESC")
end
def self.search_by(repo_name, user_name)
@@ -170,28 +170,28 @@ def self.search_by(repo_name, user_name)
end
def self.with_some_issues
- self.where("issues_count > 0")
+ where("issues_count > 0")
end
def self.without_user_subscriptions(user_id)
user_subscribed_repo_ids = RepoSubscription.where(user_id: user_id).select(:repo_id)
- self.where.not(id: user_subscribed_repo_ids)
+ where.not(id: user_subscribed_repo_ids)
end
def github_url
- File.join('https://github.com', full_name)
+ File.join("https://github.com", full_name)
end
def self.exists_with_name?(name)
- user_name, repo_name = name.downcase.split(?/)
+ user_name, repo_name = name.downcase.split("/")
Repo.exists?(user_name: user_name, name: repo_name)
end
def update_from_github
if fetcher.not_found?
- self.update!(removed_from_github: true)
+ update!(removed_from_github: true)
elsif fetcher.success?
- repo_full_name = fetcher_json.fetch('full_name', full_name)
+ repo_full_name = fetcher_json.fetch("full_name", full_name)
if repo_full_name != full_name && self.class.exists_with_name?(repo_full_name)
# TODO: Add deduplication step
@@ -199,20 +199,20 @@ def update_from_github
end
repo_user_name, repo_name = repo_full_name.split("/")
- self.update!(
+ update!(
name: repo_name,
user_name: repo_user_name,
- language: fetcher_json.fetch('language', language),
- description: fetcher_json.fetch('description', description)&.first(255),
+ language: fetcher_json.fetch("language", language),
+ description: fetcher_json.fetch("description", description)&.first(255),
full_name: repo_full_name,
removed_from_github: false,
- archived: fetcher_json.fetch('archived', archived)
+ archived: fetcher_json.fetch("archived", archived)
)
end
end
def repo_path
- File.join 'repos', path
+ File.join "repos", path
end
def active?
@@ -228,21 +228,21 @@ def update_repo_info!
end
private def downcase_name
- self.name.downcase!
- self.user_name.downcase!
+ name.downcase!
+ user_name.downcase!
end
private def set_full_name!
- if self.full_name && user_name.blank?
- self.user_name, self.name = self.full_name.split("/")
+ if full_name && user_name.blank?
+ self.user_name, self.name = full_name.split("/")
else
self.full_name = "#{user_name}/#{name}"
end
end
private def strip_whitespaces
- self.name.strip!
- self.user_name.strip!
+ name.strip!
+ user_name.strip!
end
private def github_url_exists
@@ -262,6 +262,6 @@ def update_repo_info!
repo_id = :repo_id AND
(read = true OR write = true)
SQL
- RepoSubscription.count_by_sql([sql, { repo_id: self.id }])
+ RepoSubscription.count_by_sql([sql, {repo_id: id}])
end
end
diff --git a/app/models/repo_subscription.rb b/app/models/repo_subscription.rb
index dca69ae12..7b6a3006d 100644
--- a/app/models/repo_subscription.rb
+++ b/app/models/repo_subscription.rb
@@ -1,34 +1,26 @@
# frozen_string_literal: true
class RepoSubscription < ActiveRecord::Base
- DEFAULT_READ_LIMIT = 3
+ DEFAULT_READ_LIMIT = 3
DEFAULT_WRITE_LIMIT = 3
- validates :repo_id, uniqueness: { scope: :user_id }, presence: true
- validates :user_id, presence: true
- validates :email_limit, numericality: { less_than: 21, greater_than_or_equal_to: 0 }
+ validates :repo_id, uniqueness: {scope: :user_id}, presence: true
+ validates :user_id, presence: true
+ validates :email_limit, numericality: {less_than: 21, greater_than_or_equal_to: 0}
belongs_to :repo, counter_cache: :subscribers_count, touch: true
belongs_to :user
- has_many :issue_assignments
- has_many :issues, through: :issue_assignments
- has_many :doc_assignments
+ has_many :issue_assignments
+ has_many :issues, through: :issue_assignments
+ has_many :doc_assignments
before_save :set_read_write
def set_read_write
- if read_limit.blank? || read_limit.zero?
- self.read = false
- else
- self.read = true
- end
+ self.read = !(read_limit.blank? || read_limit.zero?)
- if write_limit.blank? || write_limit.zero?
- self.write = false
- else
- self.write = true
- end
+ self.write = !(write_limit.blank? || write_limit.zero?)
true
end
@@ -46,7 +38,7 @@ def not_ready_for_next?
!ready_for_next?
end
- def unassigned_read_doc_methods(limit = self.read_limit)
+ def unassigned_read_doc_methods(limit = read_limit)
docs = repo.methods_with_docs
if doc_assignments.any?
docs = docs.where("doc_methods.id NOT IN (?)", doc_assignments.select(:doc_method_id))
@@ -59,7 +51,7 @@ def unassigned_read_doc_methods(limit = self.read_limit)
.limit(limit || DEFAULT_READ_LIMIT)
end
- def unassigned_write_doc_methods(limit = self.write_limit)
+ def unassigned_write_doc_methods(limit = write_limit)
docs = repo.methods_missing_docs
if doc_assignments.any?
docs = docs.where("doc_methods.id NOT IN (?)", doc_assignments.select(:doc_method_id))
diff --git a/app/models/user.rb b/app/models/user.rb
index c77d87cf3..a2b76940b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -6,10 +6,10 @@ class User < ActiveRecord::Base
# :omniauthable, and :registerable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :omniauthable
- validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
- validates_length_of :password, within: 8..128, allow_blank: true
+ validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
+ validates_length_of :password, within: 8..128, allow_blank: true
validates :github, presence: true, uniqueness: true
- validates :email_frequency, inclusion: { in: EmailRateLimit::USER_STATES.map(&:to_s) + [nil], message: "Not a valid frequency, pick from #{EmailRateLimit::USER_STATES}" }
+ validates :email_frequency, inclusion: {in: EmailRateLimit::USER_STATES.map(&:to_s) + [nil], message: "Not a valid frequency, pick from #{EmailRateLimit::USER_STATES}"}
# Setup accessible (or protected) attributes for your model
@@ -17,9 +17,9 @@ class User < ActiveRecord::Base
has_many :repos, through: :repo_subscriptions
has_many :issue_assignments, through: :repo_subscriptions
- has_many :issues, through: :issue_assignments
+ has_many :issues, through: :issue_assignments
- scope :public_profile, -> { where.not(users: { private: true }) }
+ scope :public_profile, -> { where.not(users: {private: true}) }
alias_attribute :token, :github_access_token
@@ -57,19 +57,19 @@ def emails_missed_since_click
def effective_streak_count
value = raw_streak_count - emails_missed_since_click
return 0 if value < 0
- return value
+ value
end
def record_click!(save: true)
return if raw_emails_since_click.zero?
- self.raw_streak_count = effective_streak_count + 1
+ self.raw_streak_count = effective_streak_count + 1
self.raw_emails_since_click = 0
- self.save! if save
+ save! if save
end
def subscribe_docs!
- subscriptions = self.repo_subscriptions.order(Arel.sql('RANDOM()')).load
+ subscriptions = repo_subscriptions.order(Arel.sql("RANDOM()")).load
DocMailerMaker.new(self, subscriptions) { |sub| sub.ready_for_next? }.deliver_later
end
@@ -94,7 +94,7 @@ def fetcher
end
def repos_fetcher(kind, options = {})
- GithubFetcher::Repos.new({ token: token, kind: kind }.merge(options))
+ GithubFetcher::Repos.new({token: token, kind: kind}.merge(options))
end
def auth_is_valid?
@@ -106,7 +106,7 @@ def auth_is_valid?
# Much faster than order("RANDOM()") but it's
# not guaranteed to return results
def self.fast_rand
- @@max_id = self.maximum(:id) if @@max_id.nil?
+ @@max_id = maximum(:id) if @@max_id.nil?
where("id >= ?", Random.new.rand(1..@@max_id))
end
@@ -125,7 +125,7 @@ def account_delete_token
end
def enqueue_inactive_email
- background_inactive_email(self.id)
+ background_inactive_email(id)
end
def able_to_edit_repo?(repo)
@@ -145,7 +145,7 @@ def subscribed_to?(repo)
end
def sub_from_repo(repo)
- self.repo_subscriptions.find_by(repo_id: repo.id)
+ repo_subscriptions.find_by(repo_id: repo.id)
end
def github_json
@@ -157,8 +157,8 @@ def fetch_avatar_url
end
def set_avatar_url!
- self.avatar_url = self.fetch_avatar_url || default_avatar_url
- self.save!
+ self.avatar_url = fetch_avatar_url || default_avatar_url
+ save!
end
def github_url
@@ -178,14 +178,14 @@ def days_since_last_clicked
def days_since_last_email
last_sent_at = repo_subscriptions.where("last_sent_at is not null").order(:last_sent_at).first.try(:last_sent_at)
- last_sent_at ||= self.created_at
+ last_sent_at ||= created_at
(
(Time.now - last_sent_at) / 1.day
).ceil # only want whole days
end
def favorite_language?(language)
- favorite_languages.include? language if favorite_languages
+ favorite_languages&.include? language
end
def has_favorite_languages?
diff --git a/app/services/git_hub_authenticator.rb b/app/services/git_hub_authenticator.rb
index 9dfdec7dc..ea70ace83 100644
--- a/app/services/git_hub_authenticator.rb
+++ b/app/services/git_hub_authenticator.rb
@@ -26,7 +26,7 @@ def authenticate
def find_user
current_user ||
User.find_by(github: auth.info.nickname) ||
- User.find_by(email: auth_email)
+ User.find_by(email: auth_email)
end
def auth_email
diff --git a/app/services/repo_label_assigner.rb b/app/services/repo_label_assigner.rb
index 09177abf3..f28058223 100644
--- a/app/services/repo_label_assigner.rb
+++ b/app/services/repo_label_assigner.rb
@@ -13,7 +13,7 @@
class RepoLabelAssigner
def initialize(repo:)
@repo = repo
- url = ['repos', repo.user_name, repo.name, 'labels'].join('/')
+ url = ["repos", repo.user_name, repo.name, "labels"].join("/")
@github_bub_response = GitHubBub.get(url)
end
@@ -21,7 +21,7 @@ def create_and_associate_labels!
return unless github_bub_response.success?
remote_labels.each do |label_hash|
- label_name = label_hash['name'].downcase
+ label_name = label_hash["name"].downcase
label = Label.where(name: label_name).first_or_create!
repo.repo_labels.where(label: label).first_or_create
end
diff --git a/app/views/user_mailer/send_daily_triage.md.erb b/app/views/user_mailer/send_daily_triage.md.erb
index 5bf02c399..ba1977752 100644
--- a/app/views/user_mailer/send_daily_triage.md.erb
+++ b/app/views/user_mailer/send_daily_triage.md.erb
@@ -39,7 +39,7 @@ Hello @<%= @user.github %>,
⇢ [<%= doc.path %>](<%= doc_method_url doc %>) ([source](<%= doc.to_github %>))
- <%= DocMethod::NeedsDocs %>
+ <%= DocMethod::NEEDS_DOCS %>
<% end %>
diff --git a/config.ru b/config.ru
index 247ea4fd2..a9fcde5db 100644
--- a/config.ru
+++ b/config.ru
@@ -2,7 +2,7 @@
# This file is used by Rack-based servers to start the application.
-require 'rbtrace'
+require "rbtrace"
require_relative "config/environment"
run Rails.application
diff --git a/config/application.rb b/config/application.rb
index 2f1761484..ed095d004 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "boot"
require "rails/all"
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 0285f8653..f3a6ae70b 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require "active_support/core_ext/integer/time"
Rails.application.configure do
@@ -17,13 +18,13 @@
# 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
config.cache_store = :memory_store
config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{2.days.to_i}"
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
@@ -59,7 +60,7 @@
# number of complex assets.
config.assets.debug = !ENV["PROFILE"]
- config.action_mailer.default_url_options = { host: "localhost:#{ENV.fetch("PORT") { '3000' }}" }
+ config.action_mailer.default_url_options = {host: "localhost:#{ENV.fetch("PORT") { "3000" }}"}
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
@@ -74,15 +75,15 @@
if ENV["PROFILE"]
config.public_file_server.enabled = true
config.public_file_server.headers = {
- 'Cache-Control' => 'public, s-maxage=31536000, maxage=31536000',
- 'Expires' => "#{1.year.from_now.to_formatted_s(:rfc822)}"
+ "Cache-Control" => "public, s-maxage=31536000, maxage=31536000",
+ "Expires" => 1.year.from_now.to_formatted_s(:rfc822).to_s
}
config.assets.compile = false
# Prod-like logging
- logger = ActiveSupport::Logger.new(STDOUT)
+ logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
- config.logger = ActiveSupport::TaggedLogging.new(logger)
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
config.action_view.cache_template_loading = true
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 115a1a5e9..cfa63b272 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -15,7 +15,7 @@
config.eager_load = true
# Full error reports are disabled and caching is turned on.
- config.consider_all_requests_local = false
+ config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
@@ -24,21 +24,21 @@
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
- config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
config.public_file_server.headers = {
- 'Cache-Control' => 'public, s-maxage=31536000, maxage=31536000',
- 'Expires' => "#{1.year.from_now.to_formatted_s(:rfc822)}"
+ "Cache-Control" => "public, s-maxage=31536000, maxage=31536000",
+ "Expires" => 1.year.from_now.to_formatted_s(:rfc822).to_s
}
# Compress JavaScripts and CSS.
- config.assets.js_compressor = Uglifier.new(:harmony => true)
+ config.assets.js_compressor = Uglifier.new(harmony: true)
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
- config.action_mailer.asset_host = "https://www.codetriage.com"
- config.action_mailer.default_url_options = { host: "codetriage.com" }
+ config.action_mailer.asset_host = "https://www.codetriage.com"
+ config.action_mailer.default_url_options = {host: "codetriage.com"}
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
@@ -94,9 +94,9 @@
# 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)
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
@@ -107,15 +107,15 @@
# config.cache_store = :file_store, "tmp/to/cache/directory"
#
- if ENV["MEMCACHIER_SERVERS"]
- config.cache_store = [:mem_cache_store, (ENV["MEMCACHIER_SERVERS"] || "").split(","),
- { :username => ENV["MEMCACHIER_USERNAME"],
- :password => ENV["MEMCACHIER_PASSWORD"],
- :failover => true,
- :socket_timeout => 1.5,
- :socket_failure_delay => 0.2 }]
+ config.cache_store = if ENV["MEMCACHIER_SERVERS"]
+ [:mem_cache_store, (ENV["MEMCACHIER_SERVERS"] || "").split(","),
+ {username: ENV["MEMCACHIER_USERNAME"],
+ password: ENV["MEMCACHIER_PASSWORD"],
+ failover: true,
+ socket_timeout: 1.5,
+ socket_failure_delay: 0.2}]
else
- config.cache_store = :mem_cache_store
+ :mem_cache_store
end
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 50fb0fa15..f8c0cf95a 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-#
+
require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's
@@ -20,11 +20,11 @@
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.
- config.consider_all_requests_local = true
+ config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :null_store
@@ -55,7 +55,7 @@
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
- config.action_mailer.default_url_options = { host: 'example.com' }
+ config.action_mailer.default_url_options = {host: "example.com"}
config.cache_store = :memory_store
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index a9b0d0f10..ba194685a 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -3,12 +3,12 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
-Rails.application.config.assets.version = '1.0'
+Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
-Rails.application.config.assets.paths << Rails.root.join('node_modules')
+Rails.application.config.assets.paths << Rails.root.join("node_modules")
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
diff --git a/config/initializers/covid.rb b/config/initializers/covid.rb
index bf4e73842..a200f9dde 100644
--- a/config/initializers/covid.rb
+++ b/config/initializers/covid.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# Here is how to add a "COVID-19" related resource to the project
#
# 1) Find the GitHub url of the project such as `https://github.com/nextstrain/ncov`
@@ -7,7 +8,7 @@
# 4) Save the file in the UI and submit a PR
# 5) Repeat
#
-COVID_REPOS = %W{
+COVID_REPOS = %W[
nextstrain/ncov
jcl5m1/ventilator
CSSEGISandData/COVID-19
@@ -31,4 +32,4 @@
Leo1690/BtPedalClient
Leo1690/BtPedalServer
covid19india/covid19india-react
-}
+]
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 16a3935d8..faf443a79 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -15,7 +15,7 @@
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
- require 'devise/orm/active_record'
+ require "devise/orm/active_record"
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
@@ -205,7 +205,7 @@
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
- config.omniauth :github, ENV['GITHUB_APP_ID'], ENV['GITHUB_APP_SECRET'], scope: 'user:email'
+ config.omniauth :github, ENV["GITHUB_APP_ID"], ENV["GITHUB_APP_SECRET"], scope: "user:email"
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
@@ -218,5 +218,5 @@
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
- config.secret_key = ENV['DEVISE_SECRET_KEY']
+ config.secret_key = ENV["DEVISE_SECRET_KEY"]
end
diff --git a/config/initializers/git_hub_bub.rb b/config/initializers/git_hub_bub.rb
index ba9020d0d..a93e890ec 100644
--- a/config/initializers/git_hub_bub.rb
+++ b/config/initializers/git_hub_bub.rb
@@ -5,8 +5,8 @@
GitHubBub::Request.send(:remove_const, :USER_AGENT)
GitHubBub::Request.send(:remove_const, :RETRIES)
-GitHubBub::Request::GITHUB_VERSION = 'vnd.github.v3.full+json'
-GitHubBub::Request::USER_AGENT = 'codetriage'
+GitHubBub::Request::GITHUB_VERSION = "vnd.github.v3.full+json"
+GitHubBub::Request::USER_AGENT = "codetriage"
GitHubBub::Request::RETRIES = 3
class CodeTraigeRandomApiKeyStore
@@ -16,13 +16,13 @@ def initialize
end
def call
- return ENV['GITHUB_API_KEY'] if ENV['GITHUB_API_KEY']
+ return ENV["GITHUB_API_KEY"] if ENV["GITHUB_API_KEY"]
until (key = @keys.pop)
populate_keys
end
- return key
+ key
end
private def get_key
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index 4b81c9620..91f7032a1 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -14,5 +14,5 @@
# These inflection rules are supported but not enabled by default:
ActiveSupport::Inflector.inflections(:en) do |inflect|
- inflect.acronym 'PHP'
+ inflect.acronym "PHP"
end
diff --git a/config/initializers/mail.rb b/config/initializers/mail.rb
index f12ef6831..473408ebe 100644
--- a/config/initializers/mail.rb
+++ b/config/initializers/mail.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
ActionMailer::Base.smtp_settings = {
- address: 'smtp.sendgrid.net',
- port: '587',
+ address: "smtp.sendgrid.net",
+ port: "587",
authentication: :plain,
- user_name: ENV['SENDGRID_USERNAME'],
- password: ENV['SENDGRID_PASSWORD'],
- domain: 'codetriage.com'
+ user_name: ENV["SENDGRID_USERNAME"],
+ password: ENV["SENDGRID_PASSWORD"],
+ domain: "codetriage.com"
}
ActionMailer::Base.delivery_method ||= :smtp
Maildown.allow_indentation = true
-Premailer::Rails.config.merge!(generate_text_part: false)
+Premailer::Rails.config[:generate_text_part] = false
diff --git a/config/initializers/mini-profiler.rb b/config/initializers/mini-profiler.rb
index f59ba8be0..2a3786b90 100644
--- a/config/initializers/mini-profiler.rb
+++ b/config/initializers/mini-profiler.rb
@@ -3,6 +3,6 @@
# set RedisStore so Rack Mini-Profiler works with multiple servers
if Rails.env.production? && ENV["REDIS_URL"]
uri = URI.parse(ENV["REDIS_URL"])
- Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore
- Rack::MiniProfiler.config.storage_options = { host: uri.host, port: uri.port, password: uri.password }
+ Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore
+ Rack::MiniProfiler.config.storage_options = {host: uri.host, port: uri.port, password: uri.password}
end
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 661c1dc7b..2ce3734ef 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -2,4 +2,4 @@
# Be sure to restart your server when you modify this file.
-Rails.application.config.session_store :cookie_store, key: '_code_triage_session'
+Rails.application.config.session_store :cookie_store, key: "_code_triage_session"
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index d41fa8901..bdd38c88d 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -2,7 +2,7 @@
sidekiq_config = {
url: ENV["REDIS_URL"],
- ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
+ ssl_params: {verify_mode: OpenSSL::SSL::VERIFY_NONE}
}
Sidekiq.configure_server do |config|
diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb
index 5d7e5a3bc..5043569ce 100644
--- a/config/initializers/time_formats.rb
+++ b/config/initializers/time_formats.rb
@@ -1,3 +1,3 @@
# frozen_string_literal: true
-Time::DATE_FORMATS[:time_only_with_zone] = '%H:%M %Z'
+Time::DATE_FORMATS[:time_only_with_zone] = "%H:%M %Z"
diff --git a/config/puma.rb b/config/puma.rb
index 1118ce5a4..f5b319576 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -17,7 +17,7 @@
plugin :tmp_restart
before_fork do
- require 'puma_worker_killer'
+ require "puma_worker_killer"
PumaWorkerKiller.enable_rolling_restart # Default is every 6 hours
end
diff --git a/config/routes.rb b/config/routes.rb
index 3cdd600c4..489d26d95 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,55 +1,55 @@
# frozen_string_literal: true
-require 'sidekiq/web'
+require "sidekiq/web"
CodeTriage::Application.routes.draw do
- sitemap_url = File.join("https://#{ENV['BUCKETEER_BUCKET_NAME']}.s3.amazonaws.com/", "sitemaps", "sitemap.xml.gz")
- get 'sitemap.xml.gz', to: redirect(sitemap_url)
+ sitemap_url = File.join("https://#{ENV["BUCKETEER_BUCKET_NAME"]}.s3.amazonaws.com/", "sitemaps", "sitemap.xml.gz")
+ get "sitemap.xml.gz", to: redirect(sitemap_url)
authenticate :user, lambda { |u| u.admin? } do
- mount Sidekiq::Web => '/sidekiq'
+ mount Sidekiq::Web => "/sidekiq"
end
resources :doc_methods, only: [:show]
resources :university, only: [:show, :index]
- get 'example_app' => 'university#show', id: 'example_app'
- get 'reproduction' => 'university#show', id: 'reproduction'
- get 'repro' => 'university#show', id: 'reproduction'
- get 'squash' => 'university#show', id: 'squash'
- get 'rebase' => 'university#show', id: 'rebase'
+ get "example_app" => "university#show", :id => "example_app"
+ get "reproduction" => "university#show", :id => "reproduction"
+ get "repro" => "university#show", :id => "reproduction"
+ get "squash" => "university#show", :id => "squash"
+ get "rebase" => "university#show", :id => "rebase"
devise_for :users, skip: [:registration],
- :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
+ controllers: {omniauth_callbacks: "users/omniauth_callbacks"}
as :user do
- get 'users/edit' => 'users#edit', as: :edit_user_registration
- patch 'users' => 'users#update', as: :user_registration
+ get "users/edit" => "users#edit", :as => :edit_user_registration
+ patch "users" => "users#update", :as => :user_registration
end
root to: "pages#index"
resources :topics, only: [:show]
- get 'what' => "pages#what"
- get 'privacy' => "pages#privacy"
- get 'support' => 'pages#support'
+ get "what" => "pages#what"
+ get "privacy" => "pages#privacy"
+ get "support" => "pages#support"
namespace :users do
resources :after_signup, only: [:show, :update]
end
- resources :users, only: [:show, :edit, :update, :destroy]
- get "/users/unsubscribe/:account_delete_token" => "users#token_delete", as: :token_delete_user
- delete "/users/unsubscribe/:account_delete_token" => "users#token_destroy"
+ resources :users, only: [:show, :edit, :update, :destroy]
+ get "/users/unsubscribe/:account_delete_token" => "users#token_delete", :as => :token_delete_user
+ delete "/users/unsubscribe/:account_delete_token" => "users#token_destroy"
- resources :issue_assignments, only: [:create]
+ resources :issue_assignments, only: [:create]
- get "/issue_assignments/:id/users/:user_id/click", to: "issue_assignments#click_issue_redirect", as: :issue_click
- get "/doc_methods/:id/users/:user_id/click", to: "doc_methods#click_method_redirect", as: :doc_method_click
- get "/doc_methods/:id/users/:user_id/source_click", to: "doc_methods#click_source_redirect", as: :doc_source_click
+ get "/issue_assignments/:id/users/:user_id/click", to: "issue_assignments#click_issue_redirect", as: :issue_click
+ get "/doc_methods/:id/users/:user_id/click", to: "doc_methods#click_method_redirect", as: :doc_method_click
+ get "/doc_methods/:id/users/:user_id/source_click", to: "doc_methods#click_source_redirect", as: :doc_source_click
resources :repo_subscriptions, only: [:create, :destroy, :update]
- get 'mail_view', to: redirect('rails/mailers')
+ get "mail_view", to: redirect("rails/mailers")
# format: false gives us rails 3.0 style routes so angular/angular.js is interpreted as
# user_name: "angular", name: "angular.js" instead of using the "js" as a format
@@ -60,15 +60,15 @@
end
end
- scope '*full_name' do
+ scope "*full_name" do
constraints full_name: /[-_a-zA-Z0-9]+\/[-_\.a-zA-Z0-9]+/ do
- get '/badges/:badge_type(.:format)', to: 'badges#show', as: 'badge'
- get 'info(.:format)', to: 'api_info#show'
+ get "/badges/:badge_type(.:format)", to: "badges#show", as: "badge"
+ get "info(.:format)", to: "api_info#show"
- get '/', to: 'repos#show', as: 'repo'
- patch '/', to: 'repos#update', as: nil
- get '/edit', to: 'repos#edit', as: 'edit_repo'
- get '/subscribers', to: 'subscribers#show', as: 'repo_subscribers'
+ get "/", to: "repos#show", as: "repo"
+ patch "/", to: "repos#update", as: nil
+ get "/edit", to: "repos#edit", as: "edit_repo"
+ get "/subscribers", to: "subscribers#show", as: "repo_subscribers"
end
end
end
diff --git a/config/sitemap.rb b/config/sitemap.rb
index 043d901f9..0b5f91c32 100644
--- a/config/sitemap.rb
+++ b/config/sitemap.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
# Set the host name for URL creation
-require 'aws-sdk-s3'
+require "aws-sdk-s3"
-if ENV['BUCKETEER_BUCKET_NAME']
+if ENV["BUCKETEER_BUCKET_NAME"]
adapter = SitemapGenerator::AwsSdkAdapter.new(
- ENV['BUCKETEER_BUCKET_NAME'],
- aws_access_key_id: ENV['BUCKETEER_AWS_ACCESS_KEY_ID'],
- aws_secret_access_key: ENV['BUCKETEER_AWS_SECRET_ACCESS_KEY'],
- aws_region: ENV['BUCKETEER_AWS_REGION']
+ ENV["BUCKETEER_BUCKET_NAME"],
+ aws_access_key_id: ENV["BUCKETEER_AWS_ACCESS_KEY_ID"],
+ aws_secret_access_key: ENV["BUCKETEER_AWS_SECRET_ACCESS_KEY"],
+ aws_region: ENV["BUCKETEER_AWS_REGION"]
)
- SitemapGenerator::Sitemap.adapter = adapter
- SitemapGenerator::Sitemap.sitemaps_host = "https://#{ENV['BUCKETEER_BUCKET_NAME']}.s3.amazonaws.com/"
- SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'
+ SitemapGenerator::Sitemap.adapter = adapter
+ SitemapGenerator::Sitemap.sitemaps_host = "https://#{ENV["BUCKETEER_BUCKET_NAME"]}.s3.amazonaws.com/"
+ SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/"
end
SitemapGenerator::Sitemap.create_index = true
diff --git a/db/migrate/20120222223509_devise_create_users.rb b/db/migrate/20120222223509_devise_create_users.rb
index b322824d5..9d18e1bcd 100644
--- a/db/migrate/20120222223509_devise_create_users.rb
+++ b/db/migrate/20120222223509_devise_create_users.rb
@@ -2,22 +2,22 @@ class DeviseCreateUsers < ActiveRecord::Migration[4.2]
def change
create_table(:users) do |t|
## Database authenticatable
- t.string :email, null: false, default: ""
+ t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
- t.string :reset_password_token
+ t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
- t.integer :sign_in_count, default: 0
+ t.integer :sign_in_count, default: 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
- t.string :current_sign_in_ip
- t.string :last_sign_in_ip
+ t.string :current_sign_in_ip
+ t.string :last_sign_in_ip
## Encryptable
# t.string :password_salt
@@ -39,7 +39,7 @@ def change
t.timestamps
end
- add_index :users, :email, unique: true
+ add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
diff --git a/db/migrate/20120222231841_user_data.rb b/db/migrate/20120222231841_user_data.rb
index 840d98a74..cec5839f0 100644
--- a/db/migrate/20120222231841_user_data.rb
+++ b/db/migrate/20120222231841_user_data.rb
@@ -1,8 +1,8 @@
class UserData < ActiveRecord::Migration[4.2]
def up
- add_column :users, :zip, :string
+ add_column :users, :zip, :string
add_column :users, :phone_number, :string
- add_column :users, :twitter, :boolean
+ add_column :users, :twitter, :boolean
end
def down
diff --git a/db/migrate/20120518083745_create_issues.rb b/db/migrate/20120518083745_create_issues.rb
index 47c3b1422..713fdc012 100644
--- a/db/migrate/20120518083745_create_issues.rb
+++ b/db/migrate/20120518083745_create_issues.rb
@@ -1,10 +1,10 @@
class CreateIssues < ActiveRecord::Migration[4.2]
def change
create_table :issues do |t|
- t.integer :comment_count
- t.string :url, :repo_name, :user_name
- t.datetime :last_touched_at
- t.integer :number
+ t.integer :comment_count
+ t.string :url, :repo_name, :user_name
+ t.datetime :last_touched_at
+ t.integer :number
t.timestamps
end
diff --git a/db/migrate/20120518085406_create_repo_subscriptions.rb b/db/migrate/20120518085406_create_repo_subscriptions.rb
index 51bf31bb0..5e8372c7e 100644
--- a/db/migrate/20120518085406_create_repo_subscriptions.rb
+++ b/db/migrate/20120518085406_create_repo_subscriptions.rb
@@ -1,8 +1,8 @@
class CreateRepoSubscriptions < ActiveRecord::Migration[4.2]
def change
create_table :repo_subscriptions do |t|
- t.string :user_name
- t.string :repo_name
+ t.string :user_name
+ t.string :repo_name
t.timestamps
end
end
diff --git a/db/migrate/20120518090213_create_issue_assignments.rb b/db/migrate/20120518090213_create_issue_assignments.rb
index c1df1c73c..7a547ffdb 100644
--- a/db/migrate/20120518090213_create_issue_assignments.rb
+++ b/db/migrate/20120518090213_create_issue_assignments.rb
@@ -1,8 +1,8 @@
class CreateIssueAssignments < ActiveRecord::Migration[4.2]
def change
create_table :issue_assignments do |t|
- t.integer :user_id
- t.integer :issue_id
+ t.integer :user_id
+ t.integer :issue_id
t.timestamps
end
diff --git a/db/migrate/20120518091140_create_repos.rb b/db/migrate/20120518091140_create_repos.rb
index 9611a67c9..dedf22a80 100644
--- a/db/migrate/20120518091140_create_repos.rb
+++ b/db/migrate/20120518091140_create_repos.rb
@@ -1,13 +1,13 @@
class CreateRepos < ActiveRecord::Migration[4.2]
def change
create_table :repos do |t|
- t.string "name"
- t.string "user_name"
- t.integer "issues_count", default: 0, null: false
- t.string "language"
- t.string "description"
- t.string "full_name"
- t.text "notes"
+ t.string "name"
+ t.string "user_name"
+ t.integer "issues_count", default: 0, null: false
+ t.string "language"
+ t.string "description"
+ t.string "full_name"
+ t.text "notes"
t.timestamps
end
diff --git a/db/migrate/20120620000230_add_github_to_users.rb b/db/migrate/20120620000230_add_github_to_users.rb
index f6b8cefc4..5660c3069 100644
--- a/db/migrate/20120620000230_add_github_to_users.rb
+++ b/db/migrate/20120620000230_add_github_to_users.rb
@@ -2,6 +2,6 @@ class AddGithubToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :github, :string
add_column :users, :github_access_token, :string
- add_index :users, :github, unique: true
+ add_index :users, :github, unique: true
end
end
diff --git a/db/migrate/20121106072214_repo_issue_counter_cache.rb b/db/migrate/20121106072214_repo_issue_counter_cache.rb
index 318b837b2..aa40de896 100644
--- a/db/migrate/20121106072214_repo_issue_counter_cache.rb
+++ b/db/migrate/20121106072214_repo_issue_counter_cache.rb
@@ -6,7 +6,7 @@ def up
Repo.reset_column_information
Repo.find_each do |repo|
- Repo.update_counters(repo.id, issues_count: repo.issues.where(state: 'open').count)
+ Repo.update_counters(repo.id, issues_count: repo.issues.where(state: "open").count)
end
end
diff --git a/db/migrate/20121110213717_add_avatar_url_to_users.rb b/db/migrate/20121110213717_add_avatar_url_to_users.rb
index d1de4f4fa..2646b4201 100644
--- a/db/migrate/20121110213717_add_avatar_url_to_users.rb
+++ b/db/migrate/20121110213717_add_avatar_url_to_users.rb
@@ -1,5 +1,5 @@
class AddAvatarUrlToUsers < ActiveRecord::Migration[4.2]
def change
- add_column :users, :avatar_url, :string, default: 'http://gravatar.com/avatar/default'
+ add_column :users, :avatar_url, :string, default: "http://gravatar.com/avatar/default"
end
end
diff --git a/db/migrate/20131107042958_add_delete_token_to_users.rb b/db/migrate/20131107042958_add_delete_token_to_users.rb
index bceb985c5..d100904e9 100644
--- a/db/migrate/20131107042958_add_delete_token_to_users.rb
+++ b/db/migrate/20131107042958_add_delete_token_to_users.rb
@@ -1,6 +1,6 @@
class AddDeleteTokenToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :account_delete_token, :string
- add_index :users, :account_delete_token
+ add_index :users, :account_delete_token
end
end
diff --git a/db/migrate/20140524120051_add_click_to_issue_assignment.rb b/db/migrate/20140524120051_add_click_to_issue_assignment.rb
index 33658e454..353bd6b02 100644
--- a/db/migrate/20140524120051_add_click_to_issue_assignment.rb
+++ b/db/migrate/20140524120051_add_click_to_issue_assignment.rb
@@ -1,7 +1,7 @@
class AddClickToIssueAssignment < ActiveRecord::Migration[4.2]
def change
- add_column :issue_assignments, :clicked, :boolean, default: false
- add_column :users, :last_clicked_at, :timestamp
+ add_column :issue_assignments, :clicked, :boolean, default: false
+ add_column :users, :last_clicked_at, :timestamp
User.find_each(&:save)
end
end
diff --git a/db/migrate/20140621155109_add_delievered_to_issue_assignment.rb b/db/migrate/20140621155109_add_delievered_to_issue_assignment.rb
index e8ee1d26d..a3accc91e 100644
--- a/db/migrate/20140621155109_add_delievered_to_issue_assignment.rb
+++ b/db/migrate/20140621155109_add_delievered_to_issue_assignment.rb
@@ -1,6 +1,6 @@
class AddDelieveredToIssueAssignment < ActiveRecord::Migration[4.2]
def change
- add_column :issue_assignments, :delivered, :boolean, { default: false }
+ add_column :issue_assignments, :delivered, :boolean, {default: false}
# add_index :users, :github, unique: true
add_index :issue_assignments, :delivered
diff --git a/db/migrate/20160321152204_create_docs_doctor_integration.rb b/db/migrate/20160321152204_create_docs_doctor_integration.rb
index 7e7b8b6df..e81e2085f 100644
--- a/db/migrate/20160321152204_create_docs_doctor_integration.rb
+++ b/db/migrate/20160321152204_create_docs_doctor_integration.rb
@@ -1,11 +1,11 @@
class CreateDocsDoctorIntegration < ActiveRecord::Migration[5.0]
def change
create_table "doc_assignments", force: :cascade do |t|
- t.integer "repo_id"
- t.integer "repo_subscription_id"
- t.integer "user_id"
- t.integer "doc_method_id"
- t.integer "doc_class_id"
+ t.integer "repo_id"
+ t.integer "repo_subscription_id"
+ t.integer "user_id"
+ t.integer "doc_method_id"
+ t.integer "doc_class_id"
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -15,22 +15,22 @@ def change
add_index "doc_assignments", ["user_id"], name: "index_doc_assignments_on_user_id", using: :btree
create_table "doc_classes", force: :cascade do |t|
- t.integer "repo_id"
- t.string "name"
+ t.integer "repo_id"
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
- t.integer "doc_comments_count", default: 0, null: false
- t.integer "line"
- t.string "path"
- t.string "file"
+ t.integer "doc_comments_count", default: 0, null: false
+ t.integer "line"
+ t.string "path"
+ t.string "file"
end
add_index "doc_classes", ["repo_id"], name: "index_doc_classes_on_repo_id", using: :btree
create_table "doc_comments", force: :cascade do |t|
- t.integer "doc_class_id"
- t.integer "doc_method_id"
- t.text "comment"
+ t.integer "doc_class_id"
+ t.integer "doc_method_id"
+ t.text "comment"
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -39,26 +39,26 @@ def change
add_index "doc_comments", ["doc_method_id"], name: "index_doc_comments_on_doc_method_id", using: :btree
create_table "doc_methods", force: :cascade do |t|
- t.integer "repo_id"
- t.string "name"
- t.integer "line"
+ t.integer "repo_id"
+ t.string "name"
+ t.integer "line"
t.datetime "created_at"
t.datetime "updated_at"
- t.integer "doc_comments_count", default: 0, null: false
- t.string "path"
- t.string "file"
- t.boolean "skip_write", default: false
- t.boolean "active", default: true
- t.boolean "skip_read", default: false
+ t.integer "doc_comments_count", default: 0, null: false
+ t.string "path"
+ t.string "file"
+ t.boolean "skip_write", default: false
+ t.boolean "active", default: true
+ t.boolean "skip_read", default: false
end
add_index "doc_methods", ["repo_id"], name: "index_doc_methods_on_repo_id", using: :btree
add_column :repo_subscriptions, :write, :boolean, default: false
- add_column :repo_subscriptions, :read, :boolean, default: false
+ add_column :repo_subscriptions, :read, :boolean, default: false
- add_column :repo_subscriptions, :write_limit, :integer
- add_column :repo_subscriptions, :read_limit, :integer
+ add_column :repo_subscriptions, :write_limit, :integer
+ add_column :repo_subscriptions, :read_limit, :integer
add_column :repos, :commit_sha, :string
end
diff --git a/db/migrate/20170629151616_add_unique_index_to_repos.rb b/db/migrate/20170629151616_add_unique_index_to_repos.rb
index 3d104b246..a080304bd 100644
--- a/db/migrate/20170629151616_add_unique_index_to_repos.rb
+++ b/db/migrate/20170629151616_add_unique_index_to_repos.rb
@@ -1,5 +1,5 @@
class AddUniqueIndexToRepos < ActiveRecord::Migration[5.1]
def change
- add_index :repos, [:name, :user_name], :unique => true
+ add_index :repos, [:name, :user_name], unique: true
end
end
diff --git a/db/migrate/20191014201819_drop_unused_indexes.rb b/db/migrate/20191014201819_drop_unused_indexes.rb
index d3027dcc3..ac971b5e1 100644
--- a/db/migrate/20191014201819_drop_unused_indexes.rb
+++ b/db/migrate/20191014201819_drop_unused_indexes.rb
@@ -3,8 +3,8 @@ def change
# public.issues | index_issues_on_number | 198 MB | 0
# public.issues | index_issues_on_repo_id | 1536 MB | 0
# public.issue_assignments | index_issue_assignments_on_repo_subscription_id_and_created_at | 370 MB | 0
- remove_index(:issues, name: 'index_issues_on_number')
- remove_index(:issues, name: 'index_issues_on_repo_id')
- remove_index(:issue_assignments, name: 'index_issue_assignments_on_repo_subscription_id_and_created_at')
+ remove_index(:issues, name: "index_issues_on_number")
+ remove_index(:issues, name: "index_issues_on_repo_id")
+ remove_index(:issue_assignments, name: "index_issue_assignments_on_repo_subscription_id_and_created_at")
end
end
diff --git a/db/migrate/20191029194525_make_timestamps_not_nullable.rb b/db/migrate/20191029194525_make_timestamps_not_nullable.rb
index 27424630d..ee8c35e57 100644
--- a/db/migrate/20191029194525_make_timestamps_not_nullable.rb
+++ b/db/migrate/20191029194525_make_timestamps_not_nullable.rb
@@ -1,8 +1,8 @@
class MakeTimestampsNotNullable < ActiveRecord::Migration[6.0]
def change
- %W{issues repos users doc_methods doc_classes repos repo_subscriptions issue_assignments}.each do |table_name|
- change_column_null table_name, :created_at, false, 'NOW()'
- change_column_null table_name, :updated_at, false, 'NOW()'
+ %W[issues repos users doc_methods doc_classes repos repo_subscriptions issue_assignments].each do |table_name|
+ change_column_null table_name, :created_at, false, "NOW()"
+ change_column_null table_name, :updated_at, false, "NOW()"
end
end
end
diff --git a/db/migrate/20201115123025_create_active_storage_variant_records.active_storage.rb b/db/migrate/20201115123025_create_active_storage_variant_records.active_storage.rb
index 1fdb3a454..9a2025fdf 100644
--- a/db/migrate/20201115123025_create_active_storage_variant_records.active_storage.rb
+++ b/db/migrate/20201115123025_create_active_storage_variant_records.active_storage.rb
@@ -7,7 +7,7 @@ def change
t.belongs_to :blob, null: false, index: false
t.string :variation_digest, null: false
- t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
+ t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 325433207..3f4c65908 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -5,7 +5,7 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
-require 'faker'
+require "faker"
Rails.application.configure do
config.active_job.queue_adapter = :test
@@ -47,14 +47,14 @@
)
user.save(validate: false)
- name = Faker::Hipster.word.gsub(/\W/, '')
+ name = Faker::Hipster.word.gsub(/\W/, "")
repo = user.repos.new(
- :user_name => username,
- :name => name,
- :issues_count => rand(30),
- :language => %w[Ruby PHP Go Javascript Java Swift].sample,
- :description => Faker::Lorem.paragraph(sentence_count: 1, supplemental: true, random_sentences_to_add: 4),
- :full_name => "#{username}/#{name}"
+ user_name: username,
+ name: name,
+ issues_count: rand(30),
+ language: %w[Ruby PHP Go Javascript Java Swift].sample,
+ description: Faker::Lorem.paragraph(sentence_count: 1, supplemental: true, random_sentences_to_add: 4),
+ full_name: "#{username}/#{name}"
)
repo.save(validate: false)
diff --git a/lib/dependency_parser/php/parse.rb b/lib/dependency_parser/php/parse.rb
index be64e0887..e8f2204d9 100644
--- a/lib/dependency_parser/php/parse.rb
+++ b/lib/dependency_parser/php/parse.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
-require 'json'
+
+require "json"
module DependencyParser
module PHP
@@ -15,17 +16,17 @@ def initialize(content)
def call
deps = JSON.parse(content, symbolize_names: true)
@direct = deps[:packages].map do |package|
- { name: package[:name], url: package.dig(:source, :url), description: package[:description] }
+ {name: package[:name], url: package.dig(:source, :url), description: package[:description]}
end
- @direct += deps[:'packages-dev'].map do |package|
- { name: package[:name], url: package.dig(:source, :url), description: package[:description] }
+ @direct += deps[:"packages-dev"].map do |package|
+ {name: package[:name], url: package.dig(:source, :url), description: package[:description]}
end
- rescue StandardError
- @errors << 'Cannot parse lock file'
+ rescue
+ @errors << "Cannot parse lock file"
end
def direct
- { repos: @direct, language: "php" }
+ {repos: @direct, language: "php"}
end
def success?
diff --git a/lib/dependency_parser/ruby/parse.rb b/lib/dependency_parser/ruby/parse.rb
index 23fe90167..396edf1b6 100644
--- a/lib/dependency_parser/ruby/parse.rb
+++ b/lib/dependency_parser/ruby/parse.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
-require 'bundler'
-require 'json'
+
+require "bundler"
+require "json"
module DependencyParser
module Ruby
@@ -23,7 +24,7 @@ def call
end
def direct
- { repos: @direct, language: "ruby" }
+ {repos: @direct, language: "ruby"}
end
def success?
@@ -39,12 +40,12 @@ def error?
attr_reader :content
def validate_lockfile!(content)
- @errors << 'No specs found' unless Bundler::LockfileParser.new(content).specs.any?
+ @errors << "No specs found" unless Bundler::LockfileParser.new(content).specs.any?
end
def fetch_spec(name:, version: nil)
full_spec = fetcher.fetch_spec([name, version])
- { name: full_spec.name, url: extract_url(full_spec), description: full_spec.description }
+ {name: full_spec.name, url: extract_url(full_spec), description: full_spec.description}
rescue
@errors << "Invalid spec #{name}"
nil
@@ -56,7 +57,7 @@ def extract_url(full_spec)
end
def fetcher
- @fetcher ||= Bundler::Fetcher.new(Bundler::Source::Rubygems::Remote.new('https://rubygems.org'))
+ @fetcher ||= Bundler::Fetcher.new(Bundler::Source::Rubygems::Remote.new("https://rubygems.org"))
end
end
end
diff --git a/lib/docs_doctor/loader.rb b/lib/docs_doctor/loader.rb
index 16f4a67d5..2ca067e3c 100644
--- a/lib/docs_doctor/loader.rb
+++ b/lib/docs_doctor/loader.rb
@@ -7,13 +7,13 @@ class Loader
def initialize(parser_lang_name, version)
@lang, @name = parser_lang_name.to_s.downcase.split("/")
- @version = Gem::Version.new version
+ @version = Gem::Version.new version
load_parser
end
def parser
- require self.path
- return constant.new
+ require path
+ constant.new
end
def constant
@@ -22,7 +22,7 @@ def constant
# parsers/ruby/rdoc.rb
def path
- [__dir__, 'parsers', lang, name_extension].join('/')
+ [__dir__, "parsers", lang, name_extension].join("/")
end
def load_parser
@@ -42,12 +42,12 @@ def name_extension
def dot_extension
@extension = extension
- @extension.prepend('.rb') unless @extension.include?('.')
+ @extension.prepend(".rb") unless @extension.include?(".")
@extension
end
def pretty_version
- version.to_s.tr('.', '_')
+ version.to_s.tr(".", "_")
end
end
end
diff --git a/lib/docs_doctor/parsers/ruby/yard.rb b/lib/docs_doctor/parsers/ruby/yard.rb
index c433da20e..0143e92e1 100644
--- a/lib/docs_doctor/parsers/ruby/yard.rb
+++ b/lib/docs_doctor/parsers/ruby/yard.rb
@@ -19,7 +19,7 @@ module Ruby
class Yard
# we don't want any files in /test or /spec unless it's
# for testing this codebase
- DEFAULT_EXCLUDE = ["(^|\/)test\/(?!fixtures)", "(^|\/)spec\/(?!fixtures)"]
+ DEFAULT_EXCLUDE = ["(^|/)test/(?!fixtures)", "(^|/)spec/(?!fixtures)"]
attr_reader :yard_objects
attr_accessor :files, :base_path
@@ -33,7 +33,7 @@ def initialize(base)
def root_path
root_path = Pathname.new(base_path).expand_path
- if root_path.to_s =~ /\.rb+$/
+ if /\.rb+$/.match?(root_path.to_s)
root_path.dirname
else
root_path
@@ -79,21 +79,19 @@ def hash_for_entity(obj, repo)
}
if doc_method_hash[:file] && doc_method_hash[:name] && doc_method_hash[:path]
- return doc_method_hash
- else
- return nil
+ doc_method_hash
end
end
end
def process(exclude = DEFAULT_EXCLUDE)
- require 'yard'
+ require "yard"
yard = YARD::CLI::Yardoc.new
# yard.files = files
- yard.excluded = exclude # http://rubydoc.org/gems/yard/YARD/Parser/SourceParser#parse-class_method
+ yard.excluded = exclude # http://rubydoc.org/gems/yard/YARD/Parser/SourceParser#parse-class_method
yard.save_yardoc = false
- yard.generate = false
+ yard.generate = false
# yard.use_cache = false'
Dir.chdir(root_path) do
@@ -107,7 +105,7 @@ def process(exclude = DEFAULT_EXCLUDE)
YARD::Registry.clear
rescue SystemStackError
Rails.logger.debug "Yard blew up while trying to read from #{root_path}"
- return false
+ false
end
def in_fork
diff --git a/lib/docs_doctor/task.rb b/lib/docs_doctor/task.rb
index 485fdf37d..5cc494852 100644
--- a/lib/docs_doctor/task.rb
+++ b/lib/docs_doctor/task.rb
@@ -2,7 +2,7 @@
namespace :docs do
task :play do
- parser = DocsDoctor::Runner.new('ruby/rdoc', '4.0.0').parser
+ parser = DocsDoctor::Runner.new("ruby/rdoc", "4.0.0").parser
puts parser.inspect
parser.add_files("test/fixtures/ruby/string/strip.rb")
parser.go!
diff --git a/lib/tasks/schedule.rake b/lib/tasks/schedule.rake
index 4e80a08d2..474b621d4 100644
--- a/lib/tasks/schedule.rake
+++ b/lib/tasks/schedule.rake
@@ -1,7 +1,7 @@
# frozen_string_literal: true
namespace :schedule do
- desc 'Sends triage emails'
+ desc "Sends triage emails"
task triage_emails: :environment do
User.with_repo_subscriptions.select(:id).find_each(batch_size: 1000) do |user|
# TODO cache last_sent_at in the user object
@@ -18,7 +18,7 @@ namespace :schedule do
end
end
- desc 'Populates github issues'
+ desc "Populates github issues"
task populate_issues: :environment do
Repo.active.select(:id, :removed_from_github).find_each(batch_size: 100) do |repo|
PopulateIssuesJob.perform_later(repo.id)
@@ -31,7 +31,7 @@ namespace :schedule do
# one way to test is by exercising the API for a value
# that should be known to exist.
- return GithubFetcher::Repo.new(user_name: "rails", name: "rails").success?
+ GithubFetcher::Repo.new(user_name: "rails", name: "rails").success?
end
desc "Update repos information"
@@ -43,7 +43,7 @@ namespace :schedule do
end
end
- desc 'Marks issues as closed'
+ desc "Marks issues as closed"
task mark_closed: :environment do
Issue.queue_mark_old_as_closed!
Repo.active.find_each(batch_size: 100) do |repo|
@@ -51,7 +51,7 @@ namespace :schedule do
end
end
- desc 'Sends an email to invite users to engage once a week'
+ desc "Sends an email to invite users to engage once a week"
task poke_inactive: :environment do
next unless Date.today.tuesday?
@@ -81,18 +81,18 @@ namespace :schedule do
# disabling it until I can make it more robust
#
next
- raise "GITHUB API APPEARS TO BE DOWN" unless github_api_up?
-
- User.where.not(token: nil).find_each(batch_size: 100) do |user|
- # Check multiple times if token is not valid
- # if token is valid once, go to next user
- next if user.auth_is_valid?
- next if user.auth_is_valid?
- next if user.auth_is_valid?
-
- # Archive bad token
- user.update(token: nil, old_token: user.token)
- end
+ # raise "GITHUB API APPEARS TO BE DOWN" unless github_api_up?
+
+ # User.where.not(token: nil).find_each(batch_size: 100) do |user|
+ # # Check multiple times if token is not valid
+ # # if token is valid once, go to next user
+ # next if user.auth_is_valid?
+ # next if user.auth_is_valid?
+ # next if user.auth_is_valid?
+
+ # # Archive bad token
+ # user.update(token: nil, old_token: user.token)
+ # end
end
task warn_invalid_token: :environment do
@@ -102,13 +102,13 @@ namespace :schedule do
end
end
- desc 'sitemaps'
+ desc "sitemaps"
task sitemap: :environment do
next unless Date.today.sunday?
- Rake::Task['sitemap:refresh'].invoke
+ Rake::Task["sitemap:refresh"].invoke
end
- desc 'fetch and assign labels for repos'
+ desc "fetch and assign labels for repos"
task fetch_labels_and_assign: :environment do
Repo.active.find_each(batch_size: 100) do |repo|
RepoLabelAssigner.new(repo: repo).create_and_associate_labels!
diff --git a/perf.rake b/perf.rake
index dd5748161..62369277c 100644
--- a/perf.rake
+++ b/perf.rake
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'bundler'
+require "bundler"
Bundler.setup
-require 'derailed_benchmarks'
-require 'derailed_benchmarks/tasks'
+require "derailed_benchmarks"
+require "derailed_benchmarks/tasks"
-ENV["RAILS_LOG_TO_STDOUT"] ||= "1"
+ENV["RAILS_LOG_TO_STDOUT"] ||= "1"
ENV["RAILS_SERVE_STATIC_FILES"] ||= "1"
-ENV["SECRET_KEY_BASE"] ||= "lol"
-ENV["DEVISE_SECRET_KEY"] ||= "lol"
+ENV["SECRET_KEY_BASE"] ||= "lol"
+ENV["DEVISE_SECRET_KEY"] ||= "lol"
diff --git a/perf_scripts/cache_version.rb b/perf_scripts/cache_version.rb
index 4cc4a8b3e..fd9860b85 100644
--- a/perf_scripts/cache_version.rb
+++ b/perf_scripts/cache_version.rb
@@ -27,13 +27,11 @@ class User < ActiveRecord::Base
end
mass_user_create = 1000.times.each.map do
- {name: "user" }
+ {name: "user"}
end
User.create(mass_user_create)
-
-
ALL_USERS = User.all
puts ALL_USERS.first.method(:cache_version).source_location
@@ -45,4 +43,3 @@ class User < ActiveRecord::Base
end
}
}
-
diff --git a/perf_scripts/dirty_tracking.rb b/perf_scripts/dirty_tracking.rb
index 6027edbcf..13d5ae783 100644
--- a/perf_scripts/dirty_tracking.rb
+++ b/perf_scripts/dirty_tracking.rb
@@ -44,4 +44,3 @@ class User < ActiveRecord::Base
}
}
}
-
diff --git a/perf_scripts/partial_cache.rb b/perf_scripts/partial_cache.rb
index 45201d044..56dd57349 100644
--- a/perf_scripts/partial_cache.rb
+++ b/perf_scripts/partial_cache.rb
@@ -25,8 +25,8 @@ class TestController < ActionController::Base
# Create a bunch of data
-letters = ('a'..'z').to_a * 5
-1000.times { Customer.create!(name: letters.shuffle.first(10).join) }
+letters = ("a".."z").to_a * 5
+1000.times { Customer.create!(name: letters.sample(10).join) }
customers = Customer.all.to_a
diff --git a/perf_scripts/respond_to.rb b/perf_scripts/respond_to.rb
index 3599255aa..b8e2d018e 100644
--- a/perf_scripts/respond_to.rb
+++ b/perf_scripts/respond_to.rb
@@ -27,7 +27,7 @@ class User < ActiveRecord::Base
user = User.create!(name: "user name", dog_name: "cinco")
user.respond_to?(:name)
-topic = user.topics.build(title: "topic title")
+user.topics.build(title: "topic title")
# Benchmark.ips do |x|
# x.report("changed?") { topic.changed? }
@@ -45,4 +45,3 @@ class User < ActiveRecord::Base
}
}
}
-
diff --git a/scratch.rb b/scratch.rb
index d50e46cbc..051ba2330 100644
--- a/scratch.rb
+++ b/scratch.rb
@@ -1,10 +1,10 @@
-require 'bigdecimal'
+require "bigdecimal"
def values_from_benchmark(file_name)
file_contents = File.read(file_name)
output = []
file_contents.each_line do |line|
- line.match(/\( +(\d+\.\d+)\)/)
+ line =~ /\( +(\d+\.\d+)\)/
begin
output << BigDecimal($1)
rescue => e
@@ -17,43 +17,41 @@ def values_from_benchmark(file_name)
def students_t_test(file_1, file_2)
series_1 = values_from_benchmark(file_1)
series_2 = values_from_benchmark(file_2)
- StatisticalTest::TTest.paired_test(alpha = 0.05, :two_tail, series_1, series_2)
+ StatisticalTest::TTest.paired_test(0.05, :two_tail, series_1, series_2)
end
branch_names = ["tmp/compare_branches/20190610170044486002/master.bench.txt", "tmp/compare_branches/20190610170044486002/d9a8778be852b34c4509353352865ade0a6172da.bench.txt"]
-series_1 = values_from_benchmark(branch_names[0])
+series_1 = values_from_benchmark(branch_names[0])
series_2 = values_from_benchmark(branch_names[1])
-require 'statistics'
-
- t_test = StatisticalTest::TTest.paired_test(alpha = 0.05, :two_tail, series_1, series_2)
-
- avg_1 = series_1.inject(&:+) / series_1.count
- avg_2 = series_2.inject(&:+) / series_2.count
-
+require "statistics"
+
+t_test = StatisticalTest::TTest.paired_test(0.05, :two_tail, series_1, series_2)
+
+avg_1 = series_1.inject(&:+) / series_1.count
+avg_2 = series_2.inject(&:+) / series_2.count
+faster = avg_2
+if avg_2 < avg_1
+ winner = branch_names[1]
+ loser = branch_names[0]
+ faster = avg_2
+ slower = avg_1
+else
+ winner = branch_names[0]
+ loser = branch_names[1]
faster = avg_1
- faster = avg_2
- if avg_2 < avg_1
- winner = branch_names[1]
- loser = branch_names[0]
- faster = avg_2
- slower = avg_1
- else
- winner = branch_names[0]
- loser = branch_names[1]
- faster = avg_1
- slower = avg_2
- end
+ slower = avg_2
+end
- ratio = slower/faster
+ratio = slower / faster
- if t_test[:alternative]
- puts "❤️ " * 40
- else
- puts "👎 " * 80
- end
+if t_test[:alternative]
+ puts "❤️ " * 40
+else
+ puts "👎 " * 80
+end
- puts "Branch #{winner.inspect} is faster than #{loser.inspect} by\n #{ratio.to_f}x\n\n"
- puts "P-value: #{t_test[:p_value].to_f}"
- puts "Is signifigant? (P-value < 0.05): #{t_test[:alternative]}"
+puts "Branch #{winner.inspect} is faster than #{loser.inspect} by\n #{ratio.to_f}x\n\n"
+puts "P-value: #{t_test[:p_value].to_f}"
+puts "Is signifigant? (P-value < 0.05): #{t_test[:alternative]}"
diff --git a/test/dependency_parsers/php_parser_test.rb b/test/dependency_parsers/php_parser_test.rb
index 2912ec906..370e6f426 100644
--- a/test/dependency_parsers/php_parser_test.rb
+++ b/test/dependency_parsers/php_parser_test.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'test_helper'
-require_relative '../../lib/dependency_parser/php/parse'
+require "test_helper"
+require_relative "../../lib/dependency_parser/php/parse"
class PHPParserTest < ActiveSupport::TestCase
test "returns nothing on invalid composer.lock" do
parser = DependencyParser::PHP::Parse.new("invalid")
parser.call
refute parser.success?
- assert_equal({ repos: [], language: "php" }, parser.direct)
+ assert_equal({repos: [], language: "php"}, parser.direct)
end
test "returns the list of dependencies (with dev dependencies) for a small composer.lock file" do
- gemfile_lock = file_fixture('composer.lock').read
+ gemfile_lock = file_fixture("composer.lock").read
parser = DependencyParser::PHP::Parse.new(gemfile_lock)
parser.call
diff --git a/test/dependency_parsers/ruby_parser_test.rb b/test/dependency_parsers/ruby_parser_test.rb
index 5aeb5b99d..dae538dd9 100644
--- a/test/dependency_parsers/ruby_parser_test.rb
+++ b/test/dependency_parsers/ruby_parser_test.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'test_helper'
-require_relative '../../lib/dependency_parser/ruby/parse'
+require "test_helper"
+require_relative "../../lib/dependency_parser/ruby/parse"
class RubyParserTest < ActiveSupport::TestCase
test "returns nothing on invalid Gemfile.lock" do
parser = DependencyParser::Ruby::Parse.new("invalid")
parser.call
refute parser.success?
- assert_equal({ repos: [], language: "ruby" }, parser.direct)
+ assert_equal({repos: [], language: "ruby"}, parser.direct)
end
test "returns the list of gems for a small Gemfle" do
@@ -34,7 +34,7 @@ class RubyParserTest < ActiveSupport::TestCase
BUNDLED WITH
2.3.21
- LOCKFILE
+ LOCKFILE
parser = DependencyParser::Ruby::Parse.new(gemfile_lock)
VCR.use_cassette("dependency_parser/rubygems") do
diff --git a/test/emails/send_daily_triage_email_test.rb b/test/emails/send_daily_triage_email_test.rb
index e956fed3c..f0fcd273d 100644
--- a/test/emails/send_daily_triage_email_test.rb
+++ b/test/emails/send_daily_triage_email_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UserMailerTest < ActionMailer::TestCase
include ActiveJob::TestHelper::TestQueueAdapter
@@ -15,13 +15,13 @@ class UserMailerTest < ActionMailer::TestCase
assert_equal 2, triage_email.parts.size
assert_equal "multipart/alternative", triage_email.mime_type
- assert_match /Help Triage \d+ Open Source Issue/, triage_email.subject
+ assert_match(/Help Triage \d+ Open Source Issue/, triage_email.subject)
# Repo groups
- assert_match /## bemurphy\/issue_triage_sandbox/, triage_email_text
+ assert_match(/## bemurphy\/issue_triage_sandbox/, triage_email_text)
# Issue number one
- assert_match /bemurphy\/issue_triage_sandbox#1/, triage_email_text
+ assert_match(/bemurphy\/issue_triage_sandbox#1/, triage_email_text)
end
test "sends docs" do
@@ -35,9 +35,9 @@ class UserMailerTest < ActionMailer::TestCase
assert_equal 2, triage_email.parts.size
assert_equal "multipart/alternative", triage_email.mime_type
- assert_match /Help Triage 1 Open Source Doc/, triage_email.subject
+ assert_match(/Help Triage 1 Open Source Doc/, triage_email.subject)
- assert_match /### Docs/, triage_email_text
+ assert_match(/### Docs/, triage_email_text)
end
test "sends subscribed/created email" do
@@ -53,8 +53,8 @@ class UserMailerTest < ActionMailer::TestCase
assert_equal 2, triage_email.parts.size
assert_equal "multipart/alternative", triage_email.mime_type
- assert_match /Help triage sinatra\/sinatra/, triage_email.subject
+ assert_match(/Help triage sinatra\/sinatra/, triage_email.subject)
- assert_match /## How To Triage?/, triage_email_text
+ assert_match(/## How To Triage?/, triage_email_text)
end
end
diff --git a/test/functional/after_register_controller_test.rb b/test/functional/after_register_controller_test.rb
index 6e142d9c4..43aeb1cd4 100644
--- a/test/functional/after_register_controller_test.rb
+++ b/test/functional/after_register_controller_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class AfterRegisterControllerTest < ActionController::TestCase
# test "the truth" do
diff --git a/test/functional/doc_methods_controller_test.rb b/test/functional/doc_methods_controller_test.rb
index 95f364ec2..b6f5c6941 100644
--- a/test/functional/doc_methods_controller_test.rb
+++ b/test/functional/doc_methods_controller_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class DocMethodsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
@@ -12,16 +12,16 @@ class DocMethodsControllerTest < ActionController::TestCase
@repo_sub = RepoSubscription.where(user_id: @user.id, repo: @triage_doc.repo).first
end
- test 'click_method_redirect with a DocAssignment redirects to the doc_method url' do
+ test "click_method_redirect with a DocAssignment redirects to the doc_method url" do
DocAssignment.create(doc_method_id: @triage_doc.id, repo_subscription_id: @repo_sub.id)
- get :click_method_redirect, params: { id: @triage_doc.id, user_id: @user.id }
+ get :click_method_redirect, params: {id: @triage_doc.id, user_id: @user.id}
assert_redirected_to doc_method_url(@triage_doc)
end
- test 'click_method_redirect without any DocAssignment returns to root an displays an error' do
- get :click_method_redirect, params: { id: @triage_doc.id, user_id: @user.id }
+ test "click_method_redirect without any DocAssignment returns to root an displays an error" do
+ get :click_method_redirect, params: {id: @triage_doc.id, user_id: @user.id}
assert flash[:notice].eql? "Bad url, if this problem persists please open an issue github.com/codetriage/codetriage"
assert_redirected_to :root
diff --git a/test/functional/issue_assignments_controller_test.rb b/test/functional/issue_assignments_controller_test.rb
index 76bf1c95e..566145665 100644
--- a/test/functional/issue_assignments_controller_test.rb
+++ b/test/functional/issue_assignments_controller_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class IssueAssignmentsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
@@ -9,27 +9,27 @@ class IssueAssignmentsControllerTest < ActionController::TestCase
sign_in users(:schneems)
end
- test '#create redirects when the user request a new issue' do
+ test "#create redirects when the user request a new issue" do
repo_sub = repo_subscriptions(:schneems_to_triage)
- post :create, params: { id: repo_sub.id }
+ post :create, params: {id: repo_sub.id}
assert_redirected_to repo_path(repo_sub.repo.full_name)
end
- test '#click_issue_redirect redirects user when assignment matches the user id' do
+ test "#click_issue_redirect redirects user when assignment matches the user id" do
user = users(:schneems)
assignment = issue_assignments(:schneems_triage_issue_assignment)
- get :click_issue_redirect, params: { id: assignment.id, user_id: user.id }
+ get :click_issue_redirect, params: {id: assignment.id, user_id: user.id}
assert_redirected_to assignment.issue.html_url
end
- test '#click_issue_redirect redirects to error when there is a bad url' do
+ test "#click_issue_redirect redirects to error when there is a bad url" do
assignment = issue_assignments(:schneems_triage_issue_assignment)
- get :click_issue_redirect, params: { id: assignment.id, user_id: 42 }
+ get :click_issue_redirect, params: {id: assignment.id, user_id: 42}
assert_redirected_to :root
end
diff --git a/test/functional/omniauth_callbacks_controller_test.rb b/test/functional/omniauth_callbacks_controller_test.rb
index cf66178bc..181ab76d7 100644
--- a/test/functional/omniauth_callbacks_controller_test.rb
+++ b/test/functional/omniauth_callbacks_controller_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class Users::OmniauthCallbacksControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
@@ -11,17 +11,17 @@ class Users::OmniauthCallbacksControllerTest < ActionController::TestCase
end
test "make user feel good when legit email address" do
- stub_oauth_user('legit@legit.com')
+ stub_oauth_user("legit@legit.com")
get :github
assert flash[:notice] == I18n.t("devise.omniauth_callbacks.success",
- kind: "GitHub")
+ kind: "GitHub")
end
test "redirect to user page and inform when bad e-mail address" do
- stub_oauth_user('awful e-mail address')
+ stub_oauth_user("awful e-mail address")
get :github
assert flash[:notice] == I18n.t("devise.omniauth_callbacks.bad_email_success",
- kind: "GitHub")
+ kind: "GitHub")
assert_redirected_to root_path
end
diff --git a/test/functional/pages_controller_test.rb b/test/functional/pages_controller_test.rb
index 296aa5993..4ac43a839 100644
--- a/test/functional/pages_controller_test.rb
+++ b/test/functional/pages_controller_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class PagesControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
@@ -9,15 +9,15 @@ class PagesControllerTest < ActionController::TestCase
sign_in users(:mockstar)
get :index
- assert_response :success, 'successfully renders index'
- assert_not_nil assigns(:repos), 'assigns to repos'
- assert_not_nil assigns(:repos_subs), 'assigns to repos_subs'
- assert_template :index, 'render index template'
+ assert_response :success, "successfully renders index"
+ assert_not_nil assigns(:repos), "assigns to repos"
+ assert_not_nil assigns(:repos_subs), "assigns to repos_subs"
+ assert_template :index, "render index template"
end
test "not signed in user" do
get :index
- assert_nil assigns(:repos_subs), 'not assigns to repos_subs'
+ assert_nil assigns(:repos_subs), "not assigns to repos_subs"
end
test "cache control for headers" do
diff --git a/test/functional/repo_subscriptions_controller_test.rb b/test/functional/repo_subscriptions_controller_test.rb
index ff8262919..2bd15cbae 100644
--- a/test/functional/repo_subscriptions_controller_test.rb
+++ b/test/functional/repo_subscriptions_controller_test.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class RepoSubscriptionsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
- test 'successfully subscribe to a repo when signed in as mockstar' do
+ test "successfully subscribe to a repo when signed in as mockstar" do
sign_in users(:mockstar)
repo = repos(:issue_triage_sandbox)
- post :create, params: { repo_subscription: { repo_id: repo.id } }
- assert flash[:notice] == I18n.t('repo_subscriptions.subscribed')
+ post :create, params: {repo_subscription: {repo_id: repo.id}}
+ assert flash[:notice] == I18n.t("repo_subscriptions.subscribed")
assert_redirected_to repo_path(repo)
end
- test 'receive failure message when subscription did not created when signed in as mockstar' do
+ test "receive failure message when subscription did not created when signed in as mockstar" do
repo = repos(:rails_rails)
sign_in users(:mockstar)
RepoSubscription.any_instance.stubs(:save).returns false
- post :create, params: { repo_subscription: { repo_id: repo.id } }
+ post :create, params: {repo_subscription: {repo_id: repo.id}}
assert_equal flash[:error], "Something went wrong"
assert_redirected_to repo_path(repo)
end
@@ -25,42 +25,42 @@ class RepoSubscriptionsControllerTest < ActionController::TestCase
test "not update schneems' subscription when signed in as mockstar" do
sign_in users(:mockstar)
assert_raise ActiveRecord::RecordNotFound do
- patch :update, params: { id: repo_subscriptions(:schneems_to_triage).id,
- repo_subscription: { email_limit: 12 } }
+ patch :update, params: {id: repo_subscriptions(:schneems_to_triage).id,
+ repo_subscription: {email_limit: 12}}
end
end
test "not destroy schneems' subscription when signed in as mockstar" do
sign_in users(:mockstar)
assert_raise ActiveRecord::RecordNotFound do
- delete :destroy, params: { id: repo_subscriptions(:schneems_to_triage).id }
+ delete :destroy, params: {id: repo_subscriptions(:schneems_to_triage).id}
end
end
- test 'destroy a subscription' do
+ test "destroy a subscription" do
before_count = RepoSubscription.count
repo_subscription = repo_subscriptions(:schneems_to_triage)
sign_in users(:schneems)
- delete :destroy, params: { id: repo_subscription.id }
+ delete :destroy, params: {id: repo_subscription.id}
assert_redirected_to repo_path(repo_subscription.repo)
assert_equal before_count - 1, RepoSubscription.count
end
- test 'update subscription limit when email limit is valid' do
+ test "update subscription limit when email limit is valid" do
repo_subscription = repo_subscriptions(:schneems_to_triage)
sign_in users(:schneems)
- patch :update, params: { id: repo_subscription.id,
- repo_subscription: { email_limit: 12 } }
+ patch :update, params: {id: repo_subscription.id,
+ repo_subscription: {email_limit: 12}}
assert_equal flash[:success], "Preferences updated!"
assert_redirected_to repo_path(repo_subscription.repo)
end
- test 'not update subscription when email limit is invalid' do
+ test "not update subscription when email limit is invalid" do
repo_subscription = repo_subscriptions(:schneems_to_triage)
sign_in users(:schneems)
- patch :update, params: { id: repo_subscription.id,
- repo_subscription: { email_limit: -1 } }
+ patch :update, params: {id: repo_subscription.id,
+ repo_subscription: {email_limit: -1}}
assert_equal flash[:error], "Something went wrong"
assert_redirected_to repo_path(repo_subscription.repo)
end
diff --git a/test/functional/repos_controller_test.rb b/test/functional/repos_controller_test.rb
index af19aab3f..e9075b173 100644
--- a/test/functional/repos_controller_test.rb
+++ b/test/functional/repos_controller_test.rb
@@ -1,47 +1,47 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class ReposControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
include ActiveJob::TestHelper
- test 'responds with 404 if repo does not exist' do
- get :show, params: { full_name: 'foo/bar' }
+ test "responds with 404 if repo does not exist" do
+ get :show, params: {full_name: "foo/bar"}
assert_redirected_to new_repo_url(user_name: "foo", name: "bar")
end
- test 'trying to create repo without logged in will redirect to login page' do
+ test "trying to create repo without logged in will redirect to login page" do
assert_no_difference -> { Repo.count } do
- post :create, params: { repo: { name: 'codetriage', user_name: 'codetriage' } }
+ post :create, params: {repo: {name: "codetriage", user_name: "codetriage"}}
end
assert_redirected_to user_github_omniauth_authorize_path(origin: "/repos")
end
- test 'do not send email for repo without issues' do
+ test "do not send email for repo without issues" do
sign_in users(:mockstar)
assert_enqueued_jobs 2, only: SendSingleTriageEmailJob do
VCR.use_cassette "create_repo_refinery", record: :once do
- post :create, params: { repo: { name: 'refinerycms', user_name: 'refinery' } }
+ post :create, params: {repo: {name: "refinerycms", user_name: "refinery"}}
end
VCR.use_cassette "create_repo_without_issues", record: :once do
- post :create, params: { repo: { name: 'scene-hub-v2', user_name: 'chrisccerami' } }
+ post :create, params: {repo: {name: "scene-hub-v2", user_name: "chrisccerami"}}
end
end
end
- test 'logged in user can create repo' do
+ test "logged in user can create repo" do
sign_in users(:mockstar)
VCR.use_cassette "create_repo_refinery", record: :once do
assert_difference -> { Repo.count } do
- post :create, params: { repo: { name: 'refinerycms', user_name: 'refinery' } }
+ post :create, params: {repo: {name: "refinerycms", user_name: "refinery"}}
end
end
- assert_redirected_to repo_path('refinery/refinerycms')
+ assert_redirected_to repo_path("refinery/refinerycms")
end
end
diff --git a/test/functional/subscribers_controller_test.rb b/test/functional/subscribers_controller_test.rb
index b1123b0e3..f7f04f3e3 100644
--- a/test/functional/subscribers_controller_test.rb
+++ b/test/functional/subscribers_controller_test.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class SubscribersControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
- test 'list subscribers for a repo' do
+ test "list subscribers for a repo" do
repo = repos(:issue_triage_sandbox)
repo.users << users(:mockstar)
- get :show, params: { full_name: "#{repo.user_name}/#{repo.name}" }
+ get :show, params: {full_name: "#{repo.user_name}/#{repo.name}"}
assert_response :success
assert_not_nil assigns(:subscribers)
assert_not_nil assigns(:repo)
diff --git a/test/functional/topics_controller_test.rb b/test/functional/topics_controller_test.rb
index 982eb7f91..36a255950 100644
--- a/test/functional/topics_controller_test.rb
+++ b/test/functional/topics_controller_test.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class TopicsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
test "redirect invalid topic" do
- get :show, params: { id: 'test' }
+ get :show, params: {id: "test"}
assert_redirected_to root_url
end
end
diff --git a/test/functional/user_mailer_test.rb b/test/functional/user_mailer_test.rb
index 767e7e3e3..7aebb2b4c 100644
--- a/test/functional/user_mailer_test.rb
+++ b/test/functional/user_mailer_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UserMailerTest < ActionMailer::TestCase
test "send_triage works" do
@@ -9,7 +9,7 @@ class UserMailerTest < ActionMailer::TestCase
email = UserMailer.send_triage(
repo: repo_sub.repo,
user: repo_sub.user,
- assignment: assignment,
+ assignment: assignment
)
assert_emails 1 do
@@ -22,7 +22,7 @@ class UserMailerTest < ActionMailer::TestCase
email = UserMailer.poke_inactive(
user: user,
min_issue_count: 0,
- min_subscriber_count: 0,
+ min_subscriber_count: 0
)
assert_emails 1 do
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index d98654b4d..a49ac94b8 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -1,43 +1,43 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UsersControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
- test '#show' do
+ test "#show" do
sign_in users(:mockstar)
user = users(:jroes)
- get :show, params: { id: user.id }
+ get :show, params: {id: user.id}
assert_redirected_to root_path
end
- test '#update should update an user' do
+ test "#update should update an user" do
user = users(:mockstar)
sign_in user
- put :update, params: { user: { name: 'New Name' } }
+ put :update, params: {user: {name: "New Name"}}
user.reload
assert_redirected_to user
- assert_equal 'New Name', user.name
+ assert_equal "New Name", user.name
end
- test '#token_delete' do
+ test "#token_delete" do
sign_in users(:schneems)
- get :token_delete, params: { account_delete_token: users(:schneems).account_delete_token }
+ get :token_delete, params: {account_delete_token: users(:schneems).account_delete_token}
assert(assigns(:lonely_repos).any?)
end
- test 'should destroy a user with the correct account_delete_token' do
+ test "should destroy a user with the correct account_delete_token" do
sign_in users(:mockstar)
assert_difference "User.count", -1 do
- delete :token_destroy, params: { account_delete_token: users(:mockstar).account_delete_token }
+ delete :token_destroy, params: {account_delete_token: users(:mockstar).account_delete_token}
end
end
end
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index cd36ca81e..22ce19367 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1,32 +1,32 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class ApplicationHelperTest < ActionView::TestCase
- test 'warning_svg' do
- expected_warning_svg = %Q{
+ test "warning_svg" do
+ expected_warning_svg = %(
-}.html_safe
+).html_safe
assert_equal expected_warning_svg, warning_svg
end
- test 'star_svg' do
- expected_star_svg = %Q{
+ test "star_svg" do
+ expected_star_svg = %(
- }.html_safe
+ ).html_safe
assert_equal expected_star_svg, star_svg
end
- test 'flash_class levels' do
- assert_equal 'info', flash_class(:notice)
- assert_equal 'error', flash_class(:error)
- assert_equal 'warning', flash_class(:alert)
+ test "flash_class levels" do
+ assert_equal "info", flash_class(:notice)
+ assert_equal "error", flash_class(:error)
+ assert_equal "warning", flash_class(:alert)
end
end
diff --git a/test/integration/adding_repos_test.rb b/test/integration/adding_repos_test.rb
index 9c21dfbdd..431565074 100644
--- a/test/integration/adding_repos_test.rb
+++ b/test/integration/adding_repos_test.rb
@@ -9,32 +9,32 @@ class AddingReposTest < ActionDispatch::IntegrationTest
test "adding a new valid repo passing the URL" do
login_via_github
- VCR.use_cassette('my_repos') do
+ VCR.use_cassette("my_repos") do
visit "/"
click_link "Submit a Repo"
- fill_in 'url', with: 'https://github.com/bemurphy/issue_triage_sandbox'
+ fill_in "url", with: "https://github.com/bemurphy/issue_triage_sandbox"
click_button "Add Repo"
end
- VCR.use_cassette('add_valid_repo') do
+ VCR.use_cassette("add_valid_repo") do
assert page.has_content?("Added bemurphy/issue_triage_sandbox for triaging")
end
end
test "modifies the URL when it has invalid params" do
login_via_github
- VCR.use_cassette('my_repos') do
+ VCR.use_cassette("my_repos") do
visit "/"
click_link "Submit a Repo"
- fill_in 'url', with: 'https://github.com/bemurphy/issue_triage_sandbox?files=1'
+ fill_in "url", with: "https://github.com/bemurphy/issue_triage_sandbox?files=1"
click_button "Add Repo"
end
- VCR.use_cassette('add_valid_repo') do
+ VCR.use_cassette("add_valid_repo") do
assert page.has_content?("Added bemurphy/issue_triage_sandbox for triaging")
end
end
@@ -43,22 +43,22 @@ class AddingReposTest < ActionDispatch::IntegrationTest
visit "/"
login_via_github
- VCR.use_cassette('my_repos') do
+ VCR.use_cassette("my_repos") do
visit "/"
click_link "Submit a Repo"
- fill_in 'url', with: 'bemurphy/issue_triage_sandbox'
+ fill_in "url", with: "bemurphy/issue_triage_sandbox"
click_button "Add Repo"
end
- VCR.use_cassette('add_valid_repo') do
+ VCR.use_cassette("add_valid_repo") do
assert page.has_content?("Added bemurphy/issue_triage_sandbox for triaging")
end
end
test "adding invalid repo with blank params" do
login_via_github
- VCR.use_cassette('blank_repo') do
+ VCR.use_cassette("blank_repo") do
visit "/"
click_link "Submit a Repo"
@@ -70,7 +70,7 @@ class AddingReposTest < ActionDispatch::IntegrationTest
test "add page without login" do
# do not login first
- VCR.use_cassette('blank_repo') do
+ VCR.use_cassette("blank_repo") do
visit "/somerando/project"
end
diff --git a/test/integration/filtering_language_test.rb b/test/integration/filtering_language_test.rb
index f5202dff8..0c08c2853 100644
--- a/test/integration/filtering_language_test.rb
+++ b/test/integration/filtering_language_test.rb
@@ -10,6 +10,6 @@ class FilteringLanguageTest < ActionDispatch::IntegrationTest
test "filtering language in normal projects" do
visit "/?language=Ruby"
- assert_equal page.all('.types-filter-button')[0].text, 'Ruby'
+ assert_equal page.all(".types-filter-button")[0].text, "Ruby"
end
end
diff --git a/test/integration/repos_test.rb b/test/integration/repos_test.rb
index dcd864a7b..628934632 100644
--- a/test/integration/repos_test.rb
+++ b/test/integration/repos_test.rb
@@ -1,63 +1,63 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class ReposTest < ActionDispatch::IntegrationTest
test "regular repo routes" do
assert_routing(
- 'rails/rails',
- { controller: "repos", action: "show", full_name: "rails/rails" },
+ "rails/rails",
+ {controller: "repos", action: "show", full_name: "rails/rails"}
)
end
test "repo index" do
- assert_routing('repos', { controller: "repos", action: "index" })
+ assert_routing("repos", {controller: "repos", action: "index"})
end
test "repo subscriber route" do
assert_routing(
- 'rails/rails/subscribers',
- { controller: "subscribers", action: "show", full_name: "rails/rails" }
+ "rails/rails/subscribers",
+ {controller: "subscribers", action: "show", full_name: "rails/rails"}
)
end
test "route with .js in it" do
assert_routing(
- 'angular/angular.js',
- { controller: "repos", action: "show", full_name: "angular/angular.js" },
+ "angular/angular.js",
+ {controller: "repos", action: "show", full_name: "angular/angular.js"}
)
end
test "access valid repo" do
- get repo_url 'rails/rails'
+ get repo_url "rails/rails"
assert_response :success
end
test "access deleted_from_github repo" do
- get repo_url 'empty/deleted'
- assert_redirected_to new_repo_url(user_name: 'empty', name: 'deleted')
+ get repo_url "empty/deleted"
+ assert_redirected_to new_repo_url(user_name: "empty", name: "deleted")
end
test "access archived repo" do
- get repo_url 'empty/archived'
- assert_redirected_to new_repo_url(user_name: 'empty', name: 'archived')
+ get repo_url "empty/archived"
+ assert_redirected_to new_repo_url(user_name: "empty", name: "archived")
end
test "edit repo where user is not the owner" do
login_as(users(:empty))
- get edit_repo_url 'rails/rails'
+ get edit_repo_url "rails/rails"
assert_redirected_to root_path
end
test "edit deleted_from_github repo" do
login_as(users(:empty))
- get edit_repo_url 'empty/deleted'
+ get edit_repo_url "empty/deleted"
assert_response :success
end
test "edit archived repo" do
login_as(users(:empty))
- get edit_repo_url 'empty/archived'
+ get edit_repo_url "empty/archived"
assert_response :success
end
@@ -67,9 +67,9 @@ class ReposTest < ActionDispatch::IntegrationTest
assert_changes -> {
repo.notes
} do
- patch repo_url 'empty/archived', params: { repo: { notes: 'Updated notes' } }
+ patch repo_url "empty/archived", params: {repo: {notes: "Updated notes"}}
repo.reload
end
- assert_redirected_to repo_url 'empty/archived'
+ assert_redirected_to repo_url "empty/archived"
end
end
diff --git a/test/integration/user_session_test.rb b/test/integration/user_session_test.rb
index 6bcf95c98..3a8415f8b 100644
--- a/test/integration/user_session_test.rb
+++ b/test/integration/user_session_test.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UserSessionTest < ActionDispatch::IntegrationTest
test "sign_in screen renders" do
visit new_user_session_path
- assert page.has_content?('Sign in')
+ assert page.has_content?("Sign in")
end
end
diff --git a/test/integration/user_unsubscribes_test.rb b/test/integration/user_unsubscribes_test.rb
index e95e7791c..9155a6005 100644
--- a/test/integration/user_unsubscribes_test.rb
+++ b/test/integration/user_unsubscribes_test.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UserUnsubscribeTest < ActionDispatch::IntegrationTest
- test 'unsubscribing successfully' do
+ test "unsubscribing successfully" do
@user = users(:mockstar)
token = @user.account_delete_token
login_as(@user, scope: :user)
@@ -11,10 +11,10 @@ class UserUnsubscribeTest < ActionDispatch::IntegrationTest
visit token_delete_user_path(token)
click_on "destroy_user"
- assert page.has_content?('Successfully removed your user account')
+ assert page.has_content?("Successfully removed your user account")
end
- test 'unsubscribing more than once' do
+ test "unsubscribing more than once" do
@user = users(:mockstar)
token = @user.account_delete_token
login_as(@user, scope: :user)
@@ -24,6 +24,6 @@ class UserUnsubscribeTest < ActionDispatch::IntegrationTest
visit token_delete_user_path(token)
- assert page.has_content?('Account could not be found. You may have already deleted it, or your GitHub username may have changed.')
+ assert page.has_content?("Account could not be found. You may have already deleted it, or your GitHub username may have changed.")
end
end
diff --git a/test/integration/user_update_test.rb b/test/integration/user_update_test.rb
index 9d66e7d89..d7ad714e1 100644
--- a/test/integration/user_update_test.rb
+++ b/test/integration/user_update_test.rb
@@ -1,88 +1,88 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UserUpdateTest < ActionDispatch::IntegrationTest
test "routing" do
user = users(:mockstar)
- assert_routing user_path(user), { controller: 'users', action: 'show', id: user.id.to_s }
+ assert_routing user_path(user), {controller: "users", action: "show", id: user.id.to_s}
end
- test 'updating the user email address' do
+ test "updating the user email address" do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
- fill_in 'Email', with: 'newemail@me.com'
- click_button 'Save'
- assert page.has_content?('User successfully updated')
+ fill_in "Email", with: "newemail@me.com"
+ click_button "Save"
+ assert page.has_content?("User successfully updated")
end
- test 'updating the user email_frequency' do
+ test "updating the user email_frequency" do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
- select 'Twice a week', from: 'Email Frequency'
- click_button 'Save'
- assert page.has_content?('User successfully updated')
+ select "Twice a week", from: "Email Frequency"
+ click_button "Save"
+ assert page.has_content?("User successfully updated")
visit edit_user_path(@user)
- assert page.has_select?('Email Frequency', selected: 'Twice a week')
+ assert page.has_select?("Email Frequency", selected: "Twice a week")
@user.reload
- assert_equal @user.email_frequency, 'twice_a_week'
+ assert_equal @user.email_frequency, "twice_a_week"
end
- test 'updating the user daily_issue_limit' do
+ test "updating the user daily_issue_limit" do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
- fill_in 'Max # of issues you want to receive per day', with: '1'
- click_button 'Save'
- assert page.has_content?('User successfully updated')
+ fill_in "Max # of issues you want to receive per day", with: "1"
+ click_button "Save"
+ assert page.has_content?("User successfully updated")
@user.reload
assert_equal @user.daily_issue_limit, 1
end
- test 'updating the user daily_issue_limit to unlimited' do
+ test "updating the user daily_issue_limit to unlimited" do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
- fill_in 'Max # of issues you want to receive per day', with: ''
- click_button 'Save'
- assert page.has_content?('User successfully updated')
+ fill_in "Max # of issues you want to receive per day", with: ""
+ click_button "Save"
+ assert page.has_content?("User successfully updated")
@user.reload
assert_nil @user.daily_issue_limit
end
- test 'updating the user email_time_of_day' do
+ test "updating the user email_time_of_day" do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
- select '05:00 UTC', from: 'Email time of day'
- click_button 'Save'
- assert page.has_content?('User successfully updated')
+ select "05:00 UTC", from: "Email time of day"
+ click_button "Save"
+ assert page.has_content?("User successfully updated")
visit edit_user_path(@user)
- assert page.has_select?('Email time of day', selected: '05:00 UTC')
+ assert page.has_select?("Email time of day", selected: "05:00 UTC")
@user.reload
- assert_equal @user.email_time_of_day, '2000-01-01 05:00:00 UTC'
+ assert_equal @user.email_time_of_day, "2000-01-01 05:00:00 UTC"
end
- test 'updating the users skip_issues_with_pr setting to true' do
+ test "updating the users skip_issues_with_pr setting to true" do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
- check 'user_skip_issues_with_pr'
- click_button 'Save'
- assert page.has_content?('User successfully updated')
+ check "user_skip_issues_with_pr"
+ click_button "Save"
+ assert page.has_content?("User successfully updated")
@user.reload
assert @user.skip_issues_with_pr
end
- test 'updating the users skip_issues_with_pr setting to false' do
+ test "updating the users skip_issues_with_pr setting to false" do
@user = users(:mockstar)
login_as(@user, scope: :user)
visit edit_user_path(@user)
- uncheck 'user_skip_issues_with_pr'
- click_button 'Save'
- assert page.has_content?('User successfully updated')
+ uncheck "user_skip_issues_with_pr"
+ click_button "Save"
+ assert page.has_content?("User successfully updated")
@user.reload
assert_equal false, @user.skip_issues_with_pr
end
diff --git a/test/jobs/background_inactive_email_job_test.rb b/test/jobs/background_inactive_email_job_test.rb
index 98a41b94a..d1b3aa57f 100644
--- a/test/jobs/background_inactive_email_job_test.rb
+++ b/test/jobs/background_inactive_email_job_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class BackgroundInactiveEmailJobTest < ActiveJob::TestCase
# test "the truth" do
diff --git a/test/jobs/parse_docs_test.rb b/test/jobs/parse_docs_test.rb
index b0d776cf4..1a0693a70 100644
--- a/test/jobs/parse_docs_test.rb
+++ b/test/jobs/parse_docs_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class ParseDocsTest < ActiveJob::TestCase
test "Can parse yard docs" do
diff --git a/test/jobs/populate_issues_job_test.rb b/test/jobs/populate_issues_job_test.rb
index adb467a8c..fa37ae943 100644
--- a/test/jobs/populate_issues_job_test.rb
+++ b/test/jobs/populate_issues_job_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class PopulateIssuesJobTest < ActiveJob::TestCase
test "#perform kicks off populate_multi_issues!" do
@@ -10,7 +10,7 @@ class PopulateIssuesJobTest < ActiveJob::TestCase
test "Works when there's no issues" do
stub_request(:any, "https://api.github.com/repos/bemurphy/issue_triage_sandbox/issues?direction=desc&page=1&sort=comments&state=open")
- .to_return({ body: [].to_json, status: 200 })
+ .to_return({body: [].to_json, status: 200})
repo = repos(:issue_triage_sandbox)
@@ -19,7 +19,7 @@ class PopulateIssuesJobTest < ActiveJob::TestCase
test "#populate_multi_issues creates issues" do
repo = repos(:issue_triage_sandbox)
- repo.issues.where(state: 'open').delete_all
+ repo.issues.where(state: "open").delete_all
VCR.use_cassette "issue_triage_sandbox_fetch_issues" do
assert_difference("Issue.count", 1) do
PopulateIssuesJob.perform_now(repo)
@@ -30,13 +30,14 @@ class PopulateIssuesJobTest < ActiveJob::TestCase
test "#populate_multi_issues stores error info when fails" do
repo = repos(:issue_triage_sandbox)
def repo.issues_fetcher
- fetcher = OpenStruct.new(error?: true, error_message: 'something went wrong', page: 1)
- def fetcher.call(*args); end
+ fetcher = OpenStruct.new(error?: true, error_message: "something went wrong", page: 1)
+ def fetcher.call(*args)
+ end
fetcher
end
PopulateIssuesJob.perform_now(repo)
- assert_equal repo.github_error_msg, 'something went wrong'
+ assert_equal repo.github_error_msg, "something went wrong"
end
test "updates existing issues" do
diff --git a/test/jobs/send_daily_triage_email_job_test.rb b/test/jobs/send_daily_triage_email_job_test.rb
index d789a83a3..c4549673f 100644
--- a/test/jobs/send_daily_triage_email_job_test.rb
+++ b/test/jobs/send_daily_triage_email_job_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class SendDailyTriageEmailJobTest < ActiveJob::TestCase
def setup
@@ -8,10 +8,14 @@ def setup
@job = SendDailyTriageEmailJob.new
end
- test 'send out daily triage email' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "send out daily triage email" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
- def @job.before_email_time_of_day?(*); false; end
+ def @job.before_email_time_of_day?(*)
+ false
+ end
# {:job=>ActionMailer::DeliveryJob, :args=>["UserMailer", "send_daily_triage", "deliver_now", {"user_id"=>110871456, "assignment_ids"=>[980190962], "write_doc_ids"=>[], "read_doc_ids"=>[], "_aj_symbol_keys"=>["user_id", "assignment_ids", "write_doc_ids", "read_doc_ids"]}], :queue=>"mailers"}.
assert_enqueued_with(job: ActionMailer::MailDeliveryJob, queue: "default") do
@@ -19,24 +23,34 @@ def @job.before_email_time_of_day?(*); false; end
end
end
- test 'does not deliver if no subscriptions' do
- def @user.issue_assignments_to_deliver; []; end
+ test "does not deliver if no subscriptions" do
+ def @user.issue_assignments_to_deliver
+ []
+ end
- def @job.before_email_time_of_day?(*); false; end
+ def @job.before_email_time_of_day?(*)
+ false
+ end
assert_not @job.perform(@user)
end
- test 'does not deliver if email should be skipped' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "does not deliver if email should be skipped" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
- def @job.skip_daily_email?(*); true; end
+ def @job.skip_daily_email?(*)
+ true
+ end
assert_not @job.perform(@user)
end
- test 'when email_time_of_day not set, it delivers after default time of day' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "when email_time_of_day not set, it delivers after default time of day" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
Time.stub(:now, time_preference_for_today(SendDailyTriageEmailJob::DEFAULT_EMAIL_TIME_OF_DAY) + 1.hour) do
assert_enqueued_jobs 1 do
@@ -45,18 +59,24 @@ def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
end
end
- test 'when email_time_of_day not set, it does not deliver before default time of day' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "when email_time_of_day not set, it does not deliver before default time of day" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
Time.stub(:now, time_preference_for_today(SendDailyTriageEmailJob::DEFAULT_EMAIL_TIME_OF_DAY) - 1.hour) do
assert_not @job.perform(@user)
end
end
- test 'when email_time_of_day set, it delivers at preferred time of day' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "when email_time_of_day set, it delivers at preferred time of day" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
- def @user.email_time_of_day; Time.utc(2000, 1, 1, 04, 0, 0); end
+ def @user.email_time_of_day
+ Time.utc(2000, 1, 1, 0o4, 0, 0)
+ end
Time.stub(:now, time_preference_for_today(@user.email_time_of_day)) do
assert_enqueued_jobs 1 do
@@ -65,20 +85,28 @@ def @user.email_time_of_day; Time.utc(2000, 1, 1, 04, 0, 0); end
end
end
- test 'when email_time_of_day set, it does not deliver before preferred time of day' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "when email_time_of_day set, it does not deliver before preferred time of day" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
- def @user.email_time_of_day; Time.utc(2000, 1, 1, 04, 0, 0); end
+ def @user.email_time_of_day
+ Time.utc(2000, 1, 1, 0o4, 0, 0)
+ end
Time.stub(:now, time_preference_for_today(@user.email_time_of_day) - 1.hour) do
assert_not @job.perform(@user)
end
end
- test 'when run multiple times a day, it does not deliver again' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "when run multiple times a day, it does not deliver again" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
- def @user.email_time_of_day; Time.utc(2000, 1, 1, 04, 0, 0); end
+ def @user.email_time_of_day
+ Time.utc(2000, 1, 1, 0o4, 0, 0)
+ end
Time.stub(:now, time_preference_for_today(@user.email_time_of_day) + 1.hour) do
@job.perform(@user)
@@ -86,10 +114,14 @@ def @user.email_time_of_day; Time.utc(2000, 1, 1, 04, 0, 0); end
end
end
- test 'when preference changed, sends at preferred time next day' do
- def @user.issue_assignments_to_deliver; IssueAssignment.all.limit(1); end
+ test "when preference changed, sends at preferred time next day" do
+ def @user.issue_assignments_to_deliver
+ IssueAssignment.all.limit(1)
+ end
- def @user.email_time_of_day; Time.utc(2000, 1, 1, 18, 0, 0); end
+ def @user.email_time_of_day
+ Time.utc(2000, 1, 1, 18, 0, 0)
+ end
Time.stub(:now, time_preference_for_today(@user.email_time_of_day)) do
assert_enqueued_jobs 1 do
@@ -97,7 +129,9 @@ def @user.email_time_of_day; Time.utc(2000, 1, 1, 18, 0, 0); end
end
end
- def @user.email_time_of_day; Time.utc(2000, 1, 1, 04, 0, 0); end
+ def @user.email_time_of_day
+ Time.utc(2000, 1, 1, 0o4, 0, 0)
+ end
Time.stub(:now, time_preference_for_today(@user.email_time_of_day) + 1.day) do
assert_enqueued_jobs 1 do
diff --git a/test/jobs/send_single_triage_email_job_test.rb b/test/jobs/send_single_triage_email_job_test.rb
index 5a8c1f35c..d5cec14b9 100644
--- a/test/jobs/send_single_triage_email_job_test.rb
+++ b/test/jobs/send_single_triage_email_job_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class SendSingleTriageEmailJobTest < ActiveJob::TestCase
# test "the truth" do
diff --git a/test/jobs/update_repo_info_job_test.rb b/test/jobs/update_repo_info_job_test.rb
index 3a1b40a9d..42eca6cba 100644
--- a/test/jobs/update_repo_info_job_test.rb
+++ b/test/jobs/update_repo_info_job_test.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UpdateRepoInfoJobTest < ActiveJob::TestCase
- test 'repo deleted or made private' do
+ test "repo deleted or made private" do
GithubFetcher::Resource.any_instance.stubs(:status).returns(404)
repo = repos(:node)
assert_changes -> {
[
- repo.removed_from_github,
+ repo.removed_from_github
]
} do
UpdateRepoInfoJob.perform_now(repo)
@@ -16,14 +16,14 @@ class UpdateRepoInfoJobTest < ActiveJob::TestCase
assert repo.removed_from_github
end
- test 'repo with information updated' do
+ test "repo with information updated" do
GithubFetcher::Resource.any_instance.stubs(:status).returns(200)
GithubFetcher::Resource.any_instance.stubs(:as_json).returns(
{
- 'full_name' => 'test_owner/test_repo',
- 'language' => 'test_language',
- 'description' => 'test_description',
- 'archived' => true
+ "full_name" => "test_owner/test_repo",
+ "language" => "test_language",
+ "description" => "test_description",
+ "archived" => true
}
)
repo = repos(:node)
@@ -41,19 +41,19 @@ class UpdateRepoInfoJobTest < ActiveJob::TestCase
repo.reload
end
assert_equal false, repo.removed_from_github
- assert_equal 'test_owner/test_repo', repo.full_name
- assert_equal 'test_repo', repo.name
- assert_equal 'test_owner', repo.user_name
- assert_equal 'test_language', repo.language
- assert_equal 'test_description', repo.description
+ assert_equal "test_owner/test_repo", repo.full_name
+ assert_equal "test_repo", repo.name
+ assert_equal "test_owner", repo.user_name
+ assert_equal "test_language", repo.language
+ assert_equal "test_description", repo.description
assert_equal true, repo.archived
end
- test 'repo rename conflict' do
+ test "repo rename conflict" do
GithubFetcher::Resource.any_instance.stubs(:status).returns(200)
GithubFetcher::Resource.any_instance.stubs(:as_json).returns(
{
- 'full_name' => 'sinatra/sinatra',
+ "full_name" => "sinatra/sinatra"
}
)
repo = repos(:node)
diff --git a/test/mailers/previews/user_preview.rb b/test/mailers/previews/user_preview.rb
index b4f7160b4..0e1892862 100644
--- a/test/mailers/previews/user_preview.rb
+++ b/test/mailers/previews/user_preview.rb
@@ -8,40 +8,40 @@ def invalid_token
# Pull data from existing fixtures
def send_spam
- user = User.last
+ user = User.last
subject = "Big launch"
message = "hello world"
::UserMailer.spam(user: user, subject: subject, message: message, htos_contributor: true)
end
def send_triage_create
- user = User.last
- repo = Repo.order(Arel.sql("RANDOM()")).first
+ user = User.last
+ repo = Repo.order(Arel.sql("RANDOM()")).first
issue = Issue.where(state: "open", repo_id: repo.id).where.not(number: nil).first!
- sub = RepoSubscription.where(user_id: user.id, repo_id: repo.id).first_or_create!
+ sub = RepoSubscription.where(user_id: user.id, repo_id: repo.id).first_or_create!
assignment = sub.issue_assignments.where(issue_id: issue.id).first_or_create!
::UserMailer.send_triage(user: user, repo: repo, assignment: assignment, create: true)
end
def send_triage
- user = User.last
- repo = Repo.order(Arel.sql("RANDOM()")).first
+ user = User.last
+ repo = Repo.order(Arel.sql("RANDOM()")).first
issue = Issue.where(state: "open", repo_id: repo.id).where.not(number: nil).first!
- sub = RepoSubscription.where(user_id: user.id, repo_id: repo.id).first_or_create!
+ sub = RepoSubscription.where(user_id: user.id, repo_id: repo.id).first_or_create!
assignment = sub.issue_assignments.where(issue_id: issue.id).first_or_create!
::UserMailer.send_triage(user: user, repo: repo, assignment: assignment)
end
def _01_send_daily_triage_mixed
write_docs = DocMethod.order(Arel.sql("RANDOM()")).includes(:repo).missing_docs.first(rand(0..8))
- read_docs = DocMethod.order(Arel.sql("RANDOM()")).includes(:repo).with_docs.first(rand(0..8))
+ read_docs = DocMethod.order(Arel.sql("RANDOM()")).includes(:repo).with_docs.first(rand(0..8))
write_docs = DocMethod.order(Arel.sql("RANDOM()")).includes(:repo).first(rand(0..8)) if write_docs.blank?
- read_docs = DocMethod.order(Arel.sql("RANDOM()")).includes(:repo).first(rand(0..8)) if read_docs.blank?
+ read_docs = DocMethod.order(Arel.sql("RANDOM()")).includes(:repo).first(rand(0..8)) if read_docs.blank?
- user = User.last
+ user = User.last
assignments = []
- repos = (write_docs + read_docs).map(&:repo)
+ repos = (write_docs + read_docs).map(&:repo)
(write_docs + read_docs).each do |doc|
RepoSubscription.where(
@@ -76,19 +76,19 @@ def _01_send_daily_triage_mixed
def _02_send_daily_triage_issues_only
issue_count = rand(3..5)
- user = User.last
+ user = User.last
assignments = []
issue_count.times.each do
issue = Issue
- .where(state: "open")
- .where.not(number: nil)
- .order(Arel.sql("RANDOM()"))
- .first
+ .where(state: "open")
+ .where.not(number: nil)
+ .order(Arel.sql("RANDOM()"))
+ .first
next if issue.nil?
- sub = RepoSubscription.where(user_id: user.id, repo_id: issue.repo.id).first_or_create!
+ sub = RepoSubscription.where(user_id: user.id, repo_id: issue.repo.id).first_or_create!
assignment = sub.issue_assignments.where(issue_id: issue.id).first_or_create!
assignments << assignment
end
@@ -110,10 +110,10 @@ def daily_docs
user = User.last
write_docs = DocMethod.order(Arel.sql("RANDOM()")).missing_docs.first(rand(0..8))
- read_docs = DocMethod.order(Arel.sql("RANDOM()")).with_docs.first(rand(0..8))
+ read_docs = DocMethod.order(Arel.sql("RANDOM()")).with_docs.first(rand(0..8))
write_docs = DocMethod.order(Arel.sql("RANDOM()")).first(rand(0..8)) if write_docs.blank?
- read_docs = DocMethod.order(Arel.sql("RANDOM()")).first(rand(0..8)) if read_docs.blank?
+ read_docs = DocMethod.order(Arel.sql("RANDOM()")).first(rand(0..8)) if read_docs.blank?
::UserMailer.daily_docs(
user: user,
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8ee77201f..2a5f4d94b 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'simplecov'
-SimpleCov.start 'rails'
+require "simplecov"
+SimpleCov.start "rails"
ENV["RAILS_ENV"] = "test"
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
+require File.expand_path("../../config/environment", __FILE__)
+require "rails/test_help"
require "capybara/rails"
-require 'webmock/minitest'
+require "webmock/minitest"
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
@@ -32,13 +32,13 @@ class ActionDispatch::IntegrationTest
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(
:github, {
- uid: 'mockstar',
+ uid: "mockstar",
credentials: {
- token: ENV['GITHUB_API_KEY'] || "d401116495671f0a0ceca9276e677eff"
+ token: ENV["GITHUB_API_KEY"] || "d401116495671f0a0ceca9276e677eff"
},
email: "mockstar@example.com",
info: {
- nickname: 'mockstar',
+ nickname: "mockstar",
email: "mockstar@example.com"
},
extra: {
@@ -54,10 +54,10 @@ class ActionDispatch::IntegrationTest
# This 'allow' should be temporary, work towards covering
# everything via vcr because github rate limits
c.allow_http_connections_when_no_cassette = false
- c.cassette_library_dir = 'test/vcr_cassettes'
+ c.cassette_library_dir = "test/vcr_cassettes"
c.hook_into :webmock
- 'GITHUB_APP_ID GITHUB_APP_SECRET GITHUB_API_KEY'.split(' ').each do |secure|
+ "GITHUB_APP_ID GITHUB_APP_SECRET GITHUB_API_KEY".split(" ").each do |secure|
sensitive = ENV[secure] ||= secure
c.filter_sensitive_data("<#{secure}>") { sensitive }
end
@@ -77,9 +77,9 @@ def login_via_github
end
end
-require 'mocha/minitest'
-require 'minitest/mock'
-require 'sidekiq/testing'
+require "mocha/minitest"
+require "minitest/mock"
+require "sidekiq/testing"
def get_process_mem_disk_location
tmp_path = File.expand_path("../../tmp", __FILE__)
@@ -89,5 +89,5 @@ def get_process_mem_disk_location
out = `cd #{tmp_path} && git clone https://github.com/schneems/get_process_mem`
raise "Cloning failed #{out.inspect}" unless $?.success?
- return path
+ path
end
diff --git a/test/unit/email_rate_limit_test.rb b/test/unit/email_rate_limit_test.rb
index 4c9199dd5..b5280249d 100644
--- a/test/unit/email_rate_limit_test.rb
+++ b/test/unit/email_rate_limit_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class EmailRateLimitTest < ActiveSupport::TestCase
def seed_array
@@ -10,10 +10,10 @@ def seed_array
test "decides daily email frequency" do
# Daily
last_clicked_days_ago = 0..3
- multiplier = 1
- valid_values = seed_array.map { |n| n * multiplier }
- day_ago = rand(last_clicked_days_ago)
- clicked_ago = valid_values.sample
+ multiplier = 1
+ valid_values = seed_array.map { |n| n * multiplier }
+ day_ago = rand(last_clicked_days_ago)
+ clicked_ago = valid_values.sample
assert EmailRateLimit.new(day_ago).now?(clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).now?(#{clicked_ago}) to be true, was not"
# Use user email frequency settings
@@ -23,22 +23,22 @@ def seed_array
test "wait" do
# wait
last_clicked_days_ago = 4..6
- multiplier = 1
- valid_values = seed_array.map { |n| n * multiplier }
- invalid_values = last_clicked_days_ago.to_a - valid_values
- day_ago = rand(last_clicked_days_ago)
- bad_clicked_ago = invalid_values.sample
+ multiplier = 1
+ valid_values = seed_array.map { |n| n * multiplier }
+ invalid_values = last_clicked_days_ago.to_a - valid_values
+ day_ago = rand(last_clicked_days_ago)
+ bad_clicked_ago = invalid_values.sample
assert EmailRateLimit.new(day_ago).skip?(bad_clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).skip?(#{bad_clicked_ago}) to be true, was not"
end
test "twice a week" do
# twice a week
last_clicked_days_ago = 7..13
- multiplier = 3
- valid_values = seed_array.map { |n| n * multiplier }
- invalid_values = last_clicked_days_ago.to_a - valid_values
- day_ago = rand(last_clicked_days_ago)
- clicked_ago = valid_values.sample
+ multiplier = 3
+ valid_values = seed_array.map { |n| n * multiplier }
+ invalid_values = last_clicked_days_ago.to_a - valid_values
+ day_ago = rand(last_clicked_days_ago)
+ clicked_ago = valid_values.sample
bad_clicked_ago = invalid_values.sample
assert EmailRateLimit.new(day_ago).now?(clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).now?(#{clicked_ago}) to be true, was not"
assert EmailRateLimit.new(day_ago).skip?(bad_clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).skip?(#{bad_clicked_ago}) to be true, was not"
@@ -50,11 +50,11 @@ def seed_array
test "once a week" do
# once a week
last_clicked_days_ago = 14..30
- multiplier = 7
- valid_values = seed_array.map { |n| n * multiplier }
- invalid_values = last_clicked_days_ago.to_a - valid_values
- day_ago = rand(last_clicked_days_ago)
- clicked_ago = valid_values.sample
+ multiplier = 7
+ valid_values = seed_array.map { |n| n * multiplier }
+ invalid_values = last_clicked_days_ago.to_a - valid_values
+ day_ago = rand(last_clicked_days_ago)
+ clicked_ago = valid_values.sample
bad_clicked_ago = invalid_values.sample
assert EmailRateLimit.new(day_ago).now?(clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).now?(#{clicked_ago}) to be true, was not"
assert EmailRateLimit.new(day_ago).skip?(bad_clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).skip?(#{bad_clicked_ago}) to be true, was not"
@@ -66,11 +66,11 @@ def seed_array
test "once a month" do
# once a month
last_clicked_days_ago = 31..10_000
- multiplier = 30
- valid_values = seed_array.map { |n| n * multiplier }
- invalid_values = last_clicked_days_ago.to_a - valid_values
- day_ago = rand(last_clicked_days_ago)
- clicked_ago = valid_values.sample
+ multiplier = 30
+ valid_values = seed_array.map { |n| n * multiplier }
+ invalid_values = last_clicked_days_ago.to_a - valid_values
+ day_ago = rand(last_clicked_days_ago)
+ clicked_ago = valid_values.sample
bad_clicked_ago = invalid_values.sample
assert EmailRateLimit.new(day_ago).now?(clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).now?(#{clicked_ago}) to be true, was not"
assert EmailRateLimit.new(day_ago).skip?(bad_clicked_ago), "Expected EmailRateLimit.new(#{day_ago}).skip?(#{bad_clicked_ago}) to be true, was not"
diff --git a/test/unit/git_branchname_generator_test.rb b/test/unit/git_branchname_generator_test.rb
index bb7053b7e..51cb3cc2c 100644
--- a/test/unit/git_branchname_generator_test.rb
+++ b/test/unit/git_branchname_generator_test.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GitBranchnameGeneratorTest < ActiveSupport::TestCase
test "replaces non alpha-numerics and underscores with dashes" do
doc_path = "Pay-)(*&^%$#@!~ment.charge?"
assert_equal "username-update-docs-Pay------------ment-charge--for-pr",
- GitBranchnameGenerator.new(username: "username", doc_path: doc_path).branchname
+ GitBranchnameGenerator.new(username: "username", doc_path: doc_path).branchname
end
test "does not allow pounds (#)" do
doc_path = "Payment#charge?"
assert_equal "username-update-docs-Payment-charge--for-pr",
- GitBranchnameGenerator.new(username: "username", doc_path: doc_path).branchname
+ GitBranchnameGenerator.new(username: "username", doc_path: doc_path).branchname
end
test "does not allow periods" do
doc_path = "Payment.charge?"
assert_equal "username-update-docs-Payment-charge--for-pr",
- GitBranchnameGenerator.new(username: "username", doc_path: doc_path).branchname
+ GitBranchnameGenerator.new(username: "username", doc_path: doc_path).branchname
end
end
diff --git a/test/unit/git_hub_authenticator_test.rb b/test/unit/git_hub_authenticator_test.rb
index 36ea7eadf..6e8d9ea98 100644
--- a/test/unit/git_hub_authenticator_test.rb
+++ b/test/unit/git_hub_authenticator_test.rb
@@ -1,50 +1,50 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GitHubAuthenticatorTest < ActiveSupport::TestCase
test "updates existing user params" do
oauth = OmniAuth::AuthHash.new(
- info: { email: 'mockstar@example.com', nickname: 'johndoe' },
- extra: { raw_info: { name: 'John Doe', avatar_url: 'avatar.png' } },
- credentials: { token: '123qwe' }
+ info: {email: "mockstar@example.com", nickname: "johndoe"},
+ extra: {raw_info: {name: "John Doe", avatar_url: "avatar.png"}},
+ credentials: {token: "123qwe"}
)
user = GitHubAuthenticator.authenticate oauth
assert user.persisted?, "User is not persisted but was expected to be #{user.inspect}\n #{user.errors.full_messages}"
- assert_equal 'johndoe', user.github
- assert_equal 'mockstar@example.com', user.email
- assert_equal 'avatar.png', user.avatar_url
+ assert_equal "johndoe", user.github
+ assert_equal "mockstar@example.com", user.email
+ assert_equal "avatar.png", user.avatar_url
end
test "creates new user user when user does not exist and oauth contains email" do
oauth = OmniAuth::AuthHash.new(
- info: { email: 'john.doe@example.com', nickname: 'johndoe' },
- extra: { raw_info: { name: 'john', avatar_url: 'avatar.png' } },
- credentials: { token: '123qwe' }
+ info: {email: "john.doe@example.com", nickname: "johndoe"},
+ extra: {raw_info: {name: "john", avatar_url: "avatar.png"}},
+ credentials: {token: "123qwe"}
)
user = GitHubAuthenticator.authenticate oauth
- assert user.persisted?, 'user is persisted'
- assert_equal 'johndoe', user.github
- assert_equal 'john.doe@example.com', user.email
- assert_equal 'avatar.png', user.avatar_url
+ assert user.persisted?, "user is persisted"
+ assert_equal "johndoe", user.github
+ assert_equal "john.doe@example.com", user.email
+ assert_equal "avatar.png", user.avatar_url
end
test "creates new user user when user does not exist and oauth does not contains email" do
oauth = OmniAuth::AuthHash.new(
- info: { nickname: 'johndoe' },
- extra: { raw_info: { name: 'john', avatar_url: 'avatar.png' } },
- credentials: { token: '123qwe' }
+ info: {nickname: "johndoe"},
+ extra: {raw_info: {name: "john", avatar_url: "avatar.png"}},
+ credentials: {token: "123qwe"}
)
- emails = Struct.new(:json_body).new ['john.doe@example.com']
- GitHubBub.expects(:get).with("/user/emails", token: '123qwe')
- .returns emails
+ emails = Struct.new(:json_body).new ["john.doe@example.com"]
+ GitHubBub.expects(:get).with("/user/emails", token: "123qwe")
+ .returns emails
user = GitHubAuthenticator.authenticate oauth
- assert user.persisted?, "User is not persisted but was expected to be "\
+ assert user.persisted?, "User is not persisted but was expected to be " \
"#{user.inspect}\n #{user.errors.full_messages}"
- assert_equal 'john.doe@example.com', user.email
+ assert_equal "john.doe@example.com", user.email
end
end
diff --git a/test/unit/github_fetcher/commit_sha_test.rb b/test/unit/github_fetcher/commit_sha_test.rb
index d38d17606..9ce1286fb 100644
--- a/test/unit/github_fetcher/commit_sha_test.rb
+++ b/test/unit/github_fetcher/commit_sha_test.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::CommitShaTest < ActiveSupport::TestCase
def fetcher(repo)
GithubFetcher::CommitSha.new(
user_name: repo.user_name,
name: repo.name,
- default_branch: 'master'
+ default_branch: "master"
)
end
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json returns json" do
@@ -20,7 +20,7 @@ def fetcher(repo)
commit_message = "Fixed geojson method in band model"
VCR.use_cassette "fetcher_commit_sha" do
- assert_equal fetcher.as_json['commit']['message'], commit_message, fetcher.as_json
+ assert_equal fetcher.as_json["commit"]["message"], commit_message, fetcher.as_json
end
end
diff --git a/test/unit/github_fetcher/email_test.rb b/test/unit/github_fetcher/email_test.rb
index bafb9a25a..2e1301da8 100644
--- a/test/unit/github_fetcher/email_test.rb
+++ b/test/unit/github_fetcher/email_test.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::EmailTest < ActiveSupport::TestCase
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json includes list of emails for given user" do
@@ -14,17 +14,17 @@ class GithubFetcher::EmailTest < ActiveSupport::TestCase
)
assert_equal email_fetcher.as_json, [
- { "email" => "dmragone@gmail.com", "primary" => true, "verified" => true, "visibility" => "public" },
- { "email" => "david.ragone@hired.com", "primary" => false, "verified" => true, "visibility" => nil }
+ {"email" => "dmragone@gmail.com", "primary" => true, "verified" => true, "visibility" => "public"},
+ {"email" => "david.ragone@hired.com", "primary" => false, "verified" => true, "visibility" => nil}
], "Failed: Got #{email_fetcher.as_json}"
end
end
test "#as_json returns null response when bad request" do
VCR.use_cassette "bad_fetch_emails" do
- email_fetcher = GithubFetcher::Email.new(token: 'asdf')
+ email_fetcher = GithubFetcher::Email.new(token: "asdf")
- assert_equal email_fetcher.as_json, { "message" => "Bad credentials", "documentation_url" => "https://developer.github.com/v3" }
+ assert_equal email_fetcher.as_json, {"message" => "Bad credentials", "documentation_url" => "https://developer.github.com/v3"}
end
end
end
diff --git a/test/unit/github_fetcher/issue_comments_test.rb b/test/unit/github_fetcher/issue_comments_test.rb
index 58c075c7f..ed5fc7a8c 100644
--- a/test/unit/github_fetcher/issue_comments_test.rb
+++ b/test/unit/github_fetcher/issue_comments_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::IssueCommentsTest < ActiveSupport::TestCase
def comments_fetcher
@@ -15,14 +15,14 @@ def comments_fetcher
end
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json returns list of comments" do
first_comment_url = "https://api.github.com/repos/sinatra/sinatra/issues/comments/5"
VCR.use_cassette "fetch_issue_comments" do
- assert_equal comments_fetcher.as_json.first['url'], first_comment_url
+ assert_equal comments_fetcher.as_json.first["url"], first_comment_url
end
end
@@ -36,12 +36,12 @@ def comments_fetcher
fetcher = comments_fetcher
fetcher.stub(:as_json, -> {
[
- { "id" => 5, "user" => { "login" => "rtomayko", "id" => 404 } },
- { "id" => 6, "user" => { "login" => "rtomayko", "id" => 404 } },
- { "id" => 7, "user" => { "login" => "DavidRagone", "id" => 22345 } },
+ {"id" => 5, "user" => {"login" => "rtomayko", "id" => 404}},
+ {"id" => 6, "user" => {"login" => "rtomayko", "id" => 404}},
+ {"id" => 7, "user" => {"login" => "DavidRagone", "id" => 22345}}
]
}) do
- assert_equal fetcher.commenters, ['rtomayko', 'DavidRagone']
+ assert_equal fetcher.commenters, ["rtomayko", "DavidRagone"]
end
end
end
diff --git a/test/unit/github_fetcher/issue_test.rb b/test/unit/github_fetcher/issue_test.rb
index 759828e70..89a607461 100644
--- a/test/unit/github_fetcher/issue_test.rb
+++ b/test/unit/github_fetcher/issue_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::IssueTest < ActiveSupport::TestCase
def issue_fetcher(issue)
@@ -12,21 +12,21 @@ def issue_fetcher(issue)
end
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json includes issue details" do
fetcher = issue_fetcher(issues(:issue_one))
VCR.use_cassette "fetch_issue" do
- assert_equal fetcher.as_json['title'], 'first test issue', fetcher.as_json
+ assert_equal fetcher.as_json["title"], "first test issue", fetcher.as_json
end
end
test "#as_json returns {} when error" do
GitHubBub.stub(:get, ->(_, _) { raise GitHubBub::RequestError }) do
fetcher = issue_fetcher(issues(:issue_one))
- assert_nil fetcher.as_json['title'], fetcher.as_json
+ assert_nil fetcher.as_json["title"], fetcher.as_json
end
end
end
diff --git a/test/unit/github_fetcher/issues_test.rb b/test/unit/github_fetcher/issues_test.rb
index 977f5e705..310e25282 100644
--- a/test/unit/github_fetcher/issues_test.rb
+++ b/test/unit/github_fetcher/issues_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::IssuesTest < ActiveSupport::TestCase
def fetcher(repo)
@@ -8,7 +8,7 @@ def fetcher(repo)
end
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json returns first page of open issues, sorted by comments desc (by default)" do
@@ -17,9 +17,9 @@ def fetcher(repo)
VCR.use_cassette "rails_rails_fetch_issues" do
as_json = fetcher.as_json
assert_equal as_json.size, 30, as_json
- assert_equal as_json.first['title'], "Missing helper file helpers//Users/xxxx/"\
+ assert_equal as_json.first["title"], "Missing helper file helpers//Users/xxxx/" \
"Sites/xxxx/app/helpers/application_helper.rb_helper.rb"
- assert_equal as_json.last['title'], "Provide a default Content Security Policy "\
+ assert_equal as_json.last["title"], "Provide a default Content Security Policy " \
"(CSP) that is lenient yet secure"
end
end
@@ -31,10 +31,10 @@ def fetcher(repo)
VCR.use_cassette "rails_rails_fetch_issues_page_two" do
as_json = fetcher.as_json
assert_equal 30, as_json.size, as_json
- assert_equal "Give clients a way to refer to ActionDispatch "\
- "middleware classes without triggering an early load of ActionDispatch", as_json.first['title']
- assert_equal "default_scope breaks chained having "\
- "statements in rails4", as_json.last['title']
+ assert_equal "Give clients a way to refer to ActionDispatch " \
+ "middleware classes without triggering an early load of ActionDispatch", as_json.first["title"]
+ assert_equal "default_scope breaks chained having " \
+ "statements in rails4", as_json.last["title"]
end
end
@@ -42,15 +42,15 @@ def fetcher(repo)
fetcher = fetcher(repos(:rails_rails))
VCR.use_cassette "rails_rails_fetch_issues" do
- assert_equal "Missing helper file helpers//Users/xxxx/"\
- "Sites/xxxx/app/helpers/application_helper.rb_helper.rb", fetcher.as_json.first['title']
+ assert_equal "Missing helper file helpers//Users/xxxx/" \
+ "Sites/xxxx/app/helpers/application_helper.rb_helper.rb", fetcher.as_json.first["title"]
end
fetcher.page = 2
VCR.use_cassette "rails_rails_fetch_issues_page_two" do
- assert_equal "Give clients a way to refer to ActionDispatch "\
- "middleware classes without triggering an early load of ActionDispatch", fetcher.as_json.first['title']
+ assert_equal "Give clients a way to refer to ActionDispatch " \
+ "middleware classes without triggering an early load of ActionDispatch", fetcher.as_json.first["title"]
end
end
@@ -85,7 +85,7 @@ def fetcher(repo)
test "bad credentials" do
stub_request(:any, %r{github.com})
- .to_return({ body: "Bad credentials", status: 401 })
+ .to_return({body: "Bad credentials", status: 401})
fetcher = GithubFetcher::Issues.new(
user_name: "schneems",
@@ -98,7 +98,7 @@ def fetcher(repo)
test "call will retry API calls" do
stub = stub_request(:any, %r{github.com})
- .to_return({ body: "Bad credentials", status: 401 })
+ .to_return({body: "Bad credentials", status: 401})
fetcher = GithubFetcher::Issues.new(
user_name: "schneems",
diff --git a/test/unit/github_fetcher/repo_test.rb b/test/unit/github_fetcher/repo_test.rb
index 28c8e5ac8..6ff18e071 100644
--- a/test/unit/github_fetcher/repo_test.rb
+++ b/test/unit/github_fetcher/repo_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::RepoTest < ActiveSupport::TestCase
def fetcher(repo)
@@ -8,7 +8,7 @@ def fetcher(repo)
end
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json returns json" do
@@ -16,7 +16,7 @@ def fetcher(repo)
expected_clone_url = "https://github.com/chrisccerami/scene-hub-v2.git"
VCR.use_cassette "create_repo_without_issues" do
- assert_equal fetcher.as_json['clone_url'], expected_clone_url, fetcher.as_json
+ assert_equal fetcher.as_json["clone_url"], expected_clone_url, fetcher.as_json
end
end
@@ -24,7 +24,7 @@ def fetcher(repo)
GitHubBub.stub(:get, ->(_, _) { raise GitHubBub::RequestError }) do
fetcher = fetcher(repos(:scene_hub_v2))
assert_equal fetcher.as_json, {}
- assert_nil fetcher.as_json['clone_url'], fetcher.as_json
+ assert_nil fetcher.as_json["clone_url"], fetcher.as_json
end
end
diff --git a/test/unit/github_fetcher/repos_test.rb b/test/unit/github_fetcher/repos_test.rb
index 3e1f15278..81add674e 100644
--- a/test/unit/github_fetcher/repos_test.rb
+++ b/test/unit/github_fetcher/repos_test.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::ReposTest < ActiveSupport::TestCase
def fetcher(kind, options = {})
GithubFetcher::Repos.new(
{
token: OmniAuth.config.mock_auth[:github][:credentials][:token],
- kind: kind,
+ kind: kind
}.merge(options)
)
end
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json returns json" do
@@ -22,15 +22,15 @@ def fetcher(kind, options = {})
expected_first_repo_name = "tscanlin/next-blog"
VCR.use_cassette "fetcher_starred_repos_for_user" do
- assert_equal fetcher.as_json.first['full_name'],
- expected_first_repo_name,
- fetcher.as_json.first
+ assert_equal fetcher.as_json.first["full_name"],
+ expected_first_repo_name,
+ fetcher.as_json.first
assert_equal fetcher.as_json.count, 30, fetcher.as_json.count
end
end
test "raises error when kind is invalid" do
- assert_raise(TypeError) { GithubFetcher::Repos.new('foo') }
+ assert_raise(TypeError) { GithubFetcher::Repos.new("foo") }
end
test "can set response size" do
@@ -44,10 +44,10 @@ def fetcher(kind, options = {})
test "can get owned repos" do
fetcher = fetcher(GithubFetcher::Repos::OWNED)
- expected_last_repo_name = 'writings'
+ expected_last_repo_name = "writings"
VCR.use_cassette "fetcher_owned_repos_for_user" do
- assert_equal fetcher.as_json.last['name'], expected_last_repo_name
+ assert_equal fetcher.as_json.last["name"], expected_last_repo_name
end
end
@@ -55,7 +55,7 @@ def fetcher(kind, options = {})
fetcher = fetcher(GithubFetcher::Repos::STARRED)
expected_first_repo_name = "tscanlin/next-blog"
VCR.use_cassette "fetcher_starred_repos_for_user" do
- assert_equal fetcher.as_json.first['full_name'], expected_first_repo_name
+ assert_equal fetcher.as_json.first["full_name"], expected_first_repo_name
end
end
@@ -63,13 +63,13 @@ def fetcher(kind, options = {})
fetcher = fetcher(GithubFetcher::Repos::SUBSCRIBED)
expected_first_repo_name = "thoughtbot/suspenders"
VCR.use_cassette "fetcher_subscribed_repos_for_user" do
- assert_equal fetcher.as_json.first['full_name'], expected_first_repo_name
+ assert_equal fetcher.as_json.first["full_name"], expected_first_repo_name
end
end
test "#as_json returns {} when error" do
GitHubBub.stub(:get, ->(_, _) { raise GitHubBub::RequestError }) do
- fetcher = fetcher('starred')
+ fetcher = fetcher("starred")
assert_equal fetcher.as_json, {}
end
end
diff --git a/test/unit/github_fetcher/resource_test.rb b/test/unit/github_fetcher/resource_test.rb
index e1ae1bd73..7cf32ece4 100644
--- a/test/unit/github_fetcher/resource_test.rb
+++ b/test/unit/github_fetcher/resource_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::ResourceTest < ActiveSupport::TestCase
def status_validation(mocked_status, method, expected_response)
@@ -9,11 +9,11 @@ def status_validation(mocked_status, method, expected_response)
assert_equal expected_response, resource.send(method)
end
- test '#not_found? is true on 404 status responses' do
+ test "#not_found? is true on 404 status responses" do
status_validation(404, :not_found?, true)
end
- test '#not_found? is false on non 404 status responses' do
+ test "#not_found? is false on non 404 status responses" do
[200, 201, 204, 400, 403, 500, 502].each { |status| status_validation(status, :not_found?, false) }
end
end
diff --git a/test/unit/github_fetcher/user_test.rb b/test/unit/github_fetcher/user_test.rb
index 014ed4587..53e537399 100644
--- a/test/unit/github_fetcher/user_test.rb
+++ b/test/unit/github_fetcher/user_test.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GithubFetcher::UserTest < ActiveSupport::TestCase
test "quacks like a GithubFetcher::Resource" do
- assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: 'asdf')
+ assert_kind_of GithubFetcher::Resource, GithubFetcher::User.new(token: "asdf")
end
test "#as_json returns user json" do
- expected_user_login = 'DavidRagone'
+ expected_user_login = "DavidRagone"
VCR.use_cassette "fetch_github_user" do
user_fetcher = GithubFetcher::User.new(
token: OmniAuth.config.mock_auth[:github][:credentials][:token]
)
- assert_equal user_fetcher.as_json['login'],
- expected_user_login,
- "Failed: Got #{user_fetcher.as_json}"
+ assert_equal user_fetcher.as_json["login"],
+ expected_user_login,
+ "Failed: Got #{user_fetcher.as_json}"
end
end
@@ -27,13 +27,13 @@ class GithubFetcher::UserTest < ActiveSupport::TestCase
)
assert_equal user_fetcher.as_json, {}
- assert_nil user_fetcher.as_json['title'], user_fetcher.as_json
+ assert_nil user_fetcher.as_json["title"], user_fetcher.as_json
end
end
test "#valid? returns true if user token is valid" do
VCR.use_cassette "fetch_github_user_valid_check" do
- user_fetcher = GithubFetcher::User.new(token: ENV['GITHUB_API_KEY'])
+ user_fetcher = GithubFetcher::User.new(token: ENV["GITHUB_API_KEY"])
assert user_fetcher.valid?
end
@@ -41,7 +41,7 @@ class GithubFetcher::UserTest < ActiveSupport::TestCase
test "#valid? returns false if user token is invalid" do
VCR.use_cassette "fetch_github_user_invalid_check" do
- user_fetcher = GithubFetcher::User.new(token: 'asdf')
+ user_fetcher = GithubFetcher::User.new(token: "asdf")
assert_not user_fetcher.valid?
end
@@ -49,7 +49,7 @@ class GithubFetcher::UserTest < ActiveSupport::TestCase
test "#valid? returns false when API error occurs" do
GitHubBub.stub(:valid_token?, ->(_) { raise GitHubBub::RequestError }) do
- user_fetcher = GithubFetcher::User.new(token: 'asdf')
+ user_fetcher = GithubFetcher::User.new(token: "asdf")
assert_not user_fetcher.valid?
end
diff --git a/test/unit/helpers/after_register_helper_test.rb b/test/unit/helpers/after_register_helper_test.rb
index e0a984558..125719a61 100644
--- a/test/unit/helpers/after_register_helper_test.rb
+++ b/test/unit/helpers/after_register_helper_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class AfterRegisterHelperTest < ActionView::TestCase
end
diff --git a/test/unit/issue_assignment_test.rb b/test/unit/issue_assignment_test.rb
index 3983d7ae5..3feb1a8aa 100644
--- a/test/unit/issue_assignment_test.rb
+++ b/test/unit/issue_assignment_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class IssueAssignmentTest < ActiveSupport::TestCase
test "validates presence of relevant ids" do
@@ -36,9 +36,13 @@ class IssueAssignmentTest < ActiveSupport::TestCase
subscriptions = user.repo_subscriptions.all
first_sub = subscriptions.first
second_sub = subscriptions.last
- def first_sub.email_limit; 1; end
+ def first_sub.email_limit
+ 1
+ end
- def second_sub.email_limit; 1; end
+ def second_sub.email_limit
+ 1
+ end
assigner = IssueAssigner.new(user, [first_sub, second_sub])
assigner.assign!
@@ -55,17 +59,19 @@ def second_sub.email_limit; 1; end
repo = Repo.where(full_name: "bemurphy/issue_triage_sandbox").first
sub = user.repo_subscriptions.where(repo_id: repo.id).first
- def sub.email_limit; 1; end
+ def sub.email_limit
+ 1
+ end
repo.issues.each do |issue|
stub_request(:get, %r{https://api.github.com/repos/bemurphy/issue_triage_sandbox/issues/#{issue.number}})
- .to_return({ body: issue.as_json.to_json, status: 200 })
+ .to_return({body: issue.as_json.to_json, status: 200})
stub_request(:get, %r{https://api.github.com/repos/bemurphy/issue_triage_sandbox/issues/#{issue.number}/comments})
.to_return({
- body: [{ "id" => 5, "user" => { "login" => "rtomayko", "id" => 404 } }].to_json,
- status: 200
- })
+ body: [{"id" => 5, "user" => {"login" => "rtomayko", "id" => 404}}].to_json,
+ status: 200
+ })
end
assigner = IssueAssigner.new(user, [sub], can_access_network: true)
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index fe7968389..208a37338 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class IssueTest < ActiveSupport::TestCase
test "issue counter cache" do
@@ -12,9 +12,9 @@ class IssueTest < ActiveSupport::TestCase
assert_difference("Repo.find(#{repo.id}).issues_count", 1) do
issue = repo.issues.new
issue.title = "Foo Bar"
- issue.url = "http://schneems.com"
+ issue.url = "http://schneems.com"
issue.last_touched_at = 2.days.ago
- issue.state = 'open'
+ issue.state = "open"
issue.html_url = "http://schneems.com"
issue.number = 42
issue.save
@@ -28,7 +28,7 @@ class IssueTest < ActiveSupport::TestCase
end
end
- test 'issue with extra long title' do
+ test "issue with extra long title" do
issue = issues(:issue_five_extra_long_title)
assert_equal true, issue.valid?
@@ -50,7 +50,7 @@ class IssueTest < ActiveSupport::TestCase
end
test "valid_for_user?" do
- user = users("mockstar")
+ user = users("mockstar")
issue = repos("rails_rails").issues.new
issue.stubs(:update_issue!).returns(true)
issue.stubs(:commenting_users).returns(["foo", "bar"])
@@ -70,7 +70,7 @@ class IssueTest < ActiveSupport::TestCase
end
test "valid_for_user? when has open issue and user skipped with PR" do
- user = users("mockstar")
+ user = users("mockstar")
issue = repos("rails_rails").issues.new
issue.stubs(:commenting_users).returns(["foo", "bar"])
@@ -80,7 +80,7 @@ class IssueTest < ActiveSupport::TestCase
end
test "valid_for_user? when has open issue and user has not skipped issues with PR" do
- user = users("mockstar")
+ user = users("mockstar")
issue = repos("rails_rails").issues.new
issue.stubs(:commenting_users).returns(["foo", "bar"])
issue.stubs(:update_issue!).returns(true)
@@ -90,7 +90,7 @@ class IssueTest < ActiveSupport::TestCase
assert issue.valid_for_user?(user, can_access_network: true), "issue is not valid for given user"
end
- test 'commenting users' do
+ test "commenting users" do
repo = repos("rails_rails")
issue = repo.issues.new
issue.repo_name = "rails"
@@ -98,14 +98,14 @@ class IssueTest < ActiveSupport::TestCase
issue.save
commenting_users = []
- VCR.use_cassette('commenting_users_issue') do
+ VCR.use_cassette("commenting_users_issue") do
commenting_users = issue.commenting_users
end
- assert_equal ['Trevoke', 'freegenie', 'pixeltrix', 'steveklabnik'], commenting_users
+ assert_equal ["Trevoke", "freegenie", "pixeltrix", "steveklabnik"], commenting_users
end
test "public_url" do
- repo = repos("rails_rails")
+ repo = repos("rails_rails")
issue = repo.issues.new(number: "8404")
assert_equal "https://github.com/repos/rails/rails/issues/8404", issue.public_url
end
@@ -113,11 +113,11 @@ class IssueTest < ActiveSupport::TestCase
test "open_issues" do
open_issues = []
repo = repos("rails_rails")
- repo.issues.new(state: 'closed')
+ repo.issues.new(state: "closed")
2.times do
number = Issue.maximum(:number) + 1
- open_issues << repo.issues.create!(state: 'open', number: number)
+ open_issues << repo.issues.create!(state: "open", number: number)
end
assert_equal open_issues, repo.open_issues.order(:created_at)
diff --git a/test/unit/mail_builder/grouped_issues_docs_test.rb b/test/unit/mail_builder/grouped_issues_docs_test.rb
index 014c04d81..4806bcf93 100644
--- a/test/unit/mail_builder/grouped_issues_docs_test.rb
+++ b/test/unit/mail_builder/grouped_issues_docs_test.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class GroupedIssuesDocsTest < ActiveSupport::TestCase
test "two issues different repos in random order" do
- assignment_one = issue_assignments(:schneems_triage_issue_assignment)
+ assignment_one = issue_assignments(:schneems_triage_issue_assignment)
expected_repo_one = assignment_one.repo
- user = assignment_one.repo_subscription.user
+ user = assignment_one.repo_subscription.user
- assignment_two = issue_assignments(:schneems_sinatra_issue_assignment)
+ assignment_two = issue_assignments(:schneems_sinatra_issue_assignment)
expected_repo_two = assignment_two.repo
assert_not_equal expected_repo_one, expected_repo_two
@@ -44,14 +44,14 @@ class GroupedIssuesDocsTest < ActiveSupport::TestCase
group = MailBuilder::GroupedIssuesDocs.new(user_id: user.id)
assert_equal false, group.any_docs?
assert_equal false, group.any_issues?
- assert_equal 0, group.count
+ assert_equal 0, group.count
group.each { raise "there should be nothing to iterate" }
end
test "only an assignment" do
- assignment = issue_assignments(:one)
+ assignment = issue_assignments(:one)
expected_repo = assignment.repo
- user = assignment.repo_subscription.user
+ user = assignment.repo_subscription.user
group = MailBuilder::GroupedIssuesDocs.new(
user_id: user.id,
@@ -59,36 +59,36 @@ class GroupedIssuesDocsTest < ActiveSupport::TestCase
)
assert_equal false, group.any_docs?
assert_equal true, group.any_issues?
- assert_equal 1, group.count
+ assert_equal 1, group.count
group.each do |g|
- assert_equal true, g.repo == expected_repo
+ assert_equal true, g.repo == expected_repo
assert_equal true, g.assignments == [assignment]
- assert_equal true, g.read_docs == []
- assert_equal true, g.write_docs == []
+ assert_equal true, g.read_docs == []
+ assert_equal true, g.write_docs == []
end
end
test "only a read doc" do
- subscription = repo_subscriptions(:read_doc_only)
+ subscription = repo_subscriptions(:read_doc_only)
expected_repo = subscription.repo
- user = subscription.user
- doc = doc_methods(:issue_triage_doc)
+ user = subscription.user
+ doc = doc_methods(:issue_triage_doc)
assert_equal expected_repo, repos(:issue_triage_sandbox)
group = MailBuilder::GroupedIssuesDocs.new(
user_id: user.id,
read_doc_ids: [doc.id]
)
- assert_equal true, group.any_docs?
+ assert_equal true, group.any_docs?
assert_equal false, group.any_issues?
- assert_equal 1, group.count
+ assert_equal 1, group.count
group.each do |g|
- assert_equal true, g.repo == expected_repo
+ assert_equal true, g.repo == expected_repo
assert_equal true, g.assignments == []
- assert_equal true, g.read_docs == [doc]
- assert_equal true, g.write_docs == []
+ assert_equal true, g.read_docs == [doc]
+ assert_equal true, g.write_docs == []
end
end
@@ -97,36 +97,36 @@ class GroupedIssuesDocsTest < ActiveSupport::TestCase
# write_doc_only
expected_repo = subscription.repo
- user = subscription.user
- doc = doc_methods(:issue_triage_doc)
+ user = subscription.user
+ doc = doc_methods(:issue_triage_doc)
assert_equal expected_repo, repos(:issue_triage_sandbox)
group = MailBuilder::GroupedIssuesDocs.new(
user_id: user.id,
write_doc_ids: [doc.id]
)
- assert_equal true, group.any_docs?
+ assert_equal true, group.any_docs?
assert_equal false, group.any_issues?
- assert_equal 1, group.count
+ assert_equal 1, group.count
group.each do |g|
assert_equal expected_repo, g.repo
- assert_equal [], g.assignments
- assert_equal [], g.read_docs
- assert_equal [doc], g.write_docs
+ assert_equal [], g.assignments
+ assert_equal [], g.read_docs
+ assert_equal [doc], g.write_docs
end
end
test "issue and a doc for same repo" do
- subscription = repo_subscriptions(:schneems_to_triage)
- assignment = issue_assignments(:one)
+ subscription = repo_subscriptions(:schneems_to_triage)
+ assignment = issue_assignments(:one)
assert_equal assignment.repo_subscription, subscription
# write_doc_only
expected_repo = subscription.repo
- user = subscription.user
- doc = doc_methods(:issue_triage_doc)
+ user = subscription.user
+ doc = doc_methods(:issue_triage_doc)
assert_equal expected_repo, repos(:issue_triage_sandbox)
group = MailBuilder::GroupedIssuesDocs.new(
@@ -136,13 +136,13 @@ class GroupedIssuesDocsTest < ActiveSupport::TestCase
)
assert_equal true, group.any_docs?
assert_equal true, group.any_issues?
- assert_equal 1, group.count
+ assert_equal 1, group.count
group.each do |g|
assert_equal expected_repo, g.repo
- assert_equal [assignment], g.assignments
- assert_equal [], g.read_docs
- assert_equal [doc], g.write_docs
+ assert_equal [assignment], g.assignments
+ assert_equal [], g.read_docs
+ assert_equal [doc], g.write_docs
end
end
end
diff --git a/test/unit/repo_labels_assigner_test.rb b/test/unit/repo_labels_assigner_test.rb
index fbda22d09..3d95a36d2 100644
--- a/test/unit/repo_labels_assigner_test.rb
+++ b/test/unit/repo_labels_assigner_test.rb
@@ -1,40 +1,40 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class RepoLabelsAssignerTest < ActiveSupport::TestCase
- test '#create_and_associate_labels! creates labels' do
+ test "#create_and_associate_labels! creates labels" do
repo = repos(:rails_rails)
- VCR.use_cassette('fetch_labels_for_repo', record: :once) do
+ VCR.use_cassette("fetch_labels_for_repo", record: :once) do
assigner = RepoLabelAssigner.new(repo: repo)
- assert_difference('Label.count', 30) do
+ assert_difference("Label.count", 30) do
assigner.create_and_associate_labels!
end
end
end
- test '#create_and_associate_labels! it does not create existing labels' do
+ test "#create_and_associate_labels! it does not create existing labels" do
repo = repos(:rails_rails)
Label.create!(name: :autoloading)
- VCR.use_cassette('fetch_labels_for_repo', record: :once) do
+ VCR.use_cassette("fetch_labels_for_repo", record: :once) do
assigner = RepoLabelAssigner.new(repo: repo)
assigner.create_and_associate_labels!
assert_equal Label.where(name: :autoloading).count, 1
end
end
- test '#create_and_associate_labels! it does not care about label case' do
+ test "#create_and_associate_labels! it does not care about label case" do
repo = repos(:rails_rails)
- VCR.use_cassette('fetch_labels_for_repo', record: :once) do
+ VCR.use_cassette("fetch_labels_for_repo", record: :once) do
assigner = RepoLabelAssigner.new(repo: repo)
assigner.create_and_associate_labels!
assert_equal Label.where(name: :ActionMailer).count, 0
end
end
- test '#create_and_associate_labels! associates labels with the repo' do
+ test "#create_and_associate_labels! associates labels with the repo" do
repo = repos(:rails_rails)
- VCR.use_cassette('fetch_labels_for_repo', record: :once) do
+ VCR.use_cassette("fetch_labels_for_repo", record: :once) do
assigner = RepoLabelAssigner.new(repo: repo)
assigner.create_and_associate_labels!
end
diff --git a/test/unit/repo_subscriptions_test.rb b/test/unit/repo_subscriptions_test.rb
index c35c9c91c..0dbec6270 100644
--- a/test/unit/repo_subscriptions_test.rb
+++ b/test/unit/repo_subscriptions_test.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
## quick and dirty tests, need to move logic to Factory or fixture
-require 'test_helper'
+require "test_helper"
class RepoSubscriptionsTest < ActiveSupport::TestCase
test "the get_issue_for_triage for new user" do
- user = users(:mockstar)
- repo = repos(:rails_rails)
- repo_sub = user.repo_subscriptions.new
+ user = users(:mockstar)
+ repo = repos(:rails_rails)
+ repo_sub = user.repo_subscriptions.new
repo_sub.repo = repo
repo_sub.save
- issue = repo.issues.new
- issue.title = "Foo Bar"
- issue.url = "http://schneems.com"
+ issue = repo.issues.new
+ issue.title = "Foo Bar"
+ issue.url = "http://schneems.com"
issue.last_touched_at = 2.days.ago
- issue.state = 'open'
- issue.html_url = "http://schneems.com"
- issue.number = 1
+ issue.state = "open"
+ issue.html_url = "http://schneems.com"
+ issue.number = 1
issue.save
Issue.any_instance.stubs(:valid_for_user?).returns(true)
@@ -26,28 +26,28 @@ class RepoSubscriptionsTest < ActiveSupport::TestCase
end
test "the get_issue_for_triage for user with existing issue assignments" do
- user = users(:empty)
- repo = repos(:rails_rails)
- repo_sub = user.repo_subscriptions.new
+ user = users(:empty)
+ repo = repos(:rails_rails)
+ repo_sub = user.repo_subscriptions.new
repo_sub.repo = repo
repo_sub.save
- issue = repo.issues.new
- issue.title = "Foo Bar"
- issue.url = "http://schneems.com"
+ issue = repo.issues.new
+ issue.title = "Foo Bar"
+ issue.url = "http://schneems.com"
issue.last_touched_at = 2.days.ago
- issue.state = 'open'
- issue.html_url = "http://schneems.com"
- issue.number = (repo.issues.last.try(:number) || 0) + 1
+ issue.state = "open"
+ issue.html_url = "http://schneems.com"
+ issue.number = (repo.issues.last.try(:number) || 0) + 1
issue.save
- assigned_issue = repo.issues.new
- assigned_issue.title = "Foo Bar"
- assigned_issue.url = "http://schneems.com"
+ assigned_issue = repo.issues.new
+ assigned_issue.title = "Foo Bar"
+ assigned_issue.url = "http://schneems.com"
assigned_issue.last_touched_at = 2.days.ago
- assigned_issue.state = 'open'
- assigned_issue.html_url = "http://schneems.com"
- assigned_issue.number = (repo.issues.last.try(:number) || 1) + 1
+ assigned_issue.state = "open"
+ assigned_issue.html_url = "http://schneems.com"
+ assigned_issue.number = (repo.issues.last.try(:number) || 1) + 1
assigned_issue.save
repo_sub.issue_assignments.create(issue: assigned_issue)
@@ -57,23 +57,23 @@ class RepoSubscriptionsTest < ActiveSupport::TestCase
assert_equal 2, user.issues.count
end
- test 'the assign_issue creates an assignment for the user' do
- user = users(:mockstar)
- repo = repos(:rails_rails)
- repo_sub = user.repo_subscriptions.new
+ test "the assign_issue creates an assignment for the user" do
+ user = users(:mockstar)
+ repo = repos(:rails_rails)
+ repo_sub = user.repo_subscriptions.new
repo_sub.repo = repo
repo_sub.save
- issue = repo.issues.new
- issue.title = "Foo Bar"
- issue.url = "http://schneems.com"
+ issue = repo.issues.new
+ issue.title = "Foo Bar"
+ issue.url = "http://schneems.com"
issue.last_touched_at = 2.days.ago
- issue.state = 'open'
- issue.html_url = "http://schneems.com"
- issue.number = 1
+ issue.state = "open"
+ issue.html_url = "http://schneems.com"
+ issue.number = 1
issue.save
- VCR.use_cassette('open_issue') do
+ VCR.use_cassette("open_issue") do
Issue.any_instance.stubs(:valid_for_user?).returns(true)
IssueAssigner.new(user, [repo_sub]).assign!
assert_equal 1, user.issue_assignments.count
@@ -81,36 +81,36 @@ class RepoSubscriptionsTest < ActiveSupport::TestCase
end
test "email_limit allows multiple issues per repo" do
- user = users(:mockstar)
- repo = repos(:rails_rails)
+ user = users(:mockstar)
+ repo = repos(:rails_rails)
repo.issues.create(title: "Foo Bar",
- url: "http://schneems.com",
- last_touched_at: 2.days.ago,
- state: 'open',
- html_url: "http://schneems.com",
- number: 9000)
+ url: "http://schneems.com",
+ last_touched_at: 2.days.ago,
+ state: "open",
+ html_url: "http://schneems.com",
+ number: 9000)
repo.issues.create(title: "Bar Bar",
- url: "http://schneems.com",
- last_touched_at: 2.days.ago,
- state: 'open',
- html_url: "http://schneems.com",
- number: 9001)
+ url: "http://schneems.com",
+ last_touched_at: 2.days.ago,
+ state: "open",
+ html_url: "http://schneems.com",
+ number: 9001)
sub = user.repo_subscriptions.create(repo: repo,
- email_limit: 2)
+ email_limit: 2)
IssueAssigner.new(user, user.repo_subscriptions).assign!
assert_equal 2, sub.issue_assignments.count
end
test ".subscriptions_for a repo" do
- user = users(:mockstar)
- repo = repos(:rails_rails)
+ user = users(:mockstar)
+ repo = repos(:rails_rails)
repo2 = repos(:rails_rails)
repo.issues.create(title: "Foo Bar",
- url: "http://schneems.com",
- last_touched_at: 2.days.ago,
- state: 'open',
- html_url: "http://schneems.com",
- number: 9000)
+ url: "http://schneems.com",
+ last_touched_at: 2.days.ago,
+ state: "open",
+ html_url: "http://schneems.com",
+ number: 9000)
sub1 = user.repo_subscriptions.create(repo: repo, email_limit: 2)
user.repo_subscriptions.create(repo: repo2, email_limit: 2)
diff --git a/test/unit/repo_test.rb b/test/unit/repo_test.rb
index 8eb9b7fb7..db34e3605 100644
--- a/test/unit/repo_test.rb
+++ b/test/unit/repo_test.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class RepoTest < ActiveSupport::TestCase
test "normalizing names to lowercase" do
VCR.use_cassette "create_repo_refinery", record: :once do
- repo = Repo.create user_name: 'Refinery', name: 'Refinerycms'
+ repo = Repo.create user_name: "Refinery", name: "Refinerycms"
assert_equal "refinery", repo.user_name
assert_equal "refinerycms", repo.name
end
@@ -13,10 +13,10 @@ class RepoTest < ActiveSupport::TestCase
test "uniqueness of repo with case insensitivity" do
VCR.use_cassette "create_repo_refinery", record: :once do
- Repo.create user_name: 'refinery', name: 'refinerycms'
+ Repo.create user_name: "refinery", name: "refinerycms"
VCR.use_cassette "create_duplicate_repo_refinery", record: :once do
assert_raises(ActiveRecord::RecordNotUnique) {
- Repo.create user_name: 'Refinery', name: 'Refinerycms'
+ Repo.create user_name: "Refinery", name: "Refinerycms"
}
end
end
@@ -24,7 +24,7 @@ class RepoTest < ActiveSupport::TestCase
test "update repo info from github" do
VCR.use_cassette "repo_info" do
- repo = Repo.new user_name: 'refinery', name: 'refinerycms'
+ repo = Repo.new user_name: "refinery", name: "refinerycms"
repo.update_from_github
assert_equal "Ruby", repo.language
assert_match "CMS", repo.description
@@ -32,17 +32,17 @@ class RepoTest < ActiveSupport::TestCase
end
test "github url validation attempts to use issue_fetcher" do
- repo = Repo.new user_name: 'codetriage', name: 'codetriage'
- repo.stub(:issues_fetcher, -> { OpenStruct.new(error?: true, api_path: '123') }) do
+ repo = Repo.new user_name: "codetriage", name: "codetriage"
+ repo.stub(:issues_fetcher, -> { OpenStruct.new(error?: true, api_path: "123") }) do
repo.send(:github_url_exists)
assert_equal "cannot reach api.github.com/123 perhaps github is down, or you mistyped something?",
- repo.errors.messages[:expiration_date].first
+ repo.errors.messages[:expiration_date].first
end
end
test "counts number of subscribers" do
VCR.use_cassette "create_repo_refinery", record: :once do
- repo = Repo.create user_name: 'Refinery', name: 'Refinerycms'
+ repo = Repo.create user_name: "Refinery", name: "Refinerycms"
repo.users << users(:jroes)
repo.users << users(:schneems)
repo.subscribers_count == 2
@@ -51,7 +51,7 @@ class RepoTest < ActiveSupport::TestCase
test "#all_languages does not contain empty string" do
VCR.use_cassette "create_repo_refinery", record: :once do
- Repo.create user_name: 'Refinery', name: "RefineryCMS", language: ""
+ Repo.create user_name: "Refinery", name: "RefineryCMS", language: ""
assert_not Repo.all_languages.include? ""
end
end
@@ -79,14 +79,14 @@ class RepoTest < ActiveSupport::TestCase
end
test "issues_fetcher.api_path (private method) returns issues path with Github api" do
- repo = Repo.new(name: 'codetriage', user_name: 'codetriage')
+ repo = Repo.new(name: "codetriage", user_name: "codetriage")
assert_equal "repos/codetriage/codetriage/issues", repo.issues_fetcher.send(:api_path)
end
test "search_by returns repo by name and user_name" do
VCR.use_cassette "create_repo_refinery", record: :once do
- repo = Repo.create user_name: 'Refinery', name: 'Refinerycms'
- assert_equal [repo], Repo.search_by('refinerycms', 'refinery')
+ repo = Repo.create user_name: "Refinery", name: "Refinerycms"
+ assert_equal [repo], Repo.search_by("refinerycms", "refinery")
end
end
@@ -104,7 +104,7 @@ class RepoTest < ActiveSupport::TestCase
end
end
- test '.without_user_subscriptions' do
+ test ".without_user_subscriptions" do
user = users(:schneems)
subscribed_repo = user.repo_subscriptions.first
unsubscribed_repo = repos(:no_subscribers)
diff --git a/test/unit/sorted_repo_collection_test.rb b/test/unit/sorted_repo_collection_test.rb
index 81b89d2b2..4120cb3d8 100644
--- a/test/unit/sorted_repo_collection_test.rb
+++ b/test/unit/sorted_repo_collection_test.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'test_helper'
-require_relative '../../lib/sorted_repo_collection'
+require "test_helper"
+require_relative "../../lib/sorted_repo_collection"
class SortedRepoCollectionTest < ActiveSupport::TestCase
test "yields repos sorted by full_name, case-insensitive" do
collection = SortedRepoCollection.new([
- { "full_name" => "alice/coolness" },
- { "full_name" => "Bob/bravado" },
- { "full_name" => "Bob/awesomeness" },
- { "full_name" => "alice/bravado" },
- { "full_name" => "charlie/bravado" }
- ])
+ {"full_name" => "alice/coolness"},
+ {"full_name" => "Bob/bravado"},
+ {"full_name" => "Bob/awesomeness"},
+ {"full_name" => "alice/bravado"},
+ {"full_name" => "charlie/bravado"}
+ ])
- full_names_in_sort_order = Array.new
+ full_names_in_sort_order = []
collection.each do |repo|
full_names_in_sort_order << repo.fetch("full_name")
end
@@ -28,14 +28,14 @@ class SortedRepoCollectionTest < ActiveSupport::TestCase
assert_equal expected_order, full_names_in_sort_order
end
- test 'yields the correct length' do
+ test "yields the correct length" do
collection = SortedRepoCollection.new([
- { "full_name" => "alice/coolness" },
- { "full_name" => "Bob/bravado" },
- { "full_name" => "Bob/awesomeness" },
- { "full_name" => "alice/bravado" },
- { "full_name" => "charlie/bravado" }
- ])
+ {"full_name" => "alice/coolness"},
+ {"full_name" => "Bob/bravado"},
+ {"full_name" => "Bob/awesomeness"},
+ {"full_name" => "alice/bravado"},
+ {"full_name" => "charlie/bravado"}
+ ])
assert_equal collection.size, 5
end
end
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 7b8fa06a7..02c90ca09 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
class UserTest < ActiveSupport::TestCase
- test 'streak tests' do
+ test "streak tests" do
# New user, first email
user = User.new(github: "whatever1")
assert_equal 0, user.effective_streak_count
@@ -50,7 +50,7 @@ class UserTest < ActiveSupport::TestCase
assert_equal 10, user.effective_streak_count
end
- test 'negative count' do
+ test "negative count" do
user = User.new(github: "negativeRawEmailcount")
user.raw_streak_count = 1
user.raw_emails_since_click = 74
@@ -58,14 +58,14 @@ class UserTest < ActiveSupport::TestCase
assert_equal 0, user.effective_streak_count
end
- test '#github_url returns github url' do
- github_url = User.new(github: 'jroes').github_url
- assert_equal 'https://github.com/jroes', github_url
+ test "#github_url returns github url" do
+ github_url = User.new(github: "jroes").github_url
+ assert_equal "https://github.com/jroes", github_url
end
- test 'public scope should only return public users' do
- user = users(:mockstar)
- private_user = users(:jroes)
+ test "public scope should only return public users" do
+ user = users(:mockstar)
+ private_user = users(:jroes)
# Sanity check for fixture state
assert_not user.private
@@ -77,7 +77,7 @@ class UserTest < ActiveSupport::TestCase
assert_includes result, user
end
- test 'able_to_edit_repo allows the correct rights' do
+ test "able_to_edit_repo allows the correct rights" do
u = User.new(github: "bob")
r = Repo.new(user_name: "bob")
assert u.able_to_edit_repo?(r)
@@ -86,12 +86,12 @@ class UserTest < ActiveSupport::TestCase
assert_not u.able_to_edit_repo?(r2)
end
- test 'valid_email? is true when valid' do
- assert User.new(email: 'richard.schneeman@gmail.com').valid_email?
+ test "valid_email? is true when valid" do
+ assert User.new(email: "richard.schneeman@gmail.com").valid_email?
end
- test 'valid_email? is false when bad' do
- assert_not User.new(email: 'a really bad e-mail address').valid_email?
+ test "valid_email? is false when bad" do
+ assert_not User.new(email: "a really bad e-mail address").valid_email?
end
test "user favorite_language?" do
@@ -137,19 +137,19 @@ class UserTest < ActiveSupport::TestCase
test "#own_repos_json" do
VCR.use_cassette "fetcher_owned_repos_for_user_first_100" do
- assert_equal users(:mockstar).own_repos_json.last['name'], 'writings'
+ assert_equal users(:mockstar).own_repos_json.last["name"], "writings"
end
end
test "#starred_repos_json" do
VCR.use_cassette "fetcher_starred_repos_for_user" do
- assert_equal users(:mockstar).starred_repos_json.first['full_name'], 'tscanlin/next-blog'
+ assert_equal users(:mockstar).starred_repos_json.first["full_name"], "tscanlin/next-blog"
end
end
test "#subscribed_repos_json" do
VCR.use_cassette "fetcher_subscribed_repos_for_user" do
- assert_equal users(:mockstar).subscribed_repos_json.first['full_name'], 'thoughtbot/suspenders'
+ assert_equal users(:mockstar).subscribed_repos_json.first["full_name"], "thoughtbot/suspenders"
end
end