Skip to content
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
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ Style/StringLiterals: { EnforcedStyle: double_quotes }
Style/SymbolArray: { EnforcedStyle: brackets }
Style/WordArray: { EnforcedStyle: brackets }

<<<<<<< HEAD
# want to enable these, but they don't work right when using `.rubocop_todo.yml`
Style/DocumentationMethod: { Enabled: false }
Style/Documentation: { Enabled: false }

I18n/GetText/DecorateString:
Exclude:
- linters/**/*.rb
=======
>>>>>>> b07674c (Rubocop: fix i18n violations (#1413))
I18n/RailsI18n/DecorateString:
Exclude:
- linters/**/*.rb
- spec/**/*.rb

################################################################################
#
Expand All @@ -73,6 +77,7 @@ I18n/RailsI18n/DecorateString:
Bundler/GemComment: { Enabled: false }
Bundler/GemVersion: { Enabled: false }
Capybara/AmbiguousClick: { Enabled: false }
I18n/GetText: { Enabled: false }
Layout/SingleLineBlockChain: { Enabled: false }
Lint/ConstantResolution: { Enabled: false }
Rails/BulkChangeTable: { Enabled: false }
Expand Down
8 changes: 8 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
# Offense count: 3
Capybara/RSpec/NegationMatcherAfterVisit:
Exclude:
<<<<<<< HEAD
- 'spec/system/account_setup_spec.rb'
- 'spec/system/stories_index_spec.rb'
=======
- 'Gemfile'
>>>>>>> b07674c (Rubocop: fix i18n violations (#1413))

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
Expand Down Expand Up @@ -239,6 +243,7 @@ Rails/InverseOf:
Exclude:
- 'app/models/feed.rb'

<<<<<<< HEAD
# Offense count: 3
Rails/ReversibleMigrationMethodDefinition:
Exclude:
Expand All @@ -259,6 +264,9 @@ Rails/SaveBang:
- 'db/migrate/20130821020313_update_nil_entry_ids.rb'

# Offense count: 2
=======
# Offense count: 1
>>>>>>> b07674c (Rubocop: fix i18n violations (#1413))
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
Rails/SkipsModelValidations:
Expand Down
50 changes: 50 additions & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

require_relative "application_controller"

class AccountsController < ApplicationController
skip_before_action(:authenticate_user, only: [:new, :create])

def show
render(Views::Accounts::Show.new(user: current_user))
end

def new
render(Views::Accounts::New.new(user: User.new))
end

def create
user = User.new(user_params)
if user.save
flash[:success] = t(".success")
log_in(user)
redirect_to(root_path)
else
flash.now[:error] = t(".error")
render(Views::Accounts::New.new(user:))
end
end

def update
if current_user.update(user_params)
flash[:success] = t(".success")
redirect_to(root_path)
else
flash.now[:error] = t(".error")
render(Views::Accounts::Show.new(user: current_user))
end
end

def destroy
current_user.destroy!
log_out
flash[:success] = t(".success")
redirect_to(root_path)
end

private

def user_params
params.expect(user: [:email, :password, :password_confirmation])
end
end
5 changes: 5 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ def create
redirect_uri = session.delete(:redirect_to) || "/"
redirect_to(redirect_uri)
else
<<<<<<< HEAD
flash.now[:error] = t("sessions.new.flash.wrong_password")
render(:new)
=======
flash.now[:error] = t(".error")
render(Views::Sessions::New.new)
>>>>>>> b07674c (Rubocop: fix i18n violations (#1413))
end
end

Expand Down
17 changes: 16 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
en:
<<<<<<< HEAD
archive:
next: Next
of: of
Expand Down Expand Up @@ -192,4 +193,18 @@ en:
stories_order: "Stories feed order"
user/stories_order:
asc: "Oldest first"
desc: "Newest first"
desc: "Newest first"
=======
accounts:
create:
success: "Account created successfully"
error: "There was a problem setting up your account"
update:
success: "Account updated successfully"
error: "There was a problem updating your account"
destroy:
success: "Account permanently deleted"
sessions:
create:
error: "Invalid email or password"
>>>>>>> b07674c (Rubocop: fix i18n violations (#1413))
Loading