Skip to content

Commit

Permalink
Fix group state field default (#475)
Browse files Browse the repository at this point in the history
* Add failing test for group state field default

* set default
  • Loading branch information
sidoh authored Jun 13, 2019
1 parent 0f20751 commit 197253c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ enum RadioInterfaceType {
LT8900 = 1,
};

static const GroupStateField DEFAULT_GROUP_STATE_FIELDS[] = {
static const std::vector<GroupStateField> DEFAULT_GROUP_STATE_FIELDS({
GroupStateField::STATE,
GroupStateField::BRIGHTNESS,
GroupStateField::COMPUTED_COLOR,
GroupStateField::MODE,
GroupStateField::COLOR_TEMP,
GroupStateField::BULB_MODE
};
});

struct GatewayConfig {
GatewayConfig(uint16_t deviceId, uint16_t port, uint8_t protocolVersion);
Expand Down Expand Up @@ -105,6 +105,7 @@ class Settings {
hostname("milight-hub"),
rf24PowerLevel(RF24PowerLevelHelpers::defaultValue()),
rf24Channels(RF24ChannelHelpers::allValues()),
groupStateFields(DEFAULT_GROUP_STATE_FIELDS),
rf24ListenChannel(RF24Channel::RF24_LOW),
_autoRestartPeriod(0)
{ }
Expand Down
23 changes: 23 additions & 0 deletions test/remote/spec/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,27 @@
expect(ping_test.ping?).to be(true)
end
end

context 'defaults' do
before(:all) do
# Clobber all settings
file = Tempfile.new('espmh-settings.json')
file.close

@client.upload_json('/settings', file.path)
end

it 'should have some group state fields defined' do
settings = @client.get('/settings')

expect(settings['group_state_fields']).to_not be_empty
end

it 'should allow for empty group state fields if set' do
@client.patch_settings(group_state_fields: [])
settings = @client.get('/settings')

expect(settings['group_state_fields']).to eq([])
end
end
end

0 comments on commit 197253c

Please sign in to comment.