Sha256: 076d62906e0e6fd2a1a5d9096871a2a375ec6afe87e10455ec2be149941608b3
Contents?: true
Size: 1.89 KB
Versions: 4
Compression:
Stored size: 1.89 KB
Contents
# frozen_string_literal: true describe Sail::ProfilesController, type: :controller do routes { Sail::Engine.routes } describe "POST create" do # :nocov: subject(:request) do if Rails::VERSION::MAJOR >= 5 post :create, params: { name: "profile" }, format: :js else post :create, name: "profile", format: :js end end # :nocov: it "returns ok" do request expect(response).to have_http_status(:ok) end it "invokes create_or_update_self from profiles" do expect(Sail::Profile).to receive(:create_or_update_self).with("profile").and_call_original request end context "when a profile with the same name exists" do before do Sail::Profile.create!(name: :profile) end it "returns ok for an update" do request expect(response).to have_http_status(:ok) end end end describe "PUT switch" do # :nocov: subject(:request) do if Rails::VERSION::MAJOR >= 5 put :switch, params: { name: "profile" }, format: :js else put :switch, name: "profile", format: :js end end # :nocov: it "returns ok" do request expect(response).to have_http_status(:ok) end it "invokes switch from profiles" do expect(Sail::Profile).to receive(:switch).with("profile") request end end describe "DELETE destroy" do # :nocov: subject(:request) do if Rails::VERSION::MAJOR >= 5 delete :destroy, params: { name: "profile" }, format: :js else delete :destroy, name: "profile", format: :js end end # :nocov: let!(:profile) { Sail::Profile.create!(name: :profile) } it "returns ok" do request expect(response).to have_http_status(:ok) end it "destroys profile" do expect { request }.to change(Sail::Profile, :count).by(-1) end end end
Version data entries
4 entries across 4 versions & 1 rubygems