Skip to content

Commit

Permalink
[ci] save_prjconf test of webui project controller
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidKang committed Jan 12, 2017
1 parent c04a2af commit 497fcc5
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/api/spec/controllers/webui/project_controller_spec.rb
Expand Up @@ -914,6 +914,49 @@
end
end

describe 'POST #save_prjconf' do
before do
login user
end

context 'can save a project config' do
before do
post :save_prjconf, params: { project: user.home_project.name, config: 'save config' }
end

it { expect(flash[:success]).to eq('Config successfully saved!') }
it { expect(response.status).to eq(200) }
end

context 'cannot save a project config' do
before do
allow_any_instance_of(ProjectConfigFile).to receive(:save).and_return(nil)
post :save_prjconf, params: { project: user.home_project.name, config: '' }
end

it { expect(flash[:error]).not_to be_nil }
it { expect(response.status).to eq(400) }
end

context 'cannot save with an unauthorized user' do
before do
post :save_prjconf, params: { project: another_project.name, config: 'save config' }
end

it { expect(flash[:error]).to eq('Sorry, you are not authorized to update this Project.') }
it { expect(response.status).to eq(302) }
it { expect(response).to redirect_to(root_path) }
end

context 'with a non existing project' do
let(:post_save_prjconf) { post :save_prjconf, params: { project: 'non:existing:project', config: 'save config' } }

it 'raise a RecordNotFound Exception' do
expect{ post_save_prjconf }.to raise_error ActiveRecord::RecordNotFound
end
end
end

describe 'GET #clear_failed_comment' do
let(:package) { create(:package_with_failed_comment_attribute, name: 'my_package', project: user.home_project) }
let(:attribute_type) { AttribType.find_by_name("OBS:ProjectStatusPackageFailComment") }
Expand Down

0 comments on commit 497fcc5

Please sign in to comment.