Sha256: ca946df97cb4115c4bdf13b78586e577d4275ec051750795571c5200e6078ed2
Contents?: true
Size: 1.46 KB
Versions: 8
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe C::Redirect, type: :model do subject { FactoryGirl.build(:c_redirect) } it { should be_valid } it "should be invalid without an old url" do subject.old_url = "" expect(subject).to be_invalid end it "should be invalid without a new url" do subject.new_url = "" expect(subject).to be_invalid end describe "#increment" do it "increments the used counter by 1" do expect { subject.increment }.to change(subject, :used_counter).by(1) end it "sets the last used time" do time_stub = Time.zone.now allow(Time).to receive(:now).and_return(time_stub) subject.increment expect(subject.last_used).to eq(time_stub) end it "saves the object" do expect { subject.increment }.to change(subject, :updated_at) end end describe "::bulk_action" do context "when action is delete" do it "should destroy all redirects" do # Save subject to provide something to delete subject.save! expect { C::Redirect.bulk_action("delete") }.to change(C::Redirect, :count).by(-1) end it "should return a string" do expect(C::Redirect.bulk_action("delete")).to eq("Deleted Redirects") end end context "when action is not delete" do it "should return a string" do expect(C::Redirect.bulk_action("something")).to eq("No action selected") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems