Skip to content

Commit

Permalink
chore: use wallaby_user instead, will take out current_user in the fu…
Browse files Browse the repository at this point in the history
…ture (#185)

* chore: use wallaby_user instead

* chore: move specs to wallaby-core

* chore: correct the document

* chore: bump version to 6.1.2
  • Loading branch information
tian-im committed Apr 12, 2020
1 parent baa04ff commit 841afd5
Show file tree
Hide file tree
Showing 105 changed files with 41 additions and 5,038 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Data audit (use papertrail) (maybe..)
- Batch data action (maybe..)

## [6.1.2](https://github.com/wallaby-rails/wallaby-core/releases/tag/6.1.2) - 2020-04-12

- chore: use wallaby_user instead, will take out current_user in the future ([#185](https://github.com/wallaby-rails/wallaby/pull/185))

## [6.1.1](https://github.com/wallaby-rails/wallaby-core/releases/tag/6.1.1) - 2020-03-24

- chore: use wt for I18n ([#184](https://github.com/wallaby-rails/wallaby/pull/184))
Expand Down
2 changes: 1 addition & 1 deletion app/views/wallaby/resources/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<%# //Resources navigation %>
<%# User account %>
<ul class="navbar-nav ml-auto">
<% if current_user.present? %>
<% if wallaby_user.present? %>
<li class="nav-item dropdown">
<a id="user_menu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
class="nav-link dropdown-toggle">
Expand Down
2 changes: 1 addition & 1 deletion docs/controller.5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ that it can be completely replaced, just need to bear in mind that `@resource` i
# to access the record, use `resource`
resource
# to re-assign the resource, assign to `@resource`
@resource = Product.find_by(id: param[:id], owner_id: current_user.id)
@resource = Product.find_by(id: param[:id], owner_id: wallaby_user.id)
super
end
end
Expand Down
8 changes: 4 additions & 4 deletions docs/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For non-resourceful actions:
And it is possible:

- [authenticate_user!](#authenticate_user) - authenticates the current user.
- [current_user](#current_user) - returns the object for the signed-in user.
- [wallaby_user](#wallaby_user) - returns the object for the signed-in user.
- [collection](#collection) - returns the paginated collection.
- [resource](#resource) - returns the resource by given ID.
- [resource_params](#resource_params) - returns the white-listed parameters for mass assignment.
Expand Down Expand Up @@ -440,7 +440,7 @@ end

Or it can be customized via [authenticate_user configuration](configuration.md#authenticate_user-and-current_user).

## current_user
## wallaby_user

This is the method that Wallaby uses to return the object of the signed-in user.

Expand All @@ -449,9 +449,9 @@ This is the method that Wallaby uses to return the object of the signed-in user.
To customize, override it:

```ruby
def current_user
def wallaby_user
# user example
@current_user ||= Class.new do
@wallaby_user ||= Class.new do
def email
'user@example.com'
end
Expand Down
2 changes: 1 addition & 1 deletion docs/servicer.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ end

> since 5.2.0
It's the reference of `current_user` from controller. To access `user`, it goes:
It's the reference of `wallaby_user` from controller. To access `user`, it goes:

```ruby
# app/servicers/admin/product_servicer.rb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module <%= class_name %>
# end

# # customize how user record should be returned
# def current_user
# def wallaby_user
# super # do something for all the subclasses
# end

Expand Down
2 changes: 1 addition & 1 deletion lib/wallaby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Wallaby
VERSION = '6.1.1' # :nodoc:
VERSION = '6.1.2' # :nodoc:
end
17 changes: 0 additions & 17 deletions spec/active_record/associations_spec.rb

This file was deleted.

61 changes: 0 additions & 61 deletions spec/active_record/mysql_types_spec.rb

This file was deleted.

0 comments on commit 841afd5

Please sign in to comment.