diff --git a/app/models/plugin_store.rb b/app/models/plugin_store.rb index 82a30c711ce..dab22ad8f9a 100644 --- a/app/models/plugin_store.rb +++ b/app/models/plugin_store.rb @@ -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 diff --git a/spec/models/plugin_store_spec.rb b/spec/models/plugin_store_spec.rb index e08788c5b58..1a3f692960a 100644 --- a/spec/models/plugin_store_spec.rb +++ b/spec/models/plugin_store_spec.rb @@ -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