mysociety/alaveteli

View on GitHub
spec/models/info_request/state/transitions_spec.rb

Summary

Maintainability
F
3 days
Test Coverage

File transitions_spec.rb has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'spec_helper'

describe InfoRequest::State::Transitions do
  let(:info_request) { FactoryGirl.create(:info_request) }

Severity: Minor
Found in spec/models/info_request/state/transitions_spec.rb - About 5 hrs to fix

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

        context "when the to_state is gone_postal" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "They are going to reply <strong>by post</strong>"
              actual = subject.transition_label("gone_postal", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 16..37
    spec/models/info_request/state/transitions_spec.rb on lines 42..63
    spec/models/info_request/state/transitions_spec.rb on lines 94..115
    spec/models/info_request/state/transitions_spec.rb on lines 120..141
    spec/models/info_request/state/transitions_spec.rb on lines 146..167
    spec/models/info_request/state/transitions_spec.rb on lines 172..193
    spec/models/info_request/state/transitions_spec.rb on lines 254..275

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

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

        context "when the to_state is partially_successful" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "I've received <strong>some of the information</strong>"
              actual = subject.transition_label("partially_successful", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 16..37
    spec/models/info_request/state/transitions_spec.rb on lines 42..63
    spec/models/info_request/state/transitions_spec.rb on lines 68..89
    spec/models/info_request/state/transitions_spec.rb on lines 94..115
    spec/models/info_request/state/transitions_spec.rb on lines 120..141
    spec/models/info_request/state/transitions_spec.rb on lines 146..167
    spec/models/info_request/state/transitions_spec.rb on lines 254..275

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

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

        context "when the to_state is waiting_clarification" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "I've been asked to <strong>clarify</strong> my request"
              actual = subject.transition_label("waiting_clarification", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 16..37
    spec/models/info_request/state/transitions_spec.rb on lines 68..89
    spec/models/info_request/state/transitions_spec.rb on lines 94..115
    spec/models/info_request/state/transitions_spec.rb on lines 120..141
    spec/models/info_request/state/transitions_spec.rb on lines 146..167
    spec/models/info_request/state/transitions_spec.rb on lines 172..193
    spec/models/info_request/state/transitions_spec.rb on lines 254..275

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

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

        context "when the to_state is waiting_response" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "I'm still <strong>waiting</strong> for my information <small>(maybe you got an acknowledgement)</small>"
              actual = subject.transition_label("waiting_response", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 42..63
    spec/models/info_request/state/transitions_spec.rb on lines 68..89
    spec/models/info_request/state/transitions_spec.rb on lines 94..115
    spec/models/info_request/state/transitions_spec.rb on lines 120..141
    spec/models/info_request/state/transitions_spec.rb on lines 146..167
    spec/models/info_request/state/transitions_spec.rb on lines 172..193
    spec/models/info_request/state/transitions_spec.rb on lines 254..275

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

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

        context "when the to_state is not_held" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "They do <strong>not have</strong> the information <small>(maybe they say who does)</small>"
              actual = subject.transition_label("not_held", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 16..37
    spec/models/info_request/state/transitions_spec.rb on lines 42..63
    spec/models/info_request/state/transitions_spec.rb on lines 68..89
    spec/models/info_request/state/transitions_spec.rb on lines 120..141
    spec/models/info_request/state/transitions_spec.rb on lines 146..167
    spec/models/info_request/state/transitions_spec.rb on lines 172..193
    spec/models/info_request/state/transitions_spec.rb on lines 254..275

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

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

        context "when the to_state is rejected" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "My request has been <strong>refused</strong>"
              actual = subject.transition_label("rejected", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 16..37
    spec/models/info_request/state/transitions_spec.rb on lines 42..63
    spec/models/info_request/state/transitions_spec.rb on lines 68..89
    spec/models/info_request/state/transitions_spec.rb on lines 94..115
    spec/models/info_request/state/transitions_spec.rb on lines 146..167
    spec/models/info_request/state/transitions_spec.rb on lines 172..193
    spec/models/info_request/state/transitions_spec.rb on lines 254..275

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

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

        context "when the to_state is successful" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "I've received <strong>all the information</strong>"
              actual = subject.transition_label("successful", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 16..37
    spec/models/info_request/state/transitions_spec.rb on lines 42..63
    spec/models/info_request/state/transitions_spec.rb on lines 68..89
    spec/models/info_request/state/transitions_spec.rb on lines 94..115
    spec/models/info_request/state/transitions_spec.rb on lines 120..141
    spec/models/info_request/state/transitions_spec.rb on lines 172..193
    spec/models/info_request/state/transitions_spec.rb on lines 254..275

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

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

        context "when the to_state is error_message" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "I've received an <strong>error message</strong>"
              actual = subject.transition_label("error_message", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 7 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 16..37
    spec/models/info_request/state/transitions_spec.rb on lines 42..63
    spec/models/info_request/state/transitions_spec.rb on lines 68..89
    spec/models/info_request/state/transitions_spec.rb on lines 94..115
    spec/models/info_request/state/transitions_spec.rb on lines 120..141
    spec/models/info_request/state/transitions_spec.rb on lines 146..167
    spec/models/info_request/state/transitions_spec.rb on lines 172..193

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

    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

        context "when the to_state is user_withdrawn" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "I would like to <strong>withdraw this request</strong>"
              actual = subject.transition_label("user_withdrawn", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 1 other location - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 280..301

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

    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

        context "when the to_state is requires_admin" do
          context "and is_owning_user is true" do
            it "returns the right label" do
              expected = "This request <strong>requires administrator attention</strong>"
              actual = subject.transition_label("requires_admin", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 1 other location - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 306..327

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

    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 "when the to_state is not_foi" do
          context "and is_owning_user is true" do
            it "does not have a label" do
              expect do
                subject.transition_label("not_foi", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 2 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 332..353
    spec/models/info_request/state/transitions_spec.rb on lines 358..379

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

    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 "when the to_state is attention_requested" do
          context "and is_owning_user is true" do
            it "does not have a label" do
              expect do
                subject.transition_label("attention_requested", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 2 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 358..379
    spec/models/info_request/state/transitions_spec.rb on lines 384..405

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

    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 "when the to_state is vexatious" do
          context "and is_owning_user is true" do
            it "does not have a label" do
              expect do
                subject.transition_label("vexatious", is_owning_user: true)
    Severity: Major
    Found in spec/models/info_request/state/transitions_spec.rb and 2 other locations - About 1 hr to fix
    spec/models/info_request/state/transitions_spec.rb on lines 332..353
    spec/models/info_request/state/transitions_spec.rb on lines 384..405

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

    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