Updated

spec/controllers/archived / signatures_controller_spec.rb

C
50 lines of codes
0 methods
N/A complexity/method
1 churn
106.78 complexity
58 duplications
require 'rails_helper' RSpec.describe Archived::SignaturesController, type: :controller do describe '#unsubscribe' do
  1. describe##unsubscribe has a flog score of 41
let(:signature) { double(:signature, id: 1, unsubscribe_token: "token") } let(:petition) { double(:petition) } before do expect(Archived::Signature).to receive(:find).with("1").and_return(signature) expect(signature).to receive(:petition).and_return(petition) allow(signature).to receive(:fraudulent?).and_return(false) allow(signature).to receive(:invalidated?).and_return(false) end context "when the signature is validated" do before do expect(signature).to receive(:unsubscribe!).with("token") end it "renders the action template" do get :unsubscribe, id: "1", token: "token" expect(response).to render_template(:unsubscribe) end end context "when the signature is fraudulent" do
  1. Similar code found in 2 nodes Locations: 0 1
before do expect(signature).to receive(:fraudulent?).and_return(true) end it "raises an ActiveRecord::RecordNotFound error" do expect { get :unsubscribe, id: "1", token: "token" }.to raise_error(ActiveRecord::RecordNotFound) end end context "when the signature is invalidated" do
  1. Similar code found in 2 nodes Locations: 0 1
before do expect(signature).to receive(:invalidated?).and_return(true) end it "raises an ActiveRecord::RecordNotFound error" do expect { get :unsubscribe, id: "1", token: "token" }.to raise_error(ActiveRecord::RecordNotFound) end end end end