repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/lesson_previews.rb | spec/factories/lesson_previews.rb | FactoryBot.define do
factory :lesson_preview do
sequence(:content) { |n| "lesson preview #{n}" }
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/path_prerequisites.rb | spec/factories/path_prerequisites.rb | FactoryBot.define do
factory :path_prerequisite do
path
prerequisite factory: :path
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/paths.rb | spec/factories/paths.rb | FactoryBot.define do
factory :path do
sequence(:title) { |n| "test path#{n}" }
sequence(:position) { |n| n }
description { 'A Path' }
identifier_uuid { SecureRandom.uuid }
badge_uri { 'badge-foundations.svg' }
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/announcements.rb | spec/factories/announcements.rb | FactoryBot.define do
factory :announcement do
message { 'a message for all users' }
expires_at { 1.day.from_now }
created_by { association :admin_user }
learn_more_url { 'https://example.com' }
trait :without_validations do
to_create { |instance| instance.save(validate: false) }
end
e... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/interview_surveys.rb | spec/factories/interview_surveys.rb | FactoryBot.define do
factory :interview_survey do
user
interview_date { Date.current }
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/courses.rb | spec/factories/courses.rb | FactoryBot.define do
factory :course do
path
sequence(:title) { |n| "test course#{n}" }
sequence(:position) { |n| n }
identifier_uuid { SecureRandom.uuid }
badge_uri { 'badge-foundations.svg' }
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/lesson_completions.rb | spec/factories/lesson_completions.rb | FactoryBot.define do
factory :lesson_completion do
user
lesson
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/admin_users.rb | spec/factories/admin_users.rb | FactoryBot.define do
factory :admin_user do
sequence(:name) { |n| "admin#{n}" }
sequence(:email) { |n| "admin#{n}@odin.com" }
password { 'password123' }
status { :activated }
role { :core }
trait :with_otp do
otp_secret { AdminUser.generate_otp_secret }
otp_required_for_login { tr... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/notifications.rb | spec/factories/notifications.rb | FactoryBot.define do
factory :notification do
recipient factory: :user
type { '' }
params { '' }
read_at { Time.zone.now }
url { '' }
message { '' }
title { '' }
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/interview_survey_concepts.rb | spec/factories/interview_survey_concepts.rb | FactoryBot.define do
factory :interview_survey_concept do
interview_survey
interview_concept
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/points.rb | spec/factories/points.rb | FactoryBot.define do
factory :point do
sequence :discord_id do |n|
n
end
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/factories/project_submissions.rb | spec/factories/project_submissions.rb | FactoryBot.define do
factory :project_submission do
repo_url { 'https://github.com/user/repo' }
live_preview_url { 'http://mysite.com' }
user
discard_at { nil }
lesson { association :lesson, previewable: true }
trait :liked do
after(:create, &:liked!)
end
trait :unliked do
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/card_component_spec.rb | spec/components/card_component_spec.rb | require 'rails_helper'
RSpec.describe CardComponent, type: :component do
it 'renders the card with custom classes' do
component = described_class.new(classes: 'a-class')
render_inline(component)
expect(page).to have_css('div.a-class')
end
it 'renders the card with an id' do
component = describ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/content_container_component_spec.rb | spec/components/content_container_component_spec.rb | require 'rails_helper'
RSpec.describe ContentContainerComponent, type: :component do
it 'renders content' do
component = described_class.new
render_inline(component) { 'Some riveting content' }
expect(page).to have_content('Some riveting content')
end
it 'renders content with classes' do
compo... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/announcement_component_spec.rb | spec/components/announcement_component_spec.rb | require 'rails_helper'
RSpec.describe AnnouncementComponent, type: :component do
context 'with an announcement' do
it 'renders the announcement' do
announcement = create(:announcement, message: 'Hello, world!')
component = described_class.new(announcement:)
render_inline(component)
expe... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/lesson_group_component_spec.rb | spec/components/lesson_group_component_spec.rb | require 'rails_helper'
RSpec.describe LessonGroupComponent, type: :component do
it 'renders the list with a title' do
component = described_class.new(title: 'HTML Basics', lessons: [])
render_inline(component)
expect(page).to have_css('h3', text: 'HTML Basics')
end
it 'renders the list of lessons'... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/pagination_component_spec.rb | spec/components/pagination_component_spec.rb | require 'rails_helper'
RSpec.describe PaginationComponent, type: :component do
context 'when there is more than one page' do
it 'renders the pagination component' do
with_request_url('/admin/flags') do
pagy = instance_double(Pagy, pages: 3, next: 3, prev: 1, from: 1, to: 10, count: 30)
comp... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/notification_component_spec.rb | spec/components/notification_component_spec.rb | require 'rails_helper'
RSpec.describe NotificationComponent, type: :component do
let(:notification) do
create(:notification, id: 1, title: 'test title', message: 'test message')
end
before do
render_inline(described_class.new(notification:))
end
it "renders the component with a link to the notifica... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/charts/horizontal_bar_chart_component_spec.rb | spec/components/charts/horizontal_bar_chart_component_spec.rb | require 'rails_helper'
RSpec.describe Charts::HorizontalBarChartComponent, type: :component do
context 'when the dataset is smaller than 5' do
it 'renders the chart with an appropiate height' do
component = described_class.new(labels: %w[A B], datasets: [1, 2])
render_inline(component)
expect... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/project_submissions/item_component_spec.rb | spec/components/project_submissions/item_component_spec.rb | require 'rails_helper'
RSpec.describe ProjectSubmissions::ItemComponent, type: :component do
context 'when the project submission is present' do
it 'renders the item component' do
project_submission = create(:project_submission)
component = described_class.new(project_submission:)
render_inlin... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/project_submissions/like_component_spec.rb | spec/components/project_submissions/like_component_spec.rb | require 'rails_helper'
RSpec.describe ProjectSubmissions::LikeComponent, type: :component do
context 'when the the project submission is liked' do
it 'renders the component as liked' do
project_submission = create(:project_submission, :liked)
component = described_class.new(project_submission:)
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/project_submissions/user_solution_component_spec.rb | spec/components/project_submissions/user_solution_component_spec.rb | require 'rails_helper'
RSpec.describe ProjectSubmissions::UserSolutionComponent, type: :component do
context 'when the project submission is present' do
it 'renders the component' do
project_submission = create(:project_submission)
component = described_class.new(project_submission:)
render_in... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/complete/icon_component_spec.rb | spec/components/complete/icon_component_spec.rb | require 'rails_helper'
RSpec.describe Complete::IconComponent, type: :component do
let(:user) { create(:user) }
it 'renders the icon button with the lesson complete state' do
lesson = create(:lesson, :complete)
component = described_class.new(lesson:, current_user: user)
render_inline(component)
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/complete/button_component_spec.rb | spec/components/complete/button_component_spec.rb | require 'rails_helper'
RSpec.describe Complete::ButtonComponent, type: :component do
it 'renders the button with the lesson complete state' do
lesson = create(:lesson, :complete)
component = described_class.new(lesson:)
render_inline(component)
expect(page).to have_button('Lesson Completed')
end
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/user/avatar_component_spec.rb | spec/components/user/avatar_component_spec.rb | require 'rails_helper'
RSpec.describe User::AvatarComponent, type: :component do
context 'when the user has an avatar' do
it 'renders the users avatar' do
user = create(:user, avatar: 'http://github/avatar.png')
component = described_class.new(current_user: user, classes: 'w-12')
render_inline... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/user/learning_goal_component_spec.rb | spec/components/user/learning_goal_component_spec.rb | require 'rails_helper'
RSpec.describe User::LearningGoalComponent, type: :component do
context 'when the user has a learning goal' do
it 'renders the learning goal' do
user = create(:user, learning_goal: 'Learn Ruby')
component = described_class.new(current_user: user)
render_inline(component)... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/nav/item_component_spec.rb | spec/components/nav/item_component_spec.rb | require 'rails_helper'
RSpec.describe Nav::ItemComponent, type: :component do
context 'when mobile' do
it 'renders mobile nav item' do
component = described_class.new(
path: '/home',
text: 'Home',
test_id: 'nav-home',
icon_path: 'icons/home.svg',
options: { mobile: t... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/flags/action_button_component_spec.rb | spec/components/flags/action_button_component_spec.rb | require 'rails_helper'
RSpec.describe Flags::ActionButtonComponent, type: :component do
context 'when the flag is active' do
it 'renders the flag action button' do
flag = build_stubbed(:flag, :active)
component = described_class.new(flag:)
render_inline(component)
expect(page).to have_c... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/course/badge_component_spec.rb | spec/components/course/badge_component_spec.rb | require 'rails_helper'
RSpec.describe Course::BadgeComponent, type: :component do
context 'when the user is signed in' do
it 'renders the loading progress circle' do
course = create(:course)
user = create(:user)
component = described_class.new(course:)
sign_in(user)
render_inline(c... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/sections/lesson_component_spec.rb | spec/components/sections/lesson_component_spec.rb | require 'rails_helper'
RSpec.describe Sections::LessonComponent, type: :component do
context 'when a project' do
it 'returns the project title' do
lesson = create(:lesson, is_project: true, title: 'HTML Basics')
component = described_class.new(lesson:, current_user: nil)
render_inline(componen... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/forms/date_picker_component_spec.rb | spec/components/forms/date_picker_component_spec.rb | require 'rails_helper'
RSpec.describe Forms::DatePickerComponent, type: :component do
context 'when min is smaller than the value of the date picker' do
it 'renders the date picker with the min date' do
component = described_class.new(name: 'date', value: '2021-01-01', min: '2020-01-01')
render_inli... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/overlays/flash_component_spec.rb | spec/components/overlays/flash_component_spec.rb | require 'rails_helper'
RSpec.describe Overlays::FlashComponent, type: :component do
context 'when the type is alert' do
it 'renders an alert flash' do
component = described_class.new(type: 'alert', message: 'Fire!')
render_inline(component)
expect(page).to have_css('.bg-red-100')
expect... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/overlays/dialog_component_spec.rb | spec/components/overlays/dialog_component_spec.rb | require 'rails_helper'
RSpec.describe Overlays::DialogComponent, type: :component do
it 'renders' do
component = described_class.new(id: 'test-dialog')
render_inline(component)
expect(page).to have_css('#test-dialog')
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/team/former_member_component_spec.rb | spec/components/team/former_member_component_spec.rb | require 'rails_helper'
RSpec.describe Team::FormerMemberComponent, type: :component do
let(:former_member) do
{
image: 'https://example.com/avatar.png',
name: 'John Doe',
url: 'https://example.com'
}
end
it 'renders the former team members avatar' do
component = described_class.new... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/team/member_component_spec.rb | spec/components/team/member_component_spec.rb | require 'rails_helper'
RSpec.describe Team::MemberComponent, type: :component do
let(:team_member) do
{
image: 'https://example.com/avatar.png',
name: 'John Doe',
location: 'Berlin',
joined: '2019',
socials: [
{ name: 'twitter', url: 'https://twitter.com' },
{ name: ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/team/navigation_component_spec.rb | spec/components/team/navigation_component_spec.rb | require 'rails_helper'
RSpec.describe Team::NavigationComponent, type: :component do
it 'renders navigation links for the different roles' do
component = described_class.new(
roles: role = [
{ name: 'Core', url: '#core' },
{ name: 'Maintainers', url: '#maintainers' },
{ name: 'Moder... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/announcement_component_preview.rb | spec/components/previews/announcement_component_preview.rb | class AnnouncementComponentPreview < ViewComponent::Preview
# @param message [String] text "The text to display in the announcement"
def with_announcment(message: 'Hello!')
render(AnnouncementComponent.new(announcement: default_announcment(message:)))
end
private
def default_announcment(**opts)
defa... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/notification_component_preview.rb | spec/components/previews/notification_component_preview.rb | class NotificationComponentPreview < ViewComponent::Preview
# @!group
# @display bg_color "#eee"
def unread
render(NotificationComponent.new(notification: unread_notification))
end
def read
render(NotificationComponent.new(notification: read_notification))
end
private
def unread_notification
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/flash_component_preview.rb | spec/components/previews/flash_component_preview.rb | # @hidden
# Not currently working, need to figure out how to pass helpers to the context
class FlashComponentPreview < ViewComponent::Preview
def alert
render(Overlays::FlashComponent.new(type: :alert, message: 'Alert!'))
end
def notice
render(Overlays::FlashComponent.new(type: :notice, message: 'Notice!... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/complete/button_component_preview.rb | spec/components/previews/complete/button_component_preview.rb | module Complete
class ButtonComponentPreview < ViewComponent::Preview
# @!group
def uncompleted
render(ButtonComponent.new(lesson: Lesson.first, current_user: User.find(21)))
end
def completed
lesson = Lesson.first
current_user = User.last
complete_lesson!(lesson, User.last)
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/complete/icon_component_preview.rb | spec/components/previews/complete/icon_component_preview.rb | module Complete
class IconComponentPreview < ViewComponent::Preview
# @!group
def uncompleted
render(IconComponent.new(lesson: Lesson.first, current_user: User.first))
end
def completed
lesson = Lesson.first
current_user = User.last
complete_lesson!(lesson, current_user)
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/user/avatar_component_preview.rb | spec/components/previews/user/avatar_component_preview.rb | class User::AvatarComponentPreview < ViewComponent::Preview
def default
current_user = User.first
render(User::AvatarComponent.new(current_user:, classes: nil))
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/about_page/belief_component_preview.rb | spec/components/previews/about_page/belief_component_preview.rb | module AboutPage
# @label Media Cards
# Note: Name is no longer really representative of what this does, should be refactored to a more general name
class BeliefComponentPreview < ViewComponent::Preview
def with_about_page_collection
render(BeliefComponent.with_collection(I18n.t('static_pages.about.beli... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/sections/lesson_component_preview.rb | spec/components/previews/sections/lesson_component_preview.rb | module Sections
class LessonComponentPreview < ViewComponent::Preview
# @!group
def with_lesson
render(LessonComponent.new(lesson: Lesson.first, current_user: User.first))
end
def with_completed_lesson
lesson = Lesson.first
current_user = User.last
complete_lesson!(lesson, cur... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/previews/paths/select_button_component_preview.rb | spec/components/previews/paths/select_button_component_preview.rb | module Paths
class SelectButtonComponentPreview < ViewComponent::Preview
def default
render(SelectButtonComponent.new(current_user: User.first, path: Path.first))
end
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/oauth/connect_button_component_spec.rb | spec/components/oauth/connect_button_component_spec.rb | require 'rails_helper'
RSpec.describe Oauth::ConnectButtonComponent, type: :component do
it 'renders a oauth provider connect button' do
component = described_class.new(provider: :github, resource_name: 'user')
render_inline(component)
expect(page).to have_content('Sign in with Github')
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/paths/view_button_component_spec.rb | spec/components/paths/view_button_component_spec.rb | require 'rails_helper'
RSpec.describe Paths::ViewButtonComponent, type: :component do
context 'when learner is signed in' do
it 'renders the view button' do
path = create(:path)
current_user = create(:user)
component = described_class.new(current_user:, path:)
render_inline(component)
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/paths/select_button_component_spec.rb | spec/components/paths/select_button_component_spec.rb | require 'rails_helper'
RSpec.describe Paths::SelectButtonComponent, type: :component do
context 'when leaner is on the path' do
it 'renders the continue button' do
path = create(:path)
current_user = create(:user, path:)
component = described_class.new(current_user:, path:)
render_inline... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/theme/switcher_component_spec.rb | spec/components/theme/switcher_component_spec.rb | require 'rails_helper'
RSpec.describe Theme::SwitcherComponent, type: :component do
context 'when dark mode is enabled' do
it 'renders the light mode button' do
component = described_class.new(current_theme: Users::Theme.for('dark'))
render_inline(component)
expect(page).to have_link(href: '/... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/components/progress_circle/component_spec.rb | spec/components/progress_circle/component_spec.rb | require 'rails_helper'
RSpec.describe ProgressCircle::Component, type: :component do
context 'when percentatge is 0' do
it 'reners 0%' do
component = described_class.new(percentage: 0)
render_inline(component)
expect(page).to have_content('0% Complete')
end
end
context 'when percenta... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/interview_survey_spec.rb | spec/models/interview_survey_spec.rb | require 'rails_helper'
RSpec.describe InterviewSurvey do
subject(:interview_survey) { create(:interview_survey) }
it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:interview_survey_concepts) }
it { is_expected.to validate_presence_of(:interview_date) }
it { is_expected.to allow_value(T... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/path_spec.rb | spec/models/path_spec.rb | require 'rails_helper'
RSpec.describe Path do
subject(:path) { described_class.new }
it { is_expected.to have_many(:users) }
it { is_expected.to have_many(:courses).order(:position) }
it { is_expected.to have_many(:lessons).through(:courses) }
it { is_expected.to have_many(:path_prerequisites).dependent(:de... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/project_submission_spec.rb | spec/models/project_submission_spec.rb | require 'rails_helper'
RSpec.describe ProjectSubmission do
subject(:project_submission) { create(:project_submission) }
it_behaves_like 'likeable', :project_submission
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:lesson) }
it { is_expected.to have_many(:flags) }
it { is_expected... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/admin_user_spec.rb | spec/models/admin_user_spec.rb | require 'rails_helper'
RSpec.describe AdminUser do
subject(:admin_user) { create(:admin_user) }
it_behaves_like 'authenticatable_with_two_factor', :admin_user
it_behaves_like 'two_factor_authenticatable'
it { is_expected.to have_many(:flags).dependent(:restrict_with_exception).with_foreign_key(:resolved_by_i... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/interview_concept_spec.rb | spec/models/interview_concept_spec.rb | require 'rails_helper'
RSpec.describe InterviewConcept do
subject(:interview_concept) { create(:interview_concept) }
it { (is_expected.to have_many(:interview_survey_concepts)) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_least(2).is_at_most(25) }
end... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/announcement_spec.rb | spec/models/announcement_spec.rb | require 'rails_helper'
RSpec.describe Announcement do
it { is_expected.to belong_to(:created_by) }
it { is_expected.to validate_presence_of(:message) }
it { is_expected.to validate_length_of(:message).is_at_most(100) }
it { is_expected.to validate_presence_of(:expires_at) }
it { is_expected.to allow_value('... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/lesson_spec.rb | spec/models/lesson_spec.rb | require 'rails_helper'
RSpec.describe Lesson do
subject(:lesson) { create(:lesson) }
it { is_expected.to belong_to(:section) }
it { is_expected.to have_one(:course).through(:section) }
it { is_expected.to have_one(:content) }
it { is_expected.to have_many(:project_submissions) }
it { is_expected.to have_m... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/like_spec.rb | spec/models/like_spec.rb | require 'rails_helper'
RSpec.describe Like do
subject { create(:like) }
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:likeable).counter_cache(true) }
it { is_expected.to validate_presence_of(:likeable_type) }
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to(%i[likeable... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flag_spec.rb | spec/models/flag_spec.rb | require 'rails_helper'
RSpec.describe Flag do
subject(:flag) { described_class.new }
it { is_expected.to belong_to(:flagger) }
it { is_expected.to belong_to(:project_submission) }
it { is_expected.to belong_to(:resolved_by).optional }
it { is_expected.to validate_presence_of(:reason) }
it { is_expected.t... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/lesson_preview_spec.rb | spec/models/lesson_preview_spec.rb | require 'rails_helper'
RSpec.describe LessonPreview do
it { is_expected.to validate_presence_of(:content) }
it { is_expected.to validate_length_of(:content).is_at_most(70_000) }
describe '.expired' do
it 'returns 2 expired lesson previews' do
expired = create_list(:lesson_preview, 2, created_at: 1.mon... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/lesson_completion_spec.rb | spec/models/lesson_completion_spec.rb | require 'rails_helper'
RSpec.describe LessonCompletion do
subject { described_class.new }
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:lesson) }
it { is_expected.to belong_to(:course).optional }
it { is_expected.to belong_to(:path).optional }
it { is_expected.to validate_uniquene... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/point_spec.rb | spec/models/point_spec.rb | require 'rails_helper'
RSpec.describe Point do
subject { described_class.new(discord_id: '123') }
it { is_expected.to validate_presence_of(:discord_id) }
it { is_expected.to validate_uniqueness_of(:discord_id).case_insensitive }
describe '#increment_points_by' do
let(:user_points) { described_class.creat... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/content_spec.rb | spec/models/content_spec.rb | require 'rails_helper'
RSpec.describe Content do
it { is_expected.to belong_to(:lesson) }
it { is_expected.to validate_presence_of(:body) }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/interview_survey_concept_spec.rb | spec/models/interview_survey_concept_spec.rb | require 'rails_helper'
RSpec.describe InterviewSurveyConcept do
subject(:interview_survey_concept) { create(:interview_survey_concept) }
it { (is_expected.to belong_to(:interview_survey)) }
it { (is_expected.to belong_to(:interview_concept)) }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/course_spec.rb | spec/models/course_spec.rb | require 'rails_helper'
RSpec.describe Course do
subject(:course) { described_class.new }
it { is_expected.to belong_to(:path) }
it { is_expected.to have_many(:sections).order(:position) }
it { is_expected.to have_many(:lessons).through(:sections) }
it { is_expected.to validate_presence_of(:position) }
d... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/user_provider_spec.rb | spec/models/user_provider_spec.rb | require 'rails_helper'
RSpec.describe UserProvider do
it { is_expected.to belong_to(:user) }
describe '.find_user' do
let(:auth) { {} }
let(:user_provider_finder) { instance_double(OmniauthProviders::Finder) }
let(:user_provider) { instance_double(described_class, user:) }
let(:user) { instance_do... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/section_spec.rb | spec/models/section_spec.rb | require 'rails_helper'
RSpec.describe Section do
subject { described_class.new }
it { is_expected.to belong_to(:course) }
it { is_expected.to have_many(:lessons).order(:position) }
it { is_expected.to validate_presence_of(:position) }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/user_spec.rb | spec/models/user_spec.rb | require 'rails_helper'
RSpec.describe User do
subject(:user) { create(:user) }
it { is_expected.to validate_uniqueness_of(:email).ignoring_case_sensitivity }
it { is_expected.to allow_value('example@email.com').for(:email) }
it { is_expected.not_to allow_value('bademail').for(:email) }
it { is_expected.to v... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/path_prerequisite_spec.rb | spec/models/path_prerequisite_spec.rb | require 'rails_helper'
RSpec.describe PathPrerequisite do
subject { create(:path_prerequisite) }
it { is_expected.to belong_to(:path) }
it { is_expected.to belong_to(:prerequisite).class_name('Path') }
it { is_expected.to validate_uniqueness_of(:prerequisite_id).scoped_to(:path_id) }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/omniauth_providers/finder_spec.rb | spec/models/omniauth_providers/finder_spec.rb | require 'rails_helper'
module OmniauthProviders
RSpec.describe Finder do
subject(:finder) { described_class.new(auth) }
let(:auth) do
OmniAuth::AuthHash.new(
provider: 'github',
uid: '123',
info: {
email: 'john@odin.com',
name: 'John',
image: 'http... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/omniauth_providers/builder_spec.rb | spec/models/omniauth_providers/builder_spec.rb | require 'rails_helper'
module OmniauthProviders
RSpec.describe Builder do
describe '#build' do
subject(:builder) { described_class.new(auth, user) }
let(:auth) { OmniAuth::AuthHash.new(provider: 'github', uid: '123') }
let(:user) { create(:user) }
it 'creates a new user provider' do
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flags/action_spec.rb | spec/models/flags/action_spec.rb | require 'rails_helper'
RSpec.describe Flags::Action do
describe '.all' do
it 'returns all available flag actions' do
expect(described_class.all.map(&:value)).to eq(
I18n.t('flag_actions').pluck(:value)
)
end
end
describe '.for' do
it 'returns the flag action for the given value' ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flags/action_factory_spec.rb | spec/models/flags/action_factory_spec.rb | require 'rails_helper'
RSpec.describe Flags::ActionFactory do
describe '#action' do
subject { described_class.for(action) }
context "when action is 'dismiss'" do
let(:action) { :dismiss }
it { is_expected.to eq(Flags::Actions::Dismiss) }
end
context "when action is 'ban'" do
let(... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flags/actions/notify_user_spec.rb | spec/models/flags/actions/notify_user_spec.rb | require 'rails_helper'
RSpec.describe Flags::Actions::NotifyUser do
let(:admin_user) { create(:admin_user) }
let(:flag) { create(:flag) }
describe '#perform' do
context 'when successful' do
it 'discards the project submission in 7 days' do
expect { described_class.perform(admin_user:, flag:) }... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flags/actions/dismiss_spec.rb | spec/models/flags/actions/dismiss_spec.rb | require 'rails_helper'
RSpec.describe Flags::Actions::Dismiss do
let(:admin_user) { create(:admin_user) }
let(:flag) { create(:flag) }
describe '#perform' do
context 'when successful' do
it 'changes the flag action taken to dismissed' do
expect { described_class.perform(admin_user:, flag:) }
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flags/actions/remove_project_submission_spec.rb | spec/models/flags/actions/remove_project_submission_spec.rb | require 'rails_helper'
RSpec.describe Flags::Actions::RemoveProjectSubmission do
let(:admin_user) { create(:admin_user) }
let(:flag) { create(:flag) }
describe '#perform' do
context 'when successful' do
it 'removes the project submission' do
expect { described_class.perform(admin_user:, flag:)... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flags/actions/null_action_spec.rb | spec/models/flags/actions/null_action_spec.rb | require 'rails_helper'
RSpec.describe Flags::Actions::NullAction do
let(:admin_user) { create(:admin_user) }
let(:flag) { create(:flag) }
describe '#perform' do
it 'returns an unsuccessful result' do
result = described_class.perform(admin_user:, flag:)
expect(result).not_to be_success
exp... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/flags/actions/ban_spec.rb | spec/models/flags/actions/ban_spec.rb | require 'rails_helper'
RSpec.describe Flags::Actions::Ban do
let(:admin_user) { create(:admin_user) }
let(:flag) { create(:flag) }
describe '#perform' do
context 'when successful' do
it 'bans the learner' do
project_submission_owner = instance_double(User, ban!: true)
allow(flag).to re... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/github/push_event_spec.rb | spec/models/github/push_event_spec.rb | require 'rails_helper'
RSpec.describe Github::PushEvent do
subject(:push_event) { described_class.new(payload) }
let(:payload) do
{
ref:,
head_commit: {
modified: ['url/one', 'url/two'],
}
}
end
let(:ref) { 'refs/heads/main' }
describe '#merged_to_main?' do
context 'wh... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/github/lesson_content_importer_spec.rb | spec/models/github/lesson_content_importer_spec.rb | require 'rails_helper'
RSpec.describe Github::LessonContentImporter do
subject(:importer) { described_class.new(lesson) }
let(:lesson) do
create(
:lesson,
title: 'Ruby Basics',
github_path: '/ruby_basics/variables',
content: create(:content, body: lesson_content)
)
end
let(:le... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/reports/all_lesson_completions_day_stat_spec.rb | spec/models/reports/all_lesson_completions_day_stat_spec.rb | require 'rails_helper'
RSpec.describe Reports::AllLessonCompletionsDayStat do
describe '.for_date_range' do
it 'returns all lesson completion stats for the given date range' do
create(:lesson_completion, created_at: Time.utc(2022, 1, 1))
create(:lesson_completion, created_at: Time.utc(2022, 1, 2))
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/reports/path_lesson_completions_day_stat_spec.rb | spec/models/reports/path_lesson_completions_day_stat_spec.rb | require 'rails_helper'
RSpec.describe Reports::PathLessonCompletionsDayStat do
it { is_expected.to belong_to(:path) }
it { is_expected.to belong_to(:course) }
describe '.for_date_range' do
it 'returns path lesson completion stats for the given date range' do
course = create(:course)
create(:less... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/reports/period_spec.rb | spec/models/reports/period_spec.rb | require 'rails_helper'
RSpec.describe Reports::Period do
describe '.all' do
it 'returns all valid periods' do
periods = described_class.all
expect(periods.map(&:name)).to eq(%w[day month year])
end
end
describe '.find' do
context 'when period with the same name is found' do
it 're... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/reports/user_sign_ups_day_stat_spec.rb | spec/models/reports/user_sign_ups_day_stat_spec.rb | require 'rails_helper'
RSpec.describe Reports::UserSignUpsDayStat do
describe '.for_date_range' do
it 'returns all user sign up stats for the given date range' do
create(:user, created_at: Time.utc(2022, 1, 1))
create(:user, created_at: Time.utc(2022, 1, 2))
create(:user, created_at: Time.utc(2... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/users/theme_spec.rb | spec/models/users/theme_spec.rb | require 'rails_helper'
RSpec.describe Users::Theme do
describe '.default_themes' do
it 'returns the default themes' do
expect(described_class.default_themes).to contain_exactly(
an_object_having_attributes(name: 'light', icon: 'moon'),
an_object_having_attributes(name: 'dark', icon: 'sun')
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/models/notifications/flag_notification_spec.rb | spec/models/notifications/flag_notification_spec.rb | require 'rails_helper'
RSpec.describe Notifications::FlagNotification do
subject(:flag_notification) { described_class }
let(:flag) { create(:flag) }
let(:recipient) { create(:user) }
let(:title) { 'Test title' }
let(:url) { '/test_path' }
let(:message) { 'test message' }
describe 'database delivery' d... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/builders/tailwind_form_builder_spec.rb | spec/builders/tailwind_form_builder_spec.rb | require 'rails_helper'
# To update all snapshots run: `UPDATE_SNAPSHOTS=true rspec spec/builders/tailwind_form_builder_spec.rb`
class TestHelper < ActionView::Base
include InlineSvg::ActionView::Helpers
end
RSpec.describe TailwindFormBuilder do
subject(:builder) { described_class.new(:user, form_object, TestHelp... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/lib/seeds/lesson_builder_spec.rb | spec/lib/seeds/lesson_builder_spec.rb | require './lib/seeds/lesson_builder'
require 'rails_helper'
RSpec.describe Seeds::LessonBuilder do
subject(:lesson_builder) { described_class.build(section, position, attributes) }
let(:section) { create(:section, course:) }
let(:course) { create(:course) }
let(:position) { 1 }
let(:attributes) do
{
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/lib/seeds/path_builder_spec.rb | spec/lib/seeds/path_builder_spec.rb | require './lib/seeds/path_builder'
require 'rails_helper'
RSpec.describe Seeds::PathBuilder do
subject(:path_builder) do
described_class.build do |path|
path.identifier_uuid = 'path_uuid'
path.title = 'Foundations'
path.description = 'a foundation path'
path.position = 1
path.defaul... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/lib/seeds/section_builder_spec.rb | spec/lib/seeds/section_builder_spec.rb | require './lib/seeds/section_builder'
require 'rails_helper'
RSpec.describe Seeds::SectionBuilder do
subject(:section_builder) do
described_class.build(course, position) do |section|
section.identifier_uuid = 'section_uuid'
section.title = 'Basics Section'
section.description = 'a basics sectio... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/lib/seeds/course_builder_spec.rb | spec/lib/seeds/course_builder_spec.rb | require './lib/seeds/course_builder'
require 'rails_helper'
RSpec.describe Seeds::CourseBuilder do
subject(:course_builder) do
described_class.build(path, position) do |course|
course.identifier_uuid = 'course_uuid'
course.title = 'Foundations'
course.description = 'a foundation course'
c... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/lib/kramdown/content_section_spec.rb | spec/lib/kramdown/content_section_spec.rb | require 'rails_helper'
require './lib/kramdown/content_section'
RSpec.describe Kramdown::ContentSection do
describe '#content' do
it 'returns content for the section' do
section = described_class.new(title: 'section title', content: "some markdown\n")
expect(section.content).to eq(
"<sectio... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/spec/lib/kramdown/document_sections_spec.rb | spec/lib/kramdown/document_sections_spec.rb | require 'rails_helper'
require './lib/kramdown/document_sections'
RSpec.describe Kramdown::DocumentSections do
describe '#all_sections' do
context "when content has sectionable headings(h3's)" do
let(:markdown) do
<<~MARKDOWN
### First header
Test first header
### Se... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/lib/seeds/helpers.rb | lib/seeds/helpers.rb | module Seeds
module Helpers
def destroy_removed_seeds(persisted_collection, seeded_collection)
removed_uuids = persisted_collection.map(&:identifier_uuid) - seeded_collection.map(&:identifier_uuid)
persisted_collection.where(identifier_uuid: removed_uuids).find_each(&:destroy)
end
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/lib/seeds/course_builder.rb | lib/seeds/course_builder.rb | require './lib/seeds/helpers'
require './lib/seeds/section_builder'
module Seeds
class CourseBuilder
include Seeds::Helpers
attr_accessor :identifier_uuid, :title, :description, :position, :show_on_homepage, :badge_uri
def initialize(path, position)
@path = path
@position = position
@... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/lib/seeds/lesson_builder.rb | lib/seeds/lesson_builder.rb | module Seeds
class LessonBuilder
def initialize(section, position, attributes)
@section = section
@position = position
@attributes = attributes
end
def self.build(section, position, attributes)
new(section, position, attributes).lesson
end
# rubocop: disable Metrics/AbcSi... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/lib/seeds/path_builder.rb | lib/seeds/path_builder.rb | require './lib/seeds/helpers'
require './lib/seeds/course_builder'
module Seeds
class PathBuilder
include Helpers
attr_accessor :identifier_uuid, :title, :description, :position, :default_path, :short_title, :badge_uri
def initialize
@seeded_courses = []
yield(self)
@path = path
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/lib/seeds/section_builder.rb | lib/seeds/section_builder.rb | # rubocop: disable Style/ClassVars
require './lib/seeds/lesson_builder'
module Seeds
class SectionBuilder
@@total_seeded_lessons = Hash.new(0)
attr_accessor :identifier_uuid, :title, :description, :position
attr_reader :seeded_lessons
def initialize(course, position)
@course = course
@p... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/lib/kramdown/document_sections.rb | lib/kramdown/document_sections.rb | require './lib/kramdown/converter/html_sections'
require './lib/kramdown/content_section'
class Kramdown::DocumentSections < Kramdown::Document
START_OF_CONTENT = 0
END_OF_CONTENT = -1
def initialize(source, options = {})
@source = source
super
end
def all_sections
return [] if sections.none?
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/lib/kramdown/content_section.rb | lib/kramdown/content_section.rb | module Kramdown
class ContentSection
HEADER_LINE = 1
HEADER_AND_NEWLINE = 2
attr_reader :title, :header_location
def initialize(title:, header_location: nil, content: nil)
@title = title
@header_location = header_location
@content = content
end
def content
"<section ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.