Skip to content

Commit

Permalink
Stop testing set_project in child controllers
Browse files Browse the repository at this point in the history
I think it's enough if we test the before filter once...
  • Loading branch information
hennevogel committed Sep 27, 2023
1 parent 8d66433 commit a734903
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 39 deletions.
11 changes: 0 additions & 11 deletions src/api/spec/controllers/webui/feeds_controller_spec.rb
Expand Up @@ -12,17 +12,6 @@
expect(assigns(:commits)).to eq([commit])
end

it 'assigns @project' do
get :commits, params: { project: project, format: 'atom' }
expect(assigns(:project)).to eq(project)
end

it 'fails if project is not existent' do
expect do
get :commits, params: { project: 'DoesNotExist', format: 'atom' }
end.to raise_error ActiveRecord::RecordNotFound
end

it 'renders the rss template' do
get :commits, params: { project: project, format: 'atom' }
expect(response).to render_template('webui/feeds/commits')
Expand Down
12 changes: 2 additions & 10 deletions src/api/spec/controllers/webui/project_controller_spec.rb
Expand Up @@ -499,11 +499,11 @@
end

it 'without a repository param' do
expect { post :remove_path_from_target, params: { project: user } }.to raise_error ActiveRecord::RecordNotFound
expect { post :remove_path_from_target, params: { project: user.home_project } }.to raise_error ActiveRecord::RecordNotFound
end

it 'with a repository param but without a path param' do
expect { post :remove_path_from_target, params: { repository: repo_for_user_home.id, project: user } }.to raise_error ActiveRecord::RecordNotFound
expect { post :remove_path_from_target, params: { repository: repo_for_user_home.id, project: user.home_project } }.to raise_error ActiveRecord::RecordNotFound
end

context 'with a repository and path' do
Expand Down Expand Up @@ -774,14 +774,6 @@
end
end
end

context 'with non existing project' do
before do
login admin_user
end

it { expect { post :move_path, params: { project: 'non:existent:project' } }.to raise_error ActiveRecord::RecordNotFound }
end
end

describe 'GET #monitor' do
Expand Down
Expand Up @@ -10,10 +10,6 @@
request.env['HTTP_REFERER'] = root_url # Needed for the redirect_to :back
end

it 'without an existent project will raise an exception' do
expect { post :create, params: { project_name: 'non:existent:project' } }.to raise_error(ActiveRecord::RecordNotFound)
end

context 'without a proper action for the maintenance project' do
before do
post :create, params: { project_name: maintenance_project, description: 'Fake description for a request' }
Expand Down
Expand Up @@ -17,12 +17,6 @@
login user
end

context 'with a nonexistent project' do
let(:post_save_meta) { post :update, params: { project_name: 'nonexistent_project' }, xhr: true }

it { expect { post_save_meta }.to raise_error(ActiveRecord::RecordNotFound) }
end

context 'with a valid project' do
context 'without a valid meta' do
before do
Expand Down
Expand Up @@ -69,13 +69,5 @@
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_update) { post :update, params: { project_name: 'non:existing:project', config: 'save config' } }

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

0 comments on commit a734903

Please sign in to comment.