clean up plugin store when removing data instead of setting the value to nil.

This commit is contained in:
Erik Ordway 2014-02-24 16:11:31 -08:00
parent 46d1c8c1e0
commit db411860c2
2 changed files with 18 additions and 0 deletions

View File

@ -22,6 +22,13 @@ class PluginStore
row.save
end
def self.remove(plugin_name, key)
if row = PluginStoreRow.where(plugin_name: plugin_name, key: key).first
row.destroy
end
end
protected

View File

@ -10,6 +10,10 @@ describe PluginStore do
PluginStore.get("my_plugin", k)
end
def remove_row(k)
PluginStore.remove("my_plugin", k)
end
it "sets strings correctly" do
set("hello", "world")
expect(get("hello")).to eq("world")
@ -46,4 +50,11 @@ describe PluginStore do
# ensure indiff access holds
expect(result[:hi]).to eq("there")
end
it "removes correctly" do
set("hello", true)
remove_row("hello")
expect(get("hello")).to eq(nil)
end
end