Sha256: 24cea4d867a24d5629dac22185d71ed07cd8021e0effb3f09c6225d159a03a5b

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

require "test_helper"

module Godmin
  module ResourceService
    class BatchActionsTest < ActiveSupport::TestCase
      def setup
        @article_service = Fakes::ArticleService.new
      end

      def test_batch_action
        assert @article_service.batch_action(:unpublish, [:foo, :bar])
        assert_equal [:foo, :bar], @article_service.called_methods[:batch_actions][:unpublish]
      end

      def test_batch_action_when_it_does_not_exist
        assert_not @article_service.batch_action(:foobar, [:foo, :bar])
        assert_nil @article_service.called_methods[:batch_actions][:foobar]
      end

      def test_batch_action_exists
        assert @article_service.batch_action?(:unpublish)
      end

      def test_batch_action_does_not_exist
        assert_not @article_service.batch_action?(:foobar)
      end

      def test_batch_action_map_with_default_options
        expected_batch_action_map = { only: nil, except: nil, confirm: false }
        assert_equal expected_batch_action_map, @article_service.batch_action_map[:unpublish]
      end

      def test_batch_action_map_with_custom_options
        expected_batch_action_map = { only: [:unpublished], except: [:published], confirm: true }
        assert_equal expected_batch_action_map, @article_service.batch_action_map[:publish]
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
godmin-2.3.0 test/unit/resources/resource_service/batch_actions_test.rb
godmin-2.2.2 test/unit/resources/resource_service/batch_actions_test.rb
godmin-2.2.1 test/unit/resources/resource_service/batch_actions_test.rb
godmin-2.2.0 test/unit/resources/resource_service/batch_actions_test.rb
godmin-2.1.0 test/unit/resources/resource_service/batch_actions_test.rb
godmin-2.0.0 test/unit/resources/resource_service/batch_actions_test.rb
godmin-1.5.0 test/lib/godmin/resources/resource_service/batch_actions_test.rb
godmin-1.4.0 test/lib/godmin/resources/resource_service/batch_actions_test.rb