Commit f9711cd8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #1355 from tsigo/gfm_spec_cleanup

GFM spec redesign
parents aecbd313 ef24576f
class CommitDecorator < ApplicationDecorator class CommitDecorator < ApplicationDecorator
decorates :commit decorates :commit
# Returns a string describing the commit for use in a link title
#
# Example
#
# "Commit: Alex Denisov - Project git clone panel"
def link_title
"Commit: #{author_name} - #{title}"
end
# Returns the commits title. # Returns the commits title.
# #
# Usually, the commit title is the first line of the commit message. # Usually, the commit title is the first line of the commit message.
......
class Commit class Commit
include ActiveModel::Conversion include ActiveModel::Conversion
include Gitlab::Encode include Gitlab::Encode
include StaticModel
extend ActiveModel::Naming extend ActiveModel::Naming
attr_accessor :commit attr_accessor :commit
...@@ -22,7 +23,6 @@ class Commit ...@@ -22,7 +23,6 @@ class Commit
:to_patch, :to_patch,
to: :commit to: :commit
class << self class << self
def find_or_first(repo, commit_id = nil, root_ref) def find_or_first(repo, commit_id = nil, root_ref)
commit = if commit_id commit = if commit_id
...@@ -105,10 +105,6 @@ class Commit ...@@ -105,10 +105,6 @@ class Commit
end end
end end
def persisted?
false
end
def initialize(raw_commit, head = nil) def initialize(raw_commit, head = nil)
@commit = raw_commit @commit = raw_commit
@head = head @head = head
......
# Provides an ActiveRecord-like interface to a model whose data is not persisted to a database.
module StaticModel
extend ActiveSupport::Concern
module ClassMethods
# Used by ActiveRecord's polymorphic association to set object_id
def primary_key
'id'
end
# Used by ActiveRecord's polymorphic association to set object_type
def base_class
self
end
end
# Used by AR for fetching attributes
#
# Pass it along if we respond to it.
def [](key)
send(key) if respond_to?(key)
end
def to_param
id
end
def persisted?
false
end
def destroyed?
false
end
end
...@@ -100,7 +100,7 @@ module Gitlab ...@@ -100,7 +100,7 @@ module Gitlab
def reference_commit(identifier) def reference_commit(identifier)
if commit = @project.commit(identifier) if commit = @project.commit(identifier)
link_to(identifier, project_commit_path(@project, id: commit.id), html_options.merge(title: "Commit: #{commit.author_name} - #{CommitDecorator.new(commit).title}", class: "gfm gfm-commit #{html_options[:class]}")) link_to(identifier, project_commit_path(@project, id: commit.id), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}"))
end end
end end
end end
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment