Skip to content

Commit

Permalink
Merge pull request #1937 from lgalis/fix_pdf_download_for_foreman_con…
Browse files Browse the repository at this point in the history
…fig_profile

Fix pdf download for configuration profiles
(cherry picked from commit 333c8a0)

https://bugzilla.redhat.com/show_bug.cgi?id=1512695
  • Loading branch information
h-kataria authored and simaishi committed Nov 13, 2017
1 parent a9750d5 commit 48946b8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
7 changes: 0 additions & 7 deletions app/controllers/automation_manager_controller.rb
Expand Up @@ -93,13 +93,6 @@ def x_show
generic_x_show
end

def identify_record(id, klass = self.class.model)
type, _id = parse_nodetype_and_id(x_node)
klass = TreeBuilder.get_model_for_prefix(type).constantize if type
record = super(id, klass)
record
end

def tree_record
@record =
case x_active_tree
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/mixins/manager_controller_mixin.rb
Expand Up @@ -118,6 +118,13 @@ def explorer
render :layout => "application"
end

def identify_record(id, klass = self.class.model)
type, _id = parse_nodetype_and_id(x_node)
klass = TreeBuilder.get_model_for_prefix(type).constantize if type
record = super(id, klass)
record
end

def tree_autoload
@view ||= session[:view]
super
Expand Down
23 changes: 23 additions & 0 deletions spec/controllers/provider_foreman_controller_spec.rb
Expand Up @@ -594,6 +594,29 @@
end
end

context 'download pdf file' do
let(:pdf_options) { controller.instance_variable_get(:@options) }

before :each do
@record = @config_profile
allow(PdfGenerator).to receive(:pdf_from_string).and_return("")
allow(controller).to receive(:tagdata).and_return(nil)
allow(controller).to receive(:x_node).and_return(config_profile_key(@config_profile))
login_as FactoryGirl.create(:user_admin)
stub_user(:features => :all)
end

it 'request returns 200' do
get :download_summary_pdf, :params => {:id => @record.id}
expect(response.status).to eq(200)
end

it 'title is set correctly' do
get :download_summary_pdf, :params => {:id => @record.id}
expect(pdf_options[:title]).to eq("#{ui_lookup(:model => @record.class.name)} \"#{@record.name}\"")
end
end

def user_with_feature(features)
features = EvmSpecHelper.specific_product_features(*features)
FactoryGirl.create(:user, :features => features)
Expand Down

0 comments on commit 48946b8

Please sign in to comment.