-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Results by cookie #79
base: master
Are you sure you want to change the base?
Conversation
Thanks for opening this up! I'll take a look at this over the next few days. |
end | ||
|
||
test "does not save results if the peek cookie is not set" do | ||
assert_not_called(Peek.adapter, :save) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be an assertion here that the cookie isn't set.
Thanks for being patient with me, I gave this a round of review. Let me know what you think. |
Great feedback. I'll fix this up. |
Hi @dewski - I updated this branch according to your feedback. I changed the the name of the cookie test from This test could be better: https://github.com/peek/peek/pull/79/files#diff-d89c7ee11ab586df930a3fb679d46386R10. It is redundant with the other tests now and is actually testing if the request is saved. Ideally, this would be testing that |
Could you clarify what you mentioned here? I'd like to have |
end | ||
|
||
test "the request id is set" do | ||
test "the request id is set when the peek cookie is set" do | ||
assert_empty Peek.adapter.requests | ||
get '/' | ||
assert_not_empty Peek.adapter.requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the test case changed here at all, just need to update the test body:
assert_empty Peek.request_id
get '/'
refute_empty Peek.request_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Will update this.
Sure. class ApplicationController < ActionController::Base
def peek_enabled?
current_user.staff?
end
end If we were to reuse Perhaps this is the behavior you would like, which would make this behavior opt-in and we should add this info to the README. It was my intention to turn this behavior on by default, because its zero-cognitive-load on the user and I cannot think of a case where a user would need the results when the bar is not visible. Either way works! |
class ApplicationController < ActionController::Base
def peek_enabled?
return false unless peek_bar_visible?
current_user.staff?
end
end |
Hi @dewski - Hoping we can resolve this soon. What are your thoughts on #79 (comment) ? |
@@ -68,4 +77,5 @@ do ($ = jQuery) -> | |||
|
|||
$ -> | |||
if peekEnabled() | |||
setPeekEnabledCookie(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't set the peek=true
cookie for every request as it will ignore the user's preference if they've set it to false.
@@ -20,7 +20,10 @@ class Railtie < ::Rails::Engine | |||
|
|||
initializer 'peek.persist_request_data' do | |||
ActiveSupport::Notifications.subscribe('process_action.action_controller') do | |||
Peek.adapter.save | |||
|_, _, _, _, payload| | |||
if payload[:peek_bar_visible] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update this to check if payload[:peek_enabled]
.
Hi @deski - Following up on our discussion in #78
This PR adds info from the peek cookie as discussed. It does not save Peek results unless the peek cookie is enabled. Always sets the cookie if peek is enabled.
In the case Peek was not enabled for a request, and is toggled on,
Peek::Views
with adata-defer-to
are hidden and a refresh message is displayed: