-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow pages to be viewed multiple times (#94)
***If one wishes to post a vanishing to note to a group*** * This allows a page to be viewed multiple times. The pages expiration controls when it is not visible. So a page set to expire in five minutes could be viewed by multiple people (e.g. in a group text thread or slack channel) before vanishing. ***Follow up*** * This could be a default option * The timing options may need to change (30 seconds could be an option even though that is pushing it with a free Heroku tier) * Perhaps more instructions could be added here too. * write a cron task to destroy the expired pages. ***Details*** * Instead of calling page.destroy! from the controller there is a new `page#view!` method that decides whether to destroy the page. If the boolean field `multiview` was set to `true` when the page was created then the page will not be destroyed. * The `unexpired` scope now prevents these pages from being destroyed. * The cron tasks that used to destroy pages do not run on Heroku (this was originally on digital ocean). This means the pages will sit around for now.
- Loading branch information
1 parent
66a068a
commit 8d0310b
Showing
8 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ def page_params | |
:duration, | ||
:expires_at, | ||
:message, | ||
:multiview, | ||
:password, | ||
:redirect, | ||
:url_key | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ def page_password | |
end | ||
|
||
def reveal(page) | ||
page.destroy! | ||
page.view! | ||
render "pages/show" | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddMultiviewToPages < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :pages, :multiview, :boolean, default: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "rails_helper" | ||
|
||
feature "create and view a multiview page" do | ||
scenario "visit a page twice" do | ||
visit new_page_path | ||
fill_in "page_url_key", with: "example" | ||
fill_in "page_message", with: "Stop Rebulba!" | ||
check "page_multiview" | ||
|
||
click_button "Create" | ||
|
||
visit page_path("example") | ||
|
||
expect(page).to have_text("Stop Rebulba!") | ||
|
||
visit page_path("example") | ||
|
||
expect(page).to have_text("Stop Rebulba!") | ||
end | ||
|
||
scenario "with password" do | ||
visit new_page_path | ||
fill_in "page_url_key", with: "example" | ||
fill_in "page_message", with: "Stop Rebulba!" | ||
check "page_multiview" | ||
fill_in "page_password", with: "password" | ||
|
||
click_button "Create" | ||
|
||
visit page_path("example") | ||
fill_in "Password", with: "password" | ||
click_button "Submit" | ||
|
||
expect(page).to have_text("Stop Rebulba!") | ||
|
||
visit page_path("example") | ||
fill_in "Password", with: "password" | ||
click_button "Submit" | ||
|
||
expect(page).to have_text("Stop Rebulba!") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters