Sha256: dcc2e2bd7d894a82d34d665ff61bd6cf1eca950e2d487fd045c4c8dc3e67d5e8

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 KB

Contents

# 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_and_assign
  end

  describe "no errors:" do
    before do
      @avatar = FactoryGirl.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 = FactoryGirl.build_stubbed(:avatar, entity: current_user)
      @avatar.errors.add(:image, "error")
      allow(current_user).to receive(:avatar).and_return(@avatar)
      assign(:user, @user = current_user)
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fat_free_crm-0.15.2 spec/views/users/upload_avatar.js.haml_spec.rb
fat_free_crm-0.16.4 spec/views/users/upload_avatar.js.haml_spec.rb
fat_free_crm-0.15.1 spec/views/users/upload_avatar.js.haml_spec.rb
fat_free_crm-0.16.3 spec/views/users/upload_avatar.js.haml_spec.rb
fat_free_crm-0.16.2 spec/views/users/upload_avatar.js.haml_spec.rb
fat_free_crm-0.16.1 spec/views/users/upload_avatar.js.haml_spec.rb
fat_free_crm-0.16.0 spec/views/users/upload_avatar.js.haml_spec.rb
fat_free_crm-0.15.0 spec/views/users/upload_avatar.js.haml_spec.rb