Sha256: 400e0161cc25596ee7808a634793f95280ef8f6fa846d9cb183f4e52fc7f9d54

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

feature "resetting settings", js: true, type: :feature do
  let!(:setting) do
    allow(Sail::Setting).to receive(:config_file_path).and_return("#{Rails.root}/config/sail.yml")

    Sail::Setting.create!(name: name, cast_type: cast_type,
                          value: setting_value,
                          description: "Setting that does something",
                          group: "feature_flags")
  end

  before do
    visit "/sail"
    within(".card") { find(".refresh-button").click }
  end

  context "for a non boolean setting" do
    let(:cast_type) { :integer }
    let(:setting_value) { "3" }
    let(:name) { "number_of_parallel_jobs" }

    it "resets value and refreshes input" do
      expect(page).to have_content("Updated!")

      within(".card") do
        expect(find("#input_for_#{setting.name}", visible: false)[:value]).to eq("2")
      end

      expect(setting.reload.value).to eq("2")
    end
  end

  context "for a boolean setting" do
    let(:cast_type) { :boolean }
    let(:setting_value) { "false" }
    let(:name) { "enable_awesome_feature" }

    it "resets value and refreshes input" do
      expect(page).to have_content("Updated!")
      expect(setting.reload.value).to eq("true")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sail-3.0.1 spec/features/resetting_settings_feature_spec.rb
sail-3.0.0 spec/features/resetting_settings_feature_spec.rb