Update site_controller_test.rb
Update site_controller_test.rb
Remove whitespace
Reset Settings.status after test is done
Update test for offline page
Update site_controller.rb
Fix indentation
Update offline controller
Update offline.html.erb
Remove flash CSS classes and fix missed tests
Updated tests
Address most PR comments
Update _flash.html.erb
Update _flash.html.erb
Update edit.html.erb
Update offline.html.erb
12 files changed:
-/* Rules for "flash" notice boxes shown at the top of the content area */
-
-.flash {
- &.error {
- background-color: #ff7070;
- }
-
- &.warning {
- background-color: #ffe0cc;
- }
-
- &.notice {
- background-color: #CBEEA7;
- }
-}
-
/* Rules for highlighting fields with rails validation errors */
.formError {
/* Rules for highlighting fields with rails validation errors */
.formError {
+ def offline
+ flash.now[:warning] = if Settings.status == "database_offline"
+ t("layouts.osm_offline")
+ else
+ t("layouts.osm_read_only")
+ end
+ render :html => nil, :layout => true
+ end
def preview
render :html => RichText.new(params[:type], params[:text]).to_html
def preview
render :html => RichText.new(params[:type], params[:text]).to_html
- <div class="flash error row mx-0 p-3 align-items-center">
+ <div class="alert alert-danger row mx-0 mb-0 p-3 rounded-0 align-items-center">
<div class="col-auto">
<picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml" />
<div class="col-auto">
<picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml" />
<% end %>
<% if flash[:warning] %>
<% end %>
<% if flash[:warning] %>
- <div class="flash warning row mx-0 p-3 align-items-center">
+ <div class="alert alert-warning row mx-0 mb-0 p-3 rounded-0 align-items-center">
<div class="col-auto">
<picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source>
<div class="col-auto">
<picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source>
<% end %>
<% if flash[:notice] %>
<% end %>
<% if flash[:notice] %>
- <div class="flash notice row mx-0 p-3 align-items-center">
+ <div class="alert alert-success row mx-0 mb-0 p-3 rounded-0 align-items-center">
<div class="col-auto">
<picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source>
<div class="col-auto">
<picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source>
<% content_for :content do %>
<% if Settings.status == "database_offline" or Settings.status == "api_offline" %>
<% content_for :content do %>
<% if Settings.status == "database_offline" or Settings.status == "api_offline" %>
- <p><%= t "layouts.osm_offline" %></p>
+ <div class="alert alert-warning text-center">
+ <p class="my-2"><%= t "layouts.osm_offline" %></p>
+ </div>
<% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %>
<% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %>
- <p><%= t "layouts.osm_read_only" %></p>
+ <div class="alert alert-warning text-center">
+ <p class="my-2"><%= t "layouts.osm_read_only" %></p>
+ </div>
<% elsif !current_user.data_public? %>
<p><%= t ".not_public" %></p>
<p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
<% elsif !current_user.data_public? %>
<p><%= t ".not_public" %></p>
<p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
+++ /dev/null
-<% if Settings.status == "database_offline" %>
-<p><%= t "layouts.osm_offline" %>
-</p>
-<% else %>
-<p><%= t "layouts.osm_read_only" %>
-</p>
-<% end %>
patch account_path, :params => { :user => new_attributes }
assert_response :success
assert_template :edit
patch account_path, :params => { :user => new_attributes }
assert_response :success
assert_template :edit
- assert_select ".notice", false
+ assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_display_name"
# Changing name to one that exists should fail, regardless of case
assert_select "form#accountForm > div > input.is-invalid#user_display_name"
# Changing name to one that exists should fail, regardless of case
patch account_path, :params => { :user => new_attributes }
assert_response :success
assert_template :edit
patch account_path, :params => { :user => new_attributes }
assert_response :success
assert_template :edit
- assert_select ".notice", false
+ assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_display_name"
# Changing name to one that doesn't exist should work
assert_select "form#accountForm > div > input.is-invalid#user_display_name"
# Changing name to one that doesn't exist should work
get edit_account_path
assert_response :success
assert_template :edit
get edit_account_path
assert_response :success
assert_template :edit
- assert_select ".notice", /^User information updated successfully/
+ assert_select ".alert-success", /^User information updated successfully/
assert_select "form#accountForm > div > input#user_display_name[value=?]", "new tester"
# Record the change of name
assert_select "form#accountForm > div > input#user_display_name[value=?]", "new tester"
# Record the change of name
end
assert_response :success
assert_template :edit
end
assert_response :success
assert_template :edit
- assert_select ".notice", false
+ assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_new_email"
# Changing email to one that exists should fail, regardless of case
assert_select "form#accountForm > div > input.is-invalid#user_new_email"
# Changing email to one that exists should fail, regardless of case
end
assert_response :success
assert_template :edit
end
assert_response :success
assert_template :edit
- assert_select ".notice", false
+ assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_new_email"
# Changing email to one that doesn't exist should work
assert_select "form#accountForm > div > input.is-invalid#user_new_email"
# Changing email to one that doesn't exist should work
get edit_account_path
assert_response :success
assert_template :edit
get edit_account_path
assert_response :success
assert_template :edit
- assert_select ".notice", /^User information updated successfully/
+ assert_select ".alert-success", /^User information updated successfully/
assert_select "form#accountForm > div > input#user_new_email[value=?]", user.new_email
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_select "form#accountForm > div > input#user_new_email[value=?]", user.new_email
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
:message => { :title => "Test Message", :body => "Test message body" })
assert_response :success
assert_template "new"
:message => { :title => "Test Message", :body => "Test message body" })
assert_response :success
assert_template "new"
- assert_select ".error", /wait a while/
+ assert_select ".alert.alert-danger", /wait a while/
end
assert_response :success
assert_template :lost_password
end
assert_response :success
assert_template :lost_password
- assert_select ".error", /^Could not find that email address/
+ assert_select ".alert.alert-danger", /^Could not find that email address/
# Test resetting using the address as recorded for a user that has an
# address which is case insensitively unique
# Test resetting using the address as recorded for a user that has an
# address which is case insensitively unique
put preferences_path, :params => { :user => user.attributes }
assert_response :success
assert_template :edit
put preferences_path, :params => { :user => user.attributes }
assert_response :success
assert_template :edit
- assert_select ".notice", false
- assert_select ".error", true
+ assert_select ".alert-success", false
+ assert_select ".alert-danger", true
assert_select "form > div > select#user_preferred_editor > option[selected]", false
# Changing to a valid editor should work
assert_select "form > div > select#user_preferred_editor > option[selected]", false
# Changing to a valid editor should work
assert_redirected_to preferences_path
follow_redirect!
assert_template :show
assert_redirected_to preferences_path
follow_redirect!
assert_template :show
- assert_select ".notice", /^Preferences updated/
+ assert_select ".alert-success", /^Preferences updated/
assert_select "dd", "iD (in-browser editor)"
# Changing to the default editor should work
assert_select "dd", "iD (in-browser editor)"
# Changing to the default editor should work
assert_redirected_to preferences_path
follow_redirect!
assert_template :show
assert_redirected_to preferences_path
follow_redirect!
assert_template :show
- assert_select ".notice", /^Preferences updated/
+ assert_select ".alert-success", /^Preferences updated/
assert_select "dd", "Default (currently iD)"
end
end
assert_select "dd", "Default (currently iD)"
end
end
follow_redirect!
assert_response :success
assert_template :show
follow_redirect!
assert_response :success
assert_template :show
- assert_select ".notice", /^Profile updated./
+ assert_select ".alert-success", /^Profile updated./
assert_select "div", "new description"
# Changing to an uploaded image should work
assert_select "div", "new description"
# Changing to an uploaded image should work
follow_redirect!
assert_response :success
assert_template :show
follow_redirect!
assert_response :success
assert_template :show
- assert_select ".notice", /^Profile updated./
+ assert_select ".alert-success", /^Profile updated./
get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep"
get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep"
follow_redirect!
assert_response :success
assert_template :show
follow_redirect!
assert_response :success
assert_template :show
- assert_select ".notice", /^Profile updated./
+ assert_select ".alert-success", /^Profile updated./
get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar"
get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar"
follow_redirect!
assert_response :success
assert_template :show
follow_redirect!
assert_response :success
assert_template :show
- assert_select ".notice", /^Profile updated./
+ assert_select ".alert-success", /^Profile updated./
get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div > input[name=avatar_action][checked]", false
assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked]", false
get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div > input[name=avatar_action][checked]", false
assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked]", false
def test_offline
get offline_path
assert_response :success
def test_offline
get offline_path
assert_response :success
- assert_template "offline"
+ assert_select ".alert-warning"
end
# Test the rich text preview
end
# Test the rich text preview
assert_template "sessions/new"
assert_select "span.username", false
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_template "sessions/new"
assert_select "span.username", false
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_template "sessions/new"
assert_select "span.username", false
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_template "sessions/new"
assert_select "span.username", false
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_template "sessions/new"
assert_select "span.username", false
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_template "sessions/new"
assert_select "span.username", false
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Connection to authentication provider failed"
+ assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false
end
assert_select "span.username", false
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Invalid authentication credentials"
+ assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false
end
assert_select "span.username", false
end
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Connection to authentication provider failed"
+ assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false
end
assert_select "span.username", false
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Invalid authentication credentials"
+ assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false
end
assert_select "span.username", false
end
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Connection to authentication provider failed"
+ assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false
end
assert_select "span.username", false
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Invalid authentication credentials"
+ assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false
end
assert_select "span.username", false
end
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Connection to authentication provider failed"
+ assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false
end
assert_select "span.username", false
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Invalid authentication credentials"
+ assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false
end
assert_select "span.username", false
end
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Connection to authentication provider failed"
+ assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false
end
assert_select "span.username", false
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Invalid authentication credentials"
+ assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false
end
assert_select "span.username", false
end
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
assert_response :success
assert_template "sessions/new"
assert_select "span.username", false
- assert_select "div.flash.error", /your account has been suspended/ do
+ assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Connection to authentication provider failed"
+ assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false
end
assert_select "span.username", false
end
follow_redirect!
assert_response :success
assert_template "sessions/new"
follow_redirect!
assert_response :success
assert_template "sessions/new"
- assert_select "div.flash.error", "Invalid authentication credentials"
+ assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false
end
assert_select "span.username", false
end