config_updates_spec.rb 942 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Gql::Subscriptions::ConfigUpdates, type: :graphql do
  4. let(:subscription) do
  5. <<~QUERY
  6. subscription configUpdates {
  7. configUpdates {
  8. setting {
  9. key
  10. value
  11. }
  12. }
  13. }
  14. QUERY
  15. end
  16. let(:mock_channel) { build_mock_channel }
  17. let(:expected_msg) do
  18. {
  19. result: {
  20. 'data' => {
  21. 'configUpdates' => {
  22. 'setting' => {
  23. 'key' => 'product_name',
  24. 'value' => 'subscription_test'
  25. }
  26. }
  27. }
  28. },
  29. more: true,
  30. }
  31. end
  32. it 'broadcasts config update events' do
  33. gql.execute(subscription, context: { channel: mock_channel })
  34. Setting.set('product_name', 'subscription_test')
  35. expect(mock_channel.mock_broadcasted_messages).to eq([expected_msg])
  36. end
  37. end