aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Respect ENV variables when finding DBs etc for the test suiteMatthew Draper2019-02-0617-36/+114
| | | | | If they're not set we'll still fall back to localhost, but this makes it possible to run the tests against a remote Postgres / Redis / whatever.
* Merge pull request #35139 from 7coAim/fix_debug_exceptionsGeorge Claghorn2019-02-053-2/+6
|\ | | | | Fix NameError : Make debug exceptions works in an environment where ActiveStorage is not loaded.
| * fix NameErrorkurosawat2019-02-053-2/+6
| | | | | | | | NameError: uninitialized constant ActionView::CompiledTemplates::ActiveStorage
* | Merge pull request #35127 from bogdan/counter-cache-loadingRyuta Kamizono2019-02-053-21/+48
|\ \ | | | | | | Bugfix association loading behavior when counter cache is zero
| * | Bugfix association loading behavior when counter cache is zeroBogdan Gusiev2019-02-053-21/+48
| | |
* | | Use ES6 short styleDavid Heinemeier Hansson2019-02-041-3/+3
| | |
* | | Match rails generator outputDavid Heinemeier Hansson2019-02-041-2/+2
| | |
* | | Update Gemfile.lock to reflect `sqlite3` updateyuuji.yaginuma2019-02-051-1/+1
| | | | | | | | | | | | Follow up to #35154.
* | | Merge pull request #35157 from sponomarev/fix/big-report-templates-sqliteRafael França2019-02-042-2/+2
|\ \ \ | | | | | | | | Specify sqlite gem version explicitly in bug report templates
| * | | Specify sqlite gem version explicitly in version-specific bug report templatesSergey Ponomarev2019-02-042-2/+2
| | | |
* | | | Merge pull request #35063 from rosa/current-before-reset-callbackRafael Mendonça França2019-02-043-9/+41
|\ \ \ \ | |/ / / |/| | | | | | | Support before_reset callback in CurrentAttributes
| * | | Support before_reset callback in CurrentAttributesRosa Gutierrez2019-01-303-8/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is useful when we need to do some work associated to `Current.reset` but that work depends on the values of the current attributes themselves. This cannot be done in the supported `resets` callback because when the block is executed, CurrentAttributes's instance has already been reset. For symmetry, `after_reset` is defined as alias of `resets`.
* | | | Merge pull request #35154 from sponomarev/chore/sqlite1.4Aaron Patterson2019-02-042-2/+2
|\ \ \ \ | | | | | | | | | | Relax sqlite3 version dependency
| * | | | Relax sqlite3 version dependencySergey Ponomarev2019-02-042-2/+2
| | | | |
* | | | | Take in to account optional arguments when deprecatingAaron Patterson2019-02-042-1/+10
| | | | | | | | | | | | | | | | | | | | Refs: rails/jbuilder#452
* | | | | Improve performance of blank? and present? in an ActiveRecord::Base instanceRafael Mendonça França2019-02-041-0/+8
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this benchmark: require "bundler/setup" require "active_record" require "benchmark/ips" # This connection will do for database-independent bug reports. ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") ActiveRecord::Schema.define do create_table :posts, force: true do |t| end end class Post < ActiveRecord::Base end new_post = Post.new Benchmark.ips do |b| b.report("present?") do new_post.present? end b.report("blank?") do new_post.blank? end end Before: Warming up -------------------------------------- present? 52.147k i/100ms blank? 53.077k i/100ms Calculating ------------------------------------- present? 580.184k (±21.8%) i/s - 2.555M in 5.427085s blank? 601.537k (± 9.2%) i/s - 2.972M in 5.003503s After: Warming up -------------------------------------- present? 378.235k i/100ms blank? 375.476k i/100ms Calculating ------------------------------------- present? 17.381M (± 7.5%) i/s - 86.238M in 5.001815s blank? 17.877M (± 6.4%) i/s - 88.988M in 5.004634s This improvement is mostly because those methods were hitting `method_missing` on a lot of levels to be able to return the value. To avoid all this stack walking we are short-circuiting those methods. Closes #35059.
* | | | Merge pull request #35134 from Edouard-chin/ec-cookie-expiry-regressionRafael França2019-02-042-16/+4
|\ \ \ \ | | | | | | | | | | Cookie doesn't expire anymore unless a flag is set:
| * | | | Cookie doesn't expire anymore unless a flag is set:Edouard CHIN2019-02-042-16/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - There is a regression in 6.0 introduced by #32937 where cookie doesn't expire anymore unless the new `use_cookies_with_metadata` configuration is set to `true`. This causes issue for app migration from 5.2 to 6.0 because the `use_cookies_with_metadata` flag can't be set to true until all servers are running on 6.0. Here is a small reproduction script that you can run in the console ```ruby ActionDispatch::Cookies request = ActionDispatch::Request.empty request.env["action_dispatch.key_generator"] = ActiveSupport::KeyGenerator.new('1234567890') request.env["action_dispatch.signed_cookie_salt"] = 'signed cookie' request.env["action_dispatch.cookies_rotations"] = ActiveSupport::Messages::RotationConfiguration.new request.env["action_dispatch.use_authenticated_cookie_encryption"] = true signed_cookie = request.cookie_jar.signed signed_cookie[:foobar] = { value: '123', expires: 1.day.ago } p signed_cookie[:foobar] ```
* | | | | Merge pull request #35152 from ↵Vipul A M2019-02-041-0/+2
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | scpike/guides-link-to-core-ext-string-inquiry-source Add a link to where "inquiry" is defined in ActiveSupport docs [ci skip]
| * | | | | Add a link to where "inquiry" is defined in ActiveSupport docsStephen Pike2019-02-041-0/+2
|/ / / / / | | | | | | | | | | | | | | | [ci skip]
* | | | | Merge pull request #35086 from gsamokovarov/cleanup-whitelisting-refsGannon McGibbon2019-02-046-10/+10
|\ \ \ \ \ | | | | | | | | | | | | Cleanup the whitelisting references after #33145
| * | | | | Cleanup the whitelisting references after #33145Genadi Samokovarov2019-02-036-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During the development of #33145, I have named a few concepts in the code as `whitelisted`. We decided to stay away from the term and I adjusted most of the code afterwards, but here are the cases I forgot to change. I also found a case in the API guide that we could have cleaned up as well. [ci skip]
* | | | | | Merge pull request #35149 from utilum/update_guide_missing_tempmlate_textEileen M. Uchitelle2019-02-041-13/+10
|\ \ \ \ \ \ | | | | | | | | | | | | | | Update template missing text in Guide
| * | | | | | Update template missing text in Guideutilum2019-02-041-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes the Getting Started guide explanation for `ActionController::MissingExactTemplate` error, to reflect the current message. Follow up for #29286, #35148 [ci skip]
* | | | | | | Allow configuring the Azure Storage service with extra client optionsgarytaylor2019-02-041-2/+2
| | | | | | |
* | | | | | | Merge pull request #35089 from ↵Eileen M. Uchitelle2019-02-043-1/+48
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | eileencodes/fix-query-cache-for-database-switching Invalidate all query caches for current thread
| * | | | | | | Invalidate query cache for all connections in the current threadEileen Uchitelle2019-02-013-1/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change ensures that all query cahces are cleared across all connections per handler for the current thread so if you write on one connection the read will have the query cache cleared.
* | | | | | | | Merge pull request #35132 from ↵Eileen M. Uchitelle2019-02-046-4/+56
|\ \ \ \ \ \ \ \ | |_|/ / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | eileencodes/allow-application-to-change-handler-names Add ability to change the names of the default handlers
| * | | | | | | Add ability to change the names of the default handlersEileen Uchitelle2019-02-016-4/+56
| |/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When I wrote the `connected_to` and `connects_to` API's I wrote them with the idea in mind that it didn't really matter what the handlers/roles were called as long as those connecting to the roles knew which one wrote and which one read. With the introduction of the middleware Rails begins to assume it's `writing` and `reading` and there's no room for other roles. At GitHub we've been using this method for a long time so we have a ton of legacy code that uses different handler names `default` and `readonly`. We could rename all our code but I think this is better for a few reasons: - Legacy apps that have been using multiple databases for a long time can have an eaiser time switching. - If we later find this to cause more issues than it's worth we can easily deprecate. - We won't force old apps to rewrite the resolver middleware just to use a different handler. Adding the writing_role/reading_role required that I move the code that creates the first handler for writing to the railtie. If I didn't move this the core class would assign the handler before I was able to assign a new one in my configuration and I'd end up with 3 handlers instead of 2.
* | | | | | | Merge pull request #35148 from utilum/update_template_missing_image_in_guideKasper Timm Hansen2019-02-041-0/+0
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Fix and update template_missing image in guide
| * | | | | | | Fix and update template_missing image in guideutilum2019-02-041-0/+0
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit updates the Missing Template image in the Getting Started Guide. The new image displays the current error message. Additionally: - New image is a PNG file, whereas the current image is in fact a misnamed JPEG. - New image is smaller. Before: ``` $ file --mime -b template_is_missing_articles_new.png image/jpeg; charset=binary $ du -h template_is_missing_articles_new.png 464K template_is_missing_articles_new.png ``` After: ``` $ file --mime -b template_is_missing_articles_new.png image/png; charset=binary $ du -h template_is_missing_articles_new.png 28K template_is_missing_articles_new.png ``` [ci-skip]
* | | | | | | Merge pull request #35105 from olivierlacan/document-table-foreign-keyGannon McGibbon2019-02-021-1/+2
|\ \ \ \ \ \ \ | |_|_|_|_|_|/ |/| | | | | | Hint at advanced options for foreign_key
| * | | | | | Hint at advanced options for foreign_keyOlivier Lacan2019-01-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We sometimes display simple examples of additional parameters that can be supplied to table-wise methods like these and I found it particularly difficult to figure out which options `t.foreign_key` accepts without drilling very deep into the specific SchemaStatements docs. Since it's relatively common to create foreign keys with custom column names or primary keys, it seems like this should help quite a few people. [ci skip]
* | | | | | | Merge pull request #35136 from andyw8/routes-syntaxRafael França2019-02-012-15/+15
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Use consistent hash syntax for routes
| * | | | | | | Use consistent hash syntax for routesAndy Waite2019-02-012-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ci skip]
* | | | | | | | Merge pull request #35119 from rails/file-templateAaron Patterson2019-02-0113-25/+105
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | Introduce a file type template
| * | | | | | | Pass source to template handler and deprecate old style handlerAaron Patterson2019-02-0110-21/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit passes the mutated source to the template handler as a parameter and deprecates the old handlers. Old handlers required that templates contain a reference to mutated source code, but we would like to make template objects "read only". This change lets the template remain "read only" while still giving template handlers access to the source code after mutations.
| * | | | | | | Introduce a file type template, deprecate `Template#refresh`Aaron Patterson2019-02-014-3/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Every template that specifies a "virtual path" loses the template source when the template gets compiled: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/actionview/lib/action_view/template.rb#L275 The "refresh" method seems to think that the source code for a template can be recovered if there is a virtual path: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/actionview/lib/action_view/template.rb#L171-L188 Every call site that allocates a template object *and* provides a "virtual path" reads the template contents from the filesystem: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/actionview/lib/action_view/template/resolver.rb#L229-L231 Templates that are inline or literals don't provide a "virtual path": https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/actionview/lib/action_view/renderer/template_renderer.rb#L34 This commit introduces a `FileTemplate` type that subclasses `Template`. The `FileTemplate` keeps a reference to the filename, and reads the source from the filesystem. This effectively makes the template source immutable. Other classes depended on the source to be mutated while being compiled, so this commit also introduces a temporary way to pass the mutated source to the ERB (or whatever) compiler. See `LegacyTemplate`. I think we should consider it an error to provide a virtual path on a non file type template an non-file templates can't recover their source. Here is an example: https://github.com/rails/rails/blob/eda0f574f129fcd5ad1fc58b55cb6d1db71ea95c/actionview/lib/action_view/testing/resolvers.rb#L53 This provides a "virtual path" so the source code (a string literal) is thrown away after compilation. Clearly we can't recover that string, so I think this should be an error.
| * | | | | | | use the source returned from encode!Aaron Patterson2019-01-311-3/+5
| | | | | | | |
* | | | | | | | Merge pull request #35133 from jhawthorn/faster_notificationsAaron Patterson2019-02-011-8/+23
|\ \ \ \ \ \ \ \ | |_|_|_|_|/ / / |/| | | | | | | Make Notifications::Fanout faster after changing subscriptions
| * | | | | | | Keep cache for strings in notifications/fanoutJohn Hawthorn2019-02-011-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When adding/removing a subscription with a string pattern, it isn't necessary to clear the entire cache, only the cache for the key being added. When adding/removing subscriptions for a regex or to match all events, the full cache is still cleared.
| * | | | | | | Make Notifications::Fanout#listeners_for fasterJohn Hawthorn2019-02-011-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we stored all subscribers in an array, and every time a new message name came in asked each subscriber if they responded to the message. This commit changes Fanout to hash subscribers with a String pattern by their pattern. This way we can look them up directly and only do the O(N) scan over the non-string (Regex or any) patterns.
* | | | | | | | Merge pull request #35130 from rails/move-delay-to-options-argumentEileen M. Uchitelle2019-02-014-11/+61
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Refactor options for database selector middleware
| * | | | | | | | Refactor options for middlewareEileen Uchitelle2019-02-014-11/+61
| | |_|_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now we only have one option that's supported, the delay. However I can see us supporting other options in the future. This PR refactors the options to get passed into the resolver so whether you're using middleware or using the config options you can pass options to the resolver. This will also make it easy to add new options in the future.
* | | | | | | | Merge pull request #35082 from Shopify/eagerly-materialize-test-transactionsRafael França2019-02-013-5/+8
|\ \ \ \ \ \ \ \ | |_|/ / / / / / |/| | | | | | | Eagerly materialize the fixtures transaction
| * | | | | | | Eagerly materialize the fixtures transactionJean Boussier2019-01-293-5/+8
| | |_|_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The transaction used to restore fixtures is an implementation detail that should be abstracted away. Idealy a test should behave the same wether or not transactional fixtures are enabled. However since transactions have been made lazy, the fixture transaction started leaking into tests case. e.g. consider the following (oversimplified) test: ```ruby class SQLSubscriber attr_accessor :sql def initialize @sql = [] end def call(*, event) sql << event[:sql] end end subscriber = SQLSubscriber.new ActiveSupport::Notifications.subscribe("sql.active_record", subscriber) User.connection.execute('SELECT 1', 'Generic name') assert_equal ['SELECT 1'], subscriber.sql ``` On Rails 6 it starts to break because the `sql` array will be `['BEGIN', 'SELECT 1']`. Several things are wrong here: - That transaction is not generated by the tested code, so it shouldn't be visible. - The transaction is not even closed yet, which again doesn't reflect the reality.
* | | | | | | Merge pull request #35131 from alkesh26/activesupport-typo-fixesRyuta Kamizono2019-02-027-7/+7
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | ActiveSupport typo fixes.
| * | | | | | | ActiveSupport typo fixes.alkesh262019-02-017-7/+7
|/ / / / / / /
* | | | | | | Merge pull request #35043 from simoleone/activestorage/s3/content-typeEileen M. Uchitelle2019-02-012-2/+20
|\ \ \ \ \ \ \ | |_|/ / / / / |/| | | | | | include the content type when uploading to S3
| * | | | | | include the content type when uploading to S3Simo Leone2019-01-242-2/+20
| | | | | | |