Sha256: 2395528366e3f17b4551e39fc63728ac7d09041503eecb87e8967d7c7b3ebbb7
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
shared_examples "#squash_many_duplicates" do |model| before do @master = FactoryBot.create(model, title: "master") @dup1 = FactoryBot.create(model, title: "dup1") @dup2 = FactoryBot.create(model, title: "dup2") end context "happy path" do before do post :squash_many_duplicates, master_id: @master.id, duplicate_id_1: @dup1.id, duplicate_id_2: @dup2.id end it "squashes the duplicates into the master" do expect(@master.duplicate_ids).to match_array([@dup1.id, @dup2.id]) end it "redirects to duplicates page for more duplicate squashing" do expect(response).to redirect_to("/#{model}s/duplicates") end it "sets the flash success message" do expect(flash[:success]).to eq(%(Squashed duplicate #{model}s ["dup1", "dup2"] into master #{@master.id}.)) end end context "with no master" do it "redirects with a failure message" do post :squash_many_duplicates, duplicate_id_1: @dup1.id, duplicate_id_2: @dup2.id expect(flash[:failure]).to eq("A master #{model} must be selected.") expect(response).to redirect_to("/#{model}s/duplicates") end end context "with no duplicates" do it "redirects with a failure message" do post :squash_many_duplicates, master_id: @master.id expect(flash[:failure]).to eq("At least one duplicate #{model} must be selected.") expect(response).to redirect_to("/#{model}s/duplicates") end end context "with duplicates containing master" do it "redirects with a failure message" do post :squash_many_duplicates, master_id: @master.id, duplicate_id_1: @master.id expect(flash[:failure]).to eq("The master #{model} could not be squashed into itself.") expect(response).to redirect_to("/#{model}s/duplicates") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
calagator-1.0.0 | spec/controllers/squash_many_duplicates_examples.rb |