Module: IssuesCalendar

Extended by:
ActiveSupport::Concern
Included in:
IssuableCollectionsAction, Projects::IssuesController
Defined in:
app/controllers/concerns/issues_calendar.rb

Instance Method Summary collapse

Instance Method Details

#render_issues_calendar(issuables) ⇒ Object

rubocop:disable Gitlab/ModuleWithInstanceVariables rubocop: disable CodeReuse/ActiveRecord


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/concerns/issues_calendar.rb', line 8

def render_issues_calendar(issuables)
  @issues = issuables
                .non_archived
                .with_due_date
                .limit(100)

  respond_to do |format|
    format.ics do
      # NOTE: with text/calendar as Content-Type, the browser always downloads
      #       the content as a file (even ignoring the Content-Disposition
      #       header). We want to display the content inline when accessed
      #       from GitLab, similarly to the RSS feed.
      if request.referer&.start_with?(::Settings.gitlab.base_url)
        response.headers['Content-Type'] = 'text/plain'
      end
    end
  end
end