diff options
Diffstat (limited to 'spec/support/services')
-rw-r--r-- | spec/support/services/deploy_token_shared_examples.rb | 4 | ||||
-rw-r--r-- | spec/support/services/issuable_update_service_shared_examples.rb | 44 |
2 files changed, 48 insertions, 0 deletions
diff --git a/spec/support/services/deploy_token_shared_examples.rb b/spec/support/services/deploy_token_shared_examples.rb index adc5ea0fcdc..d322b3fc81d 100644 --- a/spec/support/services/deploy_token_shared_examples.rb +++ b/spec/support/services/deploy_token_shared_examples.rb @@ -19,6 +19,10 @@ RSpec.shared_examples 'a deploy token creation service' do it 'returns a DeployToken' do expect(subject[:deploy_token]).to be_an_instance_of DeployToken end + + it 'sets the creator_id as the id of the current_user' do + expect(subject[:deploy_token].read_attribute(:creator_id)).to eq(user.id) + end end context 'when expires at date is not passed' do diff --git a/spec/support/services/issuable_update_service_shared_examples.rb b/spec/support/services/issuable_update_service_shared_examples.rb index 4d2843af1c4..c168df7a7d2 100644 --- a/spec/support/services/issuable_update_service_shared_examples.rb +++ b/spec/support/services/issuable_update_service_shared_examples.rb @@ -23,3 +23,47 @@ RSpec.shared_examples 'issuable update service' do end end end + +RSpec.shared_examples 'keeps issuable labels sorted after update' do + before do + update_issuable(label_ids: [label_b.id]) + end + + context 'when label is changed' do + it 'keeps the labels sorted by title ASC' do + update_issuable({ add_label_ids: [label_a.id] }) + + expect(issuable.labels).to eq([label_a, label_b]) + end + end +end + +RSpec.shared_examples 'broadcasting issuable labels updates' do + before do + update_issuable(label_ids: [label_a.id]) + end + + context 'when label is added' do + it 'triggers the GraphQL subscription' do + expect(GraphqlTriggers).to receive(:issuable_labels_updated).with(issuable) + + update_issuable({ add_label_ids: [label_b.id] }) + end + end + + context 'when label is removed' do + it 'triggers the GraphQL subscription' do + expect(GraphqlTriggers).to receive(:issuable_labels_updated).with(issuable) + + update_issuable({ remove_label_ids: [label_a.id] }) + end + end + + context 'when label is unchanged' do + it 'does not trigger the GraphQL subscription' do + expect(GraphqlTriggers).not_to receive(:issuable_labels_updated).with(issuable) + + update_issuable({ label_ids: [label_a.id] }) + end + end +end |