Sha256: ab86e9f56b484ddb2533633ff2ba04727ff5d6d30f5480b0f3694e4fb8565630

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

# 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 "/users/change_password" do
  include UsersHelper

  before do
    login
    assign(:user, @user = current_user)
  end

  describe "no errors:" do
    it "should flip [Change Password] form" do
      render

      expect(rendered).not_to include("user_#{@user.id}")
      expect(rendered).to include("crm.flip_form('change_password');")
      expect(rendered).to include("crm.set_title('change_password', 'My Profile');")
    end

    it "should show flash message" do
      render

      expect(rendered).to include("#flash")
      expect(rendered).to include("crm.flash('notice')")
    end
  end

  describe "validation errors:" do
    it "should redraw the [Change Password] form" do
      @user.errors.add(:current_password, "error")
      render

      expect(rendered).to include("$('#change_password').html")
      expect(rendered).to include("$('#current_password').focus();")
    end

    it "should redraw the [Change Password] form and correctly set focus" do
      @user.errors.add(:user_password, "error")
      render

      expect(rendered).to include("$('#user_password').focus();")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fat_free_crm-0.20.1 spec/views/users/change_password.js.haml_spec.rb
fat_free_crm-0.20.0 spec/views/users/change_password.js.haml_spec.rb