|
|
|
@ -50,7 +50,6 @@ describe Setting, :type => :model do |
|
|
|
|
describe "changing a setting" do |
|
|
|
|
context "setting doesn't exist in the database" do |
|
|
|
|
before do |
|
|
|
|
Setting.destroy_all |
|
|
|
|
Setting.host_name = "some name" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -61,6 +60,10 @@ describe Setting, :type => :model do |
|
|
|
|
it "stores the setting" do |
|
|
|
|
expect(Setting.find_by_name('host_name').value).to eq "some name" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
after do |
|
|
|
|
Setting.find_by_name('host_name').destroy |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "setting already exist in the database" do |
|
|
|
@ -76,17 +79,28 @@ describe Setting, :type => :model do |
|
|
|
|
it "stores the setting" do |
|
|
|
|
expect(Setting.find_by_name('host_name').value).to eq "some other name" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
after do |
|
|
|
|
Setting.find_by_name('host_name').destroy |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# tests the serialization feature to store complex data types like arrays in settings |
|
|
|
|
describe "serialized settings" do |
|
|
|
|
it "serializes arrays" do |
|
|
|
|
before do |
|
|
|
|
# note: notified_events is marked as serialized in settings.yml (no type-based automagic here) |
|
|
|
|
Setting.notified_events = ['some_event'] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "serializes arrays" do |
|
|
|
|
expect(Setting.notified_events).to eq ['some_event'] |
|
|
|
|
expect(Setting.find_by_name('notified_events').value).to eq ['some_event'] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
after do |
|
|
|
|
Setting.find_by_name('notified_events').destroy |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# tests stuff regarding settings callbacks |
|
|
|
@ -149,6 +163,10 @@ describe Setting, :type => :model do |
|
|
|
|
Setting.host_name = 'some other name' |
|
|
|
|
expect(collector).to include 'some name' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
after do |
|
|
|
|
Setting.destroy_all |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
end |
|
|
|
|