mysociety/alaveteli

View on GitHub
spec/controllers/admin_user_controller_spec.rb

Summary

Maintainability
C
1 day
Test Coverage

File admin_user_controller_spec.rb has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe AdminUserController do

  describe 'GET index' do
Severity: Minor
Found in spec/controllers/admin_user_controller_spec.rb - About 3 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        it 'sets the given comments visibility to hidden' do
          comments = FactoryGirl.create_list(:visible_comment, 3, :user => @user)
          comment_ids = comments.map(&:id)
    
          post :modify_comment_visibility, { :id => @user.id,
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 40 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 350..358

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 37.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        it 'sets the given comments visibility to visible' do
          comments = FactoryGirl.create_list(:hidden_comment, 3, :user => @user)
          comment_ids = comments.map(&:id)
    
          post :modify_comment_visibility, { :id => @user.id,
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 40 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 339..347

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 37.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        it 'sorts the records by updated_at_asc' do
          User.destroy_all
          u1 = FactoryGirl.create(:user, :name => 'Alice')
          u2 = FactoryGirl.create(:user, :name => 'Bob')
          u1.touch
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 35 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 85..91

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 36.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        it 'sorts the records by updated_at_desc' do
          User.destroy_all
          u1 = FactoryGirl.create(:user, :name => 'Bob')
          u2 = FactoryGirl.create(:user, :name => 'Alice')
          u1.touch
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 35 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 76..82

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 36.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        it 'sorts the records by name_asc' do
          User.destroy_all
          u1 = FactoryGirl.create(:user, :name => 'Bob')
          u2 = FactoryGirl.create(:user, :name => 'Alice')
          get :index, :sort_order => 'name_asc'
    Severity: Major
    Found in spec/controllers/admin_user_controller_spec.rb and 3 other locations - About 35 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 52..57
    spec/controllers/admin_user_controller_spec.rb on lines 60..65
    spec/controllers/admin_user_controller_spec.rb on lines 68..73

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 34.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        it 'sorts the records by name_desc' do
          User.destroy_all
          u1 = FactoryGirl.create(:user, :name => 'Alice')
          u2 = FactoryGirl.create(:user, :name => 'Bob')
          get :index, :sort_order => 'name_desc'
    Severity: Major
    Found in spec/controllers/admin_user_controller_spec.rb and 3 other locations - About 35 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 44..49
    spec/controllers/admin_user_controller_spec.rb on lines 60..65
    spec/controllers/admin_user_controller_spec.rb on lines 68..73

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 34.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        it 'sorts the records by created_at_asc' do
          User.destroy_all
          u1 = FactoryGirl.create(:user, :name => 'Bob')
          u2 = FactoryGirl.create(:user, :name => 'Alice')
          get :index, :sort_order => 'created_at_asc'
    Severity: Major
    Found in spec/controllers/admin_user_controller_spec.rb and 3 other locations - About 35 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 44..49
    spec/controllers/admin_user_controller_spec.rb on lines 52..57
    spec/controllers/admin_user_controller_spec.rb on lines 68..73

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 34.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        it 'sorts the records by created_at_desc' do
          User.destroy_all
          u1 = FactoryGirl.create(:user, :name => 'Alice')
          u2 = FactoryGirl.create(:user, :name => 'Bob')
          get :index, :sort_order => 'created_at_desc'
    Severity: Major
    Found in spec/controllers/admin_user_controller_spec.rb and 3 other locations - About 35 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 44..49
    spec/controllers/admin_user_controller_spec.rb on lines 52..57
    spec/controllers/admin_user_controller_spec.rb on lines 60..65

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 34.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          post :update, { :id => user.id,
                          :admin_user => { :name => user.name,
                                           :ban_text => user.ban_text,
                                           :about_me => user.about_me,
                                           :role_ids => [ admin_role.id ],
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 25 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 291..298

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 31.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          post :update, { :id => user.id,
                          :admin_user => { :name => user.name,
                                           :ban_text => user.ban_text,
                                           :about_me => user.about_me,
                                            :role_ids => [pro_role.id],
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 25 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 262..269

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 31.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

              comment = FactoryGirl.create(:comment, :info_request => info_request,
                                                     :user => info_request.user)
              info_request.create_embargo
              get :show, { :id => info_request.user }, { :user_id => admin_user.id }
              expect(assigns[:comments]).to eq([])
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 25 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 181..185

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

          comment = FactoryGirl.create(:comment, :info_request => info_request,
                                                 :user => info_request.user)
          info_request.create_embargo
          get :show, { :id => info_request.user }, { :user_id => admin_user.id }
          expect(assigns[:comments]).to eq([])
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 25 mins to fix
    spec/controllers/admin_user_controller_spec.rb on lines 193..197

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          it 'includes embargoed requests if the current user is a pro admin user
              and pro is enabled' do
            with_feature_enabled(:alaveteli_pro) do
              info_request.create_embargo
              get :show, { :id => info_request.user }, { :user_id => pro_admin_user.id }
    Severity: Minor
    Found in spec/controllers/admin_user_controller_spec.rb and 1 other location - About 20 mins to fix
    spec/controllers/admin_public_body_controller_spec.rb on lines 71..76

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 28.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status