Sha256: ded059463cfbb307dd9017cdf96ee6f7f8e515c92dd783b499bc42705d85e5bd

Contents?: true

Size: 1.26 KB

Versions: 58

Compression:

Stored size: 1.26 KB

Contents

require 'rails_helper'

module RedmineExtensions
  RSpec.describe EasySettingPresenter, clear_cache: true do

    let(:project) { FactoryGirl.create(:project) }

    describe 'saving values' do
      it 'create easy_setting' do
        presenter = EasySettingPresenter.new({'key' => 'value', 'key2' => 'value2'})
        expect{ presenter.save }.to change(EasySetting, :count).by(2)
        expect( EasySetting.find_by(name: 'key').value ).to eq('value')
        expect( EasySetting.value('key') ).to eq('value')
      end

      it 'create project setting' do
        presenter = EasySettingPresenter.new({'key' => 'value', 'key2' => 'value2'}, project)
        expect{ presenter.save }.to change(EasySetting, :count).by(2)
        expect( EasySetting.where(project_id: project.id).count ).to eq(2)
        expect( EasySetting.value('key') ).to eq(nil)
        expect( EasySetting.value('key', project) ).to eq('value')
      end

      it 'format value' do
        presenter = EasySettingPresenter.new({'key' => '1', 'key2' => '0'})
        expect(presenter).to receive(:boolean_keys).at_least(:once).and_return([:key, :key2])
        presenter.save
        expect(EasySetting.value('key')).to be true
        expect(EasySetting.value('key2')).to be false
      end
    end

  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
redmine_extensions-0.2.12 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.11 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.10 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.9 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.8 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.7 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.6 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.5 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.4 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.3 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.2 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.2.0 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.1.27 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.1.26 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.1.25 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.1.24 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.1.23 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.1.21 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.1.20 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb
redmine_extensions-0.0.39 spec/presenters/redmine_extensions/easy_setting_presenter_spec.rb