-
Notifications
You must be signed in to change notification settings - Fork 0
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
Copy updates, README, 1 minute expiration #95
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
GIPHY_API_KEY=dc6zaTOxFJmzC | ||
SECRET_KEY_BASE=fdc920daa3ba32addf527859a13d555ea5a54ebdd297c24d3d0c67adc336aceb6e07befeec38c6583368bdfb09c83744c41da973c0477ff82fa6ec1743d977cb | ||
HOST=test.com |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,39 @@ def duration_state | |
end | ||
end | ||
|
||
def sendable_message | ||
link = Rails.application.routes.url_helpers.page_url(self) | ||
message = "Here is a link to a onetime note" | ||
message += " that expires in #{time_until_expiration}" | ||
message += " (" | ||
message += "#{expires_at.in_time_zone.strftime("%m/%d/%Y")}" | ||
message += " at #{expires_at.in_time_zone.strftime("%I:%M%p %Z")}." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. |
||
message += ")" | ||
message += " It can only be viewed once." unless multiview? | ||
message += " " | ||
message += link | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lint/UselessAssignment: Useless assignment to variable - message. Use + instead of +=. |
||
end | ||
|
||
def to_param | ||
url_key | ||
end | ||
|
||
private | ||
|
||
def time_until_expiration | ||
seconds_until_expiration = expires_at - Time.current | ||
unit = if seconds_until_expiration > 1.day | ||
"day" | ||
elsif seconds_until_expiration > 1.hour | ||
"hour" | ||
elsif seconds_until_expiration > 1.minute | ||
"minute" | ||
else | ||
"second" | ||
end | ||
"#{(seconds_until_expiration / 1.send(unit)).round} #{unit.pluralize}" | ||
end | ||
|
||
def duration_error? | ||
errors.include?(:duration) | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,16 @@ class Application < Rails::Application | |
end | ||
|
||
config.action_controller.action_on_unpermitted_parameters = :raise | ||
Rails.application.routes.default_url_options[:host] = ENV.fetch('HOST') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
# Settings in config/environments/* take precedence over those specified here. | ||
# Application configuration should go into files in config/initializers | ||
# -- all .rb files in that directory are automatically loaded. | ||
|
||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. | ||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. | ||
# config.time_zone = 'Central Time (US & Canada)' | ||
config.time_zone = 'Eastern Time (US & Canada)' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
config.active_record.default_timezone = :local | ||
|
||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. | ||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,10 @@ | |
expect(page_presenter.optional_fields_state).to eq("") | ||
end | ||
end | ||
|
||
describe "#sendable_message" do | ||
it 'says' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning. |
||
end | ||
end | ||
end |
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.
Style/UnneededInterpolation: Prefer to_s over string interpolation.
Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.