Skip to content

Commit

Permalink
Merge pull request #3876 from ChrisBr/specs/backend_info
Browse files Browse the repository at this point in the history
[ci] Add specs for BackendInfo class
  • Loading branch information
hennevogel committed Sep 21, 2017
2 parents 63a30a7 + 95a14c6 commit c9a7790
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/api/spec/models/backend_info_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'rails_helper'

RSpec.describe BackendInfo, :type => :model do
describe '.getter' do
context 'key does not exist' do
it { expect(BackendInfo.lastnotification_nr).to eq(0) }
end

context 'key does exist' do
before do
BackendInfo.create(key: :lastnotification_nr, value: 42)
end

it { expect(BackendInfo.lastnotification_nr).to eq(42) }
end
end

describe '.setter' do
subject { BackendInfo.where(key: :lastnotification_nr).first.value.to_i }
it 'will set the assigned value' do
BackendInfo.lastnotification_nr = 100
expect(subject).to eq(100)
end
end
end
2 changes: 1 addition & 1 deletion src/api/test/models/backend_info_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../test_helper'

class BackendInfoTest < ActiveSupport::TestCase
test "basics" do
test "basics" do # spec/models/backend_info_spec.rb
old = BackendInfo.lastnotification_nr
BackendInfo.lastnotification_nr = 42
assert_equal BackendInfo.lastnotification_nr, 42
Expand Down

0 comments on commit c9a7790

Please sign in to comment.