diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-09-02 01:09:52 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-09-02 01:09:52 +0300 |
commit | ca8d225307280750597150b0b969998f99aad4a5 (patch) | |
tree | 3114b04f16b368ad3794469b8a6a158fb2c7b780 /spec/support/markdown_feature.rb | |
parent | 86f706b169bc77b7cf4323dffc5cc7124413eac1 (diff) |
Update MarkdownFeature support class
- Memoize variables a bit more cleanly
- Add user to project's team
Diffstat (limited to 'spec/support/markdown_feature.rb')
-rw-r--r-- | spec/support/markdown_feature.rb | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/spec/support/markdown_feature.rb b/spec/support/markdown_feature.rb index 39a64391460..bedc1a7f1db 100644 --- a/spec/support/markdown_feature.rb +++ b/spec/support/markdown_feature.rb @@ -15,18 +15,17 @@ class MarkdownFeature end def group - unless @group - @group = create(:group) - @group.add_developer(user) + @group ||= create(:group).tap do |group| + group.add_developer(user) end - - @group end # Direct references ---------------------------------------------------------- def project - @project ||= create(:project) + @project ||= create(:project).tap do |project| + project.team << [user, :master] + end end def issue @@ -46,12 +45,10 @@ class MarkdownFeature end def commit_range - unless @commit_range + @commit_range ||= begin commit2 = project.commit('HEAD~3') - @commit_range = CommitRange.new("#{commit.id}...#{commit2.id}", project) + CommitRange.new("#{commit.id}...#{commit2.id}", project) end - - @commit_range end def simple_label @@ -65,13 +62,12 @@ class MarkdownFeature # Cross-references ----------------------------------------------------------- def xproject - unless @xproject + @xproject ||= begin namespace = create(:namespace, name: 'cross-reference') - @xproject = create(:project, namespace: namespace) - @xproject.team << [user, :developer] + create(:project, namespace: namespace) do |project| + project.team << [user, :developer] + end end - - @xproject end def xissue @@ -91,12 +87,10 @@ class MarkdownFeature end def xcommit_range - unless @xcommit_range + @xcommit_range ||= begin xcommit2 = xproject.commit('HEAD~2') - @xcommit_range = CommitRange.new("#{xcommit.id}...#{xcommit2.id}", xproject) + CommitRange.new("#{xcommit.id}...#{xcommit2.id}", xproject) end - - @xcommit_range end def raw_markdown |