source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20241027033302_create_pages.rb
Ruby
bsd-3-clause
99
main
279
class CreatePages < ActiveRecord::Migration[8.0] def change create_table :pages, force: true, id: false do |t| t.primary_key :id, :string, default: -> { "ULID()" } t.string :request_path, null: false, index: {unique: true} t.timestamps end end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20241128134504_create_polls_answers.rb
Ruby
bsd-3-clause
99
main
370
class CreatePollsAnswers < ActiveRecord::Migration[8.0] def change create_table :polls_answers do |t| t.string :body, null: false t.references :question, null: false, foreign_key: {to_table: :polls_questions} t.integer :position, null: false, default: 0 t.integer :votes_count, null: false,...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20241109124854_create_page_topics.rb
Ruby
bsd-3-clause
99
main
337
class CreatePageTopics < ActiveRecord::Migration[8.0] def change create_table :page_topics do |t| t.references :page, null: false, foreign_key: true, type: :string t.references :topic, null: false, foreign_key: true t.timestamps end add_index :page_topics, [:page_id, :topic_id], unique...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20240624221419_create_newsletter_subscriptions.rb
Ruby
bsd-3-clause
99
main
487
class CreateNewsletterSubscriptions < ActiveRecord::Migration[7.1] def change create_table :newsletter_subscriptions, force: true, id: false do |t| t.primary_key :id, :string, default: -> { "ULID()" } t.references :subscriber, polymorphic: true, index: false, null: false, type: :string t.timesta...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20250116121529_add_revision_timestamps_to_pages.rb
Ruby
bsd-3-clause
99
main
285
class AddRevisionTimestampsToPages < ActiveRecord::Migration[8.1] def change add_column :pages, :revised_at, :datetime, null: true # For manually tracking content revisions add_column :pages, :upserted_at, :datetime, null: true # For automatically tracking upserts end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20240721210055_create_examples_posts.rb
Ruby
bsd-3-clause
99
main
244
class CreateExamplesPosts < ActiveRecord::Migration[7.1] def change create_table :examples_posts do |t| t.string :title, null: false t.references :postable, polymorphic: true, null: false t.timestamps end end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20241027034443_create_page_searches.rb
Ruby
bsd-3-clause
99
main
218
class CreatePageSearches < ActiveRecord::Migration[8.0] def up create_virtual_table :pages_search_index, :fts5, ["title", "body", "page_id"] end def down drop_virtual_table :pages_search_index end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20240826023327_create_active_storage_tables.active_storage.rb
Ruby
bsd-3-clause
99
main
2,121
# This migration comes from active_storage (originally 20170806125915) class CreateActiveStorageTables < ActiveRecord::Migration[7.0] def change # Use Active Record's configured type for primary and foreign keys primary_key_type, foreign_key_type = primary_and_foreign_key_types create_table :active_stora...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20241115130544_create_page_embeddings.rb
Ruby
bsd-3-clause
99
main
226
class CreatePageEmbeddings < ActiveRecord::Migration[8.0] def up create_virtual_table :page_embeddings, :vec0, ["id text primary key", "embedding float[1536]"] end def down drop_table :page_embeddings end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20240607120410_create_email_exchanges.rb
Ruby
bsd-3-clause
99
main
495
class CreateEmailExchanges < ActiveRecord::Migration[7.1] def change create_table :email_exchanges do |t| t.string :email, null: false t.references :user, null: false, foreign_key: true, type: :string t.string :status, null: false, default: 0 # pending t.timestamps end # Ensure t...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate/20250122224749_create_application_events.rb
Ruby
bsd-3-clause
99
main
327
class CreateApplicationEvents < ActiveRecord::Migration[8.1] def change create_table :application_events, force: true, id: false do |t| t.primary_key :id, :string, default: -> { "ULID()" } t.string :type, null: false t.text :metadata t.text :data, null: false t.timestamps end e...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/seeds/development.rb
Ruby
bsd-3-clause
99
main
274
require_relative "default/pages" require_relative "development/color_schemes" require_relative "development/flipper" require_relative "development/newsletters" require_relative "development/pages" require_relative "development/users" require_relative "development/snippets"
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/seeds/production/admin_users.rb
Ruby
bsd-3-clause
99
main
253
# Create admin user account AdminUser.find_or_create_by!( email: Rails.application.credentials.seeds.admin_email ) do |u| password = Rails.application.credentials.seeds.admin_password u.password = password u.password_confirmation = password end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/seeds/development/newsletters.rb
Ruby
bsd-3-clause
99
main
213
require "factory_bot_rails" start_count_newsletters = 5 newsletter_fill_count = start_count_newsletters - Newsletter.count FactoryBot.create_list(:newsletter, newsletter_fill_count) if newsletter_fill_count > 0
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/seeds/development/color_schemes.rb
Ruby
bsd-3-clause
99
main
257
ColorScheme.find_or_create_default hex_json_uicolors = JSON.parse(File.read("./script/colors/data/uicolors-palette-hex.json")) ColorScheme.bulk_load(hex_json_uicolors) { |name| "Custom #{name.titleize}" } Rails.cache.delete("curated_color_scheme_options")
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/seeds/development/users.rb
Ruby
bsd-3-clause
99
main
515
AdminUser.find_or_create_by!( email: "admin@example.com" ) do |u| u.password = "password" u.password_confirmation = "password" end User.find_or_create_by( email: Rails.configuration.x.emails.test_recipient ) do |u| u.password = "password" u.password_confirmation = "password" u.confirmed_at = Time.zone.no...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/seeds/development/snippets.rb
Ruby
bsd-3-clause
99
main
211
require "factory_bot_rails" snippet_count = 20 snippet_fill_count = snippet_count - Snippet.count user = User.first FactoryBot.create_list(:snippet, snippet_fill_count, author: user) if snippet_fill_count > 0
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/seeds/development/topics.rb
Ruby
bsd-3-clause
99
main
5,024
[ "A/B Testing", "Accessibility (a11y)", "ActionCable", "ActionMailbox", "ActionMailer", "ActionPack", "ActionText", "ActionView", "ActiveJob", "ActiveModel", "ActiveRecord", "ActiveStorage", "ActiveSupport", "Algorithms", "Arel", "Artificial Intelligence (AI)", "Authentication", "Au...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_cable/20240914010017_create_compact_channel.rb
Ruby
bsd-3-clause
99
main
588
# frozen_string_literal: true class CreateCompactChannel < ActiveRecord::Migration[7.2] def change change_column :solid_cable_messages, :channel, :binary, limit: 1024, null: false add_column :solid_cable_messages, :channel_hash, :integer, limit: 8, if_not_exists: true add_index :solid_cable_messages, :ch...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_cable/20240514132951_create_solid_cable_messages.rb
Ruby
bsd-3-clause
99
main
251
class CreateSolidCableMessages < ActiveRecord::Migration[7.1] def change create_table :solid_cable_messages, if_not_exists: true do |t| t.text :channel t.text :payload t.timestamps t.index :created_at end end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_queue/20240427193607_create_recurring_executions.solid_queue.rb
Ruby
bsd-3-clause
99
main
560
# This migration comes from solid_queue (originally 20240218110712) class CreateRecurringExecutions < ActiveRecord::Migration[7.1] def change create_table :solid_queue_recurring_executions do |t| t.references :job, index: {unique: true}, null: false t.string :task_key, null: false t.datetime :ru...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_queue/20240211043213_add_missing_index_to_blocked_executions.solid_queue.rb
Ruby
bsd-3-clause
99
main
307
# This migration comes from solid_queue (originally 20240110143450) class AddMissingIndexToBlockedExecutions < ActiveRecord::Migration[7.1] def change add_index :solid_queue_blocked_executions, [:concurrency_key, :priority, :job_id], name: "index_solid_queue_blocked_executions_for_release" end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_queue/20241025133648_create_recurring_tasks.solid_queue.rb
Ruby
bsd-3-clause
99
main
558
# This migration comes from solid_queue (originally 20240719134516) class CreateRecurringTasks < ActiveRecord::Migration[7.1] def change create_table :solid_queue_recurring_tasks do |t| t.string :key, null: false, index: {unique: true} t.string :schedule, null: false t.string :command, limit: 20...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_queue/20240211043212_create_solid_queue_tables.solid_queue.rb
Ruby
bsd-3-clause
99
main
3,748
# This migration comes from solid_queue (originally 20231211200639) class CreateSolidQueueTables < ActiveRecord::Migration[7.0] def change create_table :solid_queue_jobs do |t| t.string :queue_name, null: false t.string :class_name, null: false, index: true t.text :arguments t.integer :pri...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_queue/20241025223628_make_name_not_null.solid_queue.rb
Ruby
bsd-3-clause
99
main
611
# This migration comes from solid_queue (originally 20240813160053) class MakeNameNotNull < ActiveRecord::Migration[7.1] def up SolidQueue::Process.where(name: nil).find_each do |process| process.name ||= [process.kind.downcase, SecureRandom.hex(10)].join("-") process.save! end change_column ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
db/migrate_cache/20240210145644_create_solid_cache_entries.solid_cache.rb
Ruby
bsd-3-clause
99
main
551
# This migration comes from solid_cache (originally 20230724121448) class CreateSolidCacheEntries < ActiveRecord::Migration[7.0] def change create_table :solid_cache_entries do |t| t.binary :key, null: false, limit: 1024 t.binary :value, null: false, limit: 512.megabytes t.datetime :created_at, ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/spec_helper.rb
Ruby
bsd-3-clause
99
main
4,879
# This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be loaded, without a need to explicitly require ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/rails_helper.rb
Ruby
bsd-3-clause
99
main
3,142
# frozen_string_literal: true require_relative "simplecov_helper" # This file is copied to spec/ when you run 'rails generate rspec:install' require "spec_helper" ENV["RAILS_ENV"] ||= "test" require "simplecov" require_relative "../config/environment" # Prevent database truncation if the environment is production a...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/previews/emails/user_mailer_preview.rb
Ruby
bsd-3-clause
99
main
540
# Preview all emails at http://localhost:3000/rails/mailers/emails/user class Emails::UserMailerPreview < ActionMailer::Preview # Preview this email at http://localhost:3000/rails/mailers/emails/user/confirmation def confirmation Emails::UserMailer.confirmation(FactoryBot.build(:user), "confirmation_token") e...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/previews/emails/magic_session_mailer_preview.rb
Ruby
bsd-3-clause
99
main
357
# Preview all emails at http://localhost:3000/rails/mailers/magic_session class Emails::MagicSessionMailerPreview < ActionMailer::Preview def sign_in_link Emails::MagicSessionMailer.sign_in_link(FactoryBot.build(:user), "magic_session_token") end def no_account_found Emails::MagicSessionMailer.no_account...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/previews/emails/admin_user_mailer_preview.rb
Ruby
bsd-3-clause
99
main
268
# Preview all emails at http://localhost:3000/rails/mailers/admin_user class Emails::AdminUserMailerPreview < ActionMailer::Preview def new_user Emails::AdminUserMailer.new_user(admin_user: FactoryBot.build(:admin_user), user: FactoryBot.build(:user)) end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/previews/emails/heartbeat_mailer_preview.rb
Ruby
bsd-3-clause
99
main
236
# Preview all emails at http://localhost:3000/rails/mailers/mailers/heartbeat class Emails::HeartbeatMailerPreview < ActionMailer::Preview def heartbeat Emails::HeartbeatMailer.with(to: "hello@joyofrails.com").heartbeat end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/previews/emails/newsletter_mailer_preview.rb
Ruby
bsd-3-clause
99
main
345
# Preview all emails at http://localhost:3000/rails/mailers/newsletter_mailer class Emails::NewsletterMailerPreview < ActionMailer::Preview def newsletter Emails::NewsletterMailer.newsletter( newsletter: FactoryBot.build(:newsletter), user: FactoryBot.build(:user), unsubscribe_token: "unsubscrib...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/emails/newsletter_mailer_spec.rb
Ruby
bsd-3-clause
99
main
722
require "rails_helper" RSpec.describe Emails::NewsletterMailer, type: :mailer do describe "#newsletter" do let(:newsletter) { instance_double(Newsletter, title: "A Newsletter", content: Faker::Markdown.sandwich(sentences: 3)) } let(:user) { instance_double(User, email: "to@example.com") } let(:mail) { Em...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/emails/heartbeat_mailer_spec.rb
Ruby
bsd-3-clause
99
main
662
require "rails_helper" RSpec.describe Emails::HeartbeatMailer, type: :mailer do it "heartbeat" do # Create the email and store it for further assertions email = Emails::HeartbeatMailer.with(to: "friend@example.com").heartbeat # Send the email, then test that it got queued assert_emails 1 do em...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/emails/magic_session_mailer_spec.rb
Ruby
bsd-3-clause
99
main
1,006
require "rails_helper" RSpec.describe Emails::MagicSessionMailer, type: :mailer do describe "sign_in_link" do let(:user) { instance_double(User, email: "to@example.com") } let(:mail) { Emails::MagicSessionMailer.sign_in_link(user, "token") } it "renders the headers" do expect(mail.subject).to eq("...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/emails/user_mailer_spec.rb
Ruby
bsd-3-clause
99
main
1,504
require "rails_helper" RSpec.describe Emails::UserMailer, type: :mailer do describe "confirmation" do let(:user) { instance_double(User, confirmable_email: "to@example.com") } let(:mail) { Emails::UserMailer.confirmation(user, "token") } it "renders the headers" do expect(mail.subject).to eq("Conf...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/mailers/emails/admin_user_mailer_spec.rb
Ruby
bsd-3-clause
99
main
728
require "rails_helper" RSpec.describe Emails::AdminUserMailer, type: :mailer do describe "new_user" do let(:admin_user) { instance_double(AdminUser, email: "admin@example.com") } let(:user) { instance_double(User, confirmable_email: "user@example.com") } let(:mail) { Emails::AdminUserMailer.new_user(admi...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/newsletter_spec.rb
Ruby
bsd-3-clause
99
main
516
# == Schema Information # # Table name: newsletters # # id :string not null, primary key # content :text not null # sent_at :datetime # title :string not null # created_at :datetime not null # updated_at :datetime not null # # Indexes # # index_n...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/user_spec.rb
Ruby
bsd-3-clause
99
main
2,197
# == Schema Information # # Table name: users # # id :string not null, primary key # confirmed_at :datetime # email :string not null # last_sign_in_at :datetime # name :string # password_digest :string # created_at :datetime not null # update...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/gravatar_spec.rb
Ruby
bsd-3-clause
99
main
293
require "rails_helper" require "faker" RSpec.describe Gravatar do let(:email) { Faker::Internet.email } it "should return the gravatar url" do expect(Gravatar.new(email).url).to eq("https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.downcase)}?s=32&d=retro") end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/color_spec.rb
Ruby
bsd-3-clause
99
main
404
require "rails_helper" RSpec.describe Color do describe "#==" do it { expect(Color.new("#ffffff")).to eq(Color.new("#ffffff")) } it { expect(Color.new("#000000")).to eq(Color.new("#000000")) } it { expect(Color.new("#ffffff")).not_to eq(Color.new("#000000")) } it { expect(Color.new("#ffffff")).not_...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/poll_spec.rb
Ruby
bsd-3-clause
99
main
2,561
# == Schema Information # # Table name: polls # # id :string not null, primary key # title :string not null # created_at :datetime not null # updated_at :datetime not null # author_id :string not null # # Indexes # # index_polls_on_author_id (author_id)...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/snippet_spec.rb
Ruby
bsd-3-clause
99
main
2,058
# == Schema Information # # Table name: snippets # # id :string not null, primary key # author_type :string not null # description :text # filename :string # language :string # source :text not null # title :string # created_at :datetime not nul...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/admin_user_spec.rb
Ruby
bsd-3-clause
99
main
1,397
# == Schema Information # # Table name: admin_users # # id :integer not null, primary key # email :string # password_digest :string not null # created_at :datetime not null # updated_at :datetime not null # # Indexes # # index_admin_users_on_emai...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/guest_spec.rb
Ruby
bsd-3-clause
99
main
249
require "rails_helper" RSpec.describe Guest do it { expect(subject).not_to be_registered } it { expect(subject).not_to be_persisted } it { expect(subject.can_edit?).to be false } it { expect(subject.can_edit?(:anything)).to be false } end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/color_scheme_spec.rb
Ruby
bsd-3-clause
99
main
4,059
# == Schema Information # # Table name: color_schemes # # id :string not null, primary key # name :string not null # weight_100 :string not null # weight_200 :string not null # weight_300 :string not null # weight_400 :string not null # we...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/topic_spec.rb
Ruby
bsd-3-clause
99
main
1,955
# == Schema Information # # Table name: topics # # id :integer not null, primary key # description :text # name :string # pages_count :integer default(0), not null # slug :string not null # status :string default("pending"), not null # created_at ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/page_embedding_spec.rb
Ruby
bsd-3-clause
99
main
1,805
require "rails_helper" RSpec.describe PageEmbedding, type: :model do it "declared openai embedding length" do expect(described_class::OPENAI_EMBEDDING_LENGTH).to eq(1536) end it "serializes and deserializes embedding vector" do embedding = FactoryBot.generate(:random_embedding) page = FactoryBot.cre...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/application_event_spec.rb
Ruby
bsd-3-clause
99
main
948
# == Schema Information # # Table name: application_events # # id :string not null, primary key # data :text not null # metadata :text # type :string not null # created_at :datetime not null # updated_at :datetime not null # # Indexes # # inde...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/page_spec.rb
Ruby
bsd-3-clause
99
main
2,673
# == Schema Information # # Table name: pages # # id :string not null, primary key # indexed_at :datetime # published_at :datetime # request_path :string not null # revised_at :datetime # upserted_at :datetime # created_at :datetime not null # updated_at :datetime ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/application_events/deploy_spec.rb
Ruby
bsd-3-clause
99
main
677
# == Schema Information # # Table name: application_events # # id :string not null, primary key # data :text not null # metadata :text # type :string not null # created_at :datetime not null # updated_at :datetime not null # # Indexes # # inde...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/pwa/user_agent_installation_instructions_spec.rb
Ruby
bsd-3-clause
99
main
720
require "rails_helper" RSpec.describe Pwa::UserAgentInstallationInstructions, type: :model do it { expect(described_class.new("").partial_name).to eq("unsupported") } describe "#partial_name" do common_user_agents = File.read("spec/fixtures/user_agents.txt").split("\n") valid_partial_names = Pwa::NamedIns...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/pwa/named_installation_instructions_spec.rb
Ruby
bsd-3-clause
99
main
583
require "rails_helper" RSpec.describe Pwa::NamedInstallationInstructions, type: :model do describe "self.find" do it { expect { described_class.find(nil) }.to raise_error(ActiveRecord::RecordNotFound) } it { expect { described_class.find("sprinkes_and_rainbows") }.to raise_error(ActiveRecord::RecordNotFound)...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/settings/syntax_highlight_spec.rb
Ruby
bsd-3-clause
99
main
848
require "rails_helper" RSpec.describe Settings::SyntaxHighlight, type: :request do describe "#==" do it { expect(described_class.find("dracula")).to eq(described_class.find("dracula")) } it { expect(described_class.find("darcula")).not_to eq(described_class.find("dracula")) } it { expect(described_class....
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/page/searchable_spec.rb
Ruby
bsd-3-clause
99
main
1,493
require "rails_helper" RSpec.describe Page::Searchable, type: :model do describe ".search" do it "allows searching for pages" do page = FactoryBot.create(:page, :published, request_path: "/") page.update_in_search_index expect(Page.search("Joy of Rails")).to include page end it "works...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/page/similarity_spec.rb
Ruby
bsd-3-clause
99
main
1,256
require "rails_helper" RSpec.describe Page::Similarity, type: :model do describe "#related_pages" do it "finds related articles" do article = FactoryBot.create(:page, :published, request_path: "/articles/web-push-notifications-from-rails") similar = FactoryBot.create(:page, :published, request_path: ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/searches/query_parser_spec.rb
Ruby
bsd-3-clause
99
main
2,366
require "rails_helper" RSpec.describe Searches::QueryParser do subject(:parser) { described_class.new } def parse_query(query) ast = parser.parse(query) puts ast if ENV["DEBUG"] ast rescue Parslet::ParseFailed => error puts error.parse_failure_cause.ascii_tree raise error end it "can pa...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/searches/query_transformer_spec.rb
Ruby
bsd-3-clause
99
main
1,689
require "rails_helper" RSpec.describe Searches::QueryTransformer do subject(:transformer) { described_class.new } let(:parser) { Searches::QueryParser.new } it "transforms a simple query" do ast = parser.parse("hello parslet") query = transformer.apply(ast) expect(query.to_s).to eq("hello parslet")...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/examples/app_file_spec.rb
Ruby
bsd-3-clause
99
main
1,271
require "rails_helper" RSpec.describe Examples::AppFile, type: :model do describe "with path" do subject { described_class.from("config/database.yml") } it { expect(subject.app_path).to eq("config/database.yml") } it { expect(subject.read).to be =~ %r{adapter: sqlite3} } it { expect(subject.readlin...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/models/examples/counter_spec.rb
Ruby
bsd-3-clause
99
main
276
require "rails_helper" RSpec.describe Examples::Counter, type: :model do subject { described_class.new(count: 0) } it { expect(subject.count).to eq(0) } it "increments the count" do subject.assign_attributes(count: 1) expect(subject.count).to eq(1) end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/search_spec.rb
Ruby
bsd-3-clause
99
main
3,198
require "rails_helper" RSpec.describe "Searches", type: :request do describe "GET show" do it "renders empty without search query" do get search_path expect(response).to have_http_status(:success) expect(document).not_to have_content("No results") end it "renders empty without search...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/home_spec.rb
Ruby
bsd-3-clause
99
main
359
require "rails_helper" RSpec.describe "Home page", type: :request do describe "GET /" do it "renders" do get "/" within("main") do expect(response.body).to include("Joy of Rails") end within(".newsletter-banner") do expect(response.body).to include("A spark of joy for yo...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/sitemaps_spec.rb
Ruby
bsd-3-clause
99
main
1,388
require "rails_helper" RSpec.describe "Sitemaps", type: :request do describe "GET /sitemaps" do it "renders list of sitemaps" do get sitemaps_path(format: :xml) expect(response).to have_http_status(200) expect(document).to have_xpath("//sitemapindex/sitemap/loc", text: "http://example.com/site...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/feed_spec.rb
Ruby
bsd-3-clause
99
main
1,662
require "rails_helper" RSpec.describe "Feed", type: :request do let(:curated_colors) do FactoryBot.create_list(:color_scheme, 3) end before do allow(ColorScheme).to receive(:curated).and_return(curated_colors) end describe "GET /feed" do it "renders feed with expected content" do Page.ups...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/www_spec.rb
Ruby
bsd-3-clause
99
main
289
require "rails_helper" RSpec.describe "www", type: :request do before(:each) do host! "www.example.com" end it "redirects www to root domain" do get "/" expect(response.status).to eq(301) expect(response.headers["Location"]).to eq("http://example.com/") end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/pwa_spec.rb
Ruby
bsd-3-clause
99
main
1,017
require "rails_helper" RSpec.describe "PWA resources", type: :request do describe "GET /manifest.json" do it "returns the PWA manifest" do get "/manifest.json" expect(response).to have_http_status(:success) expect(response.content_type).to match(%r{application/manifest\+json}) manifest =...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/color_schemes_spec.rb
Ruby
bsd-3-clause
99
main
1,535
require "rails_helper" RSpec.describe "Color Schemes" do describe "GET /color_schemes" do context "no color schemes exist" do it "renders color schemes with expected content" do get "/color_schemes" expect(response).to have_http_status(:ok) end end context "color schemes exi...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/errors_spec.rb
Ruby
bsd-3-clause
99
main
683
require "rails_helper" RSpec.describe "Errors", type: :request do describe "GET /404" do it "returns a 404 status code" do get "/404" expect(response.body).to include("404 NOT FOUND") expect(response).to have_http_status(404) end end describe "GET /422" do it "returns a 422 status ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/newsletter_spec.rb
Ruby
bsd-3-clause
99
main
612
require "rails_helper" RSpec.describe "/newsletters", type: :request do describe "GET /" do it "renders a successful response" do FactoryBot.create_list(:newsletter, 2) get newsletters_path expect(response).to be_successful end it "renders a successful without newsletters" do g...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/admin_spec.rb
Ruby
bsd-3-clause
99
main
676
require "rails_helper" RSpec.describe "Admin", type: :request do before do allow(Rails.env).to receive(:local?).and_return(false) end describe "GET admin" do context "when signed in as admin user" do before { login_admin_user } it "renders flipper-ui" do get "/admin/flipper/features...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/topics_spec.rb
Ruby
bsd-3-clause
99
main
1,045
require "rails_helper" RSpec.describe "Topics", type: :request do describe "GET /index" do it "returns http success" do article = FactoryBot.create(:page, :published, request_path: "/articles/introducing-joy-of-rails") topic_1 = FactoryBot.create(:topic, :approved) topic_2 = FactoryBot.create(...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/admin_users/sessions_spec.rb
Ruby
bsd-3-clause
99
main
1,955
require "rails_helper" RSpec.describe "AdminUsers::Sessions", type: :request do describe "GET new" do it "returns http success" do get new_admin_users_session_path expect(response).to have_http_status(:success) end it "redirects if already signed in" do login_admin_user get new_a...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/users/sessions_spec.rb
Ruby
bsd-3-clause
99
main
3,980
require "rails_helper" RSpec.describe "Sessions", type: :request do before do Flipper[:user_registration].enable end describe "GET new" do it "succeeds" do get new_users_session_path expect(response).to have_http_status(:ok) end it "redirects if authenticated" do login_user ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/users/passwords_spec.rb
Ruby
bsd-3-clause
99
main
4,536
# frozen_string_literal: true require "rails_helper" RSpec.describe "Passwords", type: :request do before do Flipper[:user_registration].enable end describe "GET new" do it "succeeds" do get new_users_password_path expect(response).to have_http_status(:ok) end it "redirects if aut...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/users/newsletter_subscriptions_spec.rb
Ruby
bsd-3-clause
99
main
10,544
# frozen_string_literal: true require "rails_helper" RSpec.describe "Newsletter Subscriptions", type: :request do describe "GET new" do it "succeeds for signed out user" do get new_users_newsletter_subscription_path expect(response).to have_http_status(:ok) end it "succeeds for signed-in u...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/users/magic_session_tokens_spec.rb
Ruby
bsd-3-clause
99
main
1,896
# frozen_string_literal: true require "rails_helper" RSpec.describe "Magic Sessions", type: :request do before do Flipper[:user_registration].enable end describe "GET new" do it "succeeds" do get new_users_magic_session_token_path expect(response).to have_http_status(:ok) end it "...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/users/registrations_spec.rb
Ruby
bsd-3-clause
99
main
6,138
# frozen_string_literal: true require "rails_helper" RSpec.describe "Registrations", type: :request do before do Flipper[:user_registration].enable end describe "GET new" do it "succeeds for signed out user" do get new_users_registration_path expect(response).to have_http_status(:ok) e...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/users/confirmations_spec.rb
Ruby
bsd-3-clause
99
main
5,393
# frozen_string_literal: true require "rails_helper" RSpec.describe "Confirmations", type: :request do include ActiveSupport::Testing::TimeHelpers describe "POST create" do it "succeeds for unconfirmed user" do user = FactoryBot.create(:user, :unconfirmed) post users_confirmations_path, params: ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/author/snippets_spec.rb
Ruby
bsd-3-clause
99
main
8,907
require "rails_helper" RSpec.describe "/snippets", type: :request do describe "GET /index" do it "renders a successful response" do user = login_as_user Flipper.enable(:snippets, user) FactoryBot.create(:snippet, author: user) get author_snippets_url expect(response).to be_successfu...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/author/polls_spec.rb
Ruby
bsd-3-clause
99
main
6,716
require "rails_helper" RSpec.describe "/polls", type: :request do describe "GET /index" do let(:user) { login_as_user } before do Flipper.enable(:polls, user) end it "renders a successful response" do user = login_as_user Flipper.enable(:polls, user) FactoryBot.create(:poll,...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/author/polls/answers_spec.rb
Ruby
bsd-3-clause
99
main
8,796
require "rails_helper" RSpec.describe "/answers", type: :request do describe "GET /new" do it "renders a successful response" do user = login_as_user poll = FactoryBot.create(:poll, author: user) question = FactoryBot.create(:polls_question, poll:) Flipper.enable(:polls, user) get ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/author/polls/questions_spec.rb
Ruby
bsd-3-clause
99
main
7,917
require "rails_helper" RSpec.describe "/questions", type: :request do describe "GET /new" do it "renders a successful response" do user = login_as_user poll = FactoryBot.create(:poll, author: user) Flipper.enable(:polls, user) get new_author_poll_question_url(poll) expect(response...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/settings/syntax_highlights_spec.rb
Ruby
bsd-3-clause
99
main
3,720
require "rails_helper" RSpec.describe "Settings Syntax Highlights", type: :request do let(:default_syntax_highlight) { Settings::SyntaxHighlight.default } def random_syntax_highlight (Settings::SyntaxHighlight.all - [default_syntax_highlight]).sample end describe "GET syntax_highlights#show" do it "r...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/settings/color_schemes_spec.rb
Ruby
bsd-3-clause
99
main
3,679
require "rails_helper" RSpec.describe "Settings Color Schemes", type: :request do let(:default_color_scheme) { ColorScheme.find_or_create_default } let(:curated_colors) do FactoryBot.create_list(:color_scheme, 3) end before do default_color_scheme allow(ColorScheme).to receive(:curated).and_retur...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/share/snippet_screenshots_spec.rb
Ruby
bsd-3-clause
99
main
1,273
require "rails_helper" RSpec.describe "/snippets/:id/screenshot", type: :request do describe "GET show" do it "is successful" do get share_snippet_screenshot_path(FactoryBot.create(:snippet)) expect(response).to have_http_status(:success) end end describe "GET new" do it "is successful"...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/share/polls_spec.rb
Ruby
bsd-3-clause
99
main
851
require "rails_helper" RSpec.describe "/polls", type: :request do describe "GET /index" do it "renders a successful response" do FactoryBot.create(:poll, author: FactoryBot.create(:user)) get share_polls_url expect(response).to be_successful end it "does not render the New Poll button ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/share/snippets_spec.rb
Ruby
bsd-3-clause
99
main
2,175
require "rails_helper" RSpec.describe "/snippets", type: :request do describe "GET /index" do it "renders a successful response" do FactoryBot.create(:snippet) get share_snippets_url expect(response).to be_successful end it "renders a successful response without filename" do Fact...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/share/polls/votes_spec.rb
Ruby
bsd-3-clause
99
main
1,939
require "rails_helper" RSpec.describe "/votes", type: :request do describe "POST create" do it "creates a vote" do poll = FactoryBot.create(:poll) question = FactoryBot.create(:polls_question, poll: poll) answer = FactoryBot.create(:polls_answer, question: question) expect { post...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/site/conditional_get_spec.rb
Ruby
bsd-3-clause
99
main
4,134
require "rails_helper" RSpec.describe "Site: http caching" do let(:file_path) { Rails.root.join("app", "content", "pages", "articles", "introducing-joy-of-rails.html.mdrb") } let(:file) { File.open(file_path) } before do allow(Rails.application.config.action_controller).to receive(:perform_caching).and_retu...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/site/articles_spec.rb
Ruby
bsd-3-clause
99
main
1,090
require "rails_helper" RSpec.describe "Site: articles" do let(:first_article) { Page.published.first } let(:first_draft) { Page.draft.first } describe "GET /" do it "lists recent published articles" do get "/" expect(response).to have_http_status(:ok) end it "supports preview flag" do ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/pwa/web_pushes_spec.rb
Ruby
bsd-3-clause
99
main
1,243
require "rails_helper" RSpec.describe "/pwa/web_pushes", type: :request do describe "POST" do before do allow(WebPush).to receive(:payload_send) end it "creates a new web push subscription" do title = "Hello" message = "World" subscription = { endpoint: "https://fcm.googl...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/pwa/installation_instructions_spec.rb
Ruby
bsd-3-clause
99
main
1,254
require "rails_helper" require "faker" RSpec.describe "/pwa/installation_instructions", type: :request do describe "GET /pwa/installation_instructions" do it "succeeds with user agent" do get "/pwa/installation_instructions", params: {}, headers: {"HTTP_USER_AGENT" => Faker::Internet.user_agent} exp...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/admin/newsletters_spec.rb
Ruby
bsd-3-clause
99
main
7,073
require "rails_helper" RSpec.describe "/admin/newsletters", type: :request do let(:valid_attributes) { FactoryBot.attributes_for(:newsletter) } let(:invalid_attributes) { {title: "", content: ""} } describe "GET /" do it "renders a successful response" do FactoryBot.create(:newsletter) get admi...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/examples/posts_spec.rb
Ruby
bsd-3-clause
99
main
873
require "rails_helper" RSpec.describe "Examples::Posts", type: :request do describe "GET /index" do context "feature enabled" do before do user = login_user Flipper.enable(:example_posts, user) end it "is successful" do get examples_posts_path expect(response).t...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/requests/examples/counters_spec.rb
Ruby
bsd-3-clause
99
main
1,430
require "rails_helper" RSpec.describe "/examples/counters", type: :request do # This should return the minimal set of attributes required to create a valid # Examples::Counter. As you add validations to Examples::Counter, be sure to # adjust the attributes here as well. let(:valid_attributes) { { cou...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/views/share/polls/question_component_spec.rb
Ruby
bsd-3-clause
99
main
2,102
require "rails_helper" RSpec.describe Share::Polls::QuestionComponent, type: :view do context "when not voted on" do it "renders with no answers" do poll = FactoryBot.create(:poll) question = FactoryBot.create(:polls_question, poll:) render described_class.new(poll, question, voted: false) ...
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/views/share/snippet_tweets/tweet_button_spec.rb
Ruby
bsd-3-clause
99
main
307
require "rails_helper" RSpec.describe Share::SnippetTweets::TweetButton, type: :view do it "renders" do snippet = instance_double(Snippet, **FactoryBot.attributes_for(:snippet)) render Share::SnippetTweets::TweetButton.new(snippet) expect(rendered).to have_css("a[href*='x.com']") end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/views/share/snippet_tweets/tweet_spec.rb
Ruby
bsd-3-clause
99
main
293
require "rails_helper" RSpec.describe Share::SnippetTweets::Tweet, type: :view do it "renders" do snippet = instance_double(Snippet, **FactoryBot.attributes_for(:snippet)) render Share::SnippetTweets::Tweet.new(snippet) expect(rendered).to have_css(".snippet-tweet") end end
github
joyofrails/joyofrails.com
https://github.com/joyofrails/joyofrails.com
spec/views/searches/listbox_spec.rb
Ruby
bsd-3-clause
99
main
1,830
require "rails_helper" RSpec.describe Searches::Listbox, type: :view do let(:search_result) do Data.define(:title, :url, :body) do def to_key = [url.parameterize] def model_name = ActiveModel::Name.new(self, nil, "SearchResult") end end let(:search_result_component) do Class.new(Applica...