Skip to content

Commit

Permalink
Merge pull request #1284 from tomoasleep/fix-registry-store-delete
Browse files Browse the repository at this point in the history
Make sure deleted object's entries are removed from object_types
  • Loading branch information
lsegal authored Oct 30, 2019
2 parents 890d4ad + 3a4c122 commit 4b5c875
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/yard/registry_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ def put(key, value)
# Deletes an object at a given path
# @param [#to_sym] key the key to delete
# @return [void]
def delete(key) @store.delete(key.to_sym) end
def delete(key)
if @store[key.to_sym]
@object_types[@store[key.to_sym].type].delete(key.to_s)
@store.delete(key.to_sym)
end
end

# Gets all path names from the store. Loads the entire database
# if +reload+ is +true+
Expand Down
11 changes: 11 additions & 0 deletions spec/registry_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,17 @@ def saves_to_multidb
end
end

describe "#delete" do
it "deletes the given object from store" do
@store.put(:YARD, @foo)
expect(@store.get(:YARD)).to be @foo
expect(@store.paths_for_type(:method)).to eq ["YARD"]
@store.delete(:YARD)
expect(@store.get(:YARD)).to be nil
expect(@store.paths_for_type(:method)).to eq []
end
end

describe "#locale" do
it "loads ./po/LOCALE_NAME.po" do
fr_locale = I18n::Locale.new("fr")
Expand Down

0 comments on commit 4b5c875

Please sign in to comment.