summaryrefslogtreecommitdiff
path: root/app/helpers/snippets_helper.rb
blob: 906cb12cd48f911c0e1fde91be1a577315c682e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module SnippetsHelper
  def lifetime_select_options
    options = [
        ['forever', nil],
        ['1 day',   "#{Date.current + 1.day}"],
        ['1 week',  "#{Date.current + 1.week}"],
        ['1 month', "#{Date.current + 1.month}"]
    ]
    options_for_select(options)
  end

  def reliable_snippet_path(snippet)
    if snippet.project_id?
      namespace_project_snippet_path(snippet.project.namespace,
                                     snippet.project, snippet)
    else
      snippet_path(snippet)
    end
  end
end