Sha256: 73188e0298986523977dad13409148d08f594a4a794f922b18ea996e81148b1e

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 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/upload_avatar" do
  include UsersHelper

  before do
    login
  end

  describe "no errors:" do
    before do
      @avatar = build_stubbed(:avatar, entity: current_user)
      allow(current_user).to receive(:avatar).and_return(@avatar)
      assign(:user, @user = current_user)
    end

    it "should flip [Upload Avatar] form" do
      render
      expect(rendered).not_to include("user_#{@user.id}")
      expect(rendered).to include("crm.flip_form('upload_avatar'")
      expect(rendered).to include("crm.set_title('upload_avatar', 'My Profile')")
    end
  end

  describe "validation errors:" do
    before do
      @avatar = build_stubbed(:avatar, entity: current_user)
      @avatar.errors.add(:image, "error")
      allow_any_instance_of(User).to receive(:avatar).and_return(@avatar)
      assign(:user, @user = current_user)
    end

    it "should redraw the [Upload Avatar] form" do
      render
      expect(rendered).to include("$('#upload_avatar').html")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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