Sha256: f9fdeb32cfb799d414378a9dd69c409ecf4eed7147a6a8183c6e54dd8b28b8b0

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

require File.dirname(__FILE__) + '/../../test_helper'

include ChiliVideos

class ConfigTest < ActiveSupport::TestCase
  setup do
    Setting["plugin_chili_videos"] = HashWithIndifferentAccess.new({:transloadit_api_key => 'api_key', :transloadit_workflow => 'workflow_name'})
  end

    context '.api_key' do
      should "returns the value of the plugin's 'transloadit_api_key' setting" do
        assert_equal 'api_key', ChiliVideos::Config.api_key
      end
    end

    context '.workflow' do
      should "returns the value of the plugin's 'transloadit_workflow' setting" do
        assert_equal 'workflow_name', ChiliVideos::Config.workflow
      end
    end

    context '.update' do
      context 'when all required parameters are supplied' do
        setup do
          @new_values = {:api_key => 'updated-api', :workflow => 'workflow-update'}
        end

        should "the value of the plugin's 'api_key' setting is updated" do
          assert_equal 'api_key', ChiliVideos::Config.api_key
          ChiliVideos::Config.update(@new_values)
          assert_equal @new_values[:api_key], ChiliVideos::Config.api_key
        end

        should "the value of the plugin's 'workflow-update'' setting is updated" do
          assert_equal 'workflow_name', ChiliVideos::Config.workflow
          ChiliVideos::Config.update(@new_values)
          assert_equal @new_values[:workflow], ChiliVideos::Config.workflow
        end
      end

      context 'when a required parameter is missing' do
        should "an ArgumentError is raised" do
          assert_raise(ArgumentError) {
            ChiliVideos::Config.update(:api_key => 'api_key')
          }
        end
      end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chili_videos-0.2.2 test/unit/chili_video_plugin/config_test.rb
chili_videos-0.2.1 test/unit/chili_video_plugin/config_test.rb
chili_videos-0.2.0 test/unit/chili_video_plugin/config_test.rb
chili_videos-0.1.0 test/unit/chili_video_plugin/config_test.rb