Commit ca8d2253 authored by Robert Speicher's avatar Robert Speicher

Update MarkdownFeature support class

- Memoize variables a bit more cleanly
- Add user to project's team
parent 86f706b1
...@@ -15,18 +15,17 @@ class MarkdownFeature ...@@ -15,18 +15,17 @@ class MarkdownFeature
end end
def group def group
unless @group @group ||= create(:group).tap do |group|
@group = create(:group) group.add_developer(user)
@group.add_developer(user)
end end
@group
end end
# Direct references ---------------------------------------------------------- # Direct references ----------------------------------------------------------
def project def project
@project ||= create(:project) @project ||= create(:project).tap do |project|
project.team << [user, :master]
end
end end
def issue def issue
...@@ -46,12 +45,10 @@ class MarkdownFeature ...@@ -46,12 +45,10 @@ class MarkdownFeature
end end
def commit_range def commit_range
unless @commit_range @commit_range ||= begin
commit2 = project.commit('HEAD~3') commit2 = project.commit('HEAD~3')
@commit_range = CommitRange.new("#{commit.id}...#{commit2.id}", project) CommitRange.new("#{commit.id}...#{commit2.id}", project)
end end
@commit_range
end end
def simple_label def simple_label
...@@ -65,13 +62,12 @@ class MarkdownFeature ...@@ -65,13 +62,12 @@ class MarkdownFeature
# Cross-references ----------------------------------------------------------- # Cross-references -----------------------------------------------------------
def xproject def xproject
unless @xproject @xproject ||= begin
namespace = create(:namespace, name: 'cross-reference') namespace = create(:namespace, name: 'cross-reference')
@xproject = create(:project, namespace: namespace) create(:project, namespace: namespace) do |project|
@xproject.team << [user, :developer] project.team << [user, :developer]
end
end end
@xproject
end end
def xissue def xissue
...@@ -91,12 +87,10 @@ class MarkdownFeature ...@@ -91,12 +87,10 @@ class MarkdownFeature
end end
def xcommit_range def xcommit_range
unless @xcommit_range @xcommit_range ||= begin
xcommit2 = xproject.commit('HEAD~2') xcommit2 = xproject.commit('HEAD~2')
@xcommit_range = CommitRange.new("#{xcommit.id}...#{xcommit2.id}", xproject) CommitRange.new("#{xcommit.id}...#{xcommit2.id}", xproject)
end end
@xcommit_range
end end
def raw_markdown def raw_markdown
......
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