-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test set_visibility_info with different percents
- Loading branch information
1 parent
a34218b
commit ef65bf6
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe 'plans/_share_form.html.erb' do | ||
before(:each) do | ||
@plan = create(:plan, :creator) | ||
@user = @plan.owner | ||
sign_in(@user) | ||
@plan_roles = @plan.roles.where(active: true) | ||
end | ||
|
||
it 'Renders set_visibility_info correctly according to default_percentage_answered value' do | ||
# Check what renders when default_percentage_answered is between 1 and 100 | ||
Rails.configuration.x.plans.default_percentage_answered = rand(1..100) | ||
render partial: 'plans/share_form' | ||
expect(rendered.include?(format(_('Public or organisational visibility is intended for finished plans. ' \ | ||
'You must answer at least %{percentage}%% of the questions to enable ' \ | ||
'these options. Note: test plans are set to private visibility by default.'), | ||
percentage: Rails.configuration.x.plans.default_percentage_answered))).to eql(true) | ||
|
||
# Check what renders when default_percentage_answered is 0 | ||
Rails.configuration.x.plans.default_percentage_answered = 0 | ||
render partial: 'plans/share_form' | ||
expect(rendered.include?(_('Public or organisational visibility is intended for finished plans. ' \ | ||
'Note: test plans are set to private visibility by default.'))).to eql(true) | ||
end | ||
end |