Skip to content

Commit

Permalink
Merge pull request #171 from OpenSourcePolitics/develop
Browse files Browse the repository at this point in the history
Bump master from Develop
  • Loading branch information
luciegrau authored Dec 13, 2023
2 parents 9c62d88 + 0ad5bd0 commit 2456dbb
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 57 deletions.
2 changes: 1 addition & 1 deletion app/commands/decidim/create_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create_user
organization: form.current_organization,
tos_agreement: form.tos_agreement,
newsletter_notifications_at: form.newsletter_at,
email_on_notification: true,
email_on_notification: false,
accepted_tos_version: form.current_organization.tos_version,
locale: form.current_locale,
registration_metadata: registration_metadata
Expand Down
1 change: 0 additions & 1 deletion app/forms/decidim/registration_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RegistrationForm < Form
attribute :metropolis_residential_area, String
attribute :metropolis_work_area, String
attribute :gender, String
attribute :newsletter, Boolean
attribute :tos_agreement, Boolean
attribute :additional_tos, Boolean
attribute :current_locale, String
Expand Down
18 changes: 9 additions & 9 deletions app/packs/src/decidim/user_registrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ $(() => {
checkNewsletter($(event.target).data("check"));
});

$userRegistrationForm.on("submit", (event) => {
const newsletterChecked = $userRegistrationForm.find(newsletterSelector);
if (!$newsletterModal.data("continue")) {
if (!newsletterChecked.prop("checked")) {
event.preventDefault();
$newsletterModal.foundation("open");
}
}
});
// $userRegistrationForm.on("submit", (event) => {
// const newsletterChecked = $userRegistrationForm.find(newsletterSelector);
// if (!$newsletterModal.data("continue")) {
// if (!newsletterChecked.prop("checked")) {
// event.preventDefault();
// $newsletterModal.foundation("open");
// }
// }
// });
});
26 changes: 13 additions & 13 deletions app/views/decidim/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@
</div>
</div>

<div class="card" id="card__newsletter">
<div class="card__content">
<legend><%= t(".newsletter_title") %></legend>
<div class="row">
<div class="columns additional_tos_checkboxes">
<div class="field">
<%= f.check_box :newsletter, label: t(".newsletter"), checked: @form.newsletter %>
</div>
</div>
</div>
</div>
</div>
<!-- <div class="card" id="card__newsletter">-->
<!-- <div class="card__content">-->
<!-- <legend><%#= t(".newsletter_title") %></legend>-->
<!-- <div class="row">-->
<!-- <div class="columns additional_tos_checkboxes">-->
<!-- <div class="field">-->
<%#= f.check_box :newsletter, label: t(".newsletter"), checked: @form.newsletter %>
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->

<div class="card" id="card__additional_tos">
<div class="card__content">
Expand Down Expand Up @@ -196,4 +196,4 @@
</div>

</div>
<%= render "decidim/devise/shared/newsletter_modal" %>
<%#= render "decidim/devise/shared/newsletter_modal" %>
2 changes: 1 addition & 1 deletion spec/commands/decidim/create_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ module Comments
password: form.password,
password_confirmation: form.password_confirmation,
tos_agreement: form.tos_agreement,
email_on_notification: true,
email_on_notification: false,
organization: organization,
accepted_tos_version: organization.tos_version,
locale: form.current_locale,
Expand Down
8 changes: 4 additions & 4 deletions spec/system/examples/registration_hide_nickname_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
select "1992", from: :registration_user_year
check :registration_user_tos_agreement
check :registration_user_additional_tos
check :registration_user_newsletter
# check :registration_user_newsletter

find("*[type=submit]").click
end
Expand Down Expand Up @@ -81,7 +81,7 @@
select "1992", from: :registration_user_year
check :registration_user_tos_agreement
check :registration_user_additional_tos
check :registration_user_newsletter
# check :registration_user_newsletter

find("*[type=submit]").click
end
Expand Down Expand Up @@ -120,7 +120,7 @@
select "1992", from: :registration_user_year
check :registration_user_tos_agreement
check :registration_user_additional_tos
check :registration_user_newsletter
# check :registration_user_newsletter

find("*[type=submit]").click
end
Expand Down Expand Up @@ -182,7 +182,7 @@
select "1992", from: :registration_user_year
check :registration_user_tos_agreement
check :registration_user_additional_tos
check :registration_user_newsletter
# check :registration_user_newsletter

find("*[type=submit]").click
end
Expand Down
15 changes: 6 additions & 9 deletions spec/system/examples/registration_password_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
expect(page).to have_field("registration_user_nickname", with: "")
expect(page).to have_field("registration_user_email", with: "")
expect(page).to have_field("registration_user_password", with: "")
expect(page).to have_field("registration_user_newsletter", checked: false)
expect(page).not_to have_field("registration_user_newsletter", checked: false)
end

it "creates a new User" do
Expand All @@ -54,7 +54,7 @@

check :registration_user_tos_agreement
check :registration_user_additional_tos
check :registration_user_newsletter
# check :registration_user_newsletter

find("*[type=submit]").click
end
Expand Down Expand Up @@ -84,9 +84,8 @@

check :registration_user_tos_agreement
check :registration_user_additional_tos
check :registration_user_newsletter
# check :registration_user_newsletter

check :registration_user_additional_tos
find("*[type=submit]").click
end

Expand All @@ -108,7 +107,7 @@
expect(page).to have_field("registration_user_email", with: "")
expect(page).to have_field("registration_user_password", with: "")
expect(page).to have_field("registration_user_password_confirmation", with: "")
expect(page).to have_field("registration_user_newsletter", checked: false)
expect(page).not_to have_field("registration_user_newsletter", checked: false)
end

it "creates a new User" do
Expand All @@ -127,9 +126,9 @@
select "1992", from: :registration_user_year

fill_in :registration_user_password_confirmation, with: "nonsense"
check :registration_user_newsletter
check :registration_user_tos_agreement
check :registration_user_additional_tos
# check :registration_user_newsletter
find("*[type=submit]").click

expect(page).to have_content("doesn't match Password")
Expand Down Expand Up @@ -164,12 +163,10 @@
select "1992", from: :registration_user_year

fill_in :registration_user_password_confirmation, with: "DfyvHn425mYAy2HL"
check :registration_user_newsletter
check :registration_user_tos_agreement
check :registration_user_additional_tos
check :registration_user_newsletter
# check :registration_user_newsletter

check :registration_user_additional_tos
find("*[type=submit]").click
end

Expand Down
23 changes: 4 additions & 19 deletions spec/system/registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def fill_registration_form
expect(page).to have_field("registration_user_name", with: "")
expect(page).to have_field("registration_user_email", with: "")
expect(page).to have_field("registration_user_password", with: "")
expect(page).to have_field("registration_user_newsletter", checked: false)
expect(page).not_to have_field("registration_user_newsletter", checked: false)
end
end

Expand All @@ -78,40 +78,25 @@ def fill_registration_form
within ".new_user" do
find("*[type=submit]").click
end
expect(page).to have_css("#sign-up-newsletter-modal", visible: :visible)
expect(page).not_to have_css("#sign-up-newsletter-modal", visible: :visible)
end

it "checks when clicking the checking button" do
fill_registration_form
within ".new_user" do
find("*[type=submit]").click
end
expect(page).to have_css("#sign-up-newsletter-modal", visible: :all)
click_button "Check and continue"
end

it "submit after modal has been opened and selected an option" do
within ".new_user" do
find("*[type=submit]").click
end
click_button "Keep unchecked"
expect(page).to have_css("#sign-up-newsletter-modal", visible: :all)
fill_registration_form
within ".new_user" do
find("*[type=submit]").click
end
expect(page).to have_field("registration_user_newsletter", checked: false)
expect(page).not_to have_css("#sign-up-newsletter-modal", visible: :all)
end
end

context "when newsletter checkbox is checked but submit fails" do
before do
fill_registration_form
page.check("registration_user_newsletter")
end

it "keeps the user newsletter checkbox true value" do
expect(page).to have_field("registration_user_newsletter", checked: true)
expect(page).not_to have_field("registration_user_newsletter", checked: true)
within ".new_user" do
find("*[type=submit]").click
end
Expand Down

0 comments on commit 2456dbb

Please sign in to comment.