summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-12-30 08:13:05 -0700
committermo khan <mo@mokhan.ca>2013-12-30 08:13:05 -0700
commit55fd31cf068c6ef459db16f302b8cebfb689d41d (patch)
tree88adeae75f43b7cf0857e638063835b6e3b69569
parent66b3458dafa78d10bc581fd2938e180d8d028f2f (diff)
parent74148850f0c57432b1bc9c326c975c37cd335d49 (diff)
merge with master.
-rw-r--r--.gitignore1
-rw-r--r--Gemfile10
-rw-r--r--Gemfile.lock13
-rw-r--r--app/assets/images/fallback/default.pngbin11252 -> 0 bytes
-rw-r--r--app/assets/images/fallback/large_default.pngbin11252 -> 0 bytes
-rw-r--r--app/assets/images/fallback/thumb_default.pngbin11252 -> 0 bytes
-rw-r--r--app/assets/javascripts/users_edit.js2
-rw-r--r--app/controllers/application_controller.rb5
-rw-r--r--app/controllers/creation_tags_controller.rb4
-rw-r--r--app/controllers/creations_controller.rb4
-rw-r--r--app/controllers/photos_controller.rb2
-rw-r--r--app/controllers/profiles_controller.rb4
-rw-r--r--app/controllers/registrations_controller.rb16
-rw-r--r--app/controllers/sitemap_controller.rb2
-rw-r--r--app/controllers/tutorial_tags_controller.rb4
-rw-r--r--app/controllers/tutorials_controller.rb4
-rw-r--r--app/models/photo.rb37
-rw-r--r--app/models/user.rb16
-rw-r--r--app/uploaders/photo_uploader.rb11
-rw-r--r--app/views/devise/registrations/new.html.erb36
-rw-r--r--app/views/devise/sessions/new.html.erb36
-rw-r--r--app/views/notifications/index.html.erb8
-rw-r--r--app/views/profiles/show.html.erb2
-rw-r--r--app/views/public_activity/avatar/_create.html.erb5
-rw-r--r--app/views/public_activity/avatar/_destroy.html.erb5
-rw-r--r--app/views/public_activity/avatar/_update.html.erb5
-rw-r--r--app/views/public_activity/comment/_create.html.erb8
-rw-r--r--app/views/public_activity/creation/_create.html.erb5
-rw-r--r--app/views/public_activity/creation/_destroy.html.erb5
-rw-r--r--app/views/public_activity/creation/_update.html.erb5
-rw-r--r--app/views/public_activity/favorite/_create.html.erb5
-rw-r--r--app/views/public_activity/photo/_create.html.erb5
-rw-r--r--app/views/public_activity/photo/_destroy.html.erb5
-rw-r--r--app/views/public_activity/tutorial/_create.html.erb5
-rw-r--r--app/views/public_activity/tutorial/_destroy.html.erb5
-rw-r--r--app/views/public_activity/tutorial/_update.html.erb5
-rw-r--r--app/views/public_activity/user/_create.html.erb5
-rw-r--r--app/views/public_activity/user/_destroy.html.erb5
-rw-r--r--app/views/public_activity/user/_update.html.erb5
-rw-r--r--app/views/registrations/edit.html.erb69
-rw-r--r--config/GeoLiteCity.datbin0 -> 17277346 bytes
-rw-r--r--config/recipes/templates/logrotate.erb1
-rw-r--r--config/recipes/templates/nginx_unicorn.erb37
-rw-r--r--db/migrate/20131229022014_drop_table_activities.rb5
-rw-r--r--db/migrate/20131230013944_add_image_processing_to_photos.rb5
-rw-r--r--spec/controllers/photos_controller_spec.rb12
-rw-r--r--spec/controllers/registrations_controller_spec.rb30
-rw-r--r--spec/factories/photo.rb2
-rw-r--r--spec/features/registration_spec.rb1
-rw-r--r--spec/models/user_spec.rb16
-rw-r--r--spec/spec_helper.rb6
51 files changed, 118 insertions, 366 deletions
diff --git a/.gitignore b/.gitignore
index 5fac7fea..88831968 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ coverage
.vagrant
public/assets
.env
+vendor/bundler
diff --git a/Gemfile b/Gemfile
index 57a1c875..e118b0ac 100644
--- a/Gemfile
+++ b/Gemfile
@@ -29,6 +29,9 @@ gem 'airbrake'
gem 'geocoder', '~> 1.1.9'
gem 'pg'
gem 'asset_sync', '~> 1.0.0'
+gem 'geoip'
+gem 'fog'
+gem 'unf'
group :development do
gem 'capistrano'
@@ -43,7 +46,6 @@ group :development, :test do
gem 'sqlite3'
gem 'rspec-rails'
gem 'teaspoon'
- gem 'rack-mini-profiler'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'capybara'
@@ -52,14 +54,10 @@ group :development, :test do
gem 'ffaker'
gem 'selenium-webdriver'
gem 'poltergeist'
-end
-
-group :staging do
- gem 'rack-mini-profiler'
+ gem 'binding_of_caller'
end
group :production, :staging do
- gem 'fog'
gem 'newrelic_rpm'
gem 'dalli'
gem 'unicorn'
diff --git a/Gemfile.lock b/Gemfile.lock
index f4bcfb22..66e52f2f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -39,6 +39,8 @@ GEM
better_errors (1.1.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
+ binding_of_caller (0.7.2)
+ debug_inspector (>= 0.0.1)
bootstrap-sass (2.3.2.2)
sass (~> 3.2)
builder (3.1.4)
@@ -79,6 +81,7 @@ GEM
daemons (1.1.9)
dalli (2.6.4)
database_cleaner (1.2.0)
+ debug_inspector (0.0.2)
delayed_job (4.0.0)
activesupport (>= 3.0, < 4.1)
delayed_job_active_record (4.0.0)
@@ -120,6 +123,7 @@ GEM
ruby-hmac
formatador (0.2.4)
geocoder (1.1.9)
+ geoip (1.3.5)
highline (1.6.20)
hike (1.2.3)
i18n (0.6.9)
@@ -170,8 +174,6 @@ GEM
websocket-driver (>= 0.2.0)
polyglot (0.3.3)
rack (1.5.2)
- rack-mini-profiler (0.1.31)
- rack (>= 1.1.3)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.2)
@@ -255,6 +257,9 @@ GEM
uglifier (2.4.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
+ unf (0.1.3)
+ unf_ext
+ unf_ext (0.0.6)
unicorn (4.7.0)
kgio (~> 2.6)
rack
@@ -275,6 +280,7 @@ DEPENDENCIES
airbrake
asset_sync (~> 1.0.0)
better_errors
+ binding_of_caller
bootstrap-sass (~> 2.3.0)
bullet
capistrano
@@ -295,6 +301,7 @@ DEPENDENCIES
ffaker
fog
geocoder (~> 1.1.9)
+ geoip
jbuilder (~> 1.2)
jquery-fileupload-rails (~> 0.4.1)
jquery-rails
@@ -304,7 +311,6 @@ DEPENDENCIES
newrelic_rpm
pg
poltergeist
- rack-mini-profiler
rails (~> 4.0.0)
rmagick (~> 2.13.0)
rspec-rails
@@ -317,4 +323,5 @@ DEPENDENCIES
teaspoon
turbolinks
uglifier (>= 1.3.0)
+ unf
unicorn
diff --git a/app/assets/images/fallback/default.png b/app/assets/images/fallback/default.png
deleted file mode 100644
index e4c605f3..00000000
--- a/app/assets/images/fallback/default.png
+++ /dev/null
Binary files differ
diff --git a/app/assets/images/fallback/large_default.png b/app/assets/images/fallback/large_default.png
deleted file mode 100644
index e4c605f3..00000000
--- a/app/assets/images/fallback/large_default.png
+++ /dev/null
Binary files differ
diff --git a/app/assets/images/fallback/thumb_default.png b/app/assets/images/fallback/thumb_default.png
deleted file mode 100644
index e4c605f3..00000000
--- a/app/assets/images/fallback/thumb_default.png
+++ /dev/null
Binary files differ
diff --git a/app/assets/javascripts/users_edit.js b/app/assets/javascripts/users_edit.js
index 133ee8aa..493283c4 100644
--- a/app/assets/javascripts/users_edit.js
+++ b/app/assets/javascripts/users_edit.js
@@ -6,7 +6,7 @@ DeviseUsers.Edit = {
$('#user_city').autocomplete({
source: function(request, response){
$.ajax({
- url: 'https://ws.geonames.org/searchJSON',
+ url: 'http://ws.geonames.org/searchJSON',
dataType: "jsonp",
data: {
featureClass: "P",
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 39476b91..932b2a7f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,7 +2,6 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
- before_filter :profile_application
before_filter :load_categories
before_filter :load_user
before_filter :configure_permitted_parameters, if: :devise_controller?
@@ -13,10 +12,6 @@ class ApplicationController < ActionController::Base
target.new(current_user)
end
- def profile_application
- Rack::MiniProfiler.authorize_request if ENV['PROFILE_APPLICATION'] == true
- end
-
def load_categories
@categories = Category.all
end
diff --git a/app/controllers/creation_tags_controller.rb b/app/controllers/creation_tags_controller.rb
index 44d3077a..8bdf9e68 100644
--- a/app/controllers/creation_tags_controller.rb
+++ b/app/controllers/creation_tags_controller.rb
@@ -1,6 +1,8 @@
class CreationTagsController < ApplicationController
def index
@tags = Creation.tag_counts_on(:tags)
+ expires_in(6.hours)
+ fresh_when(@tags) if @tags.any?
end
def show
@@ -8,5 +10,7 @@ class CreationTagsController < ApplicationController
@total_tutorials = Tutorial.tagged_with(@tag).count
@total_creations = Creation.tagged_with(@tag).count
@creations = Creation.includes([:user, :tags, :photos]).tagged_with([@tag]).where('photos_count > 0').page(params[:page]).per(15)
+ expires_in(6.hours)
+ fresh_when(@creations)
end
end
diff --git a/app/controllers/creations_controller.rb b/app/controllers/creations_controller.rb
index ff20e86e..ff8c8f73 100644
--- a/app/controllers/creations_controller.rb
+++ b/app/controllers/creations_controller.rb
@@ -3,11 +3,15 @@ class CreationsController < ApplicationController
def index
@creations = FindAllCreationsQuery.new.fetch(params)
+ expires_in(10.minutes)
+ fresh_when(Creation.maximum(:updated_at)) if Creation.any?
end
def show
@creation = Creation.find(params[:id])
@primary_photo = @creation.primary_image
+ expires_in(1.minute)
+ fresh_when(@creation)
end
def new
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index 668ef613..0f6e2ecf 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -7,7 +7,7 @@ class PhotosController < ApplicationController
@photos = @creation.photos
respond_to do |format|
format.html # index.html.erb
- format.json { render json: {files: @photos.map { |p| p.to_jq_upload } }.to_json }
+ format.json { render json: { files: @photos.map { |photo| photo.to_jq_upload } } }
end
end
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index 0b5f0efd..4c1d49ae 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -3,6 +3,8 @@ class ProfilesController < ApplicationController
def index
@profiles = User.includes(:avatar).where('creations_count > 0').order(:creations_count => :desc).page(params[:page]).per(12)
+ expires_in(1.hour)
+ fresh_when(User.maximum(:updated_at)) if User.any?
end
def show
@@ -13,6 +15,8 @@ class ProfilesController < ApplicationController
@nearby_users.each do |user|
@map_url += "&markers=#{user.latitude}%2C#{user.longitude}"
end
+ expires_in(1.hour)
+ fresh_when(@user)
end
def favorites
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index b2b41d78..817a9309 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -1,20 +1,4 @@
class RegistrationsController < Devise::RegistrationsController
- def edit
- @user = current_user
- end
-
- # is this action used any more?
- def update
- @user = current_user
- @user.interest_ids = params[:user][:interest_ids] ||= []
- if @user.update_without_password(params[:user])
- sign_in @user, :bypass => true
- redirect_to profile_path(current_user), :notice =>'Your settings have been updated successfully!'
- else
- render "edit"
- end
- end
-
def after_sign_in_path_for(resource)
settings_path
end
diff --git a/app/controllers/sitemap_controller.rb b/app/controllers/sitemap_controller.rb
index e529c2d6..3b207a1b 100644
--- a/app/controllers/sitemap_controller.rb
+++ b/app/controllers/sitemap_controller.rb
@@ -6,6 +6,8 @@ class SitemapController < ApplicationController
@tutorials = Tutorial.all
@base_url = "https://#{request.host_with_port}"
headers['Content-Type'] = 'application/xml'
+ expires_in(1.hour)
+ fresh_when(@creations) if @creations.any?
respond_to do |format|
format.xml
end
diff --git a/app/controllers/tutorial_tags_controller.rb b/app/controllers/tutorial_tags_controller.rb
index d13d5067..c65c7d3a 100644
--- a/app/controllers/tutorial_tags_controller.rb
+++ b/app/controllers/tutorial_tags_controller.rb
@@ -1,6 +1,8 @@
class TutorialTagsController < ApplicationController
def index
@tags = Tutorial.tag_counts_on(:tags)
+ expires_in(6.hours)
+ fresh_when(@tags) if @tags.any?
end
def show
@@ -8,5 +10,7 @@ class TutorialTagsController < ApplicationController
@total_tutorials = Tutorial.tagged_with(@tag).count
@total_creations = Creation.tagged_with(@tag).count
@tutorials = Tutorial.includes(:tags).tagged_with(@tag).page(params[:page]).per(15)
+ expires_in(6.hours)
+ fresh_when(@tutorials)
end
end
diff --git a/app/controllers/tutorials_controller.rb b/app/controllers/tutorials_controller.rb
index 6080f275..b9b70653 100644
--- a/app/controllers/tutorials_controller.rb
+++ b/app/controllers/tutorials_controller.rb
@@ -3,10 +3,14 @@ class TutorialsController < ApplicationController
def index
@tutorials = Tutorial.includes(:tags).page(params[:page]).per(15)
+ expires_in(10.minutes)
+ fresh_when(Tutorial.maximum(:updated_at)) if Tutorial.any?
end
def show
@tutorial = Tutorial.find(params[:id])
+ expires_in(24.hours)
+ fresh_when(@tutorial)
end
def new
diff --git a/app/models/photo.rb b/app/models/photo.rb
index 87e20c3c..92629ada 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -2,33 +2,26 @@ class Photo < ActiveRecord::Base
belongs_to :creation, :counter_cache => true
validates :image, :presence => true
mount_uploader :image, PhotoUploader
- process_in_background :image
- #store_in_background :image
+ process_in_background :image if Rails.env.test?
+ store_in_background :image unless Rails.env.test?
- include Rails.application.routes.url_helpers
def to_jq_upload
- if image.thumb.url && image.thumb.url != image.thumb.default_url
- {
- :name => read_attribute(:image),
- :size => image.size,
- :url => image.url,
- :thumbnail_url => image.thumb.url,
- :delete_url => id,
- :delete_type => "DELETE"
- }
- else
- {
- :name => read_attribute(:image),
- :size => image.size,
- :url => image.url,
- :thumbnail_url => image.url,
- :delete_url => id,
- :delete_type => "DELETE"
- }
- end
+ {
+ :name => read_attribute(:image),
+ :url => image.url,
+ :thumbnail_url => is_processed? ? image.thumb.url : image.thumb.default_url,
+ :delete_url => id,
+ :delete_type => "DELETE"
+ }
end
def watermark
creation.watermark
end
+
+ private
+
+ def is_processed?
+ self.image_processing == nil
+ end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 21a1e861..b7c6e9f4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,22 +1,24 @@
class User < ActiveRecord::Base
geocoded_by :current_sign_in_ip, :latitude => :latitude, :longitude => :longitude
- reverse_geocoded_by :latitude, :longitude do |obj,results|
+ reverse_geocoded_by :latitude, :longitude do |user,results|
if geo = results.first
- obj.full_address = geo.formatted_address
+ user.full_address = geo.formatted_address
end
end
- after_validation :geocode, :reverse_geocode
+ before_save :geocode, :reverse_geocode
+ before_save :ensure_authentication_token
+
validates :name, :presence => true
validates :website, :format => URI::regexp(%w(http https)), :allow_blank => true
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
+
has_many :creations, :dependent => :destroy
has_many :favorites, :dependent => :destroy
has_many :tutorials, :dependent => :destroy
has_and_belongs_to_many :interests, :join_table => 'users_interests', :autosave => true
has_one :avatar
acts_as_tagger
- before_save :ensure_authentication_token
def add_favorite(creation)
creation.liked_by(self)
@@ -48,7 +50,9 @@ class User < ActiveRecord::Base
self.is_admin
end
- def self.ordered
- User.order(:creations_count => :desc)
+ class << self
+ def ordered
+ User.order(:creations_count => :desc)
+ end
end
end
diff --git a/app/uploaders/photo_uploader.rb b/app/uploaders/photo_uploader.rb
index 7fa5c6fe..187f8b6a 100644
--- a/app/uploaders/photo_uploader.rb
+++ b/app/uploaders/photo_uploader.rb
@@ -4,20 +4,21 @@ class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::MimeTypes
include ::CarrierWave::Backgrounder::Delay
- def store_dir
- "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
- end
-
process :set_content_type
version :large do
process :resize_to_fit => [570, 630]
process :watermark
end
+
version :thumb, :from_version => :large do
process :resize_to_fill => [260, 180]
end
+ def store_dir
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+
def watermark
return if model.watermark.blank?
manipulate! do |image|
@@ -48,6 +49,6 @@ class PhotoUploader < CarrierWave::Uploader::Base
#end
#end
def default_url
- "/assets/fallback/" + [version_name, "default.png"].compact.join('_')
+ "/assets/fallback/#{version_name}_default.png"
end
end
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
index 98ae3b8a..c0042c15 100644
--- a/app/views/devise/registrations/new.html.erb
+++ b/app/views/devise/registrations/new.html.erb
@@ -9,36 +9,6 @@
$('#submit-registration').attr('disabled', 'disabled');
}
});
- $('#user_city').autocomplete({
- source: function(request, response){
- $.ajax({
- url: 'https://ws.geonames.org/searchJSON',
- dataType: "jsonp",
- data: {
- featureClass: "P",
- style: 'full',
- maxRows: 12,
- name_startsWith: request.term
- },
- success: function(data){
- response( $.map(data.geonames, function(item){
- return {
- label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
- value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
- latitude: item.lat,
- longitude: item.lng
- }
- }));
- }
- });
- },
- minlength:2,
- select:function(event, ui){
- var item = ui.item;
- $('#user_latitude').val(item.latitude);
- $('#user_longitude').val(item.longitude);
- }
- });
mixpanel.track_forms(".form-inline", "signed in");
mixpanel.track_forms(".form-horizontal", "registered");
});
@@ -76,12 +46,6 @@
</div>
</div>
<div class="control-group">
- <%= f.label :city, 'City', :class => "control-label" %>
- <div class="controls">
- <%= f.text_field :city, :placeholder => 'optional' %>
- </div>
- </div>
- <div class="control-group">
<%= f.label :email, 'Email', :class => "control-label" %>
<div class="controls">
<%= f.email_field :email, :placeholder => 'required' %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
index 2c3640d8..835c47c8 100644
--- a/app/views/devise/sessions/new.html.erb
+++ b/app/views/devise/sessions/new.html.erb
@@ -9,36 +9,6 @@
$('#submit-registration').attr('disabled', 'disabled');
}
});
- $('#user_city').autocomplete({
- source: function(request, response){
- $.ajax({
- url: 'https://ws.geonames.org/searchJSON',
- dataType: "jsonp",
- data: {
- featureClass: "P",
- style: 'full',
- maxRows: 12,
- name_startsWith: request.term
- },
- success: function(data){
- response( $.map(data.geonames, function(item){
- return {
- label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
- value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
- latitude: item.lat,
- longitude: item.lng
- }
- }));
- }
- });
- },
- minlength:2,
- select:function(event, ui){
- var item = ui.item;
- $('#user_latitude').val(item.latitude);
- $('#user_longitude').val(item.longitude);
- }
- });
});
</script>
<% end %>
@@ -74,12 +44,6 @@
</div>
</div>
<div class="control-group">
- <%= f.label :city, 'City', :class => "control-label" %>
- <div class="controls">
- <%= f.text_field :city, :placeholder => 'optional' %>
- </div>
- </div>
- <div class="control-group">
<%= f.label :email, 'Email', :class => "control-label" %>
<div class="controls">
<%= f.email_field :email, :placeholder => 'required' %>
diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb
deleted file mode 100644
index 4ecea9e2..00000000
--- a/app/views/notifications/index.html.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-
-<div class="row">
- <div class="span12">
- <% @activities.each do |activity| %>
- <%= activity.render(self) %>
- <% end %>
- </div>
-</div>
diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb
index bae0f0a4..78b45cd2 100644
--- a/app/views/profiles/show.html.erb
+++ b/app/views/profiles/show.html.erb
@@ -24,7 +24,7 @@
<h4>Other Members Nearby</h4>
<ul class="unstyled">
<% @nearby_users.each do |item| %>
- <li><%= link_to item.name, profile_path(item), :class => "mix-link", "data-event" => "click-on-nearby-user" %> <small>(<%= item.city %>)</small></li>
+ <li><%= link_to item.name, profile_path(item), :class => "mix-link", "data-event" => "click-on-nearby-user" %> <small><%= item.city %></small></li>
<% end %>
<%= image_tag @map_url %>
</ul>
diff --git a/app/views/public_activity/avatar/_create.html.erb b/app/views/public_activity/avatar/_create.html.erb
deleted file mode 100644
index 4431b72f..00000000
--- a/app/views/public_activity/avatar/_create.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> added a new avatar named <%= activity.trackable.avatar.url if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/avatar/_destroy.html.erb b/app/views/public_activity/avatar/_destroy.html.erb
deleted file mode 100644
index bea6f78a..00000000
--- a/app/views/public_activity/avatar/_destroy.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> removed an avatar at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/avatar/_update.html.erb b/app/views/public_activity/avatar/_update.html.erb
deleted file mode 100644
index 471731c8..00000000
--- a/app/views/public_activity/avatar/_update.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> updated their avatar <%= activity.trackable.avatar.url if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/comment/_create.html.erb b/app/views/public_activity/comment/_create.html.erb
deleted file mode 100644
index b7a3fb83..00000000
--- a/app/views/public_activity/comment/_create.html.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name %> commented on <%= activity.trackable.commentable.name %> at <%= activity.created_at %>
- <blockquote>
- <%= activity.trackable.body %>
- </blockquote>
- </div>
-</div>
diff --git a/app/views/public_activity/creation/_create.html.erb b/app/views/public_activity/creation/_create.html.erb
deleted file mode 100644
index ea9faa5d..00000000
--- a/app/views/public_activity/creation/_create.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- a new user named <%= activity.trackable.name if activity.trackable %> signed up at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/creation/_destroy.html.erb b/app/views/public_activity/creation/_destroy.html.erb
deleted file mode 100644
index 64cbcf4d..00000000
--- a/app/views/public_activity/creation/_destroy.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- a user cancelled their account at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/creation/_update.html.erb b/app/views/public_activity/creation/_update.html.erb
deleted file mode 100644
index aa0aa8c5..00000000
--- a/app/views/public_activity/creation/_update.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> updated their account <%= activity.trackable.name if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/favorite/_create.html.erb b/app/views/public_activity/favorite/_create.html.erb
deleted file mode 100644
index fe7d3117..00000000
--- a/app/views/public_activity/favorite/_create.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> added a new creation to their favorites <%= activity.trackable if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/photo/_create.html.erb b/app/views/public_activity/photo/_create.html.erb
deleted file mode 100644
index 17667640..00000000
--- a/app/views/public_activity/photo/_create.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name %> added a new photo <%= activity.trackable.image.url if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/photo/_destroy.html.erb b/app/views/public_activity/photo/_destroy.html.erb
deleted file mode 100644
index 80c2c213..00000000
--- a/app/views/public_activity/photo/_destroy.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name %> removed a photo <%= activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/tutorial/_create.html.erb b/app/views/public_activity/tutorial/_create.html.erb
deleted file mode 100644
index b300ba76..00000000
--- a/app/views/public_activity/tutorial/_create.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> added a new tutorial named <%= activity.trackable.head if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/tutorial/_destroy.html.erb b/app/views/public_activity/tutorial/_destroy.html.erb
deleted file mode 100644
index 30d3850a..00000000
--- a/app/views/public_activity/tutorial/_destroy.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> removed a tutorial at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/tutorial/_update.html.erb b/app/views/public_activity/tutorial/_update.html.erb
deleted file mode 100644
index e76c5140..00000000
--- a/app/views/public_activity/tutorial/_update.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> updated a tutorial named <%= activity.trackable.head if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/user/_create.html.erb b/app/views/public_activity/user/_create.html.erb
deleted file mode 100644
index 2cec13e2..00000000
--- a/app/views/public_activity/user/_create.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> added a new creation named <%= activity.trackable.name if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/user/_destroy.html.erb b/app/views/public_activity/user/_destroy.html.erb
deleted file mode 100644
index 0db2588e..00000000
--- a/app/views/public_activity/user/_destroy.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> removed creation <%= activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/public_activity/user/_update.html.erb b/app/views/public_activity/user/_update.html.erb
deleted file mode 100644
index f4c40e1b..00000000
--- a/app/views/public_activity/user/_update.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="row">
- <div class="span12">
- <%= activity.owner.name if activity.owner %> updated creation named <%= activity.trackable.name if activity.trackable %> at <%= activity.created_at %>
- </div>
-</div>
diff --git a/app/views/registrations/edit.html.erb b/app/views/registrations/edit.html.erb
deleted file mode 100644
index ad7612f6..00000000
--- a/app/views/registrations/edit.html.erb
+++ /dev/null
@@ -1,69 +0,0 @@
-<% provide(:title, "My Settings") -%>
-<% content_for :javascript do %>
-<script type="text/javascript" charset="utf-8">
-$(function(){
- DeviseUsers.Edit.initialize(jQuery);
-});
-</script>
-<% end %>
-<!-- THIS PAGE IS NOT USED ANY MORE -->
-
-<div class="row">
- <div class="span10">
- <h1>My Settings</h1>
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class=> "form-horizontal" }) do |f| %>
- <fieldset>
- <div class="control-group">
- <%= f.label :name, :class => "control-label" %>
- <div class="controls"> <%= f.text_field :name, :class => "input-xlarge" %> </div>
- </div>
- <div class="control-group">
- <%= f.label :email, :class => "control-label" %>
- <div class="controls"> <%= f.email_field :email, :class => "input-xlarge" %> </div>
- </div>
- <div class="control-group">
- <%= f.label :city, :class => 'control-label' %>
- <div class="controls"> <%= f.text_field :city, :class => "input-xlarge" %> </div>
- </div>
- <div class="control-group">
- <%= f.label :website, :class => "control-label" %>
- <div class="controls"> <%= f.url_field :website, :class => "input-xlarge, url", :placeholder => "https://cakeside.com" %> </div>
- </div>
- <div class="control-group">
- <%= f.label :twitter, "Twitter username @", :class => "control-label" %>
- <div class="controls"> <%= f.text_field :twitter, :class => "input-xlarge", :placeholder => "without the @ sign", :maxlength => "255" %> </div>
- </div>
- <div class="control-group">
- <%= f.label :facebook, :class => "control-label" %>
- <div class="controls"> <%= f.text_field :facebook, :class => "input-xlarge", :placeholder => "http://www.facebook.com/your_profile", :maxlength => "255" %> </div>
- </div>
- <p class="help-block">
- <strong>Note:</strong> Help us better serve you by checking off what best describes you?
- </p>
- <div class="control-group">
- <label class="control-label">About me:</label>
- <div class="controls">
- <% for interest in Interest.all %>
- <label class="checkbox">
- <%= check_box_tag "user[interest_ids][]", interest.id, current_user.interests.include?(interest) %>
- <%= interest.name %>
- </label>
- <% end %>
- </div>
- </div><!-- /control-group -->
- <div class="form-actions">
- <input type="submit" class="btn btn-primary" value="Save changes" />
- <button type="reset" class="btn">Cancel</button>
- </div>
- <%= f.hidden_field :latitude %>
- <%= f.hidden_field :longitude %>
- </fieldset>
- <% end %>
- </div>
- <div class="span2">
- <!--
- <h4>Cancel My Account</h4>
- <p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete, :class => "btn btn-danger" %></p>
- -->
- </div>
-</div>
diff --git a/config/GeoLiteCity.dat b/config/GeoLiteCity.dat
new file mode 100644
index 00000000..ab41d5d4
--- /dev/null
+++ b/config/GeoLiteCity.dat
Binary files differ
diff --git a/config/recipes/templates/logrotate.erb b/config/recipes/templates/logrotate.erb
index 9fea806f..c5712f07 100644
--- a/config/recipes/templates/logrotate.erb
+++ b/config/recipes/templates/logrotate.erb
@@ -6,4 +6,5 @@
delaycompress
notifempty
copytruncate
+ dateext
}
diff --git a/config/recipes/templates/nginx_unicorn.erb b/config/recipes/templates/nginx_unicorn.erb
index fb87d642..ea3ceed4 100644
--- a/config/recipes/templates/nginx_unicorn.erb
+++ b/config/recipes/templates/nginx_unicorn.erb
@@ -7,30 +7,11 @@ client_max_body_size 4G;
server {
listen 80 default deferred;
server_name <%= domain %>;
- root <%= current_path %>/public;
- error_log off;
- access_log off;
-
- location ^~ /assets/ {
- gzip_static on;
- expires max;
- add_header Cache-Control public;
- }
-
- try_files $uri/index.html $uri @unicorn;
- location @unicorn {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header HOST $http_host;
- proxy_redirect off;
- proxy_pass http://unicorn;
- }
-
- error_page 500 502 503 504 /500.html;
- keepalive_timeout 10;
+ rewrite ^ https://$server_name$request_uri? permanent;
}
server {
- listen 443;
+ listen 443;
server_name <%= domain %>;
root <%= current_path %>/public;
ssl on;
@@ -39,7 +20,17 @@ server {
error_log /var/log/nginx/<%= application %>.error.log;
access_log /var/log/nginx/<%= application %>.access.log;
+ if ($host = 'cakeside.com' ) {
+ rewrite ^/(.*)$ https://<%= domain %>/$1 permanent;
+ }
+
try_files $uri/index.html $uri @unicorn;
+ location ^~ /assets/ {
+ gzip_static on;
+ expires max;
+ add_header Cache-Control public;
+ }
+
location @unicorn {
proxy_set_header X_FORWARDED_PROTO https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -48,5 +39,7 @@ server {
proxy_redirect off;
proxy_pass http://unicorn;
}
-}
+ error_page 500 502 503 504 /500.html;
+ keepalive_timeout 10;
+}
diff --git a/db/migrate/20131229022014_drop_table_activities.rb b/db/migrate/20131229022014_drop_table_activities.rb
new file mode 100644
index 00000000..e0bf13eb
--- /dev/null
+++ b/db/migrate/20131229022014_drop_table_activities.rb
@@ -0,0 +1,5 @@
+class DropTableActivities < ActiveRecord::Migration
+ def change
+ drop_table :activities
+ end
+end
diff --git a/db/migrate/20131230013944_add_image_processing_to_photos.rb b/db/migrate/20131230013944_add_image_processing_to_photos.rb
new file mode 100644
index 00000000..ae4c7766
--- /dev/null
+++ b/db/migrate/20131230013944_add_image_processing_to_photos.rb
@@ -0,0 +1,5 @@
+class AddImageProcessingToPhotos < ActiveRecord::Migration
+ def change
+ add_column :photos, :image_processing, :boolean
+ end
+end
diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb
index aa054d87..4f6ff600 100644
--- a/spec/controllers/photos_controller_spec.rb
+++ b/spec/controllers/photos_controller_spec.rb
@@ -32,6 +32,7 @@ describe PhotosController do
before :each do
creation.photos << photo
creation.save!
+ photo.update_attribute(:image_processing, nil)
delete :destroy, :creation_id => creation.id, :id => photo.id
end
@@ -48,12 +49,11 @@ describe PhotosController do
{
:files => [
{
- :name=>"example.png",
- :size=>359791,
- :url=>"/uploads/photo/image/#{photo.id}/example.png",
- :thumbnail_url=>"/uploads/photo/image/#{photo.id}/thumb_example.png",
- :delete_url=>photo.id,
- :delete_type=>"DELETE"
+ :name => "example.png",
+ :url => "/uploads/photo/image/#{photo.id}/example.png",
+ :thumbnail_url => "/uploads/photo/image/#{photo.id}/thumb_example.png",
+ :delete_url => photo.id,
+ :delete_type => "DELETE"
}]
}.to_json
end
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index 0a36fa42..a4ccb5e3 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -1,34 +1,4 @@
require 'spec_helper'
describe RegistrationsController do
- let(:sut) { RegistrationsController.new }
- let(:user){ fake }
-
- describe "when updating a users settings not including their password" do
- before(:each) do
- @payload = {
- :user => {
- :current_password => '',
- :email => 'mo@mokhan.ca',
- :facebook => 'mo',
- :name =>'mo',
- :password => '',
- :password_confirmation => '',
- :twitter => 'mocheen',
- :website => 'http://mokhan.ca/',
- :interest_ids => []
- }
- }
- sut.stub(:current_user).and_return(user)
- sut.stub(:params).and_return(@payload)
- sut.stub(:update_without_password).and_return(true)
- sut.stub(:render).and_return(true)
-
- sut.update
- end
-
- xit "should update their website" do
- user.should have_received(:update_without_password,@payload[:user])
- end
- end
end
diff --git a/spec/factories/photo.rb b/spec/factories/photo.rb
index b06b403f..95763112 100644
--- a/spec/factories/photo.rb
+++ b/spec/factories/photo.rb
@@ -1,5 +1,5 @@
FactoryGirl.define do
factory :photo, class: Photo do
- image { File.new(File.join( Rails.root, 'spec/fixtures/images/example.png')) }
+ image { File.new(File.join(Rails.root, 'spec/fixtures/images/example.png')) }
end
end
diff --git a/spec/features/registration_spec.rb b/spec/features/registration_spec.rb
index 6aa087ef..0b30baa7 100644
--- a/spec/features/registration_spec.rb
+++ b/spec/features/registration_spec.rb
@@ -6,7 +6,6 @@ describe "Registration", :js => true do
visit "/login"
within(".form-horizontal") do
fill_in('user_name', :with => 'John Smith')
- fill_in('user_city', :with => 'Calgary, Alberta, Canada')
fill_in('user_email',:with => Faker::Internet.email)
fill_in('user_password', :with => 'password')
fill_in('user_password_confirmation', :with => 'password')
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 4632e418..ae2e61be 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -22,25 +22,27 @@ describe User do
describe "when a website url is supplied" do
describe "when the url is valid" do
let(:user) {User.new}
- before(:each) do
- user.update_attributes(:website => 'http://example.com')
- end
+
+ before(:each) { user.update_attribute(:website, 'http://example.com') }
+
it "can validate" do
user.errors[:website].any?.should == false
end
+
it "should not have any validation error messages" do
user.errors[:website].should === []
end
end
describe "when the url is not valid" do
- let(:user) {User.new}
- before(:each) do
- user.update_attributes(:website => 'blah')
- end
+ let(:user) { User.new }
+
+ before(:each) { user.update_attributes(:website => 'blah') }
+
it "cannot validate" do
user.errors[:website].any?.should == true
end
+
it "should have an error message" do
user.errors[:website].should === ["is invalid"]
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c2e98406..f9f06f77 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,5 +1,9 @@
require 'simplecov'
-SimpleCov.start 'rails'
+SimpleCov.start 'rails' do
+ add_filter '/spec/'
+ add_filter '/config/'
+ add_filter '/vendor/'
+end
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)