diff --git a/.github/test-timings.json b/.github/test-timings.json
index 443c543eba..9aab4afda7 100644
--- a/.github/test-timings.json
+++ b/.github/test-timings.json
@@ -235,7 +235,6 @@
"test/commands/solution/publish_test.rb": 52.02,
"test/commands/solution/queue_head_test_run_test.rb": 1.7,
"test/commands/solution/remove_user_solutions_for_track_from_search_index_test.rb": 2.37,
- "test/commands/solution/search_community_solutions_test.rb": 13.84,
"test/commands/solution/search_favorites_test.rb": 0.51,
"test/commands/solution/search_user_solutions_test.rb": 14.28,
"test/commands/solution/search_via_representations_test.rb": 39.94,
@@ -254,13 +253,11 @@
"test/commands/solution/update_published_iteration_head_tests_status_test.rb": 0.22,
"test/commands/solution/update_snippet_test.rb": 0.69,
"test/commands/solution/update_to_latest_exercise_version_test.rb": 0.66,
- "test/commands/submission/analysis/cancel_test.rb": 0.0,
"test/commands/submission/analysis/init_test.rb": 0.25,
"test/commands/submission/analysis/process_test.rb": 0.57,
"test/commands/submission/create_test.rb": 2.4,
"test/commands/submission/link_to_matching_approach_test.rb": 0.47,
"test/commands/submission/prepare_http_files_test.rb": 0.01,
- "test/commands/submission/representation/cancel_test.rb": 0.0,
"test/commands/submission/representation/create_test.rb": 0.96,
"test/commands/submission/representation/generate_basic_test.rb": 1.85,
"test/commands/submission/representation/init_test.rb": 0.3,
@@ -564,7 +561,6 @@
"test/jobs/process_iteration_for_discussions_job_test.rb": 0.26,
"test/jobs/process_pull_request_update_job_test.rb": 0.27,
"test/jobs/recheck_insiders_job_test.rb": 0.12,
- "test/jobs/send_user_mailshot_job_test.rb": 0.08,
"test/jobs/sweep_metrics_job_test.rb": 0.0,
"test/jobs/sweep_reputation_periods_job_test.rb": 0.0,
"test/jobs/update_automator_roles_job_test.rb": 0.07,
@@ -573,7 +569,6 @@
"test/jobs/update_website_copy_job_test.rb": 0.0,
"test/lib/aws_clients_test.rb": 0.0,
"test/lib/graph_utils_test.rb": 0.01,
- "test/lib/http_authentication_token_test.rb": 0.0,
"test/mailers/application_mailer_test.rb": 0.16,
"test/mailers/donations_mailer_test.rb": 0.06,
"test/mailers/mailer_rescues_test.rb": 0.22,
@@ -679,7 +674,6 @@
"test/models/github/pull_request_test.rb": 0.01,
"test/models/github/task_test.rb": 0.06,
"test/models/github/team_member_test.rb": 0.08,
- "test/models/github/team_test.rb": 0.03,
"test/models/iteration_test.rb": 2.16,
"test/models/mailshot_test.rb": 0.01,
"test/models/mentor/discussion_post_test.rb": 1.15,
@@ -794,7 +788,6 @@
"test/models/user_track/viewed_community_solution_test.rb": 0.06,
"test/models/user_track/viewed_exercise_approach_test.rb": 0.05,
"test/models/user_track_test.rb": 5.25,
- "test/serializers/serialize_authors_or_contributors_test.rb": 2.89,
"test/serializers/serialize_community_solution_test.rb": 0.22,
"test/serializers/serialize_community_solutions_test.rb": 3.82,
"test/serializers/serialize_contributor_test.rb": 0.15,
@@ -819,7 +812,6 @@
"test/serializers/serialize_mentor_discussion_post_test.rb": 0.31,
"test/serializers/serialize_mentor_discussion_test.rb": 0.28,
"test/serializers/serialize_mentor_discussions_for_mentor_test.rb": 0.26,
- "test/serializers/serialize_mentor_discussions_for_student_test.rb": 3.4,
"test/serializers/serialize_mentor_requests_test.rb": 2.72,
"test/serializers/serialize_mentor_session_exercise_test.rb": 0.02,
"test/serializers/serialize_mentor_session_request_test.rb": 0.17,
@@ -838,7 +830,6 @@
"test/serializers/serialize_student_test.rb": 0.55,
"test/serializers/serialize_submission_test.rb": 0.05,
"test/serializers/serialize_submission_test_run_test.rb": 0.96,
- "test/serializers/serialize_submissions_test.rb": 0.05,
"test/serializers/serialize_task_test.rb": 0.02,
"test/serializers/serialize_tasks_test.rb": 0.07,
"test/serializers/serialize_track_for_select_test.rb": 0.01,
diff --git a/app/commands/solution/search_community_solutions.rb b/app/commands/solution/search_community_solutions.rb
deleted file mode 100644
index 4580c7fbac..0000000000
--- a/app/commands/solution/search_community_solutions.rb
+++ /dev/null
@@ -1,167 +0,0 @@
-class Solution::SearchCommunitySolutions
- include Mandate
-
- DEFAULT_PAGE = 1
- DEFAULT_PER = 24
- MAX_ROWS = 10_000
-
- def self.default_per
- DEFAULT_PER
- end
-
- def initialize(exercise, page: nil, per: nil, order: nil,
- criteria: nil, tests_status: nil, head_tests_status: nil, sync_status: nil)
- @exercise = exercise
- @page = page.present? && page.to_i.positive? ? page.to_i : DEFAULT_PAGE
- @per = per.present? && per.to_i.positive? ? per.to_i : self.class.default_per
- @order = order&.to_sym
- @criteria = criteria
- @tests_status = tests_status
- @head_tests_status = head_tests_status
- @sync_status = sync_status&.to_sym
- end
-
- def call
- # ES can only handle paginating up to 10_000 rows.
- # If it's above that, return nothing
- return Kaminari.paginate_array([], total_count: MAX_ROWS).page(page).per(per) if from + per > MAX_ROWS
-
- results = Exercism.opensearch_client.search(
- index: Solution::OPENSEARCH_INDEX,
- body: search_body,
- timeout: TIMEOUT,
- allow_partial_search_results: false
- )
-
- solution_ids = results["hits"]["hits"].map { |hit| hit["_source"]["id"] }
- solutions = solution_ids.present? ?
- Solution.where(id: solution_ids).sort_by { |s| solution_ids.index(s.id) } :
- []
-
- total_count = [results["hits"]["total"]["value"].to_i, MAX_ROWS].min
-
- Kaminari.paginate_array(solutions, total_count:).
- page(page).per(per)
- rescue StandardError => e
- Sentry.capture_exception(e)
- Fallback.(exercise, page, per, order, criteria, tests_status, head_tests_status, sync_status)
- end
-
- private
- attr_reader :exercise, :per, :page, :order, :solutions, :criteria, :tests_status,
- :head_tests_status, :sync_status
-
- def search_body
- {
- query: search_query,
- sort: search_sort,
-
- # Only return the solution IDs, not the entire document, to improve performance
- _source: [:id],
-
- # Paging information
- from:,
- size: per
- }
- end
-
- memoize
- def from
- (page - 1) * per
- end
-
- def search_query
- {
- bool: {
- must: [
- { term: { 'exercise.id': exercise.id } },
- { term: { 'status.keyword': 'published' } },
- @sync_status.nil? ? nil : { term: { 'out_of_date': @sync_status == :out_of_date } },
- @tests_status.blank? ? nil : { terms: { 'published_iteration.tests_status.keyword': to_terms(@tests_status) } },
- @head_tests_status.blank? ? nil : { terms: { 'published_iteration.head_tests_status.keyword': to_terms(@head_tests_status) } }, # rubocop:disable Layout/LineLength
- @criteria.blank? ? nil : {
- query_string: {
- query: criteria.split(' ').map { |c| "*#{c}*" }.join(' AND '),
- fields: ['user.handle']
- }
- }
- ].compact
- }
- }
- end
-
- def search_sort
- case order
- when :newest
- [{ published_at: { order: :desc, unmapped_type: "date" } }]
- else # :most_starred
- [{ num_stars: { order: :desc, unmapped_type: "integer" } }]
- end
- end
-
- def to_terms(value)
- return value.split if value.is_a?(String)
-
- [value].flatten
- end
-
- TIMEOUT = '400ms'.freeze
- private_constant :TIMEOUT
-
- class Fallback
- include Mandate
-
- initialize_with :exercise, :page, :per, :order, :criteria, :tests_status, :head_tests_status, :sync_status
-
- def call
- @solutions = exercise.solutions.published
-
- filter_criteria!
- filter_tests_status!
- filter_head_tests_status!
- filter_sync_status!
- sort!
-
- @solutions.page(page).per(per)
- end
-
- private
- attr_reader :solutions
-
- def filter_criteria!
- return if @criteria.blank?
-
- @solutions = @solutions.joins(:user).where("users.handle LIKE ?", "%#{criteria}%")
- end
-
- def filter_tests_status!
- return if tests_status.blank?
-
- @solutions = @solutions.joins(published_iteration: :submission).where('submissions.tests_status': tests_status)
- end
-
- def filter_head_tests_status!
- return if head_tests_status.blank?
-
- @solutions = @solutions.where(published_iteration_head_tests_status: head_tests_status)
- end
-
- def filter_sync_status!
- case sync_status
- when :up_to_date
- @solutions = @solutions.where(git_important_files_hash: exercise.git_important_files_hash)
- when :out_of_date
- @solutions = @solutions.where.not(git_important_files_hash: exercise.git_important_files_hash)
- end
- end
-
- def sort!
- case order
- when :newest
- @solutions = @solutions.order(published_at: :desc)
- else # :most_starred
- @solutions = @solutions.order(num_stars: :desc)
- end
- end
- end
-end
diff --git a/app/commands/submission/analysis/cancel.rb b/app/commands/submission/analysis/cancel.rb
deleted file mode 100644
index bb862c32ed..0000000000
--- a/app/commands/submission/analysis/cancel.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-class Submission::Analysis::Cancel
- include Mandate
-
- initialize_with :submission_uuid
-
- def call
- RestClient.post "#{orchestrator_url}/submissions/cancel", {
- submission_uuid:
- }
- end
-
- private
- def orchestrator_url
- Exercism.config.tooling_orchestrator_url
- end
-end
diff --git a/app/commands/submission/representation/cancel.rb b/app/commands/submission/representation/cancel.rb
deleted file mode 100644
index 2bed47dd67..0000000000
--- a/app/commands/submission/representation/cancel.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-class Submission::Representation::Cancel
- include Mandate
-
- initialize_with :submission_uuid
-
- def call
- RestClient.post "#{orchestrator_url}/submissions/cancel", {
- submission_uuid:
- }
- end
-
- private
- def orchestrator_url
- Exercism.config.tooling_orchestrator_url
- end
-end
diff --git a/app/commands/user/mailshot/send.rb b/app/commands/user/mailshot/send.rb
index 0f4c7d3e1d..5096015766 100644
--- a/app/commands/user/mailshot/send.rb
+++ b/app/commands/user/mailshot/send.rb
@@ -1,9 +1,3 @@
-# Send with:
-# users = User.where('reputation > 2').count
-# users = User.where('reputation > 2').count
-# users.each do |user|
-# User::Mailshot::Send.(user, :functional_february)
-# end
class User::Mailshot::Send
include Mandate
diff --git a/app/helpers/email_helper.rb b/app/helpers/email_helper.rb
deleted file mode 100644
index c9d20b9161..0000000000
--- a/app/helpers/email_helper.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module EmailHelper
- def email_button_to(text, href)
- raw <<-BUTTON
-
- BUTTON
- end
-end
diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb
index 1c48297912..d238abff1d 100644
--- a/app/helpers/layout_helper.rb
+++ b/app/helpers/layout_helper.rb
@@ -7,11 +7,6 @@ def js_packs
].compact
end
- # Always include application in the JS pack
- def css_packs
- (js_packs + ['application']).uniq
- end
-
def render_test_js_pack?
namespace_name == "test"
end
diff --git a/app/helpers/view_components/concept.rb b/app/helpers/view_components/concept.rb
deleted file mode 100644
index 76a8280dbf..0000000000
--- a/app/helpers/view_components/concept.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module ViewComponents
- class Concept < ViewComponent
- extend Mandate::Memoize
- SIZES = %i[small medium].freeze
-
- def initialize(concept, user_track, size)
- raise "Invalid concept size #{size}" unless SIZES.include?(size.to_sym)
-
- super()
-
- @concept = concept
- @user_track = user_track
- @size = size
- end
-
- def to_s
- classes = "c-concept c--#{size}"
- link_to(Exercism::Routes.track_concept_path(user_track.track, concept), class: classes) do
- tag.div(class: 'info') do
- safe_join(
- [
- ViewComponents::ConceptIcon.new(concept, :small, view_context:).to_s,
- concept.name
- ]
- )
- end +
- ViewComponents::ConceptProgressBar.new(concept, user_track, view_context:).to_s
- end
- end
-
- private
- attr_reader :concept, :user_track, :size
- end
-end
diff --git a/app/helpers/view_components/concept_progress_bar.rb b/app/helpers/view_components/concept_progress_bar.rb
deleted file mode 100644
index d744bee557..0000000000
--- a/app/helpers/view_components/concept_progress_bar.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-module ViewComponents
- class ConceptProgressBar < ViewComponent
- extend Mandate::Memoize
- def initialize(concept, user_track, view_context: nil)
- super()
-
- @concept = concept
- @user_track = user_track
- @view_context = view_context
- end
-
- def to_s
- classes = ["c-concept-progress-bar"]
- classes << "--completed" if user_track.concept_mastered?(concept)
-
- tag.progress(
- class: classes.join(" "),
- value: user_track.num_completed_exercises_for_concept(concept),
- max: user_track.num_exercises_for_concept(concept)
- )
- end
-
- private
- attr_reader :concept, :user_track, :size
- end
-end
diff --git a/app/helpers/view_components/donate_with_crypto.rb b/app/helpers/view_components/donate_with_crypto.rb
deleted file mode 100644
index 3803b111e4..0000000000
--- a/app/helpers/view_components/donate_with_crypto.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-module ViewComponents
- class DonateWithCrypto < ViewComponent
- extend Mandate::Memoize
-
- def to_s
- tag.div do
- button + js
- end
- end
-
- def button
- custom_data = current_user ? "user-#{current_user.id}" : nil
- url = "https://commerce.coinbase.com/checkout/ceb7bf37-2622-4615-a1db-69de8adfe648"
- link_to url, data: { custom: custom_data, styled: false }, class: "donate-with-crypto btn-m !flex !py-8 !px-16" do
- graphical_icon("coinbase", category: :graphics, css_class: "!filter-none") +
- tag.span(I18n.t("components.donate_with_crypto.label"), class: "!text-[16px] !font-body")
- end
- end
-
- def js
- javascript_include_tag "https://commerce.coinbase.com/v1/checkout.js?version=201807"
- end
- end
-end
diff --git a/app/helpers/view_components/nav_helpers/nav_submenus.rb b/app/helpers/view_components/nav_helpers/nav_submenus.rb
index 7f060b1fd5..9a5406fdd0 100644
--- a/app/helpers/view_components/nav_helpers/nav_submenus.rb
+++ b/app/helpers/view_components/nav_helpers/nav_submenus.rb
@@ -171,23 +171,6 @@ module NavSubmenus
}
].freeze
-
- def nav_dropdown_tracks_view
- tag.div class: 'nav-dropdown-view-content' do
- end
- end
-
- def nav_dropdown_mentoring_view
- tag.div class: 'nav-dropdown-view-content' do
- I18n.t("components.nav_submenus.views.mentoring_details")
- end
- end
-
- def nav_dropdown_challenge_48in24_view
- tag.div class: 'nav-dropdown-view-content' do
- render(template: "layouts/nav/48in24")
- end
- end
end
end
end
diff --git a/app/helpers/view_components/tab.rb b/app/helpers/view_components/tab.rb
deleted file mode 100644
index fb2c03d30f..0000000000
--- a/app/helpers/view_components/tab.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module ViewComponents
- class Tab < ViewComponent
- extend Mandate::Memoize
-
- initialize_with :text, :icon, :href, :selected
-
- def to_s
- link_to href, class: "c-tab #{'selected' if selected}" do
- graphical_icon(icon) +
- tag.span(text, data: { text: })
- end
- end
- end
-end
diff --git a/app/helpers/view_components/user_activity.rb b/app/helpers/view_components/user_activity.rb
deleted file mode 100644
index b9fd4ccdb0..0000000000
--- a/app/helpers/view_components/user_activity.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module ViewComponents
- class UserActivity < ViewComponent
- initialize_with :activity
-
- def to_s
- template = activity.class.name.split("::").last.underscore.gsub(/_activity$/, "")
- ApplicationController.render "components/user_activities/#{template}",
- locals: {
- activity: activity.rendering_data
- },
- layout: false
- end
- end
-end
diff --git a/app/jobs/send_user_mailshot_job.rb b/app/jobs/send_user_mailshot_job.rb
deleted file mode 100644
index d916fa4d09..0000000000
--- a/app/jobs/send_user_mailshot_job.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class SendUserMailshotJob < ApplicationJob
- queue_as :dribble
-
- def perform(user, mailshot_id)
- User::Mailshot::Send.(user, mailshot_id)
- end
-end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 49b7cfa5d5..2139f34707 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -3,7 +3,6 @@ class ApplicationMailer < ActionMailer::Base
default reply_to: "jeremy@exercism.org"
layout "mailer"
- helper :email
rescue_from(Mail::Field::IncompleteParseError) {}
rescue_from(Net::SMTPSyntaxError) {}
diff --git a/app/models/github/team.rb b/app/models/github/team.rb
deleted file mode 100644
index 3df5c877d4..0000000000
--- a/app/models/github/team.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-class Github::Team
- include Mandate
-
- attr_reader :name
-
- def initialize(name)
- @name = name
- end
-
- def add_membership(github_username)
- return unless organization.active?
-
- Exercism.octokit_client.add_team_membership(team_id, github_username)
- end
-
- def remove_membership(github_username)
- return unless organization.active?
-
- Exercism.octokit_client.remove_team_membership(team_id, github_username)
- end
-
- def add_to_repository(repo_name, permission)
- return unless organization.active?
-
- Exercism.octokit_client.add_team_repository(team_id, repo_name, permission:)
- end
-
- def remove_from_repository(repo_name)
- return unless organization.active?
-
- Exercism.octokit_client.remove_team_repository(team_id, repo_name)
- end
-
- def repositories
- return unless organization.active?
-
- Exercism.octokit_client.team_repositories(team_id)
- end
-
- def members
- return unless organization.active?
-
- Exercism.octokit_client.team_members(team_id)
- end
-
- def create(repo_name, parent_team: nil)
- return unless organization.active?
-
- Exercism.octokit_client.create_team(organization.name,
- name:,
- repo_names: ["#{organization.name}/#{repo_name}"],
- privacy: :closed,
- parent_team_id: parent_team&.team_id,
- accept: 'application/vnd.github.hellcat-preview+json')
- end
-
- memoize
- def team_id
- # The octokit client does not surface the API method to retrieve a team
- # by its github team name, so we just call it directly
- Exercism.octokit_client.get("https://api.github.com/orgs/#{organization.name}/teams/#{name}")[:id]
- end
-
- def organization
- Github::Organization.instance
- end
-end
diff --git a/app/serializers/serialize_author_or_contributors.rb b/app/serializers/serialize_author_or_contributors.rb
deleted file mode 100644
index 4c9e44264e..0000000000
--- a/app/serializers/serialize_author_or_contributors.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class SerializeAuthorOrContributors
- include Mandate
-
- initialize_with :users
-
- def call
- eager_loaded_users.map { |user| SerializeAuthorOrContributor.(user) }
- end
-
- private
- def eager_loaded_users
- users.to_active_relation.includes(:profile)
- end
-end
diff --git a/app/serializers/serialize_mentor_discussions_for_student.rb b/app/serializers/serialize_mentor_discussions_for_student.rb
deleted file mode 100644
index c6109ef65c..0000000000
--- a/app/serializers/serialize_mentor_discussions_for_student.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class SerializeMentorDiscussionsForStudent
- include Mandate
-
- initialize_with :discussions
-
- def call
- discussions.
- includes(
- :solution, :exercise, :track, :mentor, :student
- ).
- map { |d| SerializeMentorDiscussionForStudent.(d) }
- end
-end
diff --git a/app/serializers/serialize_submissions.rb b/app/serializers/serialize_submissions.rb
deleted file mode 100644
index 7234e17dfa..0000000000
--- a/app/serializers/serialize_submissions.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class SerializeSubmissions
- include Mandate
-
- initialize_with :submissions
-
- def call
- return [] if submissions.blank?
-
- submissions.includes(:solution).
- map { |s| SerializeSubmission.(s) }
- end
-end
diff --git a/app/views/components/user_activities/completed_exercise.html.haml b/app/views/components/user_activities/completed_exercise.html.haml
deleted file mode 100644
index 8485f22948..0000000000
--- a/app/views/components/user_activities/completed_exercise.html.haml
+++ /dev/null
@@ -1,10 +0,0 @@
-= link_to activity.url, class: 'c-user-activity c-user-activity-completed-exercise' do
- = graphical_icon :"check-circle", css_class: "--descriptive-icon"
- .--info
- .--description
- = activity.text
- .--exercise
- = graphical_icon(activity.exercise_icon_name)
- .--exercise-name= activity.exercise_title
- %time{ datetime: activity.occurred_at }= t('.time_ago', time_ago: time_ago_in_words(activity.occurred_at))
- = graphical_icon :"chevron-right", css_class: "--action-icon"
diff --git a/app/views/components/user_activities/started_exercise.html.haml b/app/views/components/user_activities/started_exercise.html.haml
deleted file mode 100644
index 2ebba76df2..0000000000
--- a/app/views/components/user_activities/started_exercise.html.haml
+++ /dev/null
@@ -1,10 +0,0 @@
-= link_to activity.url, class: 'c-user-activity c-user-activity-started-exercise' do
- = graphical_icon :"check-circle", css_class: "--descriptive-icon"
- .--info
- .--description
- = activity.text
- .--exercise
- = graphical_icon(activity.exercise_icon_name)
- .--exercise-name= activity.exercise_title
- %time{ datetime: activity.occurred_at }= t('.time_ago', time_ago: time_ago_in_words(activity.occurred_at))
- = graphical_icon :"chevron-right", css_class: "--action-icon"
diff --git a/app/views/components/user_activities/submitted_iteration.html.haml b/app/views/components/user_activities/submitted_iteration.html.haml
deleted file mode 100644
index 8904c2b331..0000000000
--- a/app/views/components/user_activities/submitted_iteration.html.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-= link_to activity.url, class: 'c-user-activity c-user-activity-submitted-iteration' do
- = graphical_icon :iteration, css_class: "--descriptive-icon"
- .--info
- .--description
- = activity.text
- .--exercise
- = graphical_icon(activity.exercise_icon_name)
- .--exercise-name= activity.exercise_title
-
- .--iteration
- = ReactComponents::Track::IterationSummary.new(activity.iteration)
- = graphical_icon :"chevron-right", css_class: "--action-icon"
-
- %time{ datetime: activity.occurred_at }= t('.time_ago', time_ago: time_ago_in_words(activity.occurred_at))
diff --git a/app/views/layouts/nav/challenge_48in24.html.haml b/app/views/layouts/nav/challenge_48in24.html.haml
deleted file mode 100644
index 87c2193fcc..0000000000
--- a/app/views/layouts/nav/challenge_48in24.html.haml
+++ /dev/null
@@ -1,12 +0,0 @@
-.text-center.flex.flex-col.items-center.items-stretch.pt-32.px-24
- %h2.text-h3.mb-8= t('.title')
- %p.text-p-base.font-semibold.mb-8
- = t('.subtitle')
- %p.text-p-base.mb-16
- = t('.description_p1')
- = t('.description_p2')
-
- = link_to t('.explore_button'), challenge_path("48in24"), class: 'btn-primary btn-s mb-12'
-
- %p.text-p-small.mb-8
- = t('.feature_info')
diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb
index a7c6689729..94da4282f2 100644
--- a/config/initializers/rack_attack.rb
+++ b/config/initializers/rack_attack.rb
@@ -1,5 +1,3 @@
-require 'http_authentication_token'
-
class Rack::Attack::Request
extend Mandate::Memoize
diff --git a/config/locales/views/components/donate_with_crypto.yml b/config/locales/views/components/donate_with_crypto.yml
deleted file mode 100644
index 897a97136d..0000000000
--- a/config/locales/views/components/donate_with_crypto.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-en:
- components:
- donate_with_crypto:
- label: "Donate with Crypto"
diff --git a/config/locales/views/components/nav_submenus.yml b/config/locales/views/components/nav_submenus.yml
index b64775cd72..7f94f2b91d 100644
--- a/config/locales/views/components/nav_submenus.yml
+++ b/config/locales/views/components/nav_submenus.yml
@@ -65,5 +65,3 @@ en:
insiders:
title: "Insiders"
description: "Our way of saying thank you"
- views:
- mentoring_details: "mentoring details"
diff --git a/config/locales/views/components/user_activities.yml b/config/locales/views/components/user_activities.yml
deleted file mode 100644
index 2c03d54b5d..0000000000
--- a/config/locales/views/components/user_activities.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-en:
- components:
- user_activities:
- completed_exercise:
- time_ago: "%{time_ago} ago"
- started_exercise:
- time_ago: "%{time_ago} ago"
- submitted_iteration:
- time_ago: "%{time_ago} ago"
diff --git a/config/locales/views/layouts/nav.yml b/config/locales/views/layouts/nav.yml
index 72e1bb6756..2209db39e9 100644
--- a/config/locales/views/layouts/nav.yml
+++ b/config/locales/views/layouts/nav.yml
@@ -16,20 +16,6 @@ en:
non_profit_info:
Exercism is a registered not-for-profit. All donations are
spent on running and improving the platform.
- challenge_48in24:
- title: "The #48in24 Challenge"
- subtitle:
- A different programming challenge each week during 2024, curated and
- guided by us!
- description_p1: Advance your programming skills one week at a time.
- description_p2:
- Join our community as we explore a different exercise each week,
- digging into how it can be solved with different languages and
- paradigms.
- explore_button: "Explore #48in24"
- feature_info:
- For each week we've chosen a different exercise to feature, with
- approaches, walkthroughs, videos, and more.
tracks:
your_recent_tracks: Your recent tracks
see_all_button: See all
diff --git a/lib/http_authentication_token.rb b/lib/http_authentication_token.rb
deleted file mode 100644
index e7a6455f70..0000000000
--- a/lib/http_authentication_token.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module HttpAuthenticationToken
- def self.from_header(header)
- token = header.to_s.match(/^Token (.*)/) { |m| m[1] }
- return nil unless token
-
- token.split(",").find do |kv|
- key, value = kv.strip.split(/="?/)
- return value.chomp('"').gsub(/\\"/, '"') if key == 'token'
- end
- rescue StandardError
- nil
- end
-end
diff --git a/test/commands/solution/search_community_solutions_test.rb b/test/commands/solution/search_community_solutions_test.rb
deleted file mode 100644
index 9abab6a74b..0000000000
--- a/test/commands/solution/search_community_solutions_test.rb
+++ /dev/null
@@ -1,482 +0,0 @@
-require "test_helper"
-
-class Solution::SearchCommunitySolutionsTest < ActiveSupport::TestCase
- test "no options returns all published" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise)
- end
-
- test "criteria: search for user handle" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- user_1 = create :user, handle: 'amy'
- user_2 = create :user, handle: 'chris'
- solution_1 = create :concept_solution, exercise:, user: user_1, num_stars: 11, published_at: Time.current,
- status: :published
- solution_2 = create :concept_solution, exercise:, user: user_2, num_stars: 22, published_at: Time.current,
- status: :published
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, criteria: nil)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, criteria: "")
- assert_equal [solution_1], Solution::SearchCommunitySolutions.(exercise, criteria: "amy")
- assert_equal [solution_2], Solution::SearchCommunitySolutions.(exercise, criteria: "ris")
- end
-
- test "criteria: search for published iteration code" do
- # TODO: enable once we allow searching for code
- skip
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, published_at: Time.current, status: :published
- submission_1 = create :submission, solution: solution_1
- iteration_1 = create :iteration, solution: solution_1, submission: submission_1
- submission_file_1 = create :submission_file, submission: submission_1
- solution_2 = create :concept_solution, exercise:, published_at: Time.current, status: :published
- submission_2 = create :submission, solution: solution_2
- iteration_2 = create :iteration, solution: solution_2, submission: submission_2
- submission_file_2 = create :submission_file, submission: submission_2
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- wait_for_opensearch_to_be_synced
-
- # Overwrite the content
- upload_to_s3(submission_file_1.s3_bucket, submission_file_1.s3_key, 'let foo = 20')
- upload_to_s3(submission_file_2.s3_bucket, submission_file_2.s3_key, 'let bar = 30')
- solution_1.update!(published_iteration: iteration_1)
- solution_2.update!(published_iteration: iteration_2)
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_2], Solution::SearchCommunitySolutions.(exercise, criteria: "bar")
- end
-
- test "filter: tests_status" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published
- submission_1 = create :submission, solution: solution_1
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published
- submission_2 = create :submission, solution: solution_2
- solution_3 = create :concept_solution, exercise:, num_stars: 33, published_at: Time.current, status: :published
- submission_3 = create :submission, solution: solution_3
- solution_1.update!(published_iteration: create(:iteration, solution: solution_1, submission: submission_1))
- solution_2.update!(published_iteration: create(:iteration, solution: solution_2, submission: submission_2))
- solution_3.update!(published_iteration: create(:iteration, solution: solution_3, submission: submission_3))
-
- # We have to set these via the update_column so they don't get
- # overriden by all the processes that kick off
- perform_enqueued_jobs
- submission_1.reload.update_column(:tests_status, :passed)
- submission_2.reload.update_column(:tests_status, :passed)
- submission_3.reload.update_column(:tests_status, :failed)
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_3, solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, tests_status: nil)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, tests_status: :passed)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, tests_status: "passed")
- assert_equal [solution_3], Solution::SearchCommunitySolutions.(exercise, tests_status: :failed)
- assert_empty Solution::SearchCommunitySolutions.(exercise, tests_status: :errored)
- assert_equal [solution_3, solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, tests_status: %i[passed failed])
- assert_equal [solution_3, solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, tests_status: "passed failed")
- end
-
- test "filter: head_tests_status" do
- # If we let this run it will override the solutions below
- Solution::QueueHeadTestRun.stubs(:defer)
-
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published,
- published_iteration_head_tests_status: :passed
- submission_1 = create :submission, solution: solution_1, tests_status: :passed
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published,
- published_iteration_head_tests_status: :passed
- submission_2 = create :submission, solution: solution_2, tests_status: :passed
- solution_3 = create :concept_solution, exercise:, num_stars: 33, published_at: Time.current, status: :published,
- published_iteration_head_tests_status: :errored
- submission_3 = create :submission, solution: solution_3, tests_status: :failed
- solution_1.update!(published_iteration: create(:iteration, solution: solution_1, submission: submission_1))
- solution_2.update!(published_iteration: create(:iteration, solution: solution_2, submission: submission_2))
- solution_3.update!(published_iteration: create(:iteration, solution: solution_3, submission: submission_3))
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_3, solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, head_tests_status: nil)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, head_tests_status: :passed)
- assert_empty Solution::SearchCommunitySolutions.(exercise, head_tests_status: :failed)
- assert_equal [solution_3], Solution::SearchCommunitySolutions.(exercise, head_tests_status: :errored)
- assert_equal [solution_3], Solution::SearchCommunitySolutions.(exercise, head_tests_status: "errored")
- assert_equal [solution_3, solution_2, solution_1],
- Solution::SearchCommunitySolutions.(exercise, head_tests_status: %i[passed errored])
- assert_equal [solution_3, solution_2, solution_1],
- Solution::SearchCommunitySolutions.(exercise, head_tests_status: "passed errored")
- end
-
- test "filter: sync_status" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, git_important_files_hash: exercise.git_important_files_hash,
- num_stars: 11, published_at: Time.current, status: :published
- solution_2 = create :concept_solution, exercise:, git_important_files_hash: exercise.git_important_files_hash,
- num_stars: 22, published_at: Time.current, status: :published
- solution_3 = create :concept_solution, exercise:, git_important_files_hash: 'different_hash', num_stars: 33,
- published_at: Time.current, status: :published
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_3, solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, sync_status: nil)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, sync_status: :up_to_date)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, sync_status: "up_to_date")
- assert_equal [solution_3], Solution::SearchCommunitySolutions.(exercise, sync_status: :out_of_date)
- assert_equal [solution_3], Solution::SearchCommunitySolutions.(exercise, sync_status: "out_of_date")
- end
-
- test "pagination" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_2], Solution::SearchCommunitySolutions.(exercise, page: 1, per: 1)
- assert_equal [solution_1], Solution::SearchCommunitySolutions.(exercise, page: 2, per: 1)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions.(exercise, page: 1, per: 2)
- assert_empty Solution::SearchCommunitySolutions.(exercise, page: 2, per: 2)
- end
-
- test "does not try and access values above 10_000" do
- # Don't do any checking in DB or ES
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
- Exercism.expects(:opensearch_client).never
-
- results = Solution::SearchCommunitySolutions.(create(:concept_exercise), page: 1001, per: 10)
- assert_empty results
- end
-
- test "pagination returns max of 10_000 results" do
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- data = { "hits" => { "hits" => [], "total" => { "value" => 10_001 } } }
- os_client = mock
- os_client.expects(:search).returns(data)
- Exercism.expects(:opensearch_client).returns(os_client)
-
- results = Solution::SearchCommunitySolutions.(create(:concept_exercise))
- assert_equal 10_000, results.total_count
- end
-
- test "sort newest first" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- new_solution = create :concept_solution, exercise:, published_at: Time.current - 1.week, status: :published
- old_solution = create :concept_solution, exercise:, published_at: Time.current - 2.weeks, status: :published
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [new_solution, old_solution], Solution::SearchCommunitySolutions.(exercise, order: "newest")
- end
-
- test "sort most starred first" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- least_starred = create :concept_solution, exercise:, num_stars: 2, published_at: Time.current - 1.week,
- status: :published
- most_starred = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current - 2.weeks,
- status: :published
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [most_starred, least_starred], Solution::SearchCommunitySolutions.(exercise, order: "most_starred")
- end
-
- test "sort most starred first by default" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- least_starred = create :concept_solution, exercise:, num_stars: 2, published_at: Time.current - 1.week,
- status: :published
- most_starred = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current - 2.weeks,
- status: :published
-
- # Sanity check: ensure that the results are not returned using the fallback
- Solution::SearchCommunitySolutions::Fallback.expects(:call).never
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [most_starred, least_starred], Solution::SearchCommunitySolutions.(exercise, order: nil)
- end
-
- test "fallback is called" do
- exercise = create :concept_exercise
- Solution::SearchCommunitySolutions::Fallback.expects(:call).with(exercise, 2, 15, :newest, "foobar", :passed, :failed, :up_to_date)
- OpenSearch::Client.expects(:new).raises
-
- Solution::SearchCommunitySolutions.(exercise, page: 2, per: 15, order: "newest", criteria: "foobar", tests_status: :passed, head_tests_status: :failed, sync_status: :up_to_date) # rubocop:disable Layout/LineLength
- end
-
- test "fallback is called when elasticsearch times out" do
- # Simulate a timeout
- Mocha::Configuration.override(stubbing_non_public_method: :allow) do
- Solution::SearchCommunitySolutions.any_instance.stubs(:search_query).returns({
- query: {
- function_score: {
- script_score: {
- script: {
- lang: "painless",
- source: "long total = 0; for (int i = 0; i < 500000; ++i) { total += i; } return total;"
- }
- }
- }
- }
- })
- end
-
- exercise = create :concept_exercise
- Solution::SearchCommunitySolutions::Fallback.expects(:call).with(exercise, 2, 15, :newest, "foobar", :passed,
- :passed, :up_to_date)
-
- Solution::SearchCommunitySolutions.(exercise, page: 2, per: 15, order: "newest", criteria: "foobar", tests_status: :passed,
- head_tests_status: :passed, sync_status: :up_to_date)
- end
-
- test "fallback: no options returns all published" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 10, nil, "", nil, nil, nil)
- end
-
- test "fallback: criteria: search for user handle" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- user_1 = create :user, handle: 'amy'
- user_2 = create :user, handle: 'chris'
- solution_1 = create :concept_solution, exercise:, user: user_1, num_stars: 11, published_at: Time.current,
- status: :published
- solution_2 = create :concept_solution, exercise:, user: user_2, num_stars: 22, published_at: Time.current,
- status: :published
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- wait_for_opensearch_to_be_synced
-
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, nil, nil, nil, nil)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, nil, nil)
- assert_equal [solution_1], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "amy", nil, nil, nil)
- assert_equal [solution_2], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "ris", nil, nil, nil)
- end
-
- test "fallback: filter: tests_status" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published
- submission_1 = create :submission, solution: solution_1, tests_status: :passed
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published
- submission_2 = create :submission, solution: solution_2, tests_status: :passed
- solution_3 = create :concept_solution, exercise:, num_stars: 33, published_at: Time.current, status: :published
- submission_3 = create :submission, solution: solution_3, tests_status: :failed
- solution_1.update!(published_iteration: create(:iteration, solution: solution_1, submission: submission_1))
- solution_2.update!(published_iteration: create(:iteration, solution: solution_2, submission: submission_2))
- solution_3.update!(published_iteration: create(:iteration, solution: solution_3, submission: submission_3))
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- assert_equal [solution_3, solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, nil, nil)
- assert_equal [solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", :passed, nil, nil)
- assert_equal [solution_3], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", :failed, nil, nil)
- assert_empty Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", :errored, nil, nil)
- assert_equal [solution_3, solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", %i[passed failed], nil, nil)
- end
-
- test "fallback: filter: head_tests_status" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published,
- published_iteration_head_tests_status: :passed
- submission_1 = create :submission, solution: solution_1, tests_status: :passed
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published,
- published_iteration_head_tests_status: :passed
- submission_2 = create :submission, solution: solution_2, tests_status: :passed
- solution_3 = create :concept_solution, exercise:, num_stars: 33, published_at: Time.current, status: :published,
- published_iteration_head_tests_status: :errored
- submission_3 = create :submission, solution: solution_3, tests_status: :failed
- solution_1.update!(published_iteration: create(:iteration, solution: solution_1, submission: submission_1))
- solution_2.update!(published_iteration: create(:iteration, solution: solution_2, submission: submission_2))
- solution_3.update!(published_iteration: create(:iteration, solution: solution_3, submission: submission_3))
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- assert_equal [solution_3, solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, nil, nil)
- assert_equal [solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, :passed, nil)
- assert_empty Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, :failed, nil)
- assert_equal [solution_3], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, :errored, nil)
- assert_equal [solution_3, solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, %i[passed errored], nil)
- end
-
- test "fallback: filter: sync_status" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, git_important_files_hash: exercise.git_important_files_hash,
- num_stars: 11, published_at: Time.current, status: :published
- solution_2 = create :concept_solution, exercise:, git_important_files_hash: exercise.git_important_files_hash,
- num_stars: 22, published_at: Time.current, status: :published
- solution_3 = create :concept_solution, exercise:, git_important_files_hash: 'different_hash', num_stars: 33,
- published_at: Time.current, status: :published
-
- # Unpublished
- create(:concept_solution, exercise:)
-
- # A different exercise
- create :concept_solution
-
- assert_equal [solution_3, solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, nil, nil)
- assert_equal [solution_2, solution_1],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, nil, :up_to_date)
- assert_equal [solution_3], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, nil, :out_of_date)
- end
-
- test "fallback: pagination" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution_1 = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current, status: :published
- solution_2 = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current, status: :published
-
- assert_equal [solution_2], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 1, nil, "", nil, nil, nil)
- assert_equal [solution_1], Solution::SearchCommunitySolutions::Fallback.(exercise, 2, 1, nil, "", nil, nil, nil)
- assert_equal [solution_2, solution_1], Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 2, nil, "", nil, nil, nil)
- assert_empty Solution::SearchCommunitySolutions::Fallback.(exercise, 2, 2, nil, "", nil, nil, nil)
- end
-
- test "fallback: sort newest first" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- new_solution = create :concept_solution, exercise:, published_at: Time.current - 1.week, status: :published
- old_solution = create :concept_solution, exercise:, published_at: Time.current - 2.weeks, status: :published
-
- assert_equal [new_solution, old_solution],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, :newest, "", nil, nil, nil)
- end
-
- test "fallback: sort most starred first" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- least_starred = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current - 1.week,
- status: :published
- most_starred = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current - 2.weeks,
- status: :published
-
- assert_equal [most_starred, least_starred],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, :most_starred, "", nil, nil, nil)
- end
-
- test "fallback: sort most starred first by default" do
- track = create :track
- exercise = create(:concept_exercise, track:)
- least_starred = create :concept_solution, exercise:, num_stars: 11, published_at: Time.current - 1.week,
- status: :published
- most_starred = create :concept_solution, exercise:, num_stars: 22, published_at: Time.current - 2.weeks,
- status: :published
-
- assert_equal [most_starred, least_starred],
- Solution::SearchCommunitySolutions::Fallback.(exercise, 1, 15, nil, "", nil, nil, nil)
- end
-end
diff --git a/test/commands/submission/analysis/cancel_test.rb b/test/commands/submission/analysis/cancel_test.rb
deleted file mode 100644
index 4620453699..0000000000
--- a/test/commands/submission/analysis/cancel_test.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'test_helper'
-
-class Submission::Analysis::CancelTest < ActiveSupport::TestCase
- test "calls to publish_message" do
- skip
- submission_uuid = SecureRandom.compact_uuid
- RestClient.expects(:post).with(
- 'http://analyzer.example.com/submissions/cancel',
- submission_uuid:
- )
- Submission::Analysis::Cancel.(submission_uuid)
- end
-end
diff --git a/test/commands/submission/representation/cancel_test.rb b/test/commands/submission/representation/cancel_test.rb
deleted file mode 100644
index 924332408e..0000000000
--- a/test/commands/submission/representation/cancel_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'test_helper'
-
-class Submission::Representation::CancelTest < ActiveSupport::TestCase
- test "calls to publish_message" do
- skip
- submission_uuid = SecureRandom.compact_uuid
- RestClient.expects(:post).with('http://representer.example.com/submissions/cancel',
- submission_uuid:)
- Submission::Representation::Cancel.(submission_uuid)
- end
-end
diff --git a/test/commands/user/destroy_account_test.rb b/test/commands/user/destroy_account_test.rb
index ad1442732a..df80b3c5a2 100644
--- a/test/commands/user/destroy_account_test.rb
+++ b/test/commands/user/destroy_account_test.rb
@@ -55,7 +55,7 @@ class User::DestroyAccountTest < ActiveSupport::TestCase
Solution::Publish.(solution, ut, 1)
end
sleep(1) # It takes a second for cloudsearch to actually update its index
- assert_equal 1, Solution::SearchCommunitySolutions.(solution.exercise).length
+ refute_nil get_opensearch_doc(Solution::OPENSEARCH_INDEX, solution.id)
# Don't wrap perform_enqueued_jobs around this, do it afterwards
# and sleep for 0.1 to ensure that user is actually deleted etc
@@ -64,6 +64,6 @@ class User::DestroyAccountTest < ActiveSupport::TestCase
sleep(0.1)
perform_enqueued_jobs
- assert_empty Solution::SearchCommunitySolutions.(solution.exercise)
+ assert_nil get_opensearch_doc(Solution::OPENSEARCH_INDEX, solution.id)
end
end
diff --git a/test/jobs/send_user_mailshot_job_test.rb b/test/jobs/send_user_mailshot_job_test.rb
deleted file mode 100644
index 338f7a1178..0000000000
--- a/test/jobs/send_user_mailshot_job_test.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require "test_helper"
-
-class SendUserMailshotJobTest < ActiveJob::TestCase
- test "sends email" do
- user = create :user
- mailshot = create :mailshot
-
- User::Mailshot::Send.expects(:call).with(user, mailshot)
-
- SendUserMailshotJob.perform_now(user, mailshot)
- end
-
- test "sends email to correct queue" do
- user = create :user
- mailshot = create :mailshot
-
- job = MailshotsMailer.with(user:, mailshot:).send(:mailshot).deliver_later
-
- assert_equal 'mailers', job.queue_name
- end
-end
diff --git a/test/lib/http_authentication_token_test.rb b/test/lib/http_authentication_token_test.rb
deleted file mode 100644
index b40fd27460..0000000000
--- a/test/lib/http_authentication_token_test.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require "test_helper"
-
-class HttpAuthenticationTokenTest < ActiveSupport::TestCase
- test "returns token when using token auth" do
- header = 'Token token=f8a4f759-1131-44df-b453-6829027da8bb'
- token = HttpAuthenticationToken.from_header(header)
- assert_equal 'f8a4f759-1131-44df-b453-6829027da8bb', token
- end
-
- test "returns token when using token auth with multiple header values" do
- header = 'Token nonce=abc,token=f8a4f759-1131-44df-b453-6829027da8bb'
- token = HttpAuthenticationToken.from_header(header)
- assert_equal 'f8a4f759-1131-44df-b453-6829027da8bb', token
- end
-
- test "returns nil when using basic auth" do
- header = 'Basic ZnJlZDpmcmVk'
- token = HttpAuthenticationToken.from_header(header)
- assert_nil token
- end
-
- test "returns nil when using bearer auth" do
- header = 'Bearer ZnJlZDpmcmVk'
- token = HttpAuthenticationToken.from_header(header)
- assert_nil token
- end
-end
diff --git a/test/models/github/team_test.rb b/test/models/github/team_test.rb
deleted file mode 100644
index 51668bd839..0000000000
--- a/test/models/github/team_test.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-require "test_helper"
-
-class Github::TeamTest < ActiveSupport::TestCase
- test "add_membership" do
- Github::Organization.any_instance.stubs(:name).returns('exercism')
-
- stub_request(:get, "https://api.github.com/orgs/exercism/teams/csharp-maintainers").
- to_return(
- status: 200,
- body: { name: "alumni", id: 2_022_925 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- stub_request(:put, "https://api.github.com/teams/2022925/memberships/ErikSchierboom").
- to_return(status: 200, body: "", headers: {})
-
- team = Github::Team.new('csharp-maintainers')
-
- team.add_membership('ErikSchierboom')
- end
-
- test "remove_membership" do
- Github::Organization.any_instance.stubs(:name).returns('exercism')
-
- stub_request(:get, "https://api.github.com/orgs/exercism/teams/csharp-maintainers").
- to_return(
- status: 200,
- body: { name: "alumni", id: 2_022_925 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- stub_request(:delete, "https://api.github.com/teams/2022925/memberships/ErikSchierboom").
- to_return(status: 200, body: "", headers: {})
-
- team = Github::Team.new('csharp-maintainers')
-
- team.remove_membership('ErikSchierboom')
- end
-
- test "add_to_repository" do
- Github::Organization.any_instance.stubs(:name).returns('exercism')
-
- stub_request(:get, "https://api.github.com/orgs/exercism/teams/reviewers").
- to_return(
- status: 200,
- body: { name: "reviewers", id: 3_076_122 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- stub_request(:put, "https://api.github.com/teams/3076122/repos/exercism/csharp").
- with(body: { permission: "push" }.to_json).
- to_return(status: 200, body: "", headers: {})
-
- team = Github::Team.new('reviewers')
-
- team.add_to_repository('exercism/csharp', :push)
- end
-
- test "remove_from_repository" do
- Github::Organization.any_instance.stubs(:name).returns('exercism')
-
- stub_request(:get, "https://api.github.com/orgs/exercism/teams/reviewers").
- to_return(
- status: 200,
- body: { name: "reviewers", id: 3_076_122 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- stub_request(:delete, "https://api.github.com/teams/3076122/repos/exercism/csharp").
- to_return(status: 200, body: "", headers: {})
-
- team = Github::Team.new('reviewers')
-
- team.remove_from_repository('exercism/csharp')
- end
-
- test "repositories" do
- Github::Organization.any_instance.stubs(:name).returns('exercism')
-
- stub_request(:get, "https://api.github.com/orgs/exercism/teams/reviewers").
- to_return(
- status: 200,
- body: { name: "reviewers", id: 3_076_122 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- stub_request(:get, "https://api.github.com/teams/3076122/repos?per_page=100").
- to_return(
- status: 200,
- body: [
- { full_name: "exercism/csharp" },
- { full_name: "exercism/ruby" }
- ].to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- team = Github::Team.new('reviewers')
-
- repositories = team.repositories
-
- assert_equal 2, repositories.size
- assert_equal ['exercism/csharp', 'exercism/ruby'], repositories.pluck(:full_name)
- end
-
- test "create without parent team" do
- Github::Organization.any_instance.stubs(:name).returns('exercism')
-
- stub_request(:post, "https://api.github.com/orgs/exercism/teams").
- with(
- body: {
- name: "csharp-maintainers",
- repo_names: ["exercism/csharp"],
- privacy: :closed,
- parent_team_id: nil
- }.to_json,
- headers: {
- accept: 'application/vnd.github.hellcat-preview+json'
- }
- ).
- to_return(
- status: 200,
- body: { name: "reviewers", id: 3_076_122 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- team = Github::Team.new('csharp-maintainers')
-
- team.create('csharp')
- end
-
- test "create with parent team" do
- Github::Organization.any_instance.stubs(:name).returns('exercism')
-
- stub_request(:get, "https://api.github.com/orgs/exercism/teams/track-maintainers").
- to_return(
- status: 200,
- body: { name: "track-maintainers", id: 2_022_925 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- stub_request(:post, "https://api.github.com/orgs/exercism/teams").
- with(
- body: {
- name: "csharp-maintainers",
- repo_names: ["exercism/csharp"],
- privacy: :closed,
- parent_team_id: 2_022_925
- }.to_json
- ).
- to_return(
- status: 200,
- body: { name: "csharp-maintainers", id: 3_076_122 }.to_json,
- headers: { 'Content-Type': 'application/json' }
- )
-
- parent_team = Github::Team.new('track-maintainers')
- team = Github::Team.new('csharp-maintainers')
-
- team.create('csharp', parent_team:)
- end
-end
diff --git a/test/serializers/serialize_authors_or_contributors_test.rb b/test/serializers/serialize_authors_or_contributors_test.rb
deleted file mode 100644
index 39b414e9b5..0000000000
--- a/test/serializers/serialize_authors_or_contributors_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'test_helper'
-
-class SerializeAuthorOrContributorsTest < ActiveSupport::TestCase
- test "n+1s handled correctly" do
- create_np1_data
-
- Bullet.profile do
- SerializeAuthorOrContributors.(User.all)
- end
- end
-end
diff --git a/test/serializers/serialize_mentor_discussions_for_student_test.rb b/test/serializers/serialize_mentor_discussions_for_student_test.rb
deleted file mode 100644
index 90a4f29739..0000000000
--- a/test/serializers/serialize_mentor_discussions_for_student_test.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'test_helper'
-
-class SerializeMentorDiscussionsForStudentTest < ActiveSupport::TestCase
- test "basic request" do
- student = create :user
- mentor = create :user
- track = create :track
- exercise = create(:concept_exercise, track:)
- solution = create :concept_solution, exercise:, user: student
- discussion = create(:mentor_discussion,
- :awaiting_mentor,
- solution:,
- mentor:)
-
- data = mock
- SerializeMentorDiscussionForStudent.expects(:call).with(discussion).returns(data)
- assert_equal [data], SerializeMentorDiscussionsForStudent.(Mentor::Discussion.all)
- end
-
- test "n+1s handled correctly" do
- create_np1_data
-
- Bullet.profile do
- SerializeMentorDiscussionsForStudent.(Mentor::Discussion.all)
- end
- end
-end
diff --git a/test/serializers/serialize_submissions_test.rb b/test/serializers/serialize_submissions_test.rb
deleted file mode 100644
index 4f9925d384..0000000000
--- a/test/serializers/serialize_submissions_test.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'test_helper'
-
-class SerializeSubmissionsTest < ActiveSupport::TestCase
- test "test submissions" do
- user = create :user
- solution = create(:concept_solution, user:)
- submission = create(:submission, tests_status: :failed, solution:)
-
- expected = [SerializeSubmission.(submission)]
- actual = SerializeSubmissions.(Submission.all)
- assert_equal expected, actual
- end
-
- test "returns [] if no solutons are passed in" do
- assert_empty SerializeSubmissions.([])
- end
-end