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 0000000..abcbf60 Binary files /dev/null and b/Thumbs.db differ diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss index 62fc71b..b4137a4 100644 --- a/app/assets/stylesheets/foundation_and_overrides.scss +++ b/app/assets/stylesheets/foundation_and_overrides.scss @@ -91,36 +91,31 @@ $info-color: $color-3; // $shiny-edge-active-color: rgba(#000, .2); // Media Query Ranges -// $small-range: (0em, 40em); -// $medium-range: (40.063em, 64em); -// $large-range: (64.063em, 90em); -// $xlarge-range: (90.063em, 120em); -// $xxlarge-range: (120.063em); - -// $screen: "only screen"; - -// $landscape: "#{$screen} and (orientation: landscape)"; -// $portrait: "#{$screen} and (orientation: portrait)"; - -// $small-up: $screen; -// $small-only: "#{$screen} and (max-width: #{upper-bound($small-range)})"; - -// $medium-up: "#{$screen} and (min-width:#{lower-bound($medium-range)})"; -// $medium-only: "#{$screen} and (min-width:#{lower-bound($medium-range)}) and (max-width:#{upper-bound($medium-range)})"; - -// $large-up: "#{$screen} and (min-width:#{lower-bound($large-range)})"; -// $large-only: "#{$screen} and (min-width:#{lower-bound($large-range)}) and (max-width:#{upper-bound($large-range)})"; - -// $xlarge-up: "#{$screen} and (min-width:#{lower-bound($xlarge-range)})"; -// $xlarge-only: "#{$screen} and (min-width:#{lower-bound($xlarge-range)}) and (max-width:#{upper-bound($xlarge-range)})"; - -// $xxlarge-up: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)})"; -// $xxlarge-only: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)}) and (max-width:#{upper-bound($xxlarge-range)})"; +$small-range: (0em, 45em); +$medium-range: (45.063em, 64em); +$large-range: (64.063em, 90em); +$xlarge-range: (90.063em, 120em); +$xxlarge-range: (120.063em); + +$screen: "only screen"; + +$landscape: "#{$screen} and (orientation: landscape)"; +$portrait: "#{$screen} and (orientation: portrait)"; +$small-up: $screen; +$small-only: "#{$screen} and (max-width: #{upper-bound($small-range)})"; +$medium-up: "#{$screen} and (min-width:#{lower-bound($medium-range)})"; +$medium-only: "#{$screen} and (min-width:#{lower-bound($medium-range)}) and (max-width:#{upper-bound($medium-range)})"; +$large-up: "#{$screen} and (min-width:#{lower-bound($large-range)})"; +$large-only: "#{$screen} and (min-width:#{lower-bound($large-range)}) and (max-width:#{upper-bound($large-range)})"; +$xlarge-up: "#{$screen} and (min-width:#{lower-bound($xlarge-range)})"; +$xlarge-only: "#{$screen} and (min-width:#{lower-bound($xlarge-range)}) and (max-width:#{upper-bound($xlarge-range)})"; +$xxlarge-up: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)})"; +$xxlarge-only: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)}) and (max-width:#{upper-bound($xxlarge-range)})"; // Legacy -// $small: $medium-up; -// $medium: $medium-up; -// $large: $large-up; +$small: $medium-up; +$medium: $medium-up; +$large: $large-up; //We use this as cursors values for enabling the option of having custom cursors in the whole site's stylesheet // $cursor-crosshair-value: crosshair; @@ -1036,6 +1031,8 @@ $label-font-sizing: 1em;//rem-calc(11); // $include-html-top-bar-classes: false;//$include-html-classes; // Background color for the top bar +$topbar-arrows: false; + $topbar-bg-color: $black; $topbar-bg: transparent;//$black; @@ -1050,7 +1047,7 @@ $topbar-title-font-size: 2em; // Style the top bar dropdown elements $topbar-dropdown-bg: transparent; // $topbar-dropdown-link-color: #fff; -$topbar-dropdown-link-bg: transparent; +$topbar-dropdown-link-bg: $black; // $topbar-dropdown-link-weight: normal; // $topbar-dropdown-toggle-size: 5px; // $topbar-dropdown-toggle-color: #fff; @@ -1063,9 +1060,9 @@ $topbar-link-color-active: $white; // $topbar-link-weight: normal; // $topbar-link-font-size: rem-calc(13); // $topbar-link-hover-lightness: -10%; // Darken by 10% -$topbar-link-bg-hover: transparent; -$topbar-link-bg-active: transparent; -$topbar-link-bg-active-hover: transparent; // scale-color($primary-color, $lightness: -14%); +$topbar-link-bg-hover: lighten($black, 25); +$topbar-link-bg-active: $black; +$topbar-link-bg-active-hover: $topbar-link-bg-hover; // scale-color($primary-color, $lightness: -14%); $topbar-link-font-family: $header-font-family; // $topbar-button-font-size: 0.75rem; @@ -1088,7 +1085,7 @@ $topbar-menu-icon-color: $white; // Transitions and breakpoint styles // $topbar-transition-speed: 300ms; // Using rem-calc for the below breakpoint causes issues with top bar -// $topbar-breakpoint: #{upper-bound($medium-range)}; // Change to 9999px for always mobile layout +$topbar-breakpoint: #{upper-bound($small-range)}; // Change to 9999px for always mobile layout // $topbar-media-query: "only screen and (min-width: #{upper-bound($medium-range)})"; // Divider Styles diff --git a/app/assets/stylesheets/sass/_layout.scss b/app/assets/stylesheets/sass/_layout.scss index 00c5721..381026d 100644 --- a/app/assets/stylesheets/sass/_layout.scss +++ b/app/assets/stylesheets/sass/_layout.scss @@ -370,4 +370,12 @@ body.organizations-show { color: #FFF; background-color: rgba(#000, 0.5); } -} \ No newline at end of file +} + +.small-text-centered { + text-align: center; + + @media #{$medium-up} { + text-align: inherit; + } +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..4c6e18d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,11 @@ 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 + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception + + before_filter :capture_page_info + + def capture_page_info + $page_info = {:path => 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 += '' + (_ action.to_s) + '' + 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