Skip to content

Commit

Permalink
wip: more tests for controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
jkremser committed Mar 15, 2017
1 parent 5c26251 commit 08d6411
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion spec/controllers/middleware_server_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@

it do
is_expected.to have_http_status 200
is_expected.to render_template(:partial => 'layouts/listnav/_middleware_server')
is_expected.to render_template(:partial => 'layouts/_textual_groups_generic')
end
end

context 'render listnav partial' do
render_views
it do
is_expected.to have_http_status 200
is_expected.to render_template(:partial => 'layouts/listnav/_middleware_server')
end
end
end

# FIXME: should test for nested entities: %w(middleware_datasources middleware_deployments middleware_messagings)
Expand All @@ -44,4 +51,56 @@
assert_nested_list(server, [deployment], 'middleware_deployments', 'All Middleware Deployments')
end
end

context '#tags_edit' do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@server = FactoryGirl.create(:hawkular_middleware_server, :properties => {}, :middleware_server_group => nil)
allow(@server).to receive(:tagged_with).with(:cat => user.userid).and_return('my tags')
classification = FactoryGirl.create(:classification, :name => 'department', :description => 'Department')
@tag1 = FactoryGirl.create(:classification_tag,
:name => 'tag1',
:parent => classification)
@tag2 = FactoryGirl.create(:classification_tag,
:name => 'tag2',
:parent => classification)
allow(Classification).to receive(:find_assigned_entries).with(@server).and_return([@tag1, @tag2])
session[:tag_db] = 'MiddlewareServer'
edit = {
:key => "MiddlewareServer_edit_tags__#{@server.id}",
:tagging => 'MiddlewareServer',
:object_ids => [@server.id],
:current => {:assignments => []},
:new => {:assignments => [@tag1.id, @tag2.id]}
}
session[:edit] = edit
end

after(:each) do
expect(response.status).to eq(200)
end

it 'builds tagging screen' do
post :button, :params => { :pressed => 'middleware_server_tag', :format => :js, :id => @server.id }
expect(assigns(:flash_array)).to be_nil
end

it 'cancels tags edit' do
session[:breadcrumbs] = [{:url => "middleware_server/show/#{@server.id}"}, 'placeholder']
post :tagging_edit, :params => { :button => 'cancel', :format => :js, :id => @server.id }
expect(assigns(:flash_array).first[:message]).to include('was cancelled by the user')
expect(assigns(:edit)).to be_nil
end

it 'save tags' do
session[:breadcrumbs] = [{:url => "middleware_server/show/#{@server.id}"}, 'placeholder']
post :tagging_edit, :params => { :button => 'save', :format => :js, :id => @server.id }
expect(assigns(:flash_array).first[:message]).to include('Tag edits were successfully saved')
expect(assigns(:edit)).to be_nil
end
end

# todo:
# include_examples '#download_summary_pdf', :middleware_server
end

0 comments on commit 08d6411

Please sign in to comment.