Sha256: 90969b53080f16e0f8ce26bc4f481dc1400100698a62d7c5c7fd0b3a30bc4fdb
Contents?: true
Size: 1.25 KB
Versions: 8
Compression:
Stored size: 1.25 KB
Contents
require "rails_helper" describe Dorsale::CommentsController, type: :controller do routes { Dorsale::Engine.routes } let(:user) { create(:user) } before(:each) { sign_in(user) } let(:valid_params){ commentable = DummyModel.create!(name: "A") { :commentable_id => commentable.id, :commentable_type => commentable.class.to_s, :comment => { :text => "Hello", }, :back_url => "/", } } describe "create" do it "should create comment" do post :create, params: valid_params expect(assigns(:comment)).to be_persisted end it "should redirect to back_url" do post :create, params: valid_params expect(response).to redirect_to("/") end end describe "update" do it "should update comment text" do comment = create(:dorsale_comment) patch :update, params: {id: comment, comment: {text: "New-comment-text"}, back_url: "/"} expect(response).to redirect_to("/") expect(comment.reload.text).to eq "New-comment-text" end end describe "destroy" do it "should destroy comment" do comment = create(:dorsale_comment) delete :destroy, params: {id: comment, back_url: "/"} expect(response).to redirect_to("/") end end end
Version data entries
8 entries across 8 versions & 1 rubygems