mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 19:14:11 +08:00
Merge pull request #2005 from eriko/plugin_store_delete
clean up plugin store when removing data instead of setting the value to...
This commit is contained in:
commit
9ebcdfba1f
@ -22,6 +22,11 @@ class PluginStore
|
|||||||
row.save
|
row.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.remove(plugin_name, key)
|
||||||
|
PluginStoreRow.where(plugin_name: plugin_name, key: key).destroy_all
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@ describe PluginStore do
|
|||||||
PluginStore.get("my_plugin", k)
|
PluginStore.get("my_plugin", k)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_row(k)
|
||||||
|
PluginStore.remove("my_plugin", k)
|
||||||
|
end
|
||||||
|
|
||||||
it "sets strings correctly" do
|
it "sets strings correctly" do
|
||||||
set("hello", "world")
|
set("hello", "world")
|
||||||
expect(get("hello")).to eq("world")
|
expect(get("hello")).to eq("world")
|
||||||
@ -46,4 +50,11 @@ describe PluginStore do
|
|||||||
# ensure indiff access holds
|
# ensure indiff access holds
|
||||||
expect(result[:hi]).to eq("there")
|
expect(result[:hi]).to eq("there")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "removes correctly" do
|
||||||
|
set("hello", true)
|
||||||
|
remove_row("hello")
|
||||||
|
expect(get("hello")).to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user