Simplify emulating last_sign_in_at
We were updating the database after starting the browser to emulate the behavior where a user logs in a day before the current request. We can use `current_sign_in_at` instead and devise will automatically copy that value to `last_sign_in_at` after users visit a page. This way we avoid setting up the database after the process runnin the browser has been started.
This commit is contained in:
@@ -484,10 +484,7 @@ describe "Proposal's dashboard" do
|
||||
end
|
||||
|
||||
describe "detect_new_actions_after_last_login" do
|
||||
before do
|
||||
visit proposal_dashboard_path(proposal)
|
||||
proposal.author.update!(last_sign_in_at: Date.yesterday)
|
||||
end
|
||||
before { proposal.author.update!(current_sign_in_at: 1.day.ago) }
|
||||
|
||||
scenario "Display tag 'new' on resouce when it is new for author since last login" do
|
||||
resource = create(:dashboard_action, :resource, :active, day_offset: 0,
|
||||
@@ -503,7 +500,7 @@ describe "Proposal's dashboard" do
|
||||
scenario "Not display tag 'new' on resouce when there is not new resources since last login" do
|
||||
resource = create(:dashboard_action, :resource, :active, day_offset: 0,
|
||||
published_proposal: false)
|
||||
proposal.author.update!(last_sign_in_at: Date.current)
|
||||
proposal.author.update!(current_sign_in_at: Date.current)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
@@ -526,7 +523,7 @@ describe "Proposal's dashboard" do
|
||||
scenario "Not display tag 'new' on proposed_action when there is not new since last login" do
|
||||
proposed_action = create(:dashboard_action, :proposed_action, :active, day_offset: 0,
|
||||
published_proposal: false)
|
||||
proposal.author.update!(last_sign_in_at: Date.current)
|
||||
proposal.author.update!(current_sign_in_at: Date.current)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
@@ -547,7 +544,7 @@ describe "Proposal's dashboard" do
|
||||
|
||||
scenario "Not display tag 'new' on sidebar when there is not a new resouce since last login" do
|
||||
create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: false)
|
||||
proposal.author.update!(last_sign_in_at: Date.current)
|
||||
proposal.author.update!(current_sign_in_at: Date.current)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user