Skip to content

Commit

Permalink
Test set_visibility_info with different percents
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronskiba committed Jan 26, 2024
1 parent a34218b commit ef65bf6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/views/plans/_share_form.html.erb_spec.rb
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

0 comments on commit ef65bf6

Please sign in to comment.