Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.71.2 to 1.75.8. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.71.2...v1.75.8) --- updated-dependencies: - dependency-name: rubocop dependency-version: 1.75.8 dependency-type: direct:development update-type: version-update:semver-minor ... Notes: This commit also includes several style and lint fixes required after updating RuboCop: - Removed redundant parentheses now detected by improved 'Style/RedundantParentheses' (1.72 and 1.75.3). - Replaced ternary expressions with logical OR when the ternary was returning 'true', as flagged by 'Style/RedundantCondition' (1.73). - Adjusted block variables to resolve new 'Lint/ShadowingOuterLocalVariable' offenses (1.75), helping avoid future conflicts during upgrades with 'rails app:updates' Signed-off-by: dependabot[bot] <support@github.com>
113 lines
2.5 KiB
Ruby
113 lines
2.5 KiB
Ruby
require "rails_helper"
|
|
|
|
describe ProgressBar do
|
|
let(:progress_bar) { build(:progress_bar) }
|
|
|
|
it_behaves_like "globalizable", :progress_bar
|
|
it_behaves_like "globalizable", :secondary_progress_bar
|
|
|
|
it "is valid" do
|
|
expect(progress_bar).to be_valid
|
|
end
|
|
|
|
it "is valid without a title" do
|
|
progress_bar.title = nil
|
|
|
|
expect(progress_bar).to be_valid
|
|
end
|
|
|
|
it "is not valid with a custom type" do
|
|
expect { progress_bar.kind = "terciary" }.to raise_exception(ArgumentError)
|
|
end
|
|
|
|
it "is not valid without a percentage" do
|
|
progress_bar.percentage = nil
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "is not valid with a non-numeric percentage" do
|
|
progress_bar.percentage = "High"
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "is not valid with a non-integer percentage" do
|
|
progress_bar.percentage = 22.83
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "is not valid with a negative percentage" do
|
|
progress_bar.percentage = -1
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "is not valid with a percentage bigger than 100" do
|
|
progress_bar.percentage = 101
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "is valid with an integer percentage within the limits" do
|
|
progress_bar.percentage = 0
|
|
|
|
expect(progress_bar).to be_valid
|
|
|
|
progress_bar.percentage = 100
|
|
|
|
expect(progress_bar).to be_valid
|
|
|
|
progress_bar.percentage = 83
|
|
|
|
expect(progress_bar).to be_valid
|
|
end
|
|
|
|
it "dynamically validates the percentage range" do
|
|
stub_const("#{ProgressBar}::RANGE", -99..99)
|
|
|
|
progress_bar.percentage = -99
|
|
|
|
expect(progress_bar).to be_valid
|
|
|
|
progress_bar.percentage = 100
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "is not valid without a progressable" do
|
|
progress_bar.progressable = nil
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "cannot have another primary progress bar for the same progressable" do
|
|
progress_bar.save!
|
|
duplicate = build(:progress_bar, progressable: progress_bar.progressable)
|
|
|
|
expect(duplicate).not_to be_valid
|
|
end
|
|
|
|
describe "secondary progress bar" do
|
|
let(:progress_bar) { build(:progress_bar, :secondary) }
|
|
|
|
it "is valid" do
|
|
expect(progress_bar).to be_valid
|
|
end
|
|
|
|
it "is invalid without a title" do
|
|
progress_bar.title = nil
|
|
|
|
expect(progress_bar).not_to be_valid
|
|
end
|
|
|
|
it "can have another secondary progress bar for the same progressable" do
|
|
progress_bar.save!
|
|
duplicate = build(:progress_bar, progressable: progress_bar.progressable)
|
|
|
|
expect(duplicate).to be_valid
|
|
end
|
|
end
|
|
end
|