Browse Source

Bundle update and style updates to follow rubocop recommandations

recurrent
echarp 7 years ago
parent
commit
d01e7c5164
  1. 2
      Gemfile
  2. 22
      Gemfile.lock
  3. 4
      app/controllers/events_controller.rb
  4. 3
      app/helpers/orgas_helper.rb
  5. 4
      app/mailers/note_mailer.rb
  6. 20
      app/models/event.rb
  7. 4
      app/models/orga.rb
  8. 4
      app/models/user.rb
  9. 29
      config/initializers/devise.rb
  10. 12
      test/models/event_test.rb

2
Gemfile

@ -38,7 +38,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc
# gem 'capistrano-rails', group: :development
gem 'haml-rails'
gem 'compass-rails'
gem 'compass-rails', '~> 2.0.4'
gem 'modernizr-rails'
# Patch older browsers so they do understand html5

22
Gemfile.lock

@ -1,6 +1,6 @@
GIT
remote: git://github.com/activeadmin/activeadmin.git
revision: 48a8674a4566fb5a916748f78a38a0b9f2e8e356
revision: 8968efcc51cc7c765c35c75aa7bf68c758ca03f3
specs:
activeadmin (1.0.0.pre1)
arbre (~> 1.0, >= 1.0.2)
@ -110,7 +110,7 @@ GEM
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1)
coffee-script-source (1.9.1.1)
columnize (0.9.0)
compass (1.0.3)
chunky_png (~> 1.2)
@ -147,7 +147,7 @@ GEM
equalizer (0.0.11)
erubis (2.7.0)
eventmachine (1.0.7)
execjs (2.5.0)
execjs (2.5.2)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
fastercsv (1.5.5)
@ -157,9 +157,9 @@ GEM
formatador (0.2.5)
formtastic (3.1.3)
actionpack (>= 3.2.13)
formtastic_i18n (0.2.0)
formtastic_i18n (0.3.0)
geocoder (1.2.8)
globalid (0.3.3)
globalid (0.3.5)
activesupport (>= 4.1.0)
guard (2.12.5)
formatador (>= 0.2.4)
@ -225,7 +225,7 @@ GEM
has_scope (~> 0.6.0.rc)
railties (>= 3.2, < 5)
responders
jbuilder (2.2.12)
jbuilder (2.2.13)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.3)
@ -261,7 +261,7 @@ GEM
method_source (0.8.2)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
minitest (5.6.0)
modernizr-rails (2.7.1)
multi_json (1.11.0)
multipart-post (2.0.0)
@ -274,7 +274,7 @@ GEM
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.5.0)
parser (2.2.0.3)
parser (2.2.2.1)
ast (>= 1.1, < 3.0)
polyamorous (1.2.0)
activerecord (>= 3.0)
@ -339,10 +339,10 @@ GEM
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.5)
ruby2ruby (2.1.3)
ruby2ruby (2.1.4)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
ruby_parser (3.6.5)
ruby_parser (3.6.6)
sexp_processor (~> 4.1)
sass (3.4.13)
sass-rails (5.0.1)
@ -433,7 +433,7 @@ DEPENDENCIES
brakeman
byebug
coffee-rails
compass-rails
compass-rails (~> 2.0.4)
devise
devise-i18n
differ

4
app/controllers/events_controller.rb

@ -22,8 +22,8 @@ class EventsController < ApplicationController
# GET /events/new
def new
@event = Event.new start_time: Time.now.change(min: 0) + 1.day + 1.hour,
end_time: Time.now.change(min: 0) + 1.day + 2.hour
@event = Event.new start_time: Time.zone.now.change(min: 0) + 1.day,
end_time: Time.zone.now.change(min: 0) + 1.day + 1.hour
end
# POST /events/preview

3
app/helpers/orgas_helper.rb

@ -7,8 +7,7 @@ module OrgasHelper
geo: {
region: @orga.region,
placename: @orga.city,
position: "#{@orga.city.try :latitude};" \
+ "#{@orga.city.try :longitude}"
position: "#{@orga.city.try :latitude}; #{@orga.city.try :longitude}"
}
end
end

4
app/mailers/note_mailer.rb

@ -5,9 +5,9 @@ class NoteMailer < ActionMailer::Base
def notify(note)
@note = note
host = ActionMailer::Base.default_url_options[:host]
mail 'In-Reply-To' =>
"<event-#{note.event.id}@" \
+ "#{ActionMailer::Base.default_url_options[:host]}>",
"<event-#{note.event.id}@#{host}>",
to: note.event.submitter,
subject: "#{t 'mail_prefix'}#{t 'note_mailer.notify.subject',
subject: note.event.title}"

20
app/models/event.rb

@ -25,8 +25,8 @@ class Event < ActiveRecord::Base
scope :moderated, -> { where moderated: true }
scope :unmoderated, -> { where moderated: false }
scope :last_year, -> { where '? <= end_time', 1.year.ago }
scope :past, -> { where 'start_time <= ?', DateTime.now }
scope :future, -> { where '? <= end_time', DateTime.now }
scope :past, -> { where 'start_time <= ?', Time.zone.now }
scope :future, -> { where '? <= end_time', Time.zone.now }
scope :daylimit, -> d { where 'end_time <= ?', (d || 30).to_i.days.from_now }
scope :year, (lambda do |year|
where '? <= end_time and start_time <= ?',
@ -34,7 +34,7 @@ class Event < ActiveRecord::Base
Date.new(year, 12, 31).end_of_week.end_of_day
end)
scope :month, (lambda do |start_date|
start_date ||= Date.today
start_date ||= Time.zone.today
where '? <= end_time and start_time <= ?',
start_date.beginning_of_month.beginning_of_week,
start_date.end_of_month.end_of_week.end_of_day
@ -50,8 +50,8 @@ class Event < ActiveRecord::Base
end
before_validation on: :create do
self.submission_time = DateTime.now
self.decision_time = DateTime.now
self.submission_time = Time.zone.now
self.decision_time = Time.zone.now
# Populate submitter using contact info if absent
self.submitter ||= contact
@ -72,20 +72,20 @@ class Event < ActiveRecord::Base
before_update do
if moderated? && moderated_was != moderated
self.decision_time = DateTime.now
self.decision_time = Time.zone.now
end
end
def as_json(_options = {})
popup = "<a href=\"/#{self.class.name.downcase.pluralize}/#{id}\""
popup += " >#{start_time.to_date} #{city}: #{title}</a>"
{ type: 'Feature', properties: {
id: id,
name: title,
tags: tags,
popupContent: "<a href=\"/#{self.class.name.downcase.pluralize}/#{id}\"" \
+ ">#{start_time.to_date} #{city}: #{title}</a>"
popupContent: popup
}, geometry: {
type: 'Point',
coordinates: [longitude, latitude]
type: 'Point', coordinates: [longitude, latitude]
} }
end

4
app/models/orga.rb

@ -12,8 +12,8 @@ class Orga < ActiveRecord::Base
validates :submitter, allow_blank: true, email: true
before_validation on: :create do
self.submission_time = DateTime.now
self.decision_time = DateTime.now
self.submission_time = Time.zone.now
self.decision_time = Time.zone.now
# Populate submitter using contact info if absent
self.submitter ||= contact

4
app/models/user.rb

@ -24,9 +24,9 @@ class User < ActiveRecord::Base
conditions = warden_conditions.dup
login = conditions.delete(:login)
if login.present?
where(conditions).where(['login = :value', { value: login }]).first
where(conditions).find_by_login login
else
where(conditions).first
find_first(conditions)
end
end

29
config/initializers/devise.rb

@ -4,9 +4,7 @@ Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
config.secret_key = 'a462883bde2ce796fa8aa481d8946a500ac8a4141ccc5f2fb1988b' \
+ 'ed8f3595b9cbd713abdca92b2d276d339a4e342768173e1b13b7a45956f6d3bda4653b' \
+ '14b6'
# config.secret_key = 'not used in rails 4'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
@ -69,7 +67,7 @@ Devise.setup do |config|
# :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
# If http headers should be returned for AJAX requests. True by default.
# If 401 status code should be returned for AJAX requests. True by default.
# config.http_authenticatable_on_xhr = true
# The realm used in Http Basic Authentication. 'Application' by default.
@ -84,7 +82,7 @@ Devise.setup do |config|
# particular strategies by setting this option.
# Notice that if you are skipping storage for all authentication paths, you
# may want to disable generating routes to Devise's sessions controller by
# passing :skip => :sessions to `devise_for` in your config/routes.rb
# passing skip: :sessions to `devise_for` in your config/routes.rb
config.skip_session_storage = [:http_auth]
# By default, Devise cleans up the CSRF token on authentication to
@ -109,10 +107,10 @@ Devise.setup do |config|
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming his account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming his account,
# confirming their account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming his account.
# the user cannot access the website without confirming their account.
# config.allow_unconfirmed_access_for = 2.days
# A period that the user is allowed to confirm their account before their
@ -137,15 +135,18 @@ Devise.setup do |config|
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
# Invalidates all the remember me tokens when the user signs out.
config.expire_all_remember_me_on_sign_out = true
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
# Options to be passed to the created cookie. For instance, you can set
# :secure => true in order to force SSL only cookies.
# secure: true in order to force SSL only cookies.
# config.rememberable_options = {}
# ==> Configuration for :validatable
# Range for password length. Default is 8..128.
# Range for password length.
config.password_length = 8..128
# Email regex used to validate email formats. It simply asserts that
@ -187,7 +188,7 @@ Devise.setup do |config|
# config.unlock_in = 1.hour
# Warn on the last attempt before the account is locked.
# config.last_attempt_warning = false
# config.last_attempt_warning = true
# ==> Configuration for :recoverable
#
@ -240,8 +241,7 @@ Devise.setup do |config|
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET',
# :scope => 'user,public_repo'
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
@ -250,8 +250,7 @@ Devise.setup do |config|
#
# config.warden do |manager|
# manager.intercept_401 = false
# manager.default_strategies(:scope => :user).unshift
# :some_external_strategy
# manager.default_strategies(scope: :user).unshift :some_external_strategy
# end
# ==> Mountable engine configurations

12
test/models/event_test.rb

@ -9,8 +9,8 @@ class EventTest < ActiveSupport::TestCase
test 'basic event' do
@event = Event.new(
title: 'hello world',
start_time: Time.new,
end_time: Time.new + 1.hour,
start_time: Time.zone.now,
end_time: Time.zone.now + 1.hour,
description: 'et hop!',
city: City.first,
region: Region.first,
@ -29,8 +29,8 @@ class EventTest < ActiveSupport::TestCase
test 'validations' do
@event = Event.new(
title: 'hello world',
start_time: Time.new,
end_time: Time.new + 1.hour,
start_time: Time.zone.now,
end_time: Time.zone.now + 1.hour,
description: 'et hop!',
city: City.first,
region: Region.first,
@ -59,8 +59,8 @@ class EventTest < ActiveSupport::TestCase
test 'moderation' do
@event = Event.new(
title: 'hello world',
start_time: Time.new,
end_time: Time.new + 1.hour,
start_time: Time.zone.now,
end_time: Time.zone.now + 1.hour,
description: 'et hop!',
city: City.first,
region: Region.first,

Loading…
Cancel
Save