Commit 477378bd9f00752402773a213137314b6ee2fb6e
1 parent
2fce2408
Exists in
colab
and in
4 other branches
Added unit test for branches_params on repositories controller
Signed-off-by: Pedro Scocco <pedroscocco@gmail.com>
Showing
1 changed file
with
28 additions
and
0 deletions
Show diff stats
spec/controllers/repositories_controller_spec.rb
| ... | ... | @@ -382,4 +382,32 @@ describe RepositoriesController, :type => :controller do |
| 382 | 382 | it { is_expected.to respond_with(:success) } |
| 383 | 383 | end |
| 384 | 384 | end |
| 385 | + | |
| 386 | + describe 'branches_params' do | |
| 387 | + let!(:url) { 'dummy-url' } | |
| 388 | + let!(:scm_type) { 'GIT' } | |
| 389 | + let(:parameters) { ActionController::Parameters.new(scm_type: scm_type, url: url) } | |
| 390 | + | |
| 391 | + context 'valid parameters' do | |
| 392 | + it 'should return a hash with the permitted parameters' do | |
| 393 | + subject.params = parameters | |
| 394 | + expect(subject.params.permitted?).to be_falsey | |
| 395 | + result = subject.send(:branches_params) | |
| 396 | + expect(result).to eq(parameters) | |
| 397 | + expect(result.permitted?).to be_truthy | |
| 398 | + end | |
| 399 | + end | |
| 400 | + | |
| 401 | + context 'invalid parameters' do | |
| 402 | + let(:invalid_parameters) { ActionController::Parameters.new(scm_type: scm_type, url: url, something_evil: 'fizzbuzz') } | |
| 403 | + | |
| 404 | + it 'should return a valid parameters hash' do | |
| 405 | + subject.params = invalid_parameters | |
| 406 | + expect(subject.params.permitted?).to be_falsey | |
| 407 | + result = subject.send(:branches_params) | |
| 408 | + expect(result).to eq(parameters) | |
| 409 | + expect(result.permitted?).to be_truthy | |
| 410 | + end | |
| 411 | + end | |
| 412 | + end | |
| 385 | 413 | end | ... | ... |