gitlab-org--gitlab-foss/app/models/blob_viewer
Francisco Javier López 5a3e6fdff9
Fixing image lfs bug and also displaying text lfs
This commit, introduced in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23812,
fixes a problem creating a displaying image diff notes when the image
is stored in LFS. The main problem was that `Gitlab::Diff::File` was
returning an invalid valid in `text?` for this kind of files.

It also fixes a rendering problem with other LFS files, like text
ones. They LFS pointer shouldn't be shown when LFS is enabled
for the project, but they were.
2018-12-27 16:51:07 +01:00
..
auxiliary.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
balsamiq.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
base.rb Fixing image lfs bug and also displaying text lfs 2018-12-27 16:51:07 +01:00
binary_stl.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
cartfile.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
changelog.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
client_side.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
composer_json.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
contributing.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
dependency_manager.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
download.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
empty.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
gemfile.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
gemspec.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
gitlab_ci_yml.rb Address MR suggestions 2018-09-07 22:22:52 +02:00
godeps_json.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
image.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
license.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
markup.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
notebook.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
package_json.rb Fix xss vulnerability sourced from package.json's homepage 2018-09-19 09:13:33 +08:00
pdf.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
podfile.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
podspec.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
podspec_json.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
readme.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
requirements_txt.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
rich.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
route_map.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
server_side.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
simple.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
sketch.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
static.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
svg.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
text.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
text_stl.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
video.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00
yarn_lock.rb Enable frozen string for app/models/**/*.rb 2018-08-03 01:44:16 -07:00

# frozen_string_literal: true

module BlobViewer
  class Readme < Base
    include Auxiliary
    include Static

    self.partial_name = 'readme'
    self.file_types = %i(readme)
    self.binary = false

    def visible_to?(current_user)
      can?(current_user, :read_wiki, project)
    end

    def render_error
      return if project.has_external_wiki? || (project.wiki_enabled? && project.wiki.has_home_page?)

      :no_wiki
    end
  end
end