2017-03-27 14:06:18 +00:00
|
|
|
require 'rails_helper'
|
2019-01-22 16:35:01 +00:00
|
|
|
require 'models/application_model_examples'
|
2019-01-28 06:04:05 +00:00
|
|
|
require 'models/concerns/can_be_imported_examples'
|
2017-03-27 14:06:18 +00:00
|
|
|
|
2019-01-22 16:35:01 +00:00
|
|
|
RSpec.describe Ticket::State, type: :model do
|
2019-01-24 10:13:04 +00:00
|
|
|
it_behaves_like 'ApplicationModel'
|
2019-01-28 06:04:05 +00:00
|
|
|
it_behaves_like 'CanBeImported'
|
2017-03-27 14:06:18 +00:00
|
|
|
|
2019-01-22 16:35:01 +00:00
|
|
|
describe '.by_category' do
|
2017-03-27 14:06:18 +00:00
|
|
|
it 'looks up states by category' do
|
2019-01-22 16:35:01 +00:00
|
|
|
expect(described_class.by_category(:open))
|
|
|
|
.to be_an(ActiveRecord::Relation)
|
|
|
|
.and include(instance_of(Ticket::State))
|
2017-03-27 14:06:18 +00:00
|
|
|
end
|
|
|
|
|
2019-01-22 16:35:01 +00:00
|
|
|
context 'with invalid category name' do
|
|
|
|
it 'raises RuntimeError' do
|
|
|
|
expect { described_class.by_category(:invalidcategoryname) }
|
|
|
|
.to raise_error(RuntimeError)
|
|
|
|
end
|
2017-03-27 14:06:18 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|