# frozen_string_literal: true # Copyright (c) 2008-2013 Michael Dvorkin and contributors. # # Fat Free CRM is freely distributable under the terms of MIT license. # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ require 'spec_helper' describe "/contacts/update" do include ContactsHelper before do login assign(:contact, @contact = build_stubbed(:contact, user: current_user)) assign(:users, [current_user]) assign(:account, @account = build_stubbed(:account)) assign(:accounts, [@account]) end describe "no errors:" do describe "on contact landing page -" do before do controller.request.env["HTTP_REFERER"] = "http://localhost/contacts/123" end it "should flip [edit_contact] form" do render expect(rendered).not_to include("contact_#{@contact.id}") end it "should update sidebar" do render expect(rendered).to include("#sidebar") expect(rendered).to have_text("Recent Items") end end describe "on contacts index page -" do before do controller.request.env["HTTP_REFERER"] = "http://localhost/contacts" end it "should replace [Edit Contact] with contact partial and highlight it" do controller.request.env["HTTP_REFERER"] = "http://localhost/contacts" render expect(rendered).to include("$('#contact_#{@contact.id}').replaceWith('