-
-
Notifications
You must be signed in to change notification settings - Fork 1k
clear cached templates between specs #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -152,6 +152,9 @@ def _include_controller_helpers | |||
view.lookup_context.prefixes << _controller_path | |||
end | |||
|
|||
# fixes bug with differing formats | |||
view.lookup_context.view_paths.map(&:clear_cache) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be each(&:clear_cache)
, which I think makes more sense since you aren't storing the array returning by map
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why I used map
, I'll change it when the build finishes... (I want to see the state of it after)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woop! Green, I'll change this now then, wait for a second green then merge :)
One of our cukes was failing because Rails caches templates and the differing format seems not to be enough to invalidate it automatically, I'm going to open a Rails patch for this but in the mean time this fixes that cuke.
clear cached templates between specs
clear cached templates between specs Fixes the 2-99 build, see #864
The caching was turned off in [1] because different formats were being cached under the same key. I believe the need to do this was removed in the previous commit. This reduces the time it takes to run FutureLearn’s view specs by about 50%. I think it’s sensible to use the view cache during test because it’s normally on between requests in other environments, and it looks like it was only turned off to work around this caching issue. [1] rspec#864
The caching was turned off in [1] because different formats were being cached under the same key. I believe the need to do this was removed in the previous commit. This reduces the time it takes to run FutureLearn’s view specs by about 50%. I think it’s sensible to use the view cache during test because it’s normally on between requests in other environments, and it looks like it was only turned off to work around this caching issue. [1] rspec#864
Rails expects the format to be a symbol. It filters formats against `Mime::SET.symbols` so formats which are unknown (or are known but are of an unexpected type) are not used in a cache keys for the Rails' `ActionView::Resolver::Cache`. This made the view cache unusable when there was multiple templates with the same name but different format and was the the reason the cache was disabled in [1]. [1] rspec#864
The caching was turned off in [1] because different formats were being cached under the same key. I believe the need to do this was removed in the previous commit. This reduces the time it takes to run FutureLearn’s view specs by 50%. I think it’s sensible to use the view resolver cache during tests because it’s normally on between requests in other environments including when creating tests with `ActionView::TestCase` in a new Rails application. It looks like it was only turned off in rspec-rails to work around this caching issue. [1] rspec#864
Rails expects the format to be a symbol. It filters formats against `Mime::SET.symbols` so formats which are unknown (or are known but are of an unexpected type) are not used in a cache keys for the Rails' `ActionView::Resolver::Cache`. This made the view cache unusable when there was multiple templates with the same name but different format and was the the reason the cache was disabled in [1]. This isn't the only way of fixing this problem- for example Rails could be changed to ensure symbols aren't compared with strings as was suggested in [2], but I feel that it's rspec-rails' responsibility to work with the existing Rails API. [1] rspec#864 [2] rails/rails#13461
The caching was turned off in [1] because different formats were being cached under the same key. I believe the need to do this was removed in the previous commit. This reduces the time it takes to run FutureLearn’s view specs by 50%. I think it’s sensible to use the view resolver cache during tests because it’s normally on between requests in other environments including when creating tests with `ActionView::TestCase` in a new Rails application. It looks like it was only turned off in rspec-rails to work around this caching issue. [1] rspec#864
Rails expects value of the `:format` option be a symbol. It filters formats against `Mime::SET.symbols` so formats which are unknown (or are known but are of an unexpected type) are not used in cache keys for the Rails' `ActionView::Resolver::Cache`. This made the resolver cache unusable when there was multiple templates with the same name but different formats and was the reason the cache was disabled in rspec-rails [1]. This isn't the only way of fixing this problem- for example Rails could be changed to ensure symbols aren't compared with strings as was suggested in [2], but I feel that it's rspec-rails' responsibility to work with the existing Rails API. [1] rspec#864 [2] rails/rails#13461
The caching was turned off in [1] because different formats were being cached under the same key. I believe the need to do this was removed in the previous commit. This reduces the time it takes to run FutureLearn’s view specs by 50%. I think it’s sensible to use the view resolver cache during tests because it’s normally on between requests in other environments including when creating tests with `ActionView::TestCase` in a new Rails application. It looks like it was only turned off in rspec-rails to work around this caching issue. I haven't added any test coverage in this change since it feels like it would be testing a negative (the resolver cache isn't cleared). [1] rspec#864
Rails expects value of the `:format` option be a symbol. It filters formats against `Mime::SET.symbols` so formats which are unknown (or are known but are of an unexpected type) are not used in cache keys for the Rails' `ActionView::Resolver::Cache`. This made the resolver cache unusable when there was multiple templates with the same name but different formats and was the reason the cache was disabled in rspec-rails [1]. This isn't the only way of fixing this problem- for example Rails could be changed to ensure symbols aren't compared with strings as was suggested in [2], but I feel that it's rspec-rails' responsibility to work with the existing Rails API. [1] rspec#864 [2] rails/rails#13461
The caching was turned off in [1] because different formats were being cached under the same key. I believe the need to do this was removed in the previous commit. This reduces the time it takes to run FutureLearn’s view specs by 50%. I think it’s sensible to use the view resolver cache during tests because it’s normally on between requests in other environments including when creating tests with `ActionView::TestCase` in a new Rails application. It looks like it was only turned off in rspec-rails to work around this caching issue. I haven't added any test coverage in this change since it feels like it would be testing a negative (the resolver cache isn't cleared). [1] rspec#864
Rails expects value of the `:format` option be a symbol. It filters formats against `Mime::SET.symbols` so formats which are unknown (or are known but are of an unexpected type) are not used in cache keys for the Rails' `ActionView::Resolver::Cache`. This made the resolver cache unusable when there was multiple templates with the same name but different formats and was the reason the cache was disabled in rspec-rails [1]. This isn't the only way of fixing this problem- for example Rails could be changed to ensure symbols aren't compared with strings as was suggested in [2], but I feel that it's rspec-rails' responsibility to work with the existing Rails API. [1] rspec#864 [2] rails/rails#13461
The caching was turned off in [1] because different formats were being cached under the same key. I believe the need to do this was removed in the previous commit. This reduces the time it takes to run FutureLearn’s view specs by 50%. I think it’s sensible to use the view resolver cache during tests because it’s normally on between requests in other environments including when creating tests with `ActionView::TestCase` in a new Rails application. It looks like it was only turned off in rspec-rails to work around this caching issue. I haven't added any test coverage in this change since it feels like it would be testing a negative (the resolver cache isn't cleared). [1] rspec#864
One of our cukes was failing because Rails caches templates and the differing
format seems not to be enough to invalidate it automatically, I'm going to
open a Rails patch for this but in the mean time this fixes that cuke.