-
Notifications
You must be signed in to change notification settings - Fork 2
[1003] Add more feature tests #355
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <% title 'Admin' %> | ||
|
|
||
| <p class="admin-intro-message"> | ||
| Choose an item from the Adminstration menu. | ||
| Choose an item from the Administration menu. | ||
| </p> |
14 changes: 8 additions & 6 deletions
14
app/views/admin/site_configurations/_alert_message_form.html.erb
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| <%= form_with url: admin_site_configuration_path, method: :patch, local: true, data: { turbo: false } do |form| %> | ||
| <div> | ||
| <%= form.text_area :alert_message, value: SiteConfiguration.alert_message %> | ||
| </div> | ||
| <%= form.submit 'Submit', class: 'btn btn-primary' %> | ||
| <% end %> | ||
| <div id='alert-message-form'> | ||
| <%= form_with url: admin_site_configuration_path, method: :patch, local: true do |form| %> | ||
| <div> | ||
| <%= form.text_area :alert_message, value: SiteConfiguration.alert_message %> | ||
| </div> | ||
| <%= form.submit 'Submit', class: 'btn btn-primary' %> | ||
| <% end %> | ||
| </div> |
2 changes: 1 addition & 1 deletion
2
app/views/admin/site_configurations/_downloads_message_form.html.erb
This file contains hidden or 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
22 changes: 12 additions & 10 deletions
22
app/views/admin/site_configurations/_toggle_deposits_form.html.erb
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| <%= form_with url: admin_site_configuration_path, method: :patch, local: true, data: { turbo: false } do |form| %> | ||
| <% if SiteConfiguration.deposits_enabled %> | ||
| <% action_label = "Disable Deposits" %> | ||
| <% enable = false %> | ||
| <% else %> | ||
| <% action_label = "Enable Deposits" %> | ||
| <% enable = true %> | ||
| <div id='deposits-toggle-form'> | ||
| <%= form_with url: admin_site_configuration_path, method: :patch, local: true, data: { turbo: false } do |form| %> | ||
| <% if SiteConfiguration.deposits_enabled %> | ||
| <% action_label = "Disable Deposits" %> | ||
| <% enable = false %> | ||
| <% else %> | ||
| <% action_label = "Enable Deposits" %> | ||
| <% enable = true %> | ||
| <% end %> | ||
| <%= form.hidden_field :deposits_enabled, value: enable %> | ||
| <%= form.submit action_label, class: "btn btn-primary" %> | ||
| <% end %> | ||
| <%= form.hidden_field :deposits_enabled, value: enable %> | ||
| <%= form.submit action_label, class: "btn btn-primary" %> | ||
| <% end %> | ||
| </div> |
26 changes: 14 additions & 12 deletions
26
app/views/admin/site_configurations/_toggle_downloads_form.html.erb
This file contains hidden or 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 |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| <%= form_with url: admin_site_configuration_path, method: :patch, local: true, data: { turbo: false } do |form| %> | ||
| <% if SiteConfiguration.downloads_enabled %> | ||
| <% action_label = "Disable Downloads" %> | ||
| <% enable = false %> | ||
| <% else %> | ||
| <% action_label = "Enable Downloads" %> | ||
| <% enable = true %> | ||
| <div id='downloads-toggle-form'> | ||
| <%= form_with url: admin_site_configuration_path, method: :patch, local: true, data: { turbo: false } do |form| %> | ||
| <% if SiteConfiguration.downloads_enabled %> | ||
| <% action_label = "Disable Downloads" %> | ||
| <% enable = false %> | ||
| <% else %> | ||
| <% action_label = "Enable Downloads" %> | ||
| <% enable = true %> | ||
| <% end %> | ||
| <div> | ||
| <%= form.hidden_field :downloads_enabled, value: enable %> | ||
| <%= form.submit action_label, class: "btn btn-primary" %> | ||
| </div> | ||
| <% end %> | ||
| <div> | ||
| <%= form.hidden_field :downloads_enabled, value: enable %> | ||
| <%= form.submit action_label, class: "btn btn-primary" %> | ||
| </div> | ||
| <% end %> | ||
| </div> |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| <%# ERROR CODE 403 %> | ||
|
|
||
| <h2>Forbidden</h2> | ||
|
|
||
| <p>You do not have access.</p> | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| <%# ERROR CODE 500 %> | ||
|
|
||
| <h2>Internal Server Error</h2> | ||
|
|
||
| <p>The server has encountered an unexpected error.</p> |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| <%# ERROR CODE 404 %> | ||
|
|
||
| <h2>Not Found</h2> | ||
|
|
||
| <p>The page you are looking for doesn't exist. Please try again or visit our <%= link_to 'homepage', root_path %>.</p> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,10 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| FactoryBot.define do | ||
| factory :email_preference do | ||
| id { 1 } | ||
| uni { 'testuser' } | ||
| unsubscribe { false } | ||
| email { 'testuser@example.com' } | ||
| end | ||
| end |
This file contains hidden or 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,122 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'rails_helper' | ||
|
|
||
| describe 'admin email preferences management', type: :feature do | ||
| include_context 'admin user for feature' | ||
|
|
||
| before do | ||
| FactoryBot.create(:email_preference) | ||
| end | ||
|
|
||
| it 'redirects to login if not authorized' do | ||
| logout(:user) | ||
| visit admin_email_preferences_path | ||
| expect(page).to have_current_path new_user_session_path | ||
| end | ||
|
|
||
| context 'when visiting email preferences index page' do | ||
| before do | ||
| visit admin_email_preferences_path | ||
| end | ||
|
|
||
| it 'displays the email preferences list' do | ||
| expect(page).to have_content 'Email Preferences' | ||
| expect(page).to have_content 'testuser@example.com' | ||
| end | ||
|
|
||
| it 'has link to create new email preference' do | ||
| expect(page).to have_link 'Create New Email Preference', href: new_admin_email_preference_path | ||
| end | ||
|
|
||
| it 'has edit buttons for each email preference' do | ||
| expect(page).to have_link 'Edit', href: edit_admin_email_preference_path(EmailPreference.first) | ||
| end | ||
|
|
||
| it 'has delete buttons for each email preference' do | ||
| expect(page).to have_button 'Destroy' | ||
| end | ||
| end | ||
|
|
||
| context 'when creating a new email preference' do | ||
| before do | ||
| visit new_admin_email_preference_path | ||
| end | ||
|
|
||
| it 'has the email preference form' do | ||
| expect(page).to have_content 'New Email Preference' | ||
| expect(page).to have_selector('[id="email-preference-form"]') | ||
| end | ||
|
|
||
| it 'has a go back to index link' do | ||
| expect(page).to have_link 'Back to Email Preferences', href: admin_email_preferences_path | ||
| end | ||
|
|
||
| it 'flashes error when creating with missing uni' do | ||
| fill_in 'email_preference[uni]', with: '' | ||
| click_button 'Create Email preference' | ||
| expect(page).to have_css 'div.alert-dismissible' | ||
| end | ||
|
|
||
| it 'displays the created email preference when successful' do | ||
| fill_in 'email_preference[uni]', with: 'newuser123' | ||
| check 'email_preference[unsubscribe]' | ||
| fill_in 'email_preference[email]', with: 'newuser123preference@example.com' | ||
| click_button 'Create Email preference' | ||
| expect(page).to have_content 'Email Preference' | ||
| expect(page).to have_content 'newuser123' | ||
| expect(page).to have_content 'true' | ||
| expect(page).to have_content 'newuser123preference@example.com' | ||
| end | ||
|
|
||
| it 'flashes success message when created successfully' do | ||
| fill_in 'email_preference[uni]', with: 'newuser123' | ||
| check 'email_preference[unsubscribe]' | ||
| fill_in 'email_preference[email]', with: 'newuser123preference@example.com' | ||
| click_button 'Create Email preference' | ||
| expect(page).to have_content 'Successfully created email preference.' | ||
| end | ||
|
|
||
| context 'when editing an existing email preference' do | ||
| before do | ||
| visit edit_admin_email_preference_path(EmailPreference.first) | ||
| end | ||
|
|
||
| it 'has the email preference form' do | ||
| expect(page).to have_content 'Edit Email Preference' | ||
| expect(page).to have_selector('[id="email-preference-form"]') | ||
| end | ||
|
|
||
| it 'displays existing values in the form fields' do | ||
| expect(find_field('email_preference[uni]').value).to eq 'testuser' | ||
| expect(find_field('email_preference[unsubscribe]').checked?).to be false | ||
| expect(find_field('email_preference[email]').value).to eq 'testuser@example.com' | ||
| end | ||
|
|
||
| it 'has a go back to index link' do | ||
| expect(page).to have_link 'Back to Email Preferences', href: admin_email_preferences_path | ||
| end | ||
|
|
||
| it 'flashes error when updating with missing uni' do | ||
| fill_in 'email_preference[uni]', with: '' | ||
| click_button 'Update Email preference' | ||
| expect(page).to have_css 'div.alert-dismissible' | ||
| end | ||
|
|
||
| it 'displays the updated email preference when successful' do | ||
| check 'email_preference[unsubscribe]' | ||
| fill_in 'email_preference[email]', with: 'updateduser@example.com' | ||
| click_button 'Update Email preference' | ||
| expect(page).to have_content 'testuser' # not changed | ||
| expect(page).to have_content 'true' | ||
| expect(page).to have_content 'updateduser@example.com' | ||
| end | ||
|
|
||
| it 'flashes success message when updated successfully' do | ||
| fill_in 'email_preference[email]', with: 'updateduser123@example.com' | ||
| click_button 'Update Email preference' | ||
| expect(page).to have_content 'Successfully updated email preference.' | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See rationale above - could this become 'data-id'?