-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sitemap updates not propagated to listeners (#327)
- Loading branch information
Showing
2 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe OpenHAB::Core::Sitemaps::Provider do | ||
let(:model_listener) { org.openhab.core.model.core.ModelRepositoryChangeListener.impl { nil } } | ||
let(:provider) { described_class.instance } | ||
|
||
before { provider.addModelChangeListener(model_listener) } | ||
after { provider.removeModelChangeListener(model_listener) } | ||
|
||
describe "#add" do | ||
it "notifies listeners with the correct name" do | ||
allow(model_listener).to receive(:modelChanged) | ||
|
||
sitemaps.build do | ||
sitemap "test" | ||
end | ||
|
||
expect(model_listener).to have_received(:modelChanged) | ||
.with("test.sitemap", org.openhab.core.model.core.EventType::ADDED) | ||
|
||
expect(model_listener).to have_received(:modelChanged) | ||
.with("test.sitemap", org.openhab.core.model.core.EventType::MODIFIED) | ||
ensure | ||
sitemaps.remove("test") | ||
end | ||
end | ||
|
||
describe "#update" do | ||
it "notifies listeners with the correct name" do | ||
sitemaps.build do | ||
sitemap "test" | ||
end | ||
|
||
expect(model_listener).not_to receive(:modelChanged) | ||
.with("test.sitemap", org.openhab.core.model.core.EventType::ADDED) | ||
|
||
expect(model_listener).to receive(:modelChanged) | ||
.with("test.sitemap", org.openhab.core.model.core.EventType::MODIFIED) | ||
|
||
sitemaps.build(update: true) do | ||
sitemap "test" | ||
end | ||
ensure | ||
sitemaps.remove("test") | ||
end | ||
end | ||
|
||
describe "#remove" do | ||
it "notifies listeners with the correct name" do | ||
sitemaps.build do | ||
sitemap "test" | ||
end | ||
|
||
expect(model_listener).to receive(:modelChanged) | ||
.with("test.sitemap", org.openhab.core.model.core.EventType::REMOVED) | ||
|
||
provider.remove("test") | ||
end | ||
end | ||
end |