-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1205 from dradis/liquid-assigns-service
Add LiquidAssignsService
- Loading branch information
Showing
6 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class LiquidAssignsService | ||
attr_accessor :project | ||
|
||
def initialize(project) | ||
@project = project | ||
end | ||
|
||
def assigns | ||
result = { 'project' => ProjectDrop.new(project) } | ||
result.merge!(assigns_pro) if defined?(Dradis::Pro) | ||
result | ||
end | ||
|
||
private | ||
|
||
def assigns_pro | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe LiquidAssignsService do | ||
let!(:project) { create(:project) } | ||
|
||
let(:liquid_assigns) { described_class.new(project).assigns } | ||
|
||
it 'builds a hash of liquid assigns' do | ||
expect(liquid_assigns['project'].name).to eq(project.name) | ||
end | ||
|
||
context 'with pro records', skip: !defined?(Dradis::Pro) do | ||
let!(:project) { create(:project, :with_team) } | ||
|
||
before do | ||
report_content = project.content_library | ||
report_content.properties = { 'dradis.project' => project.name } | ||
report_content.save | ||
end | ||
|
||
it 'builds a hash with Dradis::Pro assigns' do | ||
expect(liquid_assigns['document_properties'].available_properties).to eq({ 'dradis.project' => project.name }) | ||
expect(liquid_assigns['team'].name).to eq(project.team.name) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters