Sha256: 1bee6d7c51ff2fdc3610e864d267aa0e3ab3a3644863021cdfd13babad976d5d

Contents?: true

Size: 1.53 KB

Versions: 28

Compression:

Stored size: 1.53 KB

Contents

require 'test_helper'

module Workarea
  class SynchronizeUserMetricsTest < IntegrationTest
    def test_enqueuing
      Sidekiq::Testing.fake!
      SynchronizeUserMetrics.async

      assert_difference -> { SynchronizeUserMetrics.jobs.size }, 1 do
        create_user
      end

      assert_difference -> { SynchronizeUserMetrics.jobs.size }, 2 do
        user = create_user
        user.update!(tags: %w(foo bar))
      end

      assert_difference -> { SynchronizeUserMetrics.jobs.size }, 2 do
        user = create_user
        user.update!(admin: true)
      end

      assert_difference -> { SynchronizeUserMetrics.jobs.size }, 1 do
        create_user.update!(password: 's0m3th1ng_3ls3!')
      end
    end

    def test_perform
      user = create_user(tags: %w(foo bar))

      assert_equal(1, Metrics::User.count)
      metrics = Metrics::User.first
      assert_equal(user.email, metrics.id)
      assert_equal(user.tags, metrics.tags)

      user.update!(tags: %w(bar baz))
      assert_equal(1, Metrics::User.count)
      assert_equal(%w(bar baz), metrics.reload.tags)

      user.update!(admin: true)
      assert_equal(1, Metrics::User.count)
      assert(metrics.reload.admin?)

      user.update!(admin: false)
      assert_equal(1, Metrics::User.count)
      refute(metrics.reload.admin?)

      user.update!(super_admin: true)
      assert_equal(1, Metrics::User.count)
      assert(metrics.reload.admin?)

      user.update!(super_admin: false)
      assert_equal(1, Metrics::User.count)
      refute(metrics.reload.admin?)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.26 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.25 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.23 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.22 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.21 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.20 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.19 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.18 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.17 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.16 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.15 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.14 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.13 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.12 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.11 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.10 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.9 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.8 test/workers/workarea/synchronize_user_metrics_test.rb
workarea-core-3.5.7 test/workers/workarea/synchronize_user_metrics_test.rb