Sha256: 5de8b2533e36e2be37b31f398a23ae32b1c7d18f41013c763bfc04b996ac31bb

Contents?: true

Size: 1.79 KB

Versions: 11

Compression:

Stored size: 1.79 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
#------------------------------------------------------------------------------
#----------------------------------------------------------------------------
def set_current_tab(tab)
  controller.session[:current_tab] = tab
end

#----------------------------------------------------------------------------
def stub_task(view)
  if view == "completed"
    assigns[:task] = FactoryGirl.create(:task, :completed_at => Time.now - 1.minute)
  elsif view == "assigned"
    assigns[:task] = FactoryGirl.create(:task, :assignee => FactoryGirl.create(:user))
  else
    assigns[:task] = FactoryGirl.create(:task)
  end
end

#----------------------------------------------------------------------------
def stub_task_total(view = "pending")
  settings = (view == "completed" ? Setting.task_completed : Setting.task_bucket)
  settings.inject({ :all => 0 }) { |hash, key| hash[key] = 1; hash }
end

# Get current server timezone and set it (see rake time:zones:local for details).
#----------------------------------------------------------------------------
def set_timezone
  offset = [ Time.now.beginning_of_year.utc_offset, Time.now.beginning_of_year.change(:month => 7).utc_offset ].min
  offset *= 3600 if offset.abs < 13
  Time.zone = ActiveSupport::TimeZone.all.select { |zone| zone.utc_offset == offset }.first
end

# Adjusts current timezone by given offset (in seconds).
#----------------------------------------------------------------------------
def adjust_timezone(offset)
  if offset
    ActiveSupport::TimeZone[offset]
    adjusted_time = Time.now + offset.seconds
    Time.stub(:now).and_return(adjusted_time)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fat_free_crm-0.13.6 spec/support/macros.rb
fat_free_crm-0.13.5 spec/support/macros.rb
fat_free_crm-0.13.4 spec/support/macros.rb
fat_free_crm-0.13.3 spec/support/macros.rb
fat_free_crm-0.13.2 spec/support/macros.rb
fat_free_crm-0.12.3 spec/support/macros.rb
fat_free_crm-0.12.2 spec/support/macros.rb
fat_free_crm-0.13.1 spec/support/macros.rb
fat_free_crm-0.12.1 spec/support/macros.rb
fat_free_crm-0.13.0 spec/support/macros.rb
fat_free_crm-0.12.0 spec/support/macros.rb