Delegate Current.user to session
This commit is contained in:
@@ -3,9 +3,7 @@ module Bubble::Assignable
|
||||
|
||||
included do
|
||||
has_many :assignments, dependent: :delete_all
|
||||
|
||||
has_many :assignees, through: :assignments
|
||||
has_many :assigners, through: :assignments
|
||||
|
||||
scope :unassigned, -> { where.missing :assignments }
|
||||
scope :assigned_to, ->(users) { joins(:assignments).where(assignments: { assignee: users }) }
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
class Current < ActiveSupport::CurrentAttributes
|
||||
attribute :session, :user
|
||||
attribute :session
|
||||
|
||||
delegate :user, to: :session, allow_nil: true
|
||||
delegate :account, to: :user, allow_nil: true
|
||||
|
||||
def session=(session)
|
||||
super
|
||||
self.user = session.user
|
||||
end
|
||||
end
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
david:
|
||||
user: david
|
||||
@@ -2,7 +2,7 @@ require "test_helper"
|
||||
|
||||
class BubbleTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
Current.user = users(:kevin)
|
||||
Current.session = sessions(:david)
|
||||
end
|
||||
|
||||
test "boosting" do
|
||||
@@ -15,7 +15,6 @@ class BubbleTest < ActiveSupport::TestCase
|
||||
bubbles(:logo).assign users(:david)
|
||||
|
||||
assert_equal users(:kevin, :jz, :david), bubbles(:logo).assignees
|
||||
assert_equal users(:david, :kevin), bubbles(:logo).assigners.uniq
|
||||
assert_equal [ "David" ], Event.last.assignee_names
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user