Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/todos_helper_spec.rb')
-rw-r--r--spec/helpers/todos_helper_spec.rb81
1 files changed, 80 insertions, 1 deletions
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index 0811c2af891..6b658a475b1 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe TodosHelper do
+RSpec.describe TodosHelper do
let_it_be(:user) { create(:user) }
let_it_be(:author) { create(:user) }
let_it_be(:issue) { create(:issue, title: 'Issue 1') }
@@ -163,4 +163,83 @@ describe TodosHelper do
expect(design_option).to include(text: 'Design')
end
end
+
+ describe '#todo_target_state_pill' do
+ subject { helper.todo_target_state_pill(todo) }
+
+ shared_examples 'a rendered state pill' do |attr|
+ it 'returns expected html' do
+ aggregate_failures do
+ expect(subject).to have_css(".status-box-#{attr[:type]}-#{attr[:state].dasherize}")
+ expect(subject).to have_content(attr[:state].capitalize)
+ end
+ end
+ end
+
+ shared_examples 'no state pill' do
+ specify { expect(subject).to eq(nil) }
+ end
+
+ context 'merge request todo' do
+ let(:todo) { create(:todo, target: create(:merge_request)) }
+
+ it_behaves_like 'no state pill'
+
+ context 'merged MR' do
+ before do
+ todo.target.update!(state: 'merged')
+ end
+
+ it_behaves_like 'a rendered state pill', type: 'mr', state: 'merged'
+ end
+ end
+
+ context 'issue todo' do
+ let(:todo) { create(:todo, target: issue) }
+
+ it_behaves_like 'no state pill'
+
+ context 'closed issue' do
+ before do
+ todo.target.update!(state: 'closed')
+ end
+
+ it_behaves_like 'a rendered state pill', type: 'issue', state: 'closed'
+ end
+ end
+
+ context 'alert todo' do
+ let(:todo) { alert_todo }
+
+ it_behaves_like 'no state pill'
+
+ context 'resolved alert' do
+ before do
+ todo.target.resolve!
+ end
+
+ it_behaves_like 'a rendered state pill', type: 'alert', state: 'resolved'
+ end
+ end
+ end
+
+ describe '#todo_author_display?' do
+ using RSpec::Parameterized::TableSyntax
+
+ subject { helper.todo_author_display?(alert_todo) }
+
+ where(:action, :result) do
+ Todo::BUILD_FAILED | false
+ Todo::UNMERGEABLE | false
+ Todo::ASSIGNED | true
+ end
+
+ with_them do
+ before do
+ alert_todo.action = action
+ end
+
+ it { is_expected.to eq(result) }
+ end
+ end
end