This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for(@post) do |f| %> | |
<% if @post.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> | |
<ul> | |
<% @post.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TOTP | |
attr_reader :secret, :digits, :digest, :interval | |
DEFAULT_INTERVAL = 30 | |
DEFAULT_DIGITS = 6 | |
def initialize(s, options = {}) | |
@interval = options[:interval] || DEFAULT_INTERVAL | |
@digits = options[:digits] || DEFAULT_DIGITS | |
@digest = options[:digest] || "sha1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler' | |
Bundler.setup(:default) | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error: | |
BasicsTest#test_group_weirds_by_from: | |
SyntaxError: /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape | |
... attribute_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *arg... | |
... ^ | |
/Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape | |
...te_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args) | |
... ^ | |
/Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape | |
...e_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Failure: | |
RootTest#test_exception_behavior [test/integration/root_test.rb:6]: | |
Expected: 200 | |
Actual: 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def show | |
raise ActiveRecord::RecordNotFound | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test "Can't register with a username that has been taken" do | |
create(:user, username: "already-taken") | |
assert_raises(ActiveRecord::RecordNotSaved) do | |
post "/register", username: "already-taken" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb | |
index 6df5d8f..8d1e7bc 100644 | |
--- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb | |
+++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb | |
@@ -70,6 +70,23 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase | |
Hstore.reset_column_information | |
end | |
+ def test_adding_hstore_column_is_revertable | |
+ hstore_migration = Class.new(ActiveRecord::Migration) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KeyExtractor | |
def self.extract(key_spec, source) | |
new(key_spec.split("."), source).extract | |
end | |
def self.extract_array(key_spec, source) | |
extract(key_spec, source) || [] | |
end | |
def initialize(key_parts, source) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails' | |
require 'action_controller/railtie' | |
class TestApp < Rails::Application | |
config.root = File.dirname(__FILE__) | |
config.session_store :cookie_store, key: 'cookie_store_key' | |
config.secret_token = 'secret_token' | |
config.secret_key_base = 'secret_key_base' | |
config.logger = Logger.new($stdout) |
NewerOlder