debian-mirror-gitlab/spec/models/work_items/widgets/description_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
1.5 KiB
Ruby
Raw Normal View History

2022-07-23 23:45:48 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe WorkItems::Widgets::Description do
2022-10-11 01:57:18 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:work_item, refind: true) do
create(:work_item, description: 'Title', last_edited_at: 10.days.ago, last_edited_by: user)
end
2022-07-23 23:45:48 +05:30
describe '.type' do
subject { described_class.type }
it { is_expected.to eq(:description) }
end
describe '#type' do
subject { described_class.new(work_item).type }
it { is_expected.to eq(:description) }
end
describe '#description' do
subject { described_class.new(work_item).description }
it { is_expected.to eq(work_item.description) }
end
2022-10-11 01:57:18 +05:30
describe '#edited?' do
subject { described_class.new(work_item).edited? }
it { is_expected.to be_truthy }
end
describe '#last_edited_at' do
subject { described_class.new(work_item).last_edited_at }
it { is_expected.to eq(work_item.last_edited_at) }
end
describe '#last_edited_by' do
subject { described_class.new(work_item).last_edited_by }
context 'when the work item is edited' do
context 'when last edited user still exists in the DB' do
it { is_expected.to eq(user) }
end
context 'when last edited user no longer exists' do
before do
work_item.update!(last_edited_by: nil)
end
it { is_expected.to eq(User.ghost) }
end
end
context 'when the work item is not edited yet' do
before do
work_item.update!(last_edited_at: nil)
end
it { is_expected.to be_nil }
end
end
2022-07-23 23:45:48 +05:30
end