Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Re-Enable Some RSpec Features Tests #798

Open
wants to merge 4 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions spec/features/locales_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
abbreviation: 'en-CA'
).first_or_create,

Language.where(
default_language: false,
name: 'English (GB)',
abbreviation: 'en-GB'
).first_or_create,

Language.where(
default_language: false,
name: 'Français (CA)',
Expand All @@ -34,7 +28,7 @@
let!(:user) { create(:user, language: languages.first) }

before do
locales = %w[en-GB en-CA fr-CA]
locales = %w[en-CA fr-CA]
I18n.available_locales = locales
I18n.locale = locales.first
sign_in(user)
Expand All @@ -49,21 +43,25 @@

context 'when new locale has no region' do
scenario 'user changes their locale' do
skip 'We are now expecting locales to have region'
create_plan_text = 'Créer des plans'
create_plan_text = I18n.with_locale(:'fr-CA') do
_('Create plan')
end

click_link 'Language'
expect(current_path).to eql(plans_path)
expect(page).not_to have_text(create_plan_text)

click_link 'German'
click_link 'Français (CA)'
expect(current_path).to eql(plans_path)
expect(page).to have_text(create_plan_text)
end
end

context 'when new locale has region' do
scenario 'user changes their locale' do
create_plan_text = 'Créer des plans'
create_plan_text = I18n.with_locale('fr-CA') do
_('Create plan')
end
click_link 'Language'
expect(current_path).to eql(plans_path)
expect(page).not_to have_text(create_plan_text)
Expand Down
15 changes: 7 additions & 8 deletions spec/features/plans_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
@org = create(:org)
@research_org = create(:org, :organisation, :research_institute,
name: 'Test Research Org', templates: 1)
@funding_org = create(:org, :funder, name: 'Test Funder Org', templates: 1)
@funding_org = create(:org, :funder, templates: 1)
Rails.application.config.default_funder_id = @funding_org.id
@template = create(:template, org: @org)
@user = create(:user, org: @org)
sign_in(@user)
Expand All @@ -32,16 +33,14 @@
# )
end

xit 'User creates a new Plan', :js do
# TODO: Revisit this after we start refactoring/building out or tests for
# the new create plan workflow. For some reason the plans/new.js isn't
# firing here but works fine in the UI with manual testing
# Action
it 'User creates a new Plan', :js do
click_link 'Create plan'
fill_in :plan_title, with: 'My test plan'
choose_suggestion('plan_org_org_name', @research_org)

choose_suggestion('plan_funder_org_name', @funding_org)
within('#plan_template_id') do
select @default_template.title
end
click_button 'Create plan'

# Expectations
Expand All @@ -51,6 +50,6 @@
expect(page).to have_css("input[type=text][value='#{@plan.title}']")
expect(@plan.title).to eql('My test plan')
expect(@plan.org_id).to eql(@research_org.id)
expect(@plan.funder_id).to eql(@funding_org.id)
expect(@plan.template_id).to eql(@default_template.id)
end
end
Loading