Sha256: dc203ae5b70900e984c7e6de9996b50840b5cc801458ab9381fe5b20d1566250

Contents?: true

Size: 1.42 KB

Versions: 8

Compression:

Stored size: 1.42 KB

Contents

module AuthHelpers
  module Spec

    module Updatable
      def self.included(base)
        base.class_eval do
          describe "on update" do
            before(:each) do
              @authenticable = base.described_class.create!(@valid_attributes)
              ActionMailer::Base.deliveries = []
            end

            it "should ignore e-mail confirmation if e-mail has not changed" do
              attributes = { :email => @authenticable.email, :email_confirmation => '' }
              @authenticable.update_attributes(attributes).should be_true
            end

            it "should ignore password confirmation if password has not changed" do
              attributes = { :password => @valid_attributes[:password], :password_confirmation => '' }
              @authenticable.update_attributes(attributes).should be_true
            end

            if base.described_class.new.respond_to?(:set_confirmation_code, true)
              it "should send an e-mail if e-mail changes" do
                attributes = { :email => @valid_attributes[:email].to_s.next, :email_confirmation => @valid_attributes[:email].to_s.next }
                @authenticable.update_attributes(attributes).should be_true
                @authenticable.email.should == @valid_attributes[:email].to_s.next
                ActionMailer::Base.deliveries.length.should == 1
              end
            end
          end
        end
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
josevalim-auth_helpers-0.2.0 lib/auth_helpers/spec/updatable.rb
josevalim-auth_helpers-0.2.1 lib/auth_helpers/spec/updatable.rb
josevalim-auth_helpers-0.3.0 lib/auth_helpers/spec/updatable.rb
josevalim-auth_helpers-0.3.1 lib/auth_helpers/spec/updatable.rb
josevalim-auth_helpers-0.3.2 lib/auth_helpers/spec/updatable.rb
josevalim-auth_helpers-0.4.1 lib/auth_helpers/spec/updatable.rb
josevalim-auth_helpers-0.5.0 lib/auth_helpers/spec/updatable.rb
josevalim-auth_helpers-0.5.1 lib/auth_helpers/spec/updatable.rb