Updated

spec/presenters / petition_csv_presenter_spec.rb

C
68 lines of codes
1 methods
147.1 complexity/method
5 churn
147.11 complexity
0 duplications
require 'rails_helper' RSpec.describe PetitionCSVPresenter do include TimestampsSpecHelper describe "#initialize" do it "initializes the presenter with a petition" do presenter = described_class.new("foo") expect(presenter.petition).to eq("foo") end end describe ".fields" do it "returns a list of all the fields to serialize" do expect(described_class.fields).to be_a Array end end describe "#to_csv" do
  1. describe##to_csv has a flog score of 25
subject { described_class.new(petition).to_csv } Petition::STATES.each do |state_name| context "with a #{state_name} petition" do let!(:petition) { FactoryBot.create "#{state_name}_petition" } specify { is_expected.to eq(csvd_petition petition) } end end end def csvd_petition(petition)
  1. main#csvd_petition has a flog score of 96
[ "#{Site.send :default_url}/petitions/#{petition.id}",
  1. csvd_petition calls 'petition.id' 3 times Locations: 0 1 2
  2. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
"#{Site.send :default_moderate_url}/admin/petitions/#{petition.id}",
  1. csvd_petition calls 'petition.id' 3 times Locations: 0 1 2
  2. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.id,
  1. csvd_petition calls 'petition.id' 3 times Locations: 0 1 2
  2. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.action,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.background,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.additional_details,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.state,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.creator_name,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.creator_email,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.signature_count,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.rejection_code,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.rejection_details,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.government_response_summary,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.government_response_details,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.debate_date,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.debate_transcript_url,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.debate_video_url,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.debate_pack_url,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.debate_overview,
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.created_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.updated_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.open_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.closed_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.government_response_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
datestampify(petition.scheduled_debate_date),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.response_threshold_reached_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.debate_threshold_reached_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.rejected_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.debate_outcome_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.moderation_threshold_reached_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.government_response_created_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
timestampify(petition.government_response_updated_at),
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
petition.note.try(:details)
  1. csvd_petition refers to 'petition' more than self (maybe move it to another class?) Locations: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
].join(",") + "\n" end end