From cc948937bc4e8460f3ad1b0063cbb2dba262809d Mon Sep 17 00:00:00 2001 From: Godwin Date: Tue, 29 Apr 2014 21:02:02 -0600 Subject: [PATCH] Some updates to translation engine, added dotenv but have not yet set it up. --- .rspec | 2 - Gemfile | 27 ++-- Gemfile.lock | 141 +++++++++++++----- Guardfile | 24 +++ Thumbs.db | Bin 0 -> 13312 bytes .../stylesheets/foundation_and_overrides.scss | 63 ++++---- app/assets/stylesheets/sass/_layout.scss | 10 +- app/controllers/application_controller.rb | 12 +- app/controllers/organizations_controller.rb | 6 + app/controllers/user_sessions_controller.rb | 5 +- app/helpers/application_helper.rb | 39 ++++- app/models/user.rb | 8 +- app/views/layouts/application.html.haml | 1 - app/views/organizations/_form.html.haml | 3 +- app/views/shared/_navbar.html.haml | 26 ++-- app/views/user_sessions/_form.html.haml | 2 +- app/views/user_sessions/new.html.haml | 6 +- config/application.rb | 25 ++-- config/boot.rb | 11 ++ config/environments/development.rb | 2 + config/initializers/i18n.rb | 135 +++++++++++++++++ config/initializers/locale.rb | 2 +- config/initializers/request_global.rb | 15 ++ config/initializers/sorcery.rb | 6 +- config/locales/translations.yml | 78 ++++++++++ db/schema.rb | 6 +- lib/tasks/translations.rake | 14 ++ nbproject/project.properties | 2 +- spec/features/pages/home_spec.rb | 29 ++++ spec/features/pages/login_spec.rb | 72 +++++++++ .../pages/organization_registration_spec.rb | 21 +++ spec/spec_helper.rb | 81 +++++----- spec/support/authentication.rb | 12 +- spec/support/delorean.rb | 8 +- test/factories/users.rb | 11 +- 35 files changed, 711 insertions(+), 194 deletions(-) create mode 100644 Guardfile create mode 100644 Thumbs.db create mode 100644 config/initializers/i18n.rb create mode 100644 config/initializers/request_global.rb create mode 100644 config/locales/translations.yml create mode 100644 lib/tasks/translations.rake create mode 100644 spec/features/pages/home_spec.rb create mode 100644 spec/features/pages/login_spec.rb create mode 100644 spec/features/pages/organization_registration_spec.rb diff --git a/.rspec b/.rspec index 343805a..4e1e0d2 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1 @@ --color ---format documentation ---drb diff --git a/Gemfile b/Gemfile index ecfff8d..b7dd7ba 100644 --- a/Gemfile +++ b/Gemfile @@ -3,11 +3,11 @@ source 'http://rubygems.org' ruby '2.0.0' gem 'rails', '4.0.0' -#gem 'nokogiri', :git => '/nokogiri/' - # Servers # gem 'puma' # gem 'unicorn' +# gem 'openssl', '~> 1.1.0' + gem 'eventmachine' # Multi-environment configuration @@ -19,12 +19,9 @@ gem 'eventmachine' # ORM gem 'pg' -# Performance and Exception management -# gem 'airbrake' -# gem 'newrelic_rpm' - # Security # gem 'secure_headers' +gem 'dotenv-rails', :groups => [:development, :test] # Miscellanea # gem 'google-analytics-rails' @@ -55,11 +52,10 @@ gem 'redis' gem 'carrierwave' gem 'carrierwave-imageoptimizer' gem 'mini_magick' -#gem 'carmen-rails'#, '~> 1.0.0', github: 'jim/carmen-rails' +#gem 'carmen', :path => '../carmen /' +gem 'carmen-rails' gem 'nested_form' gem 'acts_as_list' -##gem 'jcrop-rails' -##gem 'rmagick' gem 'geocoder' gem 'forgery' @@ -67,17 +63,13 @@ gem 'paper_trail' group :development, :test do - #gem 'thin' gem 'debugger' gem 'delorean' - gem 'factory_girl_rails' - #gem 'faker' - #gem 'pry' - #gem 'pry-rails' + gem 'rspec' + gem 'rspec-rails' end group :development do - #gem 'perftools.rb' gem 'bullet' gem 'better_errors' gem 'binding_of_caller' @@ -89,15 +81,16 @@ end group :test do gem 'capybara' + gem 'guard-rspec' + gem 'factory_girl_rails' gem 'coveralls', require: false gem 'database_cleaner' gem 'email_spec' gem 'launchy' - gem 'rspec' - gem 'rspec-rails' gem 'selenium-webdriver' gem 'simplecov', require: false gem 'webmock', require: false + gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i end group :staging, :production do diff --git a/Gemfile.lock b/Gemfile.lock index 40ddd63..9b54ba3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ GIT remote: git://github.com/josevalim/rails-footnotes.git - revision: 3a6ac1971e91d822f057650cc5916ebfcbd6ee37 + revision: 8411b4cec668b133ec3f7d3be6d39e77ee3abe9e specs: - rails-footnotes (3.7.9) - rails (>= 3.0.0) + rails-footnotes (4.0.0) + rails (>= 3.2) GIT remote: git://github.com/svenfuchs/i18n-active_record.git @@ -41,9 +41,8 @@ GEM tzinfo (~> 0.3.37) acts_as_list (0.4.0) activerecord (>= 3.0) - addressable (2.3.5) + addressable (2.3.6) arel (4.0.2) - atomic (1.1.14) awesome_print (1.2.0) bcrypt (3.1.7) bcrypt (3.1.7-x86-mingw32) @@ -67,14 +66,25 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - carrierwave (0.9.0) + carmen (1.0.1) + unicode_utils (~> 1.4.0) + carmen-rails (1.0.1) + carmen (~> 1.0.0) + rails + carrierwave (0.10.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) json (>= 1.7) + mime-types (>= 1.16) carrierwave-imageoptimizer (1.2.1) carrierwave (~> 0.8) image_optimizer (~> 1.2) - childprocess (0.5.1) + celluloid (0.15.2) + timers (~> 1.1.0) + celluloid-io (0.15.0) + celluloid (>= 0.15.0) + nio4r (>= 0.5.0) + childprocess (0.5.2) ffi (~> 1.0, >= 1.0.11) chronic (0.10.2) chunky_png (1.3.0) @@ -87,12 +97,13 @@ GEM execjs coffee-script-source (1.7.0) columnize (0.3.6) - compass (0.12.2) + compass (0.12.5) chunky_png (~> 1.2) fssm (>= 0.2.7) - sass (~> 3.1) - compass-rails (1.1.3) + sass (~> 3.2.19) + compass-rails (1.1.7) compass (>= 0.12.2) + sprockets (<= 2.11.0) coveralls (0.7.0) multi_json (~> 1.3) rest-client @@ -103,25 +114,31 @@ GEM safe_yaml (~> 1.0.0) database_cleaner (1.2.0) debug_inspector (0.0.2) - debugger (1.6.5) + debugger (1.6.6) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.3.1) + debugger-ruby_core_source (~> 1.3.2) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.3.1) + debugger-ruby_core_source (1.3.2) delorean (2.1.0) chronic diff-lcs (1.2.5) docile (1.1.3) + dotenv (0.11.1) + dotenv-deployment (~> 0.0.2) + dotenv-deployment (0.0.2) + dotenv-rails (0.11.1) + dotenv (= 0.11.1) email_spec (1.5.0) launchy (~> 2.1) mail (~> 2.2) erubis (2.7.0) + eventmachine (1.0.3) eventmachine (1.0.3-x86-mingw32) execjs (2.0.2) factory_girl (4.4.0) activesupport (>= 3.0.0) - factory_girl_rails (4.4.0) + factory_girl_rails (4.4.1) factory_girl (~> 4.4.0) railties (>= 3.0.0) faraday (0.9.0) @@ -129,11 +146,21 @@ GEM ffi (1.9.3) ffi (1.9.3-x86-mingw32) forgery (0.5.0) - foundation-rails (5.1.1.0) + formatador (0.2.4) + foundation-rails (5.2.2.0) railties (>= 3.1.0) sass (>= 3.2.0) fssm (0.2.10) geocoder (1.1.9) + guard (2.6.0) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) + guard-rspec (4.2.8) + guard (~> 2.1) + rspec (>= 2.14, < 4.0) haml (4.0.5) tilt haml-rails (0.5.1) @@ -168,21 +195,31 @@ GEM multi_json (>= 1.5) launchy (2.4.2) addressable (~> 2.3) + listen (2.7.1) + celluloid (>= 0.15.2) + celluloid-io (>= 0.15.0) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + lumberjack (1.0.5) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - meta_request (0.2.8) + meta_request (0.2.9) callsite rack-contrib railties + method_source (0.8.2) mime-types (1.25.1) mini_magick (3.7.0) subexec (~> 0.2.1) - mini_portile (0.5.2) + mini_portile (0.5.3) minitest (4.7.5) - multi_json (1.8.4) + multi_json (1.9.2) multipart-post (2.0.0) nested_form (0.3.2) + nio4r (1.0.0) + nokogiri (1.6.1) + mini_portile (~> 0.5.0) nokogiri (1.6.1-x86-mingw32) mini_portile (~> 0.5.0) oauth (0.4.7) @@ -192,12 +229,21 @@ GEM jwt (~> 0.1.4) multi_json (~> 1.0) rack (~> 1.2) - paper_trail (3.0.0) + paper_trail (3.0.1) activerecord (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.0) pg (0.17.1) pg (0.17.1-x86-mingw32) - polyglot (0.3.3) + polyglot (0.3.4) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + pry (0.9.12.6-x86-mingw32) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + win32console (~> 1.3) rack (1.5.2) rack-contrib (1.1.0) rack (>= 0.9.1) @@ -221,7 +267,10 @@ GEM activesupport (= 4.0.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.1.1) + rake (10.2.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.3) + ffi (>= 0.5.0) redis (3.0.7) rest-client (1.6.7) mime-types (>= 1.16) @@ -229,11 +278,11 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - rspec-core (2.14.7) + rspec-core (2.14.8) rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.5) - rspec-rails (2.14.1) + rspec-mocks (2.14.6) + rspec-rails (2.14.2) actionpack (>= 3.0) activemodel (>= 3.0) activesupport (>= 3.0) @@ -242,15 +291,16 @@ GEM rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) ruby-drupal-hash (0.0.3) - rubyzip (1.1.0) - safe_yaml (1.0.1) - sass (3.2.14) - sass-rails (4.0.1) + rubyzip (1.1.3) + safe_yaml (1.0.2) + sass (3.2.19) + sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) - sass (>= 3.1.10) - sprockets-rails (~> 2.0.0) - selenium-webdriver (2.39.0) - childprocess (>= 0.2.5) + sass (~> 3.2.0) + sprockets (~> 2.8, <= 2.11.0) + sprockets-rails (~> 2.0) + selenium-webdriver (2.41.0) + childprocess (>= 0.5.0) multi_json (~> 1.0) rubyzip (~> 1.0) websocket (~> 1.0.4) @@ -259,11 +309,12 @@ GEM multi_json simplecov-html (~> 0.8.0) simplecov-html (0.8.0) + slop (3.5.0) sorcery (0.8.5) bcrypt-ruby (>= 3.0) oauth (~> 0.4.4) oauth2 (>= 0.8.0, < 1.0.0) - sprockets (2.10.1) + sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -275,25 +326,29 @@ GEM subexec (0.2.3) term-ansicolor (1.3.0) tins (~> 1.0) - thor (0.18.1) - thread_safe (0.1.3) - atomic + thor (0.19.1) + thread_safe (0.3.3) tilt (1.4.1) - tins (1.0.0) + timers (1.1.0) + tins (1.1.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (2.2.1) + turbolinks (2.2.2) coffee-rails - tzinfo (0.3.38) - uglifier (2.4.0) + tzinfo (0.3.39) + uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) + unicode_utils (1.4.0) uniform_notifier (1.4.0) - webmock (1.17.3) + wdm (0.1.0) + webmock (1.17.4) addressable (>= 2.2.7) crack (>= 0.3.2) websocket (1.0.7) + win32console (1.3.2) + win32console (1.3.2-x86-mingw32) xpath (2.0.0) nokogiri (~> 1.3) @@ -308,6 +363,7 @@ DEPENDENCIES binding_of_caller bullet capybara + carmen-rails carrierwave carrierwave-imageoptimizer coffee-rails (~> 4.0.0) @@ -316,12 +372,14 @@ DEPENDENCIES database_cleaner debugger delorean + dotenv-rails email_spec eventmachine factory_girl_rails forgery foundation-rails geocoder + guard-rspec haml haml-rails haml_assets @@ -351,4 +409,5 @@ DEPENDENCIES sorcery (>= 0.8.1) turbolinks uglifier (>= 1.3.0) + wdm (>= 0.1.0) webmock diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..e6e7c78 --- /dev/null +++ b/Guardfile @@ -0,0 +1,24 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +guard :rspec do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + + # Capybara features specs + watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } +end + diff --git a/Thumbs.db b/Thumbs.db new file mode 100644 index 0000000000000000000000000000000000000000..abcbf6052ffb8be507d37f2c07ff7653e1f7796f GIT binary patch literal 13312 zcmeHt1z23cmgXgmg&={TK@%WoaCd@-puvI@EVu@DNP=r12|*KrLkE}O*0@9CG|<7V z(Z-tXyf^R7`(}1_XLr8+*5=gr*Qu&|t8Se-w@%ePbw@{tVYw9#SAc&(QUC}*-QEST z|DhZMo&JNr(0u^7gHHU(qi%0+|5^wD=;VLW|3xEkgYN4e{r$lo!a^(ZkIr$>z(wOO z8hB{jLjxZT0yGHGAVLHE3IN1tkf8AZ4N^47&>%;H0u4$u{?_haTmR4a|FjX%23*j= z6JP)o0B1CJ2Yk_5`}Y$$fc5t||99K)Z&a6|H{&xh8o~HS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V4d=V)j}x~&lC9c~NHseObxx{piX z4nn4)=y}f_p(YY0hGv~9(f(x*Tm8lJuE)mICg$AMcPHE&_7~~1vT%_g1obNI&z6b3 z)fjaftK%#U?jS;H7ri-LhQy{sS9OjZ?g+F+mrMx9_x3wUGEon4s*96$FO`lOxE@dR z)zrQ3t;Znfzu4R)l*CECS#taGcIms7(>Dek&LbAFogEAEfdfA#B_a%F*h`Tg$`C?iIaVS+LLb@ zTtn!0v;Asnx&q}CNOkZJZ-E%}K0Cl-)kLdCgHXeXlcbYI!_MRLVSm@bD;;4>;>3Qh z)c!CHTHE#!O#3CAQFtAcDO&X^Dt4G*!7|oS$6&Jdp3~jr8RKN11Jfu4@euUd67sim zwLkn=IyxJl8^xdkLhsjRyuhg request.env['PATH_INFO'], :controller => params['controller'], :action => params['action']} + end end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 75e9633..b697d61 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,3 +1,5 @@ +include ApplicationHelper + class OrganizationsController < ApplicationController before_action :set_organization, only: [:show, :edit, :update, :destroy] @@ -17,6 +19,10 @@ class OrganizationsController < ApplicationController @organization = Organization.new #@organization.location = Location.new @organization.locations.build + @user_location = lookup_ip_location + @organization.locations[0].city = @user_location.city + @organization.locations[0].country = @user_location.country_code + @organization.locations[0].territory = @user_location.state_code @organization.locations_organization.build @organization.user_organization_relationships.build end diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb index 33ceb5f..7c386a8 100644 --- a/app/controllers/user_sessions_controller.rb +++ b/app/controllers/user_sessions_controller.rb @@ -1,13 +1,12 @@ class UserSessionsController < ApplicationController def new - session[:return_to] ||= request.referer + session[:return_to] ||= request.referer @user = User.new end def create if @user = login(params[:email], params[:password]) - #redirect_back_or_to(:users, notice: 'Login successful') - redirect_to session.delete(:return_to) + redirect_to session.delete(:return_to) || 'pages#home' else flash.now[:alert] = "Login failed" render action: "new" diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 08fcbe0..b19114b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -178,8 +178,8 @@ module ApplicationHelper translation['untranslated'] = I18n.translate!(config.i18n.default_locale, key, vars) translation['lang'] = config.i18n.default_locale.to_s rescue - puts _lorem_ipsum(behavior, behavior_size) - translation['untranslated'] = behavior ? _lorem_ipsum(behavior, behavior_size) || key.gsub(/^.*\.(.+)?$/, '\1') : key.gsub(/^.*\.(.+)?$/, '\1') + default_translation = I18n::MissingTranslationExceptionHandler.note(key, behavior, behavior_size) + translation['untranslated'] = default_translation end end return translation @@ -232,7 +232,7 @@ module ApplicationHelper if /select(_tag)?$/.match(type.to_s) if !label - select_prompt = placeholder || (form ? 'Select a ' + name.to_s : 'Select one') + select_prompt = placeholder || (form ? 'Select a ' + (_ ('form.select_' + name.to_s)) : 'form.Select_one') label_html = '' show_label = false end @@ -254,12 +254,12 @@ module ApplicationHelper if /^password/.match(type.to_s) placeholder = nil elsif !placeholder - placeholder = 'Type in a ' + name.to_s + placeholder = (_ 'form.Enter_your_' + name.to_s) end end if show_label - label_html = eval("(" + (form ? 'form.label' : 'label_tag') + " name, '#{label ? CGI.escapeHTML(label) : name}'.html_safe)") + label_html = eval("(" + (form ? 'form.label' : 'label_tag') + " name, '#{CGI.escapeHTML(_ (label || name.to_s))}'.html_safe)") end if label === false || !show_label @@ -370,8 +370,21 @@ module ApplicationHelper return ("
0 ? ' ' + classes.join(' ') : ''}\">" + (label_after ? '' : label_html) + form_html + (label_after ? label_html : '') + "
").html_safe end - def actions(action) - ('
').html_safe + def actions(actions = []) + if !actions.is_a?(Array) + actions = [actions] + end + + html = '
' + actions.each { |action| + if action == :facebook_sign_in + html += '' + else + html += '' + end + } + html += '
' + html.html_safe end def sortable(objects, id = 'id', url: nil, &block) @@ -521,4 +534,16 @@ module ApplicationHelper html.html_safe end + def t(*a) + _(*a) + end + + def lookup_ip_location + if request.remote_ip == '127.0.0.1' + Geocoder.search(session['remote_ip'] || (session['remote_ip'] = open("http://checkip.dyndns.org").first.gsub(/^.*\s([\d\.]+).*$/s, '\1').gsub(/[^\.\d]/, ''))).first + else + request.location + end + end + end diff --git a/app/models/user.rb b/app/models/user.rb index ed8ff62..10b80c4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ class User < ActiveRecord::Base authenticates_with_sorcery! do |config| - config.authentications_class = Authentication - end + config.authentications_class = Authentication + end validates :password, presence: true, confirmation: true, length: { minimum: 3 }, unless: ("id?" || "password_confirmation?") validates :password_confirmation, presence: true, unless: ("id?" || "password?") @@ -18,7 +18,7 @@ class User < ActiveRecord::Base has_many :user_organization_relationships has_many :organizations, through: :user_organization_relationships - has_many :authentications, :dependent => :destroy - accepts_nested_attributes_for :authentications + has_many :authentications, :dependent => :destroy + accepts_nested_attributes_for :authentications end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 1af0cb9..d09fadd 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -28,7 +28,6 @@ = javascript_include_tag '//use.typekit.net/iqv7hcg.js' = javascript_include_tag 'application' = javascript_include_tag 'nested_form' - = javascript_include_tag '//use.edgefonts.net/abel;amatic-sc.js' %body{ class: (yield_or_default :page_style) } = render 'shared/translation_control' diff --git a/app/views/organizations/_form.html.haml b/app/views/organizations/_form.html.haml index ce0aabb..2b1c3b8 100644 --- a/app/views/organizations/_form.html.haml +++ b/app/views/organizations/_form.html.haml @@ -9,7 +9,7 @@ = field f, :name, :text_field = field f, :slug, :text_field - .columns.medium-4 + .columns.medium-4.small-text-centered -#%h2=_'organization.create.intro-title', :t -#%p=_'organization.create.intro', :p =# field f, :avatar, :image_field @@ -21,7 +21,6 @@ =# = f.hidden_field :avatar_cache .columns.medium-8 = field f, :email_address, :email_field - -#= field f, :url, :text_field = f.fields_for :locations do |b| = field_set_tag 'Location' do = field b, :country, :country_select, {help: 'Select a Country'} diff --git a/app/views/shared/_navbar.html.haml b/app/views/shared/_navbar.html.haml index c96af17..b8ac285 100644 --- a/app/views/shared/_navbar.html.haml +++ b/app/views/shared/_navbar.html.haml @@ -1,5 +1,5 @@ -%nav.top-bar.row +%nav.top-bar.row{ data: { :topbar => '' } } #nav-inner %ul.title-area / Title Area @@ -10,22 +10,28 @@ %li.toggle-topbar.menu-icon %a{href: "#"} %span Menu - .top-bar-section + %section.top-bar-section / Left Nav Section %ul.left %li.active - %a{href: "/conferences/"} Conferences + = link_to (_'Conferences'), :controller => :conferences %li - %a{href: "/organizations/"} Organizations + = link_to (_'Organizations'), :controller => :organizations %li - %a{href: "/resources/"} Resources + = link_to (_'Resources'), '/resources' / Right Nav Section %ul.right - if current_user - %li.has-form.sign-out - = link_to "Sign Out", :logout, method: :post, :class => 'button' - %li.user-profile - = link_to image_tag(current_user.avatar_url(:icon)), current_user + %li.has-form.sign-out.hide-for-small + = link_to (_"Sign_Out"), :logout, method: :post, :class => 'button' + %li.user-profile.has-dropdown + = link_to current_user do + = image_tag(current_user.avatar_url(:icon)) + %span + %span.show-for-small=current_user.username + %ul.dropdown + %li= link_to 'View Profile', current_user + %li= link_to 'Edit Profile', edit_user_path(current_user.id) - else %li.has-form.sign-in - = link_to "Sign In", :login, :class => 'button' + = link_to (_"Sign_In"), :login, :class => 'button' diff --git a/app/views/user_sessions/_form.html.haml b/app/views/user_sessions/_form.html.haml index 5314e6f..91b9ff0 100644 --- a/app/views/user_sessions/_form.html.haml +++ b/app/views/user_sessions/_form.html.haml @@ -1,4 +1,4 @@ = form_tag user_sessions_path, :method => :post do = field :email, :email_field = field :password, :password_field_tag - = actions :sign_in + = actions [:sign_in, :facebook_sign_in] diff --git a/app/views/user_sessions/new.html.haml b/app/views/user_sessions/new.html.haml index 35cd257..bdc4661 100644 --- a/app/views/user_sessions/new.html.haml +++ b/app/views/user_sessions/new.html.haml @@ -4,10 +4,8 @@ .columns.medium-6 = render 'form' .columns.medium-6 - %h2 - Create an Account + %h2 #{_ 'user.Create_Account'} + %p #{_ 'user.why_register', 'paragraph'} %p - #{_ 'user.why_register', 'paragraph'} - = link_to 'Login with Facebook', auth_at_provider_path(:provider => :facebook) = render '/users/form' diff --git a/config/application.rb b/config/application.rb index 20db061..fda3b98 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,8 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' -require 'pry' +# require 'carmen' +# require 'pry' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -11,18 +12,20 @@ ENV['JPEGOPTIM_BIN'] = 'jpegoptim' ENV['OPTIPNG_BIN'] = 'optipng' module BikeBike - class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - config.i18n.default_locale = :en #:de + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + config.i18n.default_locale = :en #:de config.i18n.enforce_available_locales = false + #config.middleware.swap 'Rack::MethodOverride', 'Rack::MethodOverrideWithParams' + #config.i18n.exception_handler = I18n::MissingTranslationExceptionHandler.new end end diff --git a/config/boot.rb b/config/boot.rb index 3596736..222d337 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -2,3 +2,14 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require'rails/commands/server' + +module Rails + class Server + alias:default_options_alias :default_options + def default_options + default_options_alias.merge!(:Port=>80) + end + end +end + diff --git a/config/environments/development.rb b/config/environments/development.rb index 045ffb5..1f6a634 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,5 +1,7 @@ #require 'perftools' +OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE + BikeBike::Application.configure do # Settings specified here will take precedence over those in config/application.rb. diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb new file mode 100644 index 0000000..6c840bd --- /dev/null +++ b/config/initializers/i18n.rb @@ -0,0 +1,135 @@ +require 'i18n/backend/active_record' +require 'yaml' + +class DevTranslation < Translation + self.table_name = 'translations' + establish_connection :development +end + +module I18n + class MissingTranslationExceptionHandler < ExceptionHandler + def self.lorem_ipsum(method, size) + options = {:random => true} + case method.to_s + when 'c', 'char', 'character', 'characters' + if size + return Forgery::LoremIpsum.characters size, options + end + return Forgery::LoremIpsum.character, options + when 'w', 'word', 'words' + if size + return Forgery::LoremIpsum.words size, options + end + #return'LOREM' + return Forgery::LoremIpsum.word options + when 's', 'sentence', 'sentences' + if size + return Forgery::LoremIpsum.sentences size, options + end + return Forgery::LoremIpsum.sentence options + when 'p', 'paragraph', 'paragraphs' + if size + return Forgery::LoremIpsum.paragraphs size, options.merge({:sentences => 10}) + end + return Forgery::LoremIpsum.sentences 10, options + when 't', 'title' + return Forgery::LoremIpsum.sentences 1, options + end + return nil + end + + def self.note(key, behavior = nil, behavior_size = nil) + I18n.backend.needs_translation(key) + if behavior + return self.lorem_ipsum(behavior, behavior_size) + end + key.to_s.gsub(/^world\..*\.(.+)\.name$/, '\1').gsub(/^.*\.(.+)?$/, '\1').gsub('_', ' ') + end + + def call(exception, locale, key, options) + if exception.is_a?(MissingTranslation) + I18n::MissingTranslationExceptionHandler.note(key, options[:behavior] || nil, options[:behavior_size] || nil) + else + super + end + end + end + + module Backend + class BikeBike < I18n::Backend::ActiveRecord + @@needs_translation + + @@translations_file = 'config/locales/.translations.yml' + @@translation_cache_file = 'config/locales/.translation-cache.yml' + @@translation_cache + + def needs_translation(key) + @@needs_translation ||= Array.new + @@needs_translation << key + end + + def initialized? + begin + super + rescue + return false + end + end + + def initialize + if Rails.env.test? + File.open(@@translations_file, 'w+') + File.open(@@translation_cache_file, 'w+') + end + @@translation_cache = YAML.load(File.read(@@translation_cache_file)) || Hash.new + super + end + + protected + def lookup(locale, key, scope = [], options = {}) + result = nil + if @@translation_cache && @@translation_cache.has_key?(locale.to_s) && @@translation_cache[locale.to_s].has_key?(key.to_s) + result = @@translation_cache[locale.to_s][key.to_s] + end + if !result + result = super(locale, key, scope, options) + + if Rails.env.test? + if result + @@translation_cache[locale.to_s] ||= Hash.new + @@translation_cache[locale.to_s][key.to_s] = result + File.open(@@translation_cache_file, 'w') { |f| f.write @@translation_cache.to_yaml } + end + + translations = YAML.load_file(@@translations_file) + translations ||= Hash.new + translations[key.to_s] ||= Hash.new + translations[key.to_s]['langauges'] ||= Hash.new + if result != nil + translations[key.to_s]['langauges'][locale.to_s] = result + end + translations[key.to_s]['pages'] ||= Array.new + unless translations[key.to_s].has_key?('data') + translations[key.to_s]['data'] = Array.new + DevTranslation.where("key = '#{key.to_s}' OR key LIKE '#{key.to_s}#{I18n::Backend::Flatten::FLATTEN_SEPARATOR}%'").each { |t| + translations[key.to_s]['data'] << t.becomes(Translation) + } + end + path = $page_info[:path] + unless translations[key.to_s]['pages'].include?(path) + translations[key.to_s]['pages'] << path + end + File.open(@@translations_file, 'w') { |f| f.write translations.to_yaml } + end + end + + if Rails.env.test? + end + + result + end + end + end +end + +I18n.exception_handler = I18n::MissingTranslationExceptionHandler.new diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb index 2ab40a3..936bdf0 100644 --- a/config/initializers/locale.rb +++ b/config/initializers/locale.rb @@ -1,4 +1,4 @@ require 'i18n/backend/active_record' -I18n.backend = I18n::Backend::ActiveRecord.new +I18n.backend = I18n::Backend::BikeBike.new # I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize) # I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten) diff --git a/config/initializers/request_global.rb b/config/initializers/request_global.rb new file mode 100644 index 0000000..9cef274 --- /dev/null +++ b/config/initializers/request_global.rb @@ -0,0 +1,15 @@ +module Rack + class MethodOverrideWithParams < Rack::MethodOverride + def call(env) + #puts "\n\nENV: " + env.to_json.to_s + "\n\n" + #puts "\n\nTT: " + #puts I18n::Backend::BikeBike.translations_file + "\n\n" + $request = Rack::Request.new(env) + #Rails.I18n.translations_file ||= 'config/locales/.translations.yml' + #if Rails.env.test? + # File.open(Rails.I18n.translations_file, 'w+')# { |f| f.write {}.to_yaml } + #end + super(env) + end + end +end diff --git a/config/initializers/sorcery.rb b/config/initializers/sorcery.rb index 750459f..f044c6b 100644 --- a/config/initializers/sorcery.rb +++ b/config/initializers/sorcery.rb @@ -110,9 +110,9 @@ Rails.application.config.sorcery.configure do |config| # config.twitter.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=twitter" # config.twitter.user_info_mapping = {:email => "screen_name"} - config.facebook.key = "726202304080642" - config.facebook.secret = "386a7b717d348af4120aeb1bb0ca3516" - config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook" + config.facebook.key = "257350517701074" + config.facebook.secret = "2f6ab1fd7eeff9aee73140991fc68314" + config.facebook.callback_url = "http://dev.bikebike.org/oauth/callback?provider=facebook" config.facebook.user_info_mapping = {:email => "email", :username => "username", :avatar => "picture/data/url"} config.facebook.scope = "email" config.facebook.display = "popup" diff --git a/config/locales/translations.yml b/config/locales/translations.yml new file mode 100644 index 0000000..f52465a --- /dev/null +++ b/config/locales/translations.yml @@ -0,0 +1,78 @@ +--- +nola_2013.about: + langauges: {} + pages: + - "/" +home.its_awesome: + langauges: {} + pages: + - "/" +Conferences: + langauges: {} + pages: + - "/" + - "/login" +Organizations: + langauges: {} + pages: + - "/" + - "/login" +Resources: + langauges: {} + pages: + - "/" + - "/login" +Sign_In: + langauges: {} + pages: + - "/" + - "/login" +missing.translation: + langauges: {} + pages: + - "/" + - "/login" +form.Enter_your_email: + langauges: {} + pages: + - "/login" +email: + langauges: {} + pages: + - "/login" +password: + langauges: {} + pages: + - "/login" +sign_in: + langauges: {} + pages: + - "/login" +facebook_sign_in: + langauges: {} + pages: + - "/login" +user.Create_Account: + langauges: {} + pages: + - "/login" +user.why_register: + langauges: {} + pages: + - "/login" +form.Enter_your_username: + langauges: {} + pages: + - "/login" +username: + langauges: {} + pages: + - "/login" +password_confirmation: + langauges: {} + pages: + - "/login" +register: + langauges: {} + pages: + - "/login" diff --git a/db/schema.rb b/db/schema.rb index ae14854..6d53cdb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -182,8 +182,8 @@ ActiveRecord::Schema.define(version: 20140315183241) do end create_table "user_organization_relationships", force: true do |t| - t.integer "user_id" - t.integer "organization_id" + t.integer "user_id", null: false + t.integer "organization_id", null: false t.string "relationship" t.datetime "created_at" t.datetime "updated_at" @@ -221,7 +221,7 @@ ActiveRecord::Schema.define(version: 20140315183241) do t.string "whodunnit" t.text "object" t.datetime "created_at" - t.string "value" + t.text "value" end create_table "workshop_facilitators", force: true do |t| diff --git a/lib/tasks/translations.rake b/lib/tasks/translations.rake new file mode 100644 index 0000000..8ac0a73 --- /dev/null +++ b/lib/tasks/translations.rake @@ -0,0 +1,14 @@ +namespace :translations do + desc "Migrates collected translations from the dev and testing environments" + task migrate: :environment do + #File.open('config/locales/.translations.yml', 'w') + #File.open('config/locales/.translation-cache.yml', 'w+') + + translations = YAML.load(File.read('config/locales/.translations.yml')) || Hash.new + translations.each { |k,t| + if t['data'] + t['data'].each { |tt| tt.save } + end + } + end +end diff --git a/nbproject/project.properties b/nbproject/project.properties index 8a59f1a..cee3f44 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,3 +1,3 @@ platform.active=Ruby -rails.port=3000 +rails.port=80 source.encoding=UTF-8 diff --git a/spec/features/pages/home_spec.rb b/spec/features/pages/home_spec.rb new file mode 100644 index 0000000..9b6c269 --- /dev/null +++ b/spec/features/pages/home_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe 'Home' do + it "has a title which is Bike!Bike!" do + visit root_path + expect(page).to have_link 'Bike!Bike!' + end + + it "has a link to login" do + visit root_path + expect(page).to have_link 'Sign In', :href => '/login' + end + + it "has a link to conferences" do + visit root_path + expect(find '.top-bar-section a[href$="/conferences"]').to have_text 'Conferences' + end + + it "has a link to organizations" do + visit root_path + expect(find '.top-bar-section a[href$="/organizations"]').to have_text 'Organizations' + end + + it "has a link to resources" do + visit root_path + expect(find '.top-bar-section a[href$="/resources"]').to have_text 'Resources' + end + +end diff --git a/spec/features/pages/login_spec.rb b/spec/features/pages/login_spec.rb new file mode 100644 index 0000000..7aaae1f --- /dev/null +++ b/spec/features/pages/login_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper' + +describe 'Login' do + + it "has a title which is Bike!Bike!" do + visit login_path + expect(page).to have_link 'Bike!Bike!' + end + + it "has a link to login" do + visit login_path + expect(page).to have_link 'Sign In', :href => '/login' + end + + it "has a link to conferences" do + visit login_path + expect(find '.top-bar-section a[href$="/conferences"]').to have_text 'Conferences' + end + + it "has a link to organizations" do + visit login_path + expect(find '.top-bar-section a[href$="/organizations"]').to have_text 'Organizations' + end + + it "has a link to resources" do + visit login_path + expect(find '.top-bar-section a[href$="/resources"]').to have_text 'Resources' + end + + it "has a login form" do + visit login_path + form = find 'form[action$="/user_sessions"]' + expect(form).to have_button 'sign in' + expect(form).to have_field 'email_' + expect(form).to have_field 'password' + expect(form).to have_link 'facebook' + end + + it "has a register form" do + visit login_path + form = find 'form[action$="/users"]' + expect(form).to have_button 'register' + expect(form).to have_field 'user_username' + expect(form).to have_field 'user_email' + expect(form).to have_field 'user_password' + expect(form).to have_field 'user_password_confirmation' + end + + it "allows you to register" do + visit login_path + fill_in "user_username", :with => "John" + fill_in "user_email", :with => "johnsemail@example.com" + fill_in "user_password", :with => "johnspassword" + fill_in "user_password_confirmation", :with => "johnspassword" + click_button "register" + end + + describe "can actually happen" do + + let(:user) { FactoryGirl.create(:user) } + + it "allows you to login" do + visit login_path + form = find 'form[action$="/user_sessions"]' + form.find("#email_").set(user.email) + form.find("#password").set('secret') + click_button "sign_in" + end + + end + +end diff --git a/spec/features/pages/organization_registration_spec.rb b/spec/features/pages/organization_registration_spec.rb new file mode 100644 index 0000000..0a46821 --- /dev/null +++ b/spec/features/pages/organization_registration_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe 'Organization Registration' do + + let(:user) { FactoryGirl.create(:user) } + + before(:each) do + visit login_path + form = find 'form[action$="/user_sessions"]' + form.find("#email_").set(user.email) + form.find("#password").set('secret') + click_button "sign_in" + visit new_organization_path + end + + it "works as expected" do + fill_in 'organization_name', :with => 'Bike Kitchen' + fill_in 'organization_slug', :with => 'bike-kitchen' + fill_in 'organization_email_address', :with => 'bikekitchen@example.com' + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3c4e392..ddd19f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,16 +1,6 @@ -if ENV['CI'] - require 'coveralls' - Coveralls.wear! 'rails' -end - -unless ENV['DRB'] - require 'simplecov' - SimpleCov.start 'rails' -end - # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' @@ -18,28 +8,51 @@ require 'rspec/autorun' # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } -require 'webmock/rspec' -require 'capybara/rspec' - -#Capybara.ignore_hidden_elements = false # testing hidden fields - -include Sorcery::TestHelpers::Rails +# Checks for pending migrations before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) RSpec.configure do |config| - # == Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr - # config.mock_with :rspec - - config.include AuthenticationForFeatureRequest, type: :feature - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = 'random' + # ## Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" + + config.before(:each) do + Translation.connection.execute("TRUNCATE TABLE translations RESTART IDENTITY;") + translations = DevTranslation.connection.select_all("SELECT * FROM translations") + + translations.each { |t| + Translation.connection.execute(" + INSERT INTO + translations + (id, locale, key, value, interpolations, is_proc, created_at, updated_at) + VALUES + (#{t['id']}, #{Translation.sanitize(t['locale'])}, #{Translation.sanitize(t['key'])}, #{Translation.sanitize(t['value'])}, #{Translation.sanitize(t['interpolations'])}, #{Translation.sanitize(t['is_proc'])}, #{Translation.sanitize(t['created_at'])}, #{Translation.sanitize(t['updated_at'])}) + ;") + } + end + end diff --git a/spec/support/authentication.rb b/spec/support/authentication.rb index deb7d9d..395d7c1 100644 --- a/spec/support/authentication.rb +++ b/spec/support/authentication.rb @@ -1,8 +1,8 @@ module AuthenticationForFeatureRequest - def login user, password = 'login' - user.update_attribute :password, password + def login user, password = 'login' + user.update_attribute :password, password - page.driver.post sessions_url, {email: user.email, password: password} - visit root_url - end -end \ No newline at end of file + page.driver.post sessions_url, {email: user.email, password: password} + visit root_url + end +end diff --git a/spec/support/delorean.rb b/spec/support/delorean.rb index 9ca9b40..7c8303b 100644 --- a/spec/support/delorean.rb +++ b/spec/support/delorean.rb @@ -1,7 +1,7 @@ RSpec.configure do |config| - config.include Delorean + config.include Delorean - config.before(:each) do - back_to_the_present - end + config.before(:each) do + back_to_the_present + end end diff --git a/test/factories/users.rb b/test/factories/users.rb index 26b30ef..5872d03 100644 --- a/test/factories/users.rb +++ b/test/factories/users.rb @@ -1,6 +1,13 @@ # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do - factory :user do - end + sequence(:email) { |n| "person-#{n}@example.com" } + sequence(:username) { |n| "person-#{n}" } + + factory :user, class: User do + username + email + password "secret" + password_confirmation "secret" + end end