diff --git a/Dangerfile b/Dangerfile index 91faaa0b..87c734a6 100644 --- a/Dangerfile +++ b/Dangerfile @@ -19,7 +19,8 @@ suggester.suggest eslint.lint # Report your Ruby app test suite code coverage in Danger. -simplecov.report 'coverage/coverage.json' +# simplecov.report 'coverage/coverage.json' # Report missing test coverage of new changes in Danger -undercover.report +# Commented as undercover reports needs tests to run, which needs a different env +# undercover.report diff --git a/app/assets/images/.keep b/app/assets/images/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/assets/images/logo.svg b/app/assets/images/logo.svg new file mode 100644 index 00000000..9835d3e8 --- /dev/null +++ b/app/assets/images/logo.svg @@ -0,0 +1 @@ + diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 44acc398..e3e801c8 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -12,6 +12,7 @@ // Base // Layouts +@import 'layouts/default'; // Components diff --git a/app/assets/stylesheets/components/.keep b/app/assets/stylesheets/components/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/assets/stylesheets/layouts/.keep b/app/assets/stylesheets/layouts/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/assets/stylesheets/layouts/default.scss b/app/assets/stylesheets/layouts/default.scss new file mode 100644 index 00000000..9576dda0 --- /dev/null +++ b/app/assets/stylesheets/layouts/default.scss @@ -0,0 +1,9 @@ +.layout-default { + .app-footer { + width: 100%; + height: 60px; + margin-top: 2rem; + line-height: 60px; + background-color: $gray-100; + } +} diff --git a/app/assets/stylesheets/vendor/bootstrap/bootstrap.scss b/app/assets/stylesheets/vendor/bootstrap/bootstrap.scss index 3f52ecb0..6e11d02e 100644 --- a/app/assets/stylesheets/vendor/bootstrap/bootstrap.scss +++ b/app/assets/stylesheets/vendor/bootstrap/bootstrap.scss @@ -10,33 +10,33 @@ @import 'bootstrap/scss/reboot'; @import 'bootstrap/scss/type'; @import 'bootstrap/scss/utilities'; -@import 'bootstrap/scss/images'; +//@import 'bootstrap/scss/images'; @import 'bootstrap/scss/grid'; @import 'bootstrap/scss/forms'; @import 'bootstrap/scss/buttons'; -@import 'bootstrap/scss/tables'; -@import 'bootstrap/scss/code'; -@import 'bootstrap/scss/transitions'; +//@import 'bootstrap/scss/tables'; +//@import 'bootstrap/scss/code'; +//@import 'bootstrap/scss/transitions'; @import 'bootstrap/scss/dropdown'; @import 'bootstrap/scss/button-group'; @import 'bootstrap/scss/input-group'; -@import 'bootstrap/scss/custom-forms'; +//@import 'bootstrap/scss/custom-forms'; @import 'bootstrap/scss/nav'; @import 'bootstrap/scss/navbar'; @import 'bootstrap/scss/card'; -@import 'bootstrap/scss/breadcrumb'; +//@import 'bootstrap/scss/breadcrumb'; @import 'bootstrap/scss/pagination'; -@import 'bootstrap/scss/badge'; -@import 'bootstrap/scss/jumbotron'; +//@import 'bootstrap/scss/badge'; +//@import 'bootstrap/scss/jumbotron'; @import 'bootstrap/scss/alert'; @import 'bootstrap/scss/progress'; -@import 'bootstrap/scss/media'; -@import 'bootstrap/scss/list-group'; -@import 'bootstrap/scss/close'; -@import 'bootstrap/scss/toasts'; -@import 'bootstrap/scss/modal'; -@import 'bootstrap/scss/tooltip'; -@import 'bootstrap/scss/popover'; -@import 'bootstrap/scss/carousel'; -@import 'bootstrap/scss/spinners'; -@import 'bootstrap/scss/print'; +//@import 'bootstrap/scss/media'; +//@import 'bootstrap/scss/list-group'; +//@import 'bootstrap/scss/close'; +//@import 'bootstrap/scss/toasts'; +//@import 'bootstrap/scss/modal'; +//@import 'bootstrap/scss/tooltip'; +//@import 'bootstrap/scss/popover'; +//@import 'bootstrap/scss/carousel'; +//@import 'bootstrap/scss/spinners'; +//@import 'bootstrap/scss/print'; diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb index b12dd0cb..ef6f83cf 100644 --- a/app/views/devise/confirmations/new.html.erb +++ b/app/views/devise/confirmations/new.html.erb @@ -1,6 +1,7 @@

Resend confirmation instructions

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index 5fbb9ff0..bfd05421 100644 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -1,7 +1,9 @@

Change your password

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + <%= f.hidden_field :reset_password_token %>
diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index 9b486b81..b91f56de 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -1,6 +1,7 @@

Forgot your password?

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %>
diff --git a/app/views/devise/registrations/_edit_form.html.erb b/app/views/devise/registrations/_edit_form.html.erb new file mode 100644 index 00000000..7a5340bc --- /dev/null +++ b/app/views/devise/registrations/_edit_form.html.erb @@ -0,0 +1,70 @@ +<%= form_for(resource, as: resource_name, + url: registration_path(resource_name), html: { method: :put }) do |f| %> + + <%= render "devise/shared/error_messages", resource: resource %> + +
+
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name, class: 'form-control' %> +
+
+
+
+
+ <%= f.label :email %> +
+ <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> +
+ + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
<%= t('waiting_confirmation_for') %>: <%= resource.unconfirmed_email %>
+ <% end %> +
+
+
+ <%= f.label :current_password %> + <%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %> +
+
+
+ +
+ <% if @minimum_password_length %> + (<%= "#{@minimum_password_length} #{t('min_char')}" %>) + <% end %> +
+
+
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: "new-password", class: 'form-control' %> +
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> +
+
+
+
+ + <%= f.submit t('update'), class: 'btn btn-primary btn-block' %> + +<% end %> diff --git a/app/views/devise/registrations/_new_form.html.erb b/app/views/devise/registrations/_new_form.html.erb new file mode 100644 index 00000000..34d4bc85 --- /dev/null +++ b/app/views/devise/registrations/_new_form.html.erb @@ -0,0 +1,31 @@ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name, class: 'form-control' %> +
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> +
+
+ <%= f.label :password %>
+ <% if @minimum_password_length %> + (<%= "#{@minimum_password_length} #{t('min_char')}" %>) + <% end %>
+ <%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %> +
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> +
+
+ <%= f.submit t('auth.sign_up'), class: 'btn btn-primary btn-block' %> +
+<% end %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3bfea996..bd41fae2 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,53 +1,29 @@ -

Edit <%= resource_name.to_s.humanize %>

- -<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> - -
- <%= f.label :first_name %>
- <%= f.text_field :first_name, autofocus: true %> +
+
+
+
+
+

Edit <%= resource_name.to_s.humanize %>

+ + <%= render 'edit_form' %> +
+
+
- -
- <%= f.label :last_name %>
- <%= f.text_field :last_name %> -
- -
- <%= f.label :email %>
- <%= f.email_field :email, autocomplete: "email" %> +
+
+
+
+

Cancel my account

+ +

<%= t('unhappy') %>? 🥺

+ <%= button_to t('auth.cancel_my_account'), + registration_path(resource_name), + data: { confirm: t('confirm') }, + method: :delete, + class: 'btn btn-danger btn-block' %> +
+
+
- - <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
- <% end %> - -
- <%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password, autocomplete: "new-password" %> - <% if @minimum_password_length %> -
- <%= @minimum_password_length %> characters minimum - <% end %> -
- -
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> -
- -
- <%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password, autocomplete: "current-password" %> -
- -
- <%= f.submit "Update" %> -
-<% end %> - -

Cancel my account

- -

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

- -<%= link_to "Back", :back %> +
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 2a4fe044..ff1f46d9 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,39 +1,14 @@ -

Sign up

- -<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> - -
- <%= f.label :first_name %>
- <%= f.text_field :first_name, autofocus: true %> -
- -
- <%= f.label :last_name %>
- <%= f.text_field :last_name %> -
- -
- <%= f.label :email %>
- <%= f.email_field :email, autocomplete: "email" %> -
- -
- <%= f.label :password %> - <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) - <% end %>
- <%= f.password_field :password, autocomplete: "new-password" %> -
- -
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> -
- -
- <%= f.submit "Sign up" %> -
-<% end %> - -<%= render "devise/shared/links" %> +
+
+
+
+
+ <%= link_to t('auth.sign_in'), new_session_path(resource_name), class: 'float-right btn btn-outline-primary' %> +

Sign up

+ + <%= render 'devise/registrations/new_form' %> +
+
+
+
+
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 5ede9648..f59a2ec7 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,26 +1,35 @@ -

Log in

- -<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> -
- -
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "current-password" %> -
- - <% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me %> - <%= f.label :remember_me %> +
+
+
+
+
+ <%= link_to t('auth.sign_up'), new_registration_path(resource_name), + class: 'float-right btn btn-outline-primary' %> +

Sign in

+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %> +
+
+ <%= link_to t('forgot_password'), new_password_path(resource_name), class:'float-right' %>
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: 'current-password', class: 'form-control' %> +
+
+ <% if devise_mapping.rememberable? %> +
+ <%= f.check_box :remember_me %> + <%= f.label :remember_me %> +
+ <% end %> +
+
+ <%= f.submit t('auth.sign_in'), class: 'btn btn-primary btn-block' %> +
+ <% end %> +
+
- <% end %> - -
- <%= f.submit "Log in" %>
-<% end %> - -<%= render "devise/shared/links" %> +
diff --git a/app/views/devise/shared/_error_messages.html.erb b/app/views/devise/shared/_error_messages.html.erb index bb5b70b0..a01e694a 100644 --- a/app/views/devise/shared/_error_messages.html.erb +++ b/app/views/devise/shared/_error_messages.html.erb @@ -1,15 +1,7 @@ <% if resource.errors.any? %> -
-

- <%= t("errors.messages.not_saved", - count: resource.errors.count, - resource: resource.class.model_name.human.downcase) - %> -

-
    - <% resource.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
+
+ <% resource.errors.full_messages.each do |message| %> +

<%= message %>

+ <% end %>
<% end %> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb index ffc34de8..e7d3d269 100644 --- a/app/views/devise/unlocks/new.html.erb +++ b/app/views/devise/unlocks/new.html.erb @@ -1,6 +1,7 @@

Resend unlock instructions

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c9e413bb..d8006bf0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,21 +1,31 @@ - - - GoogleSearchRuby - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> + + + <%= t('app_name') %> + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> - <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_pack_tag 'application' %> - - - - <% if user_signed_in? %> - <%= button_to t('logout'), destroy_user_session_path, method: :delete %> - <% end %> -

<%= notice %>

-

<%= alert %>

+ <%= stylesheet_link_tag 'application', media: 'all' %> + <%= javascript_pack_tag 'application' %> + + + + diff --git a/app/views/shared/_footer.html.erb b/app/views/shared/_footer.html.erb new file mode 100644 index 00000000..e286c240 --- /dev/null +++ b/app/views/shared/_footer.html.erb @@ -0,0 +1,8 @@ +
+
+ + This project is a Ruby/Rails Internal Certification for + <%= link_to 'Nimble', "https://nimblehq.co/", target: "_blank" %>. + +
+
diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb new file mode 100644 index 00000000..761412eb --- /dev/null +++ b/app/views/shared/_header.html.erb @@ -0,0 +1,30 @@ +
+ +
diff --git a/config/brakeman.ignore b/config/brakeman.ignore new file mode 100644 index 00000000..777a653e --- /dev/null +++ b/config/brakeman.ignore @@ -0,0 +1,22 @@ +{ + "ignored_warnings": [ + { + "warning_type": "Cross-Site Scripting", + "warning_code": 106, + "fingerprint": "c8adc1c0caf2c9251d1d8de588fb949070212d0eed5e1580aee88bab2287b772", + "check_name": "SanitizeMethods", + "message": "loofah gem 2.10.0 is vulnerable (CVE-2018-8048). Upgrade to 2.2.1", + "file": "Gemfile.lock", + "line": 214, + "link": "https://github.com/flavorjones/loofah/issues/144", + "code": null, + "render_path": null, + "location": null, + "user_input": null, + "confidence": "Medium", + "note": "2.10.0 is HIGHER than 2.2.1, thus already patched!" + } + ], + "updated": "2021-06-18 15:28:26 +0700", + "brakeman_version": "5.0.1" +} diff --git a/config/environments/test.rb b/config/environments/test.rb index b21e485d..3c34aede 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -78,4 +78,5 @@ # Do not fallback to assets pipeline if a precompiled asset is missing. config.assets.compile = false + config.assets.unknown_asset_fallback = false end diff --git a/config/locales/en.yml b/config/locales/en.yml index 14ffadfb..50e76d0c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,4 +30,16 @@ # available at https://guides.rubyonrails.org/i18n.html. en: - logout: "Sign out" + app_name: 'Google Search Ruby' + auth: + logout: 'Sign out' + sign_up: 'Sign up' + sign_in: 'Sign in' + cancel_my_account: 'Cancel my account' + min_char: 'characters minimum' + confirm: 'Are you sure?' + update: 'Update' + unhappy: 'Unhappy' + waiting_confirmation_for: 'Currently waiting confirmation for' + forgot_password: 'Forgot your password?' + my_profile: 'My Profile' diff --git a/log/.keep b/log/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/support/authentication_helper.rb b/spec/support/authentication_helper.rb index 7a9ffded..39b44b89 100644 --- a/spec/support/authentication_helper.rb +++ b/spec/support/authentication_helper.rb @@ -16,7 +16,7 @@ def sign_in_ui(user = nil) fill_in 'user_email', with: user.email fill_in 'user_password', with: user.password - click_button 'Log in' + click_button 'Sign in' end def sign_in(user) diff --git a/spec/systems/signup_spec.rb b/spec/systems/signup_spec.rb index 8cb5e2f9..fdba0c24 100644 --- a/spec/systems/signup_spec.rb +++ b/spec/systems/signup_spec.rb @@ -43,7 +43,7 @@ it 'displays an error message' do sign_up_ui 'good@email.com', '123' - expect(page).to have_selector('#error_explanation li') + expect(page).to have_selector('#error_explanation') end end @@ -51,13 +51,13 @@ it 'displays an error message' do sign_up_ui 'good@email.com', 'complex123password', 'differentPassword123' - expect(page).to have_selector('#error_explanation li') + expect(page).to have_selector('#error_explanation') end end context 'when an authenticated user reaches the sign up page' do it 'redirects him to the root_page' do - sign_in_ui + sign_in(Fabricate(:user)) visit new_user_registration_path expect(page).to have_current_path(root_path)