Skip to content

Commit

Permalink
Remove method named "hash"
Browse files Browse the repository at this point in the history
We can't use the FixtureResolver as a hash key because it doesn't
implement `hash` correctly.  This commit renames the method to "data"
(which is just as unfortunately named :(  )
  • Loading branch information
tenderlove committed Jan 28, 2019
1 parent 2f9f699 commit a2be6ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions actionview/lib/action_view/testing/resolvers.rb
Expand Up @@ -8,13 +8,15 @@ module ActionView #:nodoc:
# useful for testing extensions that have no way of knowing what the file
# system will look like at runtime.
class FixtureResolver < PathResolver
attr_reader :hash

def initialize(hash = {}, pattern = nil)
super(pattern)
@hash = hash
end

def data
@hash
end

def to_s
@hash.keys.join(", ")
end
Expand Down
12 changes: 6 additions & 6 deletions actionview/test/template/lookup_context_test.rb
Expand Up @@ -162,7 +162,7 @@ def teardown

# Now we are going to change the template, but it won't change the returned template
# since we will hit the cache.
@lookup_context.view_paths.first.hash["test/_foo.erb"] = "Bar"
@lookup_context.view_paths.first.data["test/_foo.erb"] = "Bar"
template = @lookup_context.find("foo", %w(test), true)
assert_equal "Foo", template.source

Expand Down Expand Up @@ -221,12 +221,12 @@ def setup

# Now we are going to change the template, but it won't change the returned template
# since the timestamp is the same.
@resolver.hash["test/_foo.erb"][0] = "Bar"
@resolver.data["test/_foo.erb"][0] = "Bar"
template = @lookup_context.find("foo", %w(test), true)
assert_equal "Foo", template.source

# Now update the timestamp.
@resolver.hash["test/_foo.erb"][1] = Time.now.utc
@resolver.data["test/_foo.erb"][1] = Time.now.utc
template = @lookup_context.find("foo", %w(test), true)
assert_equal "Bar", template.source
end
Expand All @@ -237,7 +237,7 @@ def setup
template = @lookup_context.find("foo", %w(test), true)
assert_equal "Foo", template.source

@resolver.hash.clear
@resolver.data.clear
assert_raise ActionView::MissingTemplate do
@lookup_context.find("foo", %w(test), true)
end
Expand All @@ -246,12 +246,12 @@ def setup

test "if no template was cached in the first lookup, retrieval should work in the second call" do
ActionView::Resolver.stub(:caching?, false) do
@resolver.hash.clear
@resolver.data.clear
assert_raise ActionView::MissingTemplate do
@lookup_context.find("foo", %w(test), true)
end

@resolver.hash["test/_foo.erb"] = ["Foo", Time.utc(2000)]
@resolver.data["test/_foo.erb"] = ["Foo", Time.utc(2000)]
template = @lookup_context.find("foo", %w(test), true)
assert_equal "Foo", template.source
end
Expand Down

0 comments on commit a2be6ce

Please sign in to comment.