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
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_textarea.rb
Ruby
mit
4,441
main
1,605
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormTextarea < Mechanize::TestCase def setup super @page = @mech.get("http://localhost/tc_textarea.html") end def test_empty_text_area form = @page.forms_with(:name => 'form1').first assert_equal('', form.field_with...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_directory_saver.rb
Ruby
mit
4,441
main
1,326
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeDirectorySaver < Mechanize::TestCase def setup super @uri = URI 'http://example/relative/tc_relative_links.html' @io = StringIO.new 'hello world' end def test_self_save_to in_tmpdir do saver = Mechanize::Direc...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_link.rb
Ruby
mit
4,441
main
5,424
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeLink < Mechanize::TestCase def test_search page = @mech.get("http://localhost/find_link.html") link = page.link_with(text: "Form Test") assert_equal('Form Test', link.text) link_with_search = page.link_with(search: "//*...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize.rb
Ruby
mit
4,441
main
36,944
# coding: utf-8 # frozen_string_literal: true require 'mechanize/test_case' class TestMechanize < Mechanize::TestCase def setup super @uri = URI 'http://example/' @req = Net::HTTP::Get.new '/' @res = Net::HTTPOK.allocate @res.instance_variable_set :@code, 200 @res.instance_variable_set :@...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
examples/latest_user_agents.rb
Ruby
mit
4,441
main
3,257
require 'mechanize' require 'ostruct' # LatestUAFetcher fetches latest user agents from `WhatIsMyBrowser.com`. # It can use to update `Mechanize::AGENT_ALIASES`. class LatestUAFetcher attr_reader :user_agents USER_AGENT_TYPES = OpenStruct.new( linux_firefox: "Linux Firefox", mac_firefox: "Mac Firefox", ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
examples/spider.rb
Ruby
mit
4,441
main
469
require 'rubygems' require 'mechanize' agent = Mechanize.new agent.max_history = nil # unlimited history stack = agent.get(ARGV[0]).links while l = stack.pop next unless l.uri host = l.uri.host next unless host.nil? or host == agent.history.first.uri.host next if agent.visited? l.href puts "crawling #{l.ur...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
examples/rubygems.rb
Ruby
mit
4,441
main
665
# This example logs a user in to rubygems and prints out the body of the # page after logging the user in. require 'rubygems' require 'mechanize' require 'logger' # Create a new mechanize object mech = Mechanize.new mech.log = Logger.new $stderr mech.agent.http.debug_output = $stderr # Load the rubygems website page ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
examples/wikipedia_links_to_philosophy.rb
Ruby
mit
4,441
main
3,117
require 'mechanize' require 'tsort' ## # This example implements the alt-text of http://xkcd.com/903/ which states: # # Wikipedia trivia: if you take any article, click on the first link in the # article text not in parentheses or italics, and then repeat, you will # eventually end up at "Philosophy". class Wikipedia...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
examples/flickr_upload.rb
Ruby
mit
4,441
main
518
require 'rubygems' require 'mechanize' agent = Mechanize.new # Get the flickr sign in page page = agent.get 'http://flickr.com/signin/flickr/' # Fill out the login form form = page.form_with :name => 'flickrloginform' form.email = ARGV[0] form.password = ARGV[1] form.submit # Go to the upload page page...
github
rails/jbuilder
https://github.com/rails/jbuilder
Rakefile
Ruby
mit
4,413
main
403
# frozen_string_literal: true require "bundler/setup" require "bundler/gem_tasks" require "rake/testtask" if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"] require "appraisal/task" Appraisal::Task.new task default: :appraisal else Rake::TestTask.new do |test| require "rails/version" test.libs << "test" ...
github
rails/jbuilder
https://github.com/rails/jbuilder
Appraisals
Ruby
mit
4,413
main
442
# frozen_string_literal: true appraise "rails-7-0" do gem "rails", "~> 7.0.0" gem "concurrent-ruby", "< 1.3.5" # to avoid problem described in https://github.com/rails/rails/pull/54264 end appraise "rails-7-1" do gem "rails", "~> 7.1.0" end appraise "rails-7-2" do gem "rails", "~> 7.2.0" end appraise "rails...
github
rails/jbuilder
https://github.com/rails/jbuilder
jbuilder.gemspec
Ruby
mit
4,413
main
1,177
# frozen_string_literal: true require_relative "lib/jbuilder/version" Gem::Specification.new do |s| s.name = 'jbuilder' s.version = Jbuilder::VERSION s.authors = 'David Heinemeier Hansson' s.email = 'david@basecamp.com' s.summary = 'Create JSON structures via a Builder-style DSL' s.homepage = 'h...
github
rails/jbuilder
https://github.com/rails/jbuilder
test/jbuilder_generator_test.rb
Ruby
mit
4,413
main
2,517
require 'test_helper' require 'rails/generators/test_case' require 'generators/rails/jbuilder_generator' class JbuilderGeneratorTest < Rails::Generators::TestCase tests Rails::Generators::JbuilderGenerator arguments %w(Post title body:text password:digest) destination File.expand_path('../tmp', __FILE__) setup...
github
rails/jbuilder
https://github.com/rails/jbuilder
test/scaffold_controller_generator_test.rb
Ruby
mit
4,413
main
4,332
require 'test_helper' require 'rails/generators/test_case' require 'generators/rails/scaffold_controller_generator' class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase tests Rails::Generators::ScaffoldControllerGenerator arguments %w(Post title body:text images:attachments --skip-routes) destinat...
github
rails/jbuilder
https://github.com/rails/jbuilder
test/jbuilder_dependency_tracker_test.rb
Ruby
mit
4,413
main
2,098
require 'test_helper' require 'jbuilder/jbuilder_dependency_tracker' class FakeTemplate attr_reader :source, :handler def initialize(source, handler = :jbuilder) @source, @handler = source, handler end end class JbuilderDependencyTrackerTest < ActiveSupport::TestCase def make_tracker(name, sour...
github
rails/jbuilder
https://github.com/rails/jbuilder
test/test_helper.rb
Ruby
mit
4,413
main
1,065
require "bundler/setup" require "rails" require "jbuilder" require "active_support/core_ext/array/access" require "active_support/cache/memory_store" require "active_support/json" require "active_model" require 'action_controller/railtie' require 'action_view/railtie' require "active_support/testing/autorun" requir...
github
rails/jbuilder
https://github.com/rails/jbuilder
test/scaffold_api_controller_generator_test.rb
Ruby
mit
4,413
main
2,677
require 'test_helper' require 'rails/generators/test_case' require 'generators/rails/scaffold_controller_generator' class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase tests Rails::Generators::ScaffoldControllerGenerator arguments %w(Post title body:text images:attachments --api --skip-routes) ...
github
rails/jbuilder
https://github.com/rails/jbuilder
test/jbuilder_test.rb
Ruby
mit
4,413
main
23,690
require 'test_helper' require 'active_support/inflector' require 'jbuilder' def jbuild(*args, &block) Jbuilder.new(*args, &block).attributes! end Comment = Struct.new(:content, :id) class NonEnumerable def initialize(collection) @collection = collection end delegate :map, :count, to: :@collection end c...
github
rails/jbuilder
https://github.com/rails/jbuilder
test/jbuilder_template_test.rb
Ruby
mit
4,413
main
13,908
require "test_helper" require "action_view/testing/resolvers" class JbuilderTemplateTest < ActiveSupport::TestCase POST_PARTIAL = <<-JBUILDER json.extract! post, :id, :body json.author do first_name, last_name = post.author_name.split(nil, 2) json.first_name first_name json.last_name last_n...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/jbuilder.rb
Ruby
mit
4,413
main
9,939
# frozen_string_literal: true require 'active_support' require 'jbuilder/jbuilder' require 'jbuilder/blank' require 'jbuilder/key_formatter' require 'jbuilder/errors' require 'json' require 'active_support/core_ext/hash/deep_merge' class Jbuilder @@key_formatter = nil @@ignore_nil = false @@deep_format_keys ...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/jbuilder/jbuilder_template.rb
Ruby
mit
4,413
main
7,936
# frozen_string_literal: true require 'jbuilder/jbuilder' require 'jbuilder/collection_renderer' require 'action_dispatch/http/mime_type' require 'active_support/cache' class JbuilderTemplate < Jbuilder class << self attr_accessor :template_lookup_options end self.template_lookup_options = { handlers: [:jb...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/jbuilder/jbuilder_dependency_tracker.rb
Ruby
mit
4,413
main
2,006
# frozen_string_literal: true class Jbuilder::DependencyTracker EXPLICIT_DEPENDENCY = /# Template Dependency: (\S+)/ # Matches: # json.partial! "messages/message" # json.partial!('messages/message') # DIRECT_RENDERS = / \w+\.partial! # json.partial! \(?\s* # optional par...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/jbuilder/railtie.rb
Ruby
mit
4,413
main
951
# frozen_string_literal: true require 'rails' require 'jbuilder/jbuilder_template' class Jbuilder class Railtie < ::Rails::Railtie initializer :jbuilder do ActiveSupport.on_load :action_view do ActionView::Template.register_template_handler :jbuilder, JbuilderHandler require 'jbuilder/jbui...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/jbuilder/collection_renderer.rb
Ruby
mit
4,413
main
1,396
# frozen_string_literal: true require 'delegate' require 'action_view' require 'action_view/renderer/collection_renderer' class Jbuilder class CollectionRenderer < ::ActionView::CollectionRenderer # :nodoc: class ScopedIterator < ::SimpleDelegator # :nodoc: include Enumerable def initialize(obj, sc...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/jbuilder/key_formatter.rb
Ruby
mit
4,413
main
772
# frozen_string_literal: true require 'jbuilder/jbuilder' class Jbuilder class KeyFormatter def initialize(*formats, **formats_with_options) @mutex = Mutex.new @formats = formats @formats_with_options = formats_with_options @cache = {} end def format(key) @cache[key] || @m...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/jbuilder/errors.rb
Ruby
mit
4,413
main
608
# frozen_string_literal: true require 'jbuilder/version' class Jbuilder class NullError < ::NoMethodError def self.build(key) message = "Failed to add #{key.to_s.inspect} property to null object" new(message) end end class ArrayError < ::StandardError def self.build(key) message =...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/generators/rails/scaffold_controller_generator.rb
Ruby
mit
4,413
main
523
# frozen_string_literal: true require 'rails/generators' require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator' module Rails module Generators class ScaffoldControllerGenerator source_paths << File.expand_path('../templates', __FILE__) hook_for :jbuilder, type: :boolean,...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/generators/rails/jbuilder_generator.rb
Ruby
mit
4,413
main
1,979
# frozen_string_literal: true require 'rails/generators/named_base' require 'rails/generators/resource_helpers' module Rails module Generators class JbuilderGenerator < NamedBase # :nodoc: include Rails::Generators::ResourceHelpers source_root File.expand_path('../templates', __FILE__) argum...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/generators/rails/templates/api_controller.rb
Ruby
mit
4,413
main
2,206
<% if namespaced? -%> require_dependency "<%= namespaced_path %>/application_controller" <% end -%> <% module_namespacing do -%> class <%= controller_class_name %>Controller < ApplicationController before_action :set_<%= singular_table_name %>, only: %i[ show update destroy ] # GET <%= route_url %> # GET <%= ro...
github
rails/jbuilder
https://github.com/rails/jbuilder
lib/generators/rails/templates/controller.rb
Ruby
mit
4,413
main
3,121
<% if namespaced? -%> require_dependency "<%= namespaced_path %>/application_controller" <% end -%> <% module_namespacing do -%> class <%= controller_class_name %>Controller < ApplicationController before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ] # GET <%= route_url %> or <%= ro...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
strong_migrations.gemspec
Ruby
mit
4,389
master
656
require_relative "lib/strong_migrations/version" Gem::Specification.new do |spec| spec.name = "strong_migrations" spec.version = StrongMigrations::VERSION spec.summary = "Catch unsafe migrations in development" spec.homepage = "https://github.com/ankane/strong_migrations" spec.licen...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
Gemfile
Ruby
mit
4,389
master
227
source "https://rubygems.org" gemspec gem "rake" gem "minitest" gem "activerecord", "~> 8.1.0" gem "pg", platform: [:ruby, :windows] gem "mysql2", platform: :ruby gem "trilogy", platform: :ruby gem "sqlite3", platform: :ruby
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/misc_test.rb
Ruby
mit
4,389
master
2,324
require_relative "test_helper" class MiscTest < Minitest::Test def test_execute_arbitrary_sql assert_unsafe ExecuteArbitrarySQL end def test_rename_column assert_unsafe RenameColumn end def test_rename_table assert_unsafe RenameTable end def test_rename_schema assert_unsafe RenameSchem...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/remove_column_test.rb
Ruby
mit
4,389
master
624
require_relative "test_helper" class RemoveColumnTest < Minitest::Test def test_remove_column assert_unsafe RemoveColumn end def test_remove_columns assert_unsafe RemoveColumns end def test_remove_columns_type assert_unsafe RemoveColumnsType, 'self.ignored_columns += ["name", "other"]' end ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/start_after_test.rb
Ruby
mit
4,389
master
678
require_relative "test_helper" class StartAfterTest < Minitest::Test def test_version_safe with_start_after(20170101000001) do assert_safe Version end end def test_version_unsafe with_start_after(20170101000000) do assert_unsafe Version end end def test_revert_version_safe m...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/change_column_null_test.rb
Ruby
mit
4,389
master
1,075
require_relative "test_helper" class ChangeColumnNullTest < Minitest::Test def test_basic if postgresql? assert_unsafe ChangeColumnNull else assert_safe ChangeColumnNull end end def test_constraint skip unless postgresql? assert_safe ChangeColumnNullConstraint end def test_...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/add_column_test.rb
Ruby
mit
4,389
master
2,009
require_relative "test_helper" class AddColumnTest < Minitest::Test def test_default assert_safe AddColumnDefault end def test_default_null skip unless postgresql? assert_safe AddColumnDefaultNull end def test_default_not_null skip unless postgresql? assert_unsafe AddColumnDefaultNotNul...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/test_helper.rb
Ruby
mit
4,389
master
4,173
require "bundler/setup" Bundler.require(:default) require "minitest/autorun" require_relative "support/active_record" require_relative "support/helpers" class Minitest::Test include Helpers def migrate(migration, direction: :up, version: 123) schema_migration.delete_all_versions migration = migration.new...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/alphabetize_schema_test.rb
Ruby
mit
4,389
master
1,071
require_relative "test_helper" class AlphabetizeSchemaTest < Minitest::Test def test_default schema = dump_schema if ar_version >= 8.1 expected_columns = <<-EOS t.string "name" t.bigint "order_id" EOS else expected_columns = <<-EOS t.string "name" t.string "city" ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/add_check_constraint_test.rb
Ruby
mit
4,389
master
805
require_relative "test_helper" class AddCheckConstraintTest < Minitest::Test def test_basic assert_unsafe AddCheckConstraint end def test_safe if postgresql? assert_safe AddCheckConstraintSafe else assert_unsafe AddCheckConstraintSafe end end def test_validate_same_transaction ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/check_down_test.rb
Ruby
mit
4,389
master
1,483
require_relative "test_helper" class CheckDownTest < Minitest::Test def test_basic migrate CheckDown with_check_down do assert_unsafe CheckDown, direction: :down end assert_safe CheckDown, direction: :down end def test_safe migrate CheckDownSafe with_check_down do assert_safe...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/remove_index_test.rb
Ruby
mit
4,389
master
1,430
require_relative "test_helper" class RemoveIndexTest < Minitest::Test def test_concurrently skip unless postgresql? migrate AddIndexConcurrently begin StrongMigrations.enable_check(:remove_index) assert_unsafe RemoveIndex, "remove_index :users, :name, algorithm: :concurrently" assert_u...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/add_unique_constraint_test.rb
Ruby
mit
4,389
master
349
require_relative "test_helper" class AddUniqueConstraintTest < Minitest::Test def setup skip unless postgresql? super end def test_basic assert_unsafe AddUniqueConstraint end def test_using_index assert_safe AddUniqueConstraintUsingIndex end def test_new_table assert_safe AddUnique...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/change_column_default_test.rb
Ruby
mit
4,389
master
931
require_relative "test_helper" class ChangeColumnDefaultTest < Minitest::Test def test_partial_inserts with_partial_inserts(true) do assert_unsafe ChangeColumnDefault end end def test_partial_inserts_hash with_partial_inserts(true) do assert_unsafe ChangeColumnDefaultHash end end ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/change_column_test.rb
Ruby
mit
4,389
master
5,658
require_relative "test_helper" class ChangeColumnTest < Minitest::Test def test_unsafe assert_unsafe ChangeColumn end def test_varchar_to_text skip unless postgresql? assert_safe ChangeColumnVarcharToText end def test_varchar_to_citext skip unless postgresql? assert_safe ChangeColumnVar...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/multiple_databases_test.rb
Ruby
mit
4,389
master
1,907
require_relative "test_helper" class MultipleDatabasesTest < Minitest::Test def test_target_version skip unless postgresql? with_target_version({primary: 12, animals: 16}) do with_database(:primary) do # TODO use new check # assert_unsafe AddColumnDefault end with_database(...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/add_reference_test.rb
Ruby
mit
4,389
master
2,901
require_relative "test_helper" class AddReferenceTest < Minitest::Test def test_basic if postgresql? assert_unsafe AddReference else assert_safe AddReference end end def test_polymorphic if postgresql? assert_unsafe AddReferencePolymorphic else assert_safe AddReferenc...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/add_foreign_key_test.rb
Ruby
mit
4,389
master
666
require_relative "test_helper" class AddForeignKeyTest < Minitest::Test def test_basic assert_unsafe AddForeignKey end def test_safe skip unless postgresql? assert_safe AddForeignKeySafe end def test_validate_same_transaction skip unless postgresql? assert_unsafe AddForeignKeyValidate...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/add_index_test.rb
Ruby
mit
4,389
master
3,409
require_relative "test_helper" class AddIndexTest < Minitest::Test def test_non_concurrently if postgresql? assert_unsafe AddIndex, <<~EOF Adding an index non-concurrently blocks writes. Instead, use: class AddIndex < ActiveRecord::Migration[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/timeouts_test.rb
Ruby
mit
4,389
master
7,579
require_relative "test_helper" class TimeoutsTest < Minitest::Test def teardown reset_timeouts end def test_timeouts skip unless postgresql? || mysql? || mariadb? StrongMigrations.statement_timeout = 1.hour StrongMigrations.transaction_timeout = 2.hours StrongMigrations.lock_timeout = 10.se...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/add_exclusion_constraint_test.rb
Ruby
mit
4,389
master
282
require_relative "test_helper" class AddExclusionConstraintTest < Minitest::Test def setup skip unless postgresql? super end def test_basic assert_unsafe AddExclusionConstraint end def test_new_table assert_safe AddExclusionConstraintNewTable end end
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/safe_by_default_test.rb
Ruby
mit
4,389
master
6,748
require_relative "test_helper" class SafeByDefaultTest < Minitest::Test def setup StrongMigrations.safe_by_default = true super end def teardown StrongMigrations.safe_by_default = false end def test_add_index assert_safe AddIndexes end def test_add_index_invalid skip unless postgre...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/add_check_constraint.rb
Ruby
mit
4,389
master
1,232
class AddCheckConstraint < TestMigration def change add_check_constraint :users, "credit_score > 0" end end class AddCheckConstraintSafe < TestMigration def change add_check_constraint :users, "credit_score > 0", validate: false end end class AddCheckConstraintValidateSameTransaction < TestMigration ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/add_exclusion_constraint.rb
Ruby
mit
4,389
master
394
class AddExclusionConstraint < TestMigration def change add_exclusion_constraint :users, "credit_score WITH =", using: :gist end end class AddExclusionConstraintNewTable < TestMigration def change create_table :new_users do |t| t.decimal :credit_score, precision: 10, scale: 5 end add_exclu...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/change_column_null.rb
Ruby
mit
4,389
master
2,773
class ChangeColumnNull < TestMigration def change change_column_null :users, :name, false end end class ChangeColumnNullConstraint < TestMigration def up safety_assured do execute 'ALTER TABLE "users" ADD CONSTRAINT "test" CHECK ("name" IS NOT NULL) NOT VALID' execute 'ALTER TABLE "users" VAL...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/remove_column.rb
Ruby
mit
4,389
master
738
class RemoveColumn < TestMigration def change remove_column :users, :name, :string end end class RemoveColumns < TestMigration def change remove_columns :users, :name, :other end end class RemoveColumnsType < TestMigration def change remove_columns :users, :name, :other, type: :text end end c...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/change_column.rb
Ruby
mit
4,389
master
10,200
class ChangeColumn < TestMigration def change change_column :users, :properties, :bad_name end end class ChangeColumnVarcharToText < TestMigration def up change_column :users, :name, :text end def down change_column :users, :name, :string end end class ChangeColumnVarcharToCitext < TestMigrat...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/misc.rb
Ruby
mit
4,389
master
1,477
class ExecuteArbitrarySQL < TestMigration def change execute "SELECT 1" end end class RenameColumn < TestMigration def change rename_column :users, :properties, :bad_name end end class RenameTable < TestMigration def change rename_table :users, :bad_name end end class RenameSchema < TestMigra...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/add_index.rb
Ruby
mit
4,389
master
2,318
class AddIndex < TestMigration def change add_index :users, :name end end class AddIndexes < TestMigration def change add_index :users, :name add_index :users, :city end end class AddIndexUnique < TestMigration def change add_index :users, :name, unique: true end end class AddIndexUp < Te...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/remove_index.rb
Ruby
mit
4,389
master
1,202
class RemoveIndex < TestMigration def change remove_index :users, :name end end class RemoveIndexColumn < TestMigration def change remove_index :users, column: :name end end class RemoveIndexName < TestMigration def change remove_index :users, name: "my_index" end end class RemoveIndexOptions...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/timeouts.rb
Ruby
mit
4,389
master
2,286
class CheckTimeouts < TestMigration include Helpers def change safety_assured { execute "SELECT 1" } $statement_timeout = if postgresql? connection.select_all("SHOW statement_timeout").first["statement_timeout"] elsif mysql? connection.select_all("SHOW VARIABLES LIKE 'max_execu...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/change_column_default.rb
Ruby
mit
4,389
master
421
class ChangeColumnDefault < TestMigration def change change_column_default :users, :name, "Test" end end class ChangeColumnDefaultHash < TestMigration def change change_column_default :users, :name, from: nil, to: "Test" end end class ChangeColumnDefaultNewColumn < TestMigration def change add_c...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/add_reference.rb
Ruby
mit
4,389
master
2,648
class AddReference < TestMigration def change add_reference :users, :device, index: true end end class AddReferencePolymorphic < TestMigration def change add_reference :users, :device, polymorphic: true, index: true end end class AddReferenceNoIndex < TestMigration def change add_reference :user...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/add_foreign_key.rb
Ruby
mit
4,389
master
1,441
class AddForeignKey < TestMigration def change add_foreign_key :users, :orders end end class AddForeignKeySafe < TestMigration def change add_foreign_key :users, :orders, validate: false end end class AddForeignKeyValidateSameTransaction < TestMigration def change add_foreign_key :users, :orders...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/add_unique_constraint.rb
Ruby
mit
4,389
master
586
class AddUniqueConstraint < TestMigration def change add_unique_constraint :users, :name end end class AddUniqueConstraintUsingIndex < TestMigration disable_ddl_transaction! def up add_index :users, :name, unique: true, algorithm: :concurrently add_unique_constraint :users, using_index: "index_use...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/check_down.rb
Ruby
mit
4,389
master
840
class CheckDown < TestMigration def up add_column :users, :age, :integer end def down remove_column :users, :age end end class CheckDownSafe < TestMigration def up add_column :users, :age, :integer end def down safety_assured do remove_column :users, :age end end end class ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/migrations/add_column.rb
Ruby
mit
4,389
master
2,626
class AddColumnDefault < TestMigration def change add_column :users, :nice, :boolean, default: true end end class AddColumnDefaultNull < TestMigration def change add_column :users, :nice, :boolean, default: nil end end class AddColumnDefaultNotNull < TestMigration def change add_column :users, :...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/support/helpers.rb
Ruby
mit
4,389
master
523
module Helpers def postgresql? $adapter == "postgresql" end def mysql? ($adapter == "mysql2" || $adapter == "trilogy") && !ActiveRecord::Base.connection.mariadb? end def mariadb? ($adapter == "mysql2" || $adapter == "trilogy") && ActiveRecord::Base.connection.mariadb? end def postgresql_ver...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
test/support/active_record.rb
Ruby
mit
4,389
master
1,856
require "active_record" # needed for target_version module Rails class << self attr_accessor :env end self.env = ActiveSupport::StringInquirer.new("test") end $adapter = ENV["ADAPTER"] || "postgresql" connection_options = { adapter: $adapter, database: "strong_migrations_test" } if $adapter == "mysql2" ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations.rb
Ruby
mit
4,389
master
3,092
# dependencies require "active_support" # adapters require_relative "strong_migrations/adapters/abstract_adapter" require_relative "strong_migrations/adapters/mysql_adapter" require_relative "strong_migrations/adapters/mariadb_adapter" require_relative "strong_migrations/adapters/postgresql_adapter" # modules require...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/schema_dumper.rb
Ruby
mit
4,389
master
725
module StrongMigrations module SchemaDumper def initialize(connection, ...) return super unless StrongMigrations.alphabetize_schema super(WrappedConnection.new(connection), ...) end end class WrappedConnection delegate_missing_to :@connection def initialize(connection) @connec...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/error_messages.rb
Ruby
mit
4,389
master
9,966
module StrongMigrations self.error_messages = { add_column_default: "Adding a column with a %{default_type} default blocks %{rewrite_blocks} while the entire table is rewritten. Instead, add the column without a default value, then change the default. class %{migration_name} < ActiveRecord::Migration%{migration_...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/migration.rb
Ruby
mit
4,389
master
1,122
module StrongMigrations module Migration def migrate(direction) strong_migrations_checker.direction = direction super connection.begin_db_transaction if strong_migrations_checker.transaction_disabled end def method_missing(method, *args) return super if is_a?(ActiveRecord::Schema)...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/migration_context.rb
Ruby
mit
4,389
master
913
module StrongMigrations module MigrationContext def up(...) super rescue => e strong_migrations_process_exception(e) end def down(...) super rescue => e strong_migrations_process_exception(e) end def run(...) super rescue => e strong_migrations_pro...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/checker.rb
Ruby
mit
4,389
master
8,344
module StrongMigrations class Checker include Checks include SafeMethods attr_accessor :direction, :transaction_disabled, :timeouts_set class << self attr_accessor :safe end def initialize(migration) @migration = migration reset end def reset @new_tables = [...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/safe_methods.rb
Ruby
mit
4,389
master
5,483
module StrongMigrations module SafeMethods def safe_by_default_method?(method) StrongMigrations.safe_by_default && !version_safe? && [:add_index, :add_belongs_to, :add_reference, :remove_index, :add_foreign_key, :add_check_constraint, :change_column_null].include?(method) end def safe_add_index(*ar...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/checks.rb
Ruby
mit
4,389
master
22,510
# TODO better pattern module StrongMigrations module Checks private def check_add_check_constraint(*args) options = args.extract_options! table, expression = args if !new_table?(table) if postgresql? && options[:validate] != false add_options = options.merge(validate: fal...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/railtie.rb
Ruby
mit
4,389
master
213
# ensure activerecord tasks are loaded first require "active_record/railtie" module StrongMigrations class Railtie < Rails::Railtie rake_tasks do load "tasks/strong_migrations.rake" end end end
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/migrator.rb
Ruby
mit
4,389
master
863
module StrongMigrations module Migrator def ddl_transaction(migration, ...) retries = StrongMigrations.lock_timeout_retries > 0 && use_transaction?(migration) return super unless retries || StrongMigrations.transaction_timeout # handle MigrationProxy class migration = migration.send(:migr...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/adapters/postgresql_adapter.rb
Ruby
mit
4,389
master
7,958
module StrongMigrations module Adapters class PostgreSQLAdapter < AbstractAdapter def name "PostgreSQL" end def min_version "12" end def server_version @version ||= begin target_version(StrongMigrations.target_postgresql_version) do ver...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/adapters/mariadb_adapter.rb
Ruby
mit
4,389
master
754
module StrongMigrations module Adapters class MariaDBAdapter < MySQLAdapter def name "MariaDB" end def min_version "10.5" end def server_version @server_version ||= begin target_version(StrongMigrations.target_mariadb_version) do select...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/adapters/abstract_adapter.rb
Ruby
mit
4,389
master
1,799
module StrongMigrations module Adapters class AbstractAdapter def initialize(checker) @checker = checker end def name "Unknown" end def min_version end def set_statement_timeout(timeout) # do nothing end def set_transaction_timeout(...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/strong_migrations/adapters/mysql_adapter.rb
Ruby
mit
4,389
master
3,732
# note: MariaDB inherits from this adapter # when making changes, be sure to see how it affects it module StrongMigrations module Adapters class MySQLAdapter < AbstractAdapter def name "MySQL" end def min_version "8.0" end def server_version @server_version ...
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/tasks/strong_migrations.rake
Ruby
mit
4,389
master
273
namespace :strong_migrations do # https://www.pgrs.net/2008/03/12/alphabetize-schema-rb-columns/ task :alphabetize_columns do $stderr.puts "Dumping schema" ActiveRecord::Base.logger.level = Logger::INFO StrongMigrations.alphabetize_schema = true end end
github
ankane/strong_migrations
https://github.com/ankane/strong_migrations
lib/generators/strong_migrations/install_generator.rb
Ruby
mit
4,389
master
974
require "rails/generators" module StrongMigrations module Generators class InstallGenerator < Rails::Generators::Base source_root File.join(__dir__, "templates") def create_initializer template "initializer.rb", "config/initializers/strong_migrations.rb" end def start_after ...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
Gemfile
Ruby
mit
4,370
main
2,651
ruby File.read('.ruby-version').strip source 'https://rubygems.org' gem 'rails', '8.1.3' gem 'aasm', '~> 5.5' gem 'barnes', '~> 0.0' gem 'bootsnap', '~> 1.18', require: false gem 'class_variants', '~> 1.1' gem 'cssbundling-rails', '~> 1.4' gem 'devise', '~> 5.0' gem 'devise_invitable', '~> 2.0' gem 'devise-two-facto...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/rails_helper.rb
Ruby
mit
4,370
main
882
if ENV.fetch('COVERAGE', false) require 'simplecov' SimpleCov.start 'rails' end ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../config/environment', __dir__) abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' Rails.root.glob('spec/support/**/*.r...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/lesson_navigation_spec.rb
Ruby
mit
4,370
main
2,235
require 'rails_helper' RSpec.describe 'Navigating Lessons' do let!(:course) { create(:course, path: create(:path, default_path: true)) } let!(:section) { create(:section, position: 1, course:) } let!(:lesson) { create(:lesson, position: 1, section:) } before do sign_in(create(:user)) end describe 'th...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/user_notification_spec.rb
Ruby
mit
4,370
main
2,467
require 'rails_helper' RSpec.describe 'User Notifications' do let!(:flag) { create(:flag, project_submission:) } let(:project_submission) { create(:project_submission, lesson:, user: submission_owner) } let(:lesson) { create(:lesson, is_project: true, accepts_submission: true, previewable: true) } let(:submiss...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/select_path_spec.rb
Ruby
mit
4,370
main
1,094
require 'rails_helper' RSpec.describe 'Selecting Paths' do let!(:default_path) { create(:path, title: 'Foundations', default_path: true) } let!(:rails_path) { create(:path, title: 'Rails') } let!(:user) { create(:user, path: default_path) } before do sign_in(user) end context 'when on the paths index...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/user_settings_spec.rb
Ruby
mit
4,370
main
3,432
require 'rails_helper' RSpec.describe 'User Profile' do let!(:user) do create( :user, username: 'Jeremy Beagle', email: 'jezza@beagle.com', learning_goal: 'Learn JavaScript', password: 'password' ) end before do sign_in(user) visit edit_users_profile_path end d...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/all_lesson_project_submissions_spec.rb
Ruby
mit
4,370
main
2,456
require 'rails_helper' RSpec.describe 'View all Project Submissions for a Lesson' do let(:user) { create(:user) } context 'when the lesson accepts project submissions' do let(:lesson) { create(:lesson, :project) } it 'paginates the results' do create_list(:project_submission, 25, lesson:) # rubocop...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/lesson_completion_spec.rb
Ruby
mit
4,370
main
1,392
require 'rails_helper' RSpec.describe 'Lesson Completions' do let!(:user) { create(:user) } let!(:lesson) { create(:lesson) } context 'when user is signed in' do before do sign_in(user) visit lesson_path(lesson) end it 'can complete a lesson' do find(:test_id, 'complete-button').c...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/interview_survey_spec.rb
Ruby
mit
4,370
main
624
require 'rails_helper' RSpec.describe 'Interview survey' do let(:user) { create(:user) } before do sign_in(user) end context 'when the feature is enabled' do before do Flipper.enable(:survey_feature) end it 'shows the survey' do visit new_interview_survey_path expect(page)....
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/sign_in_spec.rb
Ruby
mit
4,370
main
1,725
require 'rails_helper' RSpec.describe 'Sign in' do let!(:user) { create(:user, email: 'odinstudent@example.com') } context 'when using an email and password' do it 'allows the user to sign in' do visit root_path find(:test_id, 'nav-sign-in').click find(:test_id, 'email-field').fill_in(with...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/user_reset_progress_spec.rb
Ruby
mit
4,370
main
1,921
require 'rails_helper' RSpec.describe 'User Reset Progress' do let!(:user) { create(:user) } let!(:foundations_path) { create(:path, title: 'Foundations', default_path: true) } let!(:foundation_course) { create(:course, title: 'Foundations', path: foundations_path) } let!(:rails_path) { create(:path, title: 'R...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/sign_up_spec.rb
Ruby
mit
4,370
main
4,079
require 'rails_helper' RSpec.describe 'Sign Up' do let!(:default_path) { create(:path, title: 'Foundations', default_path: true) } before do visit root_path find(:test_id, 'nav-sign-up').click end context 'when using email and password to sign up' do it 'signs up successfully' do find(:test...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/course_lesson_completion_spec.rb
Ruby
mit
4,370
main
1,084
require 'rails_helper' RSpec.describe 'Course Lesson Completions' do let!(:user) { create(:user) } let!(:path) { create(:path, default_path: true) } let!(:course) { create(:course, path:) } let!(:section) { create(:section, course:) } context 'when user is signed in' do before do create(:lesson, s...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/course_progress_badge_spec.rb
Ruby
mit
4,370
main
1,617
require 'rails_helper' RSpec.describe 'Course Progress Badge' do let!(:path) { create(:path, default_path: true) } let!(:course) { create(:course, path:) } let!(:first_lesson) { create(:lesson, course:) } let!(:second_lesson) { create(:lesson, course:) } context 'when signed in' do before do sign_...
github
TheOdinProject/theodinproject
https://github.com/TheOdinProject/theodinproject
spec/system/admin/sign_in_and_out_spec.rb
Ruby
mit
4,370
main
2,448
require 'rails_helper' RSpec.describe 'Admin sign in and sign out' do describe 'sign in' do context 'with valid credentials' do it 'signs the admin user in' do admin_user = create(:admin_user) visit admin_root_path fill_in 'Email', with: admin_user.email fill_in 'Password'...