Sha256: f802a576954f1ca4d541cc867b11226096860d5591331e9975877088a76a7d2c

Contents?: true

Size: 1.2 KB

Versions: 18

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

include FatFreeCRM::Cloudfuji::EventObservers

describe AppObserver do
  describe "App Claimed" do
    before do
      @observer = AppObserver.new
      @observer.params = {
        'data' => {
          'ido_id' => '57a57c56b57d76e76f',
          'email'  => 'cloudfuji_user@cloudfuji.com'
        }
      }
    end

    it "should update a known user if app is claimed by a recognized email address" do
      @user = FactoryGirl.create(:user, :email => 'cloudfuji_user@cloudfuji.com', :ido_id => "123456789")
      original_name = [@user.first_name, @user.last_name]

      @observer.app_claimed

      # Should not create a new user
      User.find_all_by_email('cloudfuji_user@cloudfuji.com').size.should == 1

      @user.reload
      [@user.first_name, @user.last_name].should == original_name
      @user.ido_id.should == '57a57c56b57d76e76f'
    end

    it "should create a new user if app is claimed by an unrecognized email address" do
      @observer.app_claimed

      @user = User.find_by_email('cloudfuji_user@cloudfuji.com')
      @user.first_name.should == "cloudfuji_user"
      @user.last_name.should == "cloudfuji.com"
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ffcrm_cloudfuji-0.4.1 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.3.1 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.3.0 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.11 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.10 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.9 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.8 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.7 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.6 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.5 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.4 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.3 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.2 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.1 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.2.0 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.1.7 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.1.6 spec/event_observers/app_observer_spec.rb
ffcrm_cloudfuji-0.1.5 spec/event_observers/app_observer_spec.rb