spec/features/emails_spec.rb

Summary

Maintainability
D
2 days
Test Coverage

File emails_spec.rb has 419 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

feature 'Emails' do

  background do
Severity: Minor
Found in spec/features/emails_spec.rb - About 6 hrs to fix

    TODO found
    Open

        # TODO i18n : broken because of test locale change
    Severity: Minor
    Found in spec/features/emails_spec.rb by fixme

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

      context 'Debate comments' do
        let(:user)   { create(:user, email_on_comment: true) }
        let(:debate) { create(:debate, author: user) }
    
        scenario 'Send email on debate comment' do
    Severity: Major
    Found in spec/features/emails_spec.rb and 2 other locations - About 2 hrs to fix
    spec/features/emails_spec.rb on lines 27..50
    spec/features/emails_spec.rb on lines 136..159

    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 85.

    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 3 locations. Consider refactoring.
    Open

      context 'Proposal comments' do
        let(:user)     { create(:user, email_on_comment: true) }
        let(:proposal) { create(:proposal, author: user) }
    
        scenario 'Send email on proposal comment' do
    Severity: Major
    Found in spec/features/emails_spec.rb and 2 other locations - About 2 hrs to fix
    spec/features/emails_spec.rb on lines 54..77
    spec/features/emails_spec.rb on lines 136..159

    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 85.

    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 3 locations. Consider refactoring.
    Open

      context 'Poll comments' do
        let(:user) { create(:user, email_on_comment: true) }
        let(:poll) { create(:poll, author: user) }
    
        scenario 'Send email on poll comment' do
    Severity: Major
    Found in spec/features/emails_spec.rb and 2 other locations - About 2 hrs to fix
    spec/features/emails_spec.rb on lines 27..50
    spec/features/emails_spec.rb on lines 54..77

    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 85.

    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

        scenario "Selected investment" do
          author1 = create(:user)
          author2 = create(:user)
          author3 = create(:user)
    
    
    Severity: Major
    Found in spec/features/emails_spec.rb and 1 other location - About 2 hrs to fix
    spec/features/emails_spec.rb on lines 444..463

    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 84.

    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

        scenario "Unselected investment" do
          author1 = create(:user)
          author2 = create(:user)
          author3 = create(:user)
    
    
    Severity: Major
    Found in spec/features/emails_spec.rb and 1 other location - About 2 hrs to fix
    spec/features/emails_spec.rb on lines 422..441

    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 84.

    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

        scenario 'Send email on budget investment comment' do
          comment_on(investment)
    
          email = open_last_email
          expect(email).to have_subject('Someone has commented on your investment')
    Severity: Minor
    Found in spec/features/emails_spec.rb and 1 other location - About 45 mins to fix
    spec/features/emails_spec.rb on lines 113..121

    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 39.

    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

        scenario 'Send email on topic comment' do
          comment_on(topic)
    
          email = open_last_email
          expect(email).to have_subject('Someone has commented on your topic')
    Severity: Minor
    Found in spec/features/emails_spec.rb and 1 other location - About 45 mins to fix
    spec/features/emails_spec.rb on lines 85..93

    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 39.

    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

    Line is too long. [118/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        expect(email).to have_subject("Your investment project '#{spending_proposal.code}' has been marked as unfeasible")
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    Line is too long. [105/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        fill_in 'spending_proposal_feasible_explanation', with: 'This is not legal as stated in Article 34.9'
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    Line is too long. [108/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          fill_in 'budget_investment_description', with: 'We have lots of people that require medical attention'
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    Line is too long. [113/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          expect(email).to have_subject("Your investment project '#{investment.code}' has been marked as unfeasible")
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    Line is too long. [101/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          expect(email).to have_subject("Your investment project '#{investment.code}' has been selected")
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    Line is too long. [106/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          expect(email).to have_body_text(budget_investment_path(investment, budget_id: investment.budget_id))
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    Line is too long. [112/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          fill_in 'budget_investment_unfeasibility_explanation', with: 'This is not legal as stated in Article 34.9'
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    Line is too long. [105/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          expect(email).to have_subject("Your investment project '#{investment.code}' has not been selected")
    Severity: Minor
    Found in spec/features/emails_spec.rb by rubocop

    There are no issues that match your filters.

    Category
    Status