From 06c6b0ce8963fdffbe89ef1079f94116e181d6b0 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 13 Mar 2015 20:12:42 -0500 Subject: [PATCH 01/33] Merge resolution --- Gemfile | 57 +---- Gemfile.lock | 201 ++++++--------- Rakefile | 3 +- app/{models/.gitkeep => assets/images/.keep} | 0 .../controllers/concerns/.keep | 0 log/.gitkeep => app/mailers/.keep | 0 test/functional/.gitkeep => app/models/.keep | 0 app/models/character.rb | 71 +----- .../.gitkeep => app/models/concerns/.keep | 0 app/models/equipment.rb | 28 +-- app/models/language.rb | 23 +- app/models/location.rb | 50 +--- app/models/magic.rb | 32 +-- app/models/session.rb | 7 +- app/models/universe.rb | 55 +--- app/models/user.rb | 62 +---- bin/bundle | 3 + bin/rails | 8 + bin/rake | 8 + bin/spring | 18 ++ config/application.rb | 52 +--- config/boot.rb | 4 +- config/database.yml | 25 ++ config/environment.rb | 6 +- config/environments/production.rb | 20 +- config/environments/test.rb | 4 +- config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + config/mongoid.yml | 18 -- config/secrets.yml | 22 ++ db/migrate/20140713043535_create_models.rb | 236 ++++++++++++++++++ db/schema.rb | 169 +++++++++++++ test/unit/.gitkeep => lib/assets/.keep | 0 .../javascripts/.gitkeep => lib/tasks/.keep | 0 lib/tasks/mongo.rake | 7 - .../assets/stylesheets/.gitkeep => log/.keep | 0 script/rails | 6 - .../.gitkeep => test/controllers/.keep | 0 test/factories/factories.rb | 23 -- test/fixtures/.keep | 0 test/fixtures/characters.yml | 2 + test/fixtures/equipment.yml | 2 + test/fixtures/languages.yml | 2 + test/fixtures/locations.yml | 2 + test/fixtures/magics.yml | 2 + test/fixtures/sessions.yml | 3 + test/fixtures/universes.yml | 2 + test/fixtures/users.yml | 4 + test/functional/characters_controller_test.rb | 67 ----- test/functional/generator_controller_test.rb | 7 - test/functional/main_controller_test.rb | 9 - test/functional/sessions_controller_test.rb | 33 --- test/functional/users_controller_test.rb | 4 - test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/{unit => models}/character_test.rb | 2 +- test/models/equipment_test.rb | 7 + test/models/language_test.rb | 7 + test/models/location_test.rb | 7 + test/models/magic_test.rb | 7 + test/{unit => models}/session_test.rb | 2 +- test/models/universe_test.rb | 7 + test/{unit => models}/user_test.rb | 2 +- test/test_helper.rb | 12 +- test/unit/helpers/characters_helper_test.rb | 4 - test/unit/helpers/generator_helper_test.rb | 4 - test/unit/helpers/main_helper_test.rb | 4 - test/unit/helpers/sessions_helper_test.rb | 4 - test/unit/helpers/users_helper_test.rb | 4 - vendor/assets/javascripts/.keep | 0 vendor/assets/stylesheets/.keep | 0 73 files changed, 685 insertions(+), 752 deletions(-) rename app/{models/.gitkeep => assets/images/.keep} (100%) rename lib/assets/.gitkeep => app/controllers/concerns/.keep (100%) rename log/.gitkeep => app/mailers/.keep (100%) rename test/functional/.gitkeep => app/models/.keep (100%) rename test/integration/.gitkeep => app/models/concerns/.keep (100%) create mode 100755 bin/bundle create mode 100755 bin/rails create mode 100755 bin/rake create mode 100755 bin/spring create mode 100644 config/database.yml create mode 100644 config/initializers/cookies_serializer.rb create mode 100644 config/initializers/filter_parameter_logging.rb delete mode 100644 config/mongoid.yml create mode 100644 config/secrets.yml create mode 100644 db/migrate/20140713043535_create_models.rb create mode 100644 db/schema.rb rename test/unit/.gitkeep => lib/assets/.keep (100%) rename vendor/assets/javascripts/.gitkeep => lib/tasks/.keep (100%) delete mode 100644 lib/tasks/mongo.rake rename vendor/assets/stylesheets/.gitkeep => log/.keep (100%) delete mode 100755 script/rails rename vendor/plugins/.gitkeep => test/controllers/.keep (100%) delete mode 100644 test/factories/factories.rb create mode 100644 test/fixtures/.keep create mode 100644 test/fixtures/characters.yml create mode 100644 test/fixtures/equipment.yml create mode 100644 test/fixtures/languages.yml create mode 100644 test/fixtures/locations.yml create mode 100644 test/fixtures/magics.yml create mode 100644 test/fixtures/sessions.yml create mode 100644 test/fixtures/universes.yml create mode 100644 test/fixtures/users.yml delete mode 100644 test/functional/characters_controller_test.rb delete mode 100644 test/functional/generator_controller_test.rb delete mode 100644 test/functional/main_controller_test.rb delete mode 100644 test/functional/sessions_controller_test.rb delete mode 100644 test/functional/users_controller_test.rb create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep rename test/{unit => models}/character_test.rb (58%) create mode 100644 test/models/equipment_test.rb create mode 100644 test/models/language_test.rb create mode 100644 test/models/location_test.rb create mode 100644 test/models/magic_test.rb rename test/{unit => models}/session_test.rb (59%) create mode 100644 test/models/universe_test.rb rename test/{unit => models}/user_test.rb (59%) delete mode 100644 test/unit/helpers/characters_helper_test.rb delete mode 100644 test/unit/helpers/generator_helper_test.rb delete mode 100644 test/unit/helpers/main_helper_test.rb delete mode 100644 test/unit/helpers/sessions_helper_test.rb delete mode 100644 test/unit/helpers/users_helper_test.rb create mode 100644 vendor/assets/javascripts/.keep create mode 100644 vendor/assets/stylesheets/.keep diff --git a/Gemfile b/Gemfile index afa2f701..7c7e8090 100644 --- a/Gemfile +++ b/Gemfile @@ -1,53 +1,16 @@ source 'https://rubygems.org' -ruby '2.0.0' -gem 'rails', '3.2.13' - -# Mongo stuff -gem 'bson_ext', '1.6.0' -gem 'mongo', '1.6.0' -gem 'mongoid' - -# File uploads -gem 'mongoid-paperclip', :require => "mongoid_paperclip" -gem 'aws-sdk', '~> 1.3.4' +gem 'rails', '4.1.0' +gem 'sqlite3' +gem 'paperclip', '~> 4.2.0' gem 'rmagick' -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'less-rails' - #gem 'less-rails-fontawesome' - gem 'coffee-rails', '~> 3.2.1' - - #gem 'bootplus-rails' - #gem 'twitter-bootstrap-rails' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', '~> 0.12.1', :platform => :ruby - - gem 'uglifier', '>= 1.0.3' -end - -group :test do - gem 'factory_girl_rails' - gem 'database_cleaner' -end +gem 'sass-rails', '~> 4.0.3' +gem 'less-rails' +gem 'less-rails-fontawesome' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'therubyracer', platforms: :ruby +gem 'bootplus-rails' gem 'jquery-rails' - -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# To use Jbuilder templates for JSON -# gem 'jbuilder' - -# Use unicorn as the app server -# gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/Gemfile.lock b/Gemfile.lock index cecf9b7f..b229183f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,70 +1,52 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.13) - actionpack (= 3.2.13) - mail (~> 2.5.3) - actionpack (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - builder (~> 3.0.0) + actionmailer (4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + mail (~> 2.5.4) + actionpack (4.1.0) + actionview (= 4.1.0) + activesupport (= 4.1.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.13) - activesupport (= 3.2.13) - builder (~> 3.0.0) - activerecord (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - activesupport (3.2.13) - i18n (= 0.6.1) - multi_json (~> 1.0) - arel (3.0.3) - aws-sdk (1.3.9) - httparty (~> 0.7) - json (~> 1.4) - nokogiri (>= 1.4.4) - uuidtools (~> 2.1) - bson (1.6.0) - bson_ext (1.6.0) - bson (= 1.6.0) - builder (3.0.4) + activemodel (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) + activerecord (4.1.0) + activemodel (= 4.1.0) + activesupport (= 4.1.0) + arel (~> 5.0.0) + activesupport (4.1.0) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.1.20140414130214) + bootplus-rails (1.0.0) + builder (3.2.2) climate_control (0.0.3) activesupport (>= 3.0) - cocaine (0.5.3) + cocaine (0.5.4) climate_control (>= 0.0.3, < 1.0) - coffee-rails (3.2.2) + coffee-rails (4.0.1) coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.6.3) + coffee-script-source (1.7.1) commonjs (0.2.7) - database_cleaner (1.2.0) erubis (2.7.0) - execjs (2.0.2) - factory_girl (4.4.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.4.1) - factory_girl (~> 4.4.0) - railties (>= 3.0.0) + execjs (2.2.1) hike (1.2.3) - httparty (0.13.0) - json (~> 1.8) - multi_xml (>= 0.5.2) - i18n (0.6.1) - journey (1.0.4) - jquery-rails (3.1.0) + i18n (0.6.11) + jquery-rails (3.1.1) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) @@ -78,98 +60,79 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) - mini_portile (0.5.2) - mongo (1.6.0) - bson (= 1.6.0) - mongoid (3.1.6) - activemodel (~> 3.2) - moped (~> 1.4) - origin (~> 1.0) - tzinfo (~> 0.3.29) - mongoid-paperclip (0.0.9) - paperclip (>= 2.3.6) - moped (1.5.2) - multi_json (1.9.0) - multi_xml (0.5.5) - nokogiri (1.6.1) - mini_portile (~> 0.5.0) - nokogiri (1.6.1-x86-mingw32) - mini_portile (~> 0.5.0) - origin (1.1.0) - paperclip (4.1.1) + minitest (5.4.0) + multi_json (1.10.1) + paperclip (4.2.0) activemodel (>= 3.0.0) activesupport (>= 3.0.0) cocaine (~> 0.5.3) mime-types - polyglot (0.3.4) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.3) - rack + polyglot (0.3.5) + rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (3.2.13) - actionmailer (= 3.2.13) - actionpack (= 3.2.13) - activerecord (= 3.2.13) - activeresource (= 3.2.13) - activesupport (= 3.2.13) - bundler (~> 1.0) - railties (= 3.2.13) - railties (3.2.13) - actionpack (= 3.2.13) - activesupport (= 3.2.13) - rack-ssl (~> 1.3.2) + rails (4.1.0) + actionmailer (= 4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + activemodel (= 4.1.0) + activerecord (= 4.1.0) + activesupport (= 4.1.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.0) + sprockets-rails (~> 2.0) + railties (4.1.0) + actionpack (= 4.1.0) + activesupport (= 4.1.0) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.1.1) - rdoc (3.12.2) - json (~> 1.4) + thor (>= 0.18.1, < 2.0) + rake (10.3.2) ref (1.0.5) rmagick (2.13.2) - sass (3.3.3) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - sprockets (2.2.2) + sass (3.2.19) + sass-rails (4.0.3) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.0) + sprockets (~> 2.8, <= 2.11.0) + sprockets-rails (~> 2.0) + sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.1.3) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + sqlite3 (1.3.9) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref - thor (0.18.1) + thor (0.19.1) + thread_safe (0.3.4) tilt (1.4.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.39) - uglifier (2.5.0) + tzinfo (1.2.1) + thread_safe (~> 0.1) + uglifier (2.5.1) execjs (>= 0.3.0) json (>= 1.8.0) - uuidtools (2.1.4) PLATFORMS ruby - x86-mingw32 DEPENDENCIES - aws-sdk (~> 1.3.4) - bson_ext (= 1.6.0) - coffee-rails (~> 3.2.1) - database_cleaner - factory_girl_rails + bootplus-rails + coffee-rails (~> 4.0.0) jquery-rails less-rails - mongo (= 1.6.0) - mongoid - mongoid-paperclip - rails (= 3.2.13) + less-rails-fontawesome + paperclip (~> 4.2.0) + rails (= 4.1.0) rmagick - sass-rails (~> 3.2.3) - therubyracer (~> 0.12.1) - uglifier (>= 1.0.3) + sass-rails (~> 4.0.3) + sqlite3 + therubyracer + uglifier (>= 1.3.0) \ No newline at end of file diff --git a/Rakefile b/Rakefile index 659f1981..ba6b733d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,6 @@ -#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) -PlanCharacters::Application.load_tasks +Rails.application.load_tasks diff --git a/app/models/.gitkeep b/app/assets/images/.keep similarity index 100% rename from app/models/.gitkeep rename to app/assets/images/.keep diff --git a/lib/assets/.gitkeep b/app/controllers/concerns/.keep similarity index 100% rename from lib/assets/.gitkeep rename to app/controllers/concerns/.keep diff --git a/log/.gitkeep b/app/mailers/.keep similarity index 100% rename from log/.gitkeep rename to app/mailers/.keep diff --git a/test/functional/.gitkeep b/app/models/.keep similarity index 100% rename from test/functional/.gitkeep rename to app/models/.keep diff --git a/app/models/character.rb b/app/models/character.rb index 69ed96aa..9d52c188 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,71 +1,2 @@ -class Character - include Mongoid::Document - - # General - field :name, :type => String - field :role, :type => String - field :gender, :type => String - field :age, :type => String - - # Appearance - field :height, :type => String - field :weight, :type => String - field :haircolor, :type => String - field :hairstyle, :type => String - field :facialhair, :type => String - field :eyecolor, :type => String - field :race, :type => String - field :skintone, :type => String - field :bodytype, :type => String - field :identmarks, :type => String # Identifying marks - - # Social - field :bestfriend, :type => String - field :religion, :type => String - field :politics, :type => String - field :prejudices, :type => String - field :occupation, :type => String - field :pets, :type => String - #How might others describe him? - #What would others change about him? - - # Behavior - field :mannerisms, :type => String - #What drives this character? - #What is standing in his way? - #What is he most afraid of? - #What does he need most? - #What makes him vulnerable? - #What kind of trouble does he get in? - - # History - field :birthday, :type => String - field :birthplace, :type => String - field :education, :type => String - field :background, :type => String - #What is his deepest secret? - #Does he have a history of criminal activity? - - # Favorites - field :fave_color, :type => String - field :fave_food, :type => String - field :fave_possession, :type => String - field :fave_weapon, :type => String - field :fave_animal, :type => String - #favorite leisure activities - - # Relationships - field :father, :type => String - field :mother, :type => String - field :spouse, :type => String - field :siblings, :type => String - field :archenemy, :type => String - - # Notes - field :notes, :type => String - field :private_notes, :type => String - #additional fields - - belongs_to :user - belongs_to :universe +class Character < ActiveRecord::Base end diff --git a/test/integration/.gitkeep b/app/models/concerns/.keep similarity index 100% rename from test/integration/.gitkeep rename to app/models/concerns/.keep diff --git a/app/models/equipment.rb b/app/models/equipment.rb index f503869c..0cd8d98b 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -1,28 +1,2 @@ -class Equipment - include Mongoid::Document - - # General - field :name, :type => String - field :equip_type, :type => String - - # Appearance - field :description, :type => String - field :weight, :type => String - - # History - field :original_owner, :type => String - field :current_owner, :type => String - field :made_by, :type => String - field :materials, :type => String - field :year_made, :type => String - - # Abilities - field :magic, :type => String # Magical Properties - - # Notes - field :notes, :type => String - field :private_notes, :type => String - - belongs_to :user - belongs_to :universe +class Equipment < ActiveRecord::Base end diff --git a/app/models/language.rb b/app/models/language.rb index 447df506..addcdda6 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,23 +1,2 @@ -class Language - include Mongoid::Document - - # General - field :name, :type => String - - # Vocabulary - field :words, :type => String - - # History - field :established_year, :type => String - field :established_location, :type => String - - # Speakers - field :characters, :type => String - field :locations, :type => String - - # More - field :notes, :type => String - - belongs_to :user - belongs_to :universe +class Language < ActiveRecord::Base end diff --git a/app/models/location.rb b/app/models/location.rb index 34ab75da..e3acd900 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,50 +1,2 @@ -class Location - include Mongoid::Document - include Mongoid::Paperclip - - # General - field :name, :type => String - field :type_of, :type => String - field :description, :type => String - - # Map - has_mongoid_attached_file :map, - styles: { -# original: '1920x1680>', -# thumb: '200x200>', -# todo -# make banner for cards -# resize full-size for large-cards -# make thumbnail for small-cards - }, - default_url: '/assets/placeholders/map.png' - - # Culture - field :population, :type => String - field :language, :type => String - field :currency, :type => String - field :motto, :type => String - #field :flag, :type => Image - #field :seal, :type => Image - - # Cities - field :capital, :type => String - field :largest_city, :type => String - field :notable_cities, :type => String - - # Geography - field :area, :type => String - field :crops, :type => String - field :located_at, :type => String - - # History - field :established_year, :type => String - field :notable_wars, :type => String - - # Notes - field :notes, :type => String - field :private_notes, :type => String - - belongs_to :user - belongs_to :universe +class Location < ActiveRecord::Base end diff --git a/app/models/magic.rb b/app/models/magic.rb index e7ae7a56..2ab3d408 100644 --- a/app/models/magic.rb +++ b/app/models/magic.rb @@ -1,32 +1,2 @@ -class Magic - include Mongoid::Document - - # General - field :name, :type => String - field :type_of, :type => String # "Type of": Spell, Ability, Enchantment, etc - - # Appearance - field :manifestation, :type => String - field :symptoms, :type => String - - # Alignment - field :element, :type => String - field :diety, :type => String - - # Effects - field :harmfulness, :type => String # Harmful effects - field :helpfulness, :type => String # Helpful effects - field :neutralness, :type => String # Neutral effects - - # Requirements - field :resource, :type => String # Resource required - field :skill_level, :type => String # Skill required - field :limitations, :type => String - - # Notes - field :notes, :type => String - field :private_notes, :type => String - - belongs_to :user - belongs_to :universe +class Magic < ActiveRecord::Base end diff --git a/app/models/session.rb b/app/models/session.rb index 2cf4aaf2..54fee45a 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -1,7 +1,2 @@ -class Session - include Mongoid::Document - field :username, :type => String - field :password, :type => String - - validates_presence_of :username, :password +class Session < ActiveRecord::Base end diff --git a/app/models/universe.rb b/app/models/universe.rb index 7c914e20..47c1fe6a 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -1,55 +1,2 @@ -class Universe - include Mongoid::Document - - # General - field :name, :type => String - field :description, :type => String - - # History - field :history, :type => String - - # More... - field :notes, :type => String - field :private_notes, :type => String - - # Settings - field :privacy, :type => String # Whether or not this universe is public, options are 'private' or 'public' - - belongs_to :user - - def content_count - [ - characters.length, - equipment.length, - languages.length, - locations.length, - magics.length, - ].sum - end - - def characters - Character.where(universe_id: id) - end - - def equipment - Equipment.where(universe_id: id) - end - - def languages - Language.where(universe_id: id) - end - - def locations - Location.where(universe_id: id) - end - - def magics - Magic.where(universe_id: id) - end - - - def to_s - self.name - end - +class Universe < ActiveRecord::Base end diff --git a/app/models/user.rb b/app/models/user.rb index 57842360..4a57cf07 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,62 +1,2 @@ -class User - include Mongoid::Document - field :name, :type => String - field :email, :type => String - field :password, :type => String - - validates_presence_of :name, :email, :password - validates_uniqueness_of :name, :email - - before_save :hash_password - def hash_password - require 'digest' - self.password = Digest::MD5.hexdigest(self.name + "'s password IS... " + self.password + " (lol!)") - end - - def content - { - :characters => characters, - :equipment => equipment, - :languages => languages, - :locations => locations, - :magics => magics, - :universes => universes - } - end - - def content_count - [ - characters.length, - equipment.length, - languages.length, - locations.length, - magics.length, - universes.length - ].sum - end - - def characters - Character.where(user_id: id) - end - - def equipment - Equipment.where(user_id: id) - end - - def languages - Language.where(user_id: id) - end - - def locations - Location.where(user_id: id) - end - - def magics - Magic.where(user_id: id) - end - - def universes - Universe.where(user_id: id) - end - +class User < ActiveRecord::Base end diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 00000000..66e9889e --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 00000000..7feb6a30 --- /dev/null +++ b/bin/rails @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 00000000..8017a027 --- /dev/null +++ b/bin/rake @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/spring b/bin/spring new file mode 100755 index 00000000..253ec37c --- /dev/null +++ b/bin/spring @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast +# It gets overwritten when you run the `spring binstub` command + +unless defined?(Spring) + require "rubygems" + require "bundler" + + if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) + ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) + ENV["GEM_HOME"] = "" + Gem.paths = ENV + + gem "spring", match[1] + require "spring/binstub" + end +end diff --git a/config/application.rb b/config/application.rb index 981ae916..42446113 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,38 +1,17 @@ require File.expand_path('../boot', __FILE__) -# Pick the frameworks you want: -# require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -require "active_resource/railtie" -require "sprockets/railtie" -require "rails/test_unit/railtie" +require 'rails/all' -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) module PlanCharacters class Application < Rails::Application - Mongoid.load!("config/mongoid.yml") - # 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. - # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - # 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)' @@ -40,28 +19,5 @@ module PlanCharacters # 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 = :de - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - - # Use SQL instead of Active Record's schema dumper when creating the database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true - - # Enable the asset pipeline - config.assets.enabled = true - - # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.0' end end diff --git a/config/boot.rb b/config/boot.rb index 4489e586..5e5f0c1f 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,4 @@ -require 'rubygems' - # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 00000000..1c1a37ca --- /dev/null +++ b/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/config/environment.rb b/config/environment.rb index 1edd35da..ee8d90dc 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application +# Load the Rails application. require File.expand_path('../application', __FILE__) -# Initialize the rails application -PlanCharacters::Application.initialize! +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/production.rb b/config/environments/production.rb index 14873536..d2e49ed6 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,5 +1,5 @@ -PlanCharacters::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests config.cache_classes = true @@ -11,8 +11,9 @@ PlanCharacters::Application.configure do # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static_assets = false - # Compress JavaScripts and CSS - config.assets.compress = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = true @@ -20,8 +21,8 @@ PlanCharacters::Application.configure do # Generate digests for assets URLs config.assets.digest = true - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache @@ -30,8 +31,8 @@ PlanCharacters::Application.configure do # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # See everything in the log (default is :info) - # config.log_level = :debug + # Set to :debug to see everything in the log. + config.log_level = :info # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] @@ -74,3 +75,6 @@ PlanCharacters::Application.configure do end + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb index 4d7c9d33..10109e20 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,5 @@ -PlanCharacters::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..7a06a89f --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/mongoid.yml b/config/mongoid.yml deleted file mode 100644 index e9c31c2e..00000000 --- a/config/mongoid.yml +++ /dev/null @@ -1,18 +0,0 @@ -development: - sessions: - default: - database: plan_characters_dev - hosts: - - localhost:27017 - -test: - sessions: - default: - database: myapp_test - hosts: - - localhost:27017 - -production: - sessions: - default: - uri: <%= ENV['MONGOHQ_URL'] %> diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 00000000..c2f2dfba --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: d522bcefa477c6fbfe9b6c69f25a41f242e26cfd281dcfbb6c867e41e3b56c1c9ac6007737742b70b55a66207b2284f129734345707507c7b0d34fb45218005c + +test: + secret_key_base: ecaa93d4fba650ef30ef4925df71b8e9e8bdb47f0424166a2689950e268a1d27227a27f72f8f790f4272c2ef5ad06e86d05dad20eecd8df6c47ab12bed37c27a + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/db/migrate/20140713043535_create_models.rb b/db/migrate/20140713043535_create_models.rb new file mode 100644 index 00000000..e6bf2526 --- /dev/null +++ b/db/migrate/20140713043535_create_models.rb @@ -0,0 +1,236 @@ +class CreateModels < ActiveRecord::Migration + def change + create_table :characters do |t| + t.string :name, :null => false + t.string :role + t.string :gender + t.string :age + + # Appearance + t.string :height + t.string :weight + t.string :haircolor + t.string :hairstyle + t.string :facialhair + t.string :eyecolor + t.string :race + t.string :skintone + t.string :bodytype + t.string :identmarks # Identifying marks + + # Social + t.text :bestfriend + t.text :religion + t.text :politics + t.text :prejudices + t.text :occupation + t.text :pets + #How might others describe him? + #What would others change about him? + + # Behavior + t.text :mannerisms + #What drives this character? + #What is standing in his way? + #What is he most afraid of? + #What does he need most? + #What makes him vulnerable? + #What kind of trouble does he get in? + + # History + t.text :birthday + t.text :birthplace + t.text :education + t.text :background + #What is his deepest secret? + #Does he have a history of criminal activity? + + # Favorites + t.string :fave_color + t.string :fave_food + t.string :fave_possession + t.string :fave_weapon + t.string :fave_animal + #favorite leisure activities + + # Relationships + t.text :father + t.text :mother + t.text :spouse + t.text :siblings + t.text :archenemy + + # Notes + t.text :notes + t.text :private_notes + + t.belongs_to :user + t.belongs_to :universe + + t.timestamps + end + + create_table :equipment do |t| + # General + t.string :name, :null => false + t.string :equip_type + + # Appearance + t.text :description + t.string :weight + + # History + t.string :original_owner + t.string :current_owner + t.text :made_by + t.text :materials + t.string :year_made + + # Abilities + t.text :magic # Magical Properties + + # Notes + t.text :notes + t.text :private_notes + + t.belongs_to :user + t.belongs_to :universe + + t.timestamps + end + + create_table :languages do |t| + # General + t.string :name, :null => false + + # Vocabulary + t.text :words + + # History + t.string :established_year + t.string :established_location + + # Speakers + t.text :characters + t.text :locations + + # More + t.text :notes + + t.belongs_to :user + t.belongs_to :universe + + t.timestamps + end + + create_table :locations do |t| + # General + t.string :name, :null => false + t.string :type_of + t.text :description + + # Map + t.attachment :map + + # Culture + t.string :population + t.string :language + t.string :currency + t.string :motto + #field :flag, :type => Image + #field :seal, :type => Image + + # Cities + t.text :capital + t.text :largest_city + t.text :notable_cities + + # Geography + t.text :area + t.text :crops + t.text :located_at + + # History + t.string :established_year + t.text :notable_wars + + # Notes + t.text :notes + t.text :private_notes + + t.belongs_to :user + t.belongs_to :universe + + t.timestamps + end + + create_table :magics do |t| + # General + t.string :name, :null => false + t.string :type_of # "Type of": Spell, Ability, Enchantment, etc + + # Appearance + t.text :manifestation + t.text :symptoms + + # Alignment + t.string :element + t.string :diety + + # Effects + t.text :harmfulness # Harmful effects + t.text :helpfulness # Helpful effects + t.text :neutralness # Neutral effects + + # Requirements + t.text :resource # Resource required + t.text :skill_level # Skill required + t.text :limitations + + # Notes + t.text :notes + t.text :private_notes + + t.belongs_to :user + t.belongs_to :universe + + t.timestamps + end + + create_table :sessions do |t| + + t.string :username, :unique => true, :null => false + t.string :password, :null => false + + t.timestamps + end + + create_table :universes do |t| + # General + t.string :name, :null => false + t.text :description + + # History + t.text :history + + # More... + t.text :notes + t.text :private_notes + + # Settings + t.string :privacy # 'private' or 'public' + + t.belongs_to :user + + t.timestamps + end + + create_table :users do |t| + t.string :name, :unique => true, :null => false + t.string :email, :unique => true, :null => false + t.string :password, :null => false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..76293d63 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,169 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20140713043535) do + + create_table "characters", force: true do |t| + t.string "name", null: false + t.string "role" + t.string "gender" + t.string "age" + t.string "height" + t.string "weight" + t.string "haircolor" + t.string "hairstyle" + t.string "facialhair" + t.string "eyecolor" + t.string "race" + t.string "skintone" + t.string "bodytype" + t.string "identmarks" + t.text "bestfriend" + t.text "religion" + t.text "politics" + t.text "prejudices" + t.text "occupation" + t.text "pets" + t.text "mannerisms" + t.text "birthday" + t.text "birthplace" + t.text "education" + t.text "background" + t.string "fave_color" + t.string "fave_food" + t.string "fave_possession" + t.string "fave_weapon" + t.string "fave_animal" + t.text "father" + t.text "mother" + t.text "spouse" + t.text "siblings" + t.text "archenemy" + t.text "notes" + t.text "private_notes" + t.integer "user_id" + t.integer "universe_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "equipment", force: true do |t| + t.string "name", null: false + t.string "equip_type" + t.text "description" + t.string "weight" + t.string "original_owner" + t.string "current_owner" + t.text "made_by" + t.text "materials" + t.string "year_made" + t.text "magic" + t.text "notes" + t.text "private_notes" + t.integer "user_id" + t.integer "universe_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "languages", force: true do |t| + t.string "name", null: false + t.text "words" + t.string "established_year" + t.string "established_location" + t.text "characters" + t.text "locations" + t.text "notes" + t.integer "user_id" + t.integer "universe_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "locations", force: true do |t| + t.string "name", null: false + t.string "type_of" + t.text "description" + t.string "map_file_name" + t.string "map_content_type" + t.integer "map_file_size" + t.datetime "map_updated_at" + t.string "population" + t.string "language" + t.string "currency" + t.string "motto" + t.text "capital" + t.text "largest_city" + t.text "notable_cities" + t.text "area" + t.text "crops" + t.text "located_at" + t.string "established_year" + t.text "notable_wars" + t.text "notes" + t.text "private_notes" + t.integer "user_id" + t.integer "universe_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "magics", force: true do |t| + t.string "name", null: false + t.string "type_of" + t.text "manifestation" + t.text "symptoms" + t.string "element" + t.string "diety" + t.text "harmfulness" + t.text "helpfulness" + t.text "neutralness" + t.text "resource" + t.text "skill_level" + t.text "limitations" + t.text "notes" + t.text "private_notes" + t.integer "user_id" + t.integer "universe_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "sessions", force: true do |t| + t.string "username", null: false + t.string "password", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "universes", force: true do |t| + t.string "name", null: false + t.text "description" + t.text "history" + t.text "notes" + t.text "private_notes" + t.string "privacy" + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "users", force: true do |t| + t.string "name", null: false + t.string "email", null: false + t.string "password", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/test/unit/.gitkeep b/lib/assets/.keep similarity index 100% rename from test/unit/.gitkeep rename to lib/assets/.keep diff --git a/vendor/assets/javascripts/.gitkeep b/lib/tasks/.keep similarity index 100% rename from vendor/assets/javascripts/.gitkeep rename to lib/tasks/.keep diff --git a/lib/tasks/mongo.rake b/lib/tasks/mongo.rake deleted file mode 100644 index a9e8b52e..00000000 --- a/lib/tasks/mongo.rake +++ /dev/null @@ -1,7 +0,0 @@ -namespace :db do - namespace :test do - task :prepare do - # Stub out for MongoDB - end - end -end diff --git a/vendor/assets/stylesheets/.gitkeep b/log/.keep similarity index 100% rename from vendor/assets/stylesheets/.gitkeep rename to log/.keep diff --git a/script/rails b/script/rails deleted file mode 100755 index f8da2cff..00000000 --- a/script/rails +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands' diff --git a/vendor/plugins/.gitkeep b/test/controllers/.keep similarity index 100% rename from vendor/plugins/.gitkeep rename to test/controllers/.keep diff --git a/test/factories/factories.rb b/test/factories/factories.rb deleted file mode 100644 index bfab37e8..00000000 --- a/test/factories/factories.rb +++ /dev/null @@ -1,23 +0,0 @@ -FactoryGirl.define do - factory :user do - sequence(:name) {|n| "testuser#{n}" } - sequence(:email) {|n| "testemail#{n}" } - password "userpassword" - end - - factory :universe do - name "Test universe" - end - - factory :character do - name "MyString" - age "MyString" - end - - factory :session do - username "MyString" - password "MyString" - end - - -end diff --git a/test/fixtures/.keep b/test/fixtures/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/fixtures/characters.yml b/test/fixtures/characters.yml new file mode 100644 index 00000000..f227f68d --- /dev/null +++ b/test/fixtures/characters.yml @@ -0,0 +1,2 @@ +one: + name: Test diff --git a/test/fixtures/equipment.yml b/test/fixtures/equipment.yml new file mode 100644 index 00000000..f227f68d --- /dev/null +++ b/test/fixtures/equipment.yml @@ -0,0 +1,2 @@ +one: + name: Test diff --git a/test/fixtures/languages.yml b/test/fixtures/languages.yml new file mode 100644 index 00000000..f227f68d --- /dev/null +++ b/test/fixtures/languages.yml @@ -0,0 +1,2 @@ +one: + name: Test diff --git a/test/fixtures/locations.yml b/test/fixtures/locations.yml new file mode 100644 index 00000000..f227f68d --- /dev/null +++ b/test/fixtures/locations.yml @@ -0,0 +1,2 @@ +one: + name: Test diff --git a/test/fixtures/magics.yml b/test/fixtures/magics.yml new file mode 100644 index 00000000..f227f68d --- /dev/null +++ b/test/fixtures/magics.yml @@ -0,0 +1,2 @@ +one: + name: Test diff --git a/test/fixtures/sessions.yml b/test/fixtures/sessions.yml new file mode 100644 index 00000000..72e00171 --- /dev/null +++ b/test/fixtures/sessions.yml @@ -0,0 +1,3 @@ +one: + username: Test + password: Test \ No newline at end of file diff --git a/test/fixtures/universes.yml b/test/fixtures/universes.yml new file mode 100644 index 00000000..f227f68d --- /dev/null +++ b/test/fixtures/universes.yml @@ -0,0 +1,2 @@ +one: + name: Test diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 00000000..5f9df600 --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,4 @@ +one: + name: Test + email: Test + password: Test diff --git a/test/functional/characters_controller_test.rb b/test/functional/characters_controller_test.rb deleted file mode 100644 index fb8405ae..00000000 --- a/test/functional/characters_controller_test.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'test_helper' - -class CharactersControllerTest < ActionController::TestCase - setup do - @user = create(:user) - @session = create(:session) - @universe = create(:universe) - @character = build(:character, user: @user) - end - - teardown do - DatabaseCleaner.clean - end - - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:characters) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create character" do - assert_difference('Character.count') do - post :create, character: { age: @character.age, name: @character.name, universe: @universe} - end - - assert_redirected_to character_path(assigns(:character)) - end - - test "should show character" do - @character.save - get :show, id: @character - assert_response :success - end - - test "should get edit" do - @character.save - get :edit, id: @character - assert_response 302 - assert_redirected_to character_edit_path(@character) - end - - test "should update character" do - @character.save - put :update, id: @character, character: { age: @character.age, name: @character.name, universe: @universe } - - assert_response 302 - assert_redirected_to character_path(@character) - end - - test "should destroy character" do - @character.save - - assert_difference('Character.count', -1) do - delete :destroy, id: @character - end - - get :show, id: @character - assert_response 404 - - assert_redirected_to characters_path - end -end diff --git a/test/functional/generator_controller_test.rb b/test/functional/generator_controller_test.rb deleted file mode 100644 index 79831d68..00000000 --- a/test/functional/generator_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class GeneratorControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/functional/main_controller_test.rb b/test/functional/main_controller_test.rb deleted file mode 100644 index ce24b34c..00000000 --- a/test/functional/main_controller_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' - -class MainControllerTest < ActionController::TestCase - test "should get index" do - get :index - assert_response :success - end - -end diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb deleted file mode 100644 index 6fe60f8a..00000000 --- a/test/functional/sessions_controller_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'test_helper' - -class SessionsControllerTest < ActionController::TestCase - setup do - @session = build(:session) - end - - teardown do - DatabaseCleaner.clean - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create session" do - assert_difference('Session.count') do - post :create, session: { password: @session.password, username: @session.username } - end - - assert_redirected_to session_path(assigns(:session)) - end - - test "should destroy session" do - @session.save - assert_difference('Session.count', -1) do - delete :destroy, id: @session - end - - assert_redirected_to sessions_path - end -end diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb deleted file mode 100644 index c67c56b5..00000000 --- a/test/functional/users_controller_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class UsersControllerTest < ActionController::TestCase -end diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/unit/character_test.rb b/test/models/character_test.rb similarity index 58% rename from test/unit/character_test.rb rename to test/models/character_test.rb index bb4ff173..6749ea6d 100644 --- a/test/unit/character_test.rb +++ b/test/models/character_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class CharacterTest < ActiveSupport::TestCase test "character exists" do - assert_not_nil build(:character), "Characters factory is returning nil" + assert_not_nil characters(:one) end end diff --git a/test/models/equipment_test.rb b/test/models/equipment_test.rb new file mode 100644 index 00000000..e4f5a89f --- /dev/null +++ b/test/models/equipment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class EquipmentTest < ActiveSupport::TestCase + test "equipement exists" do + assert_not_nil equipment(:one) + end +end diff --git a/test/models/language_test.rb b/test/models/language_test.rb new file mode 100644 index 00000000..d9cd552c --- /dev/null +++ b/test/models/language_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LanguageTest < ActiveSupport::TestCase + test "language exists" do + assert_not_nil languages(:one) + end +end diff --git a/test/models/location_test.rb b/test/models/location_test.rb new file mode 100644 index 00000000..16d8b64f --- /dev/null +++ b/test/models/location_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LocationTest < ActiveSupport::TestCase + test "location exists" do + assert_not_nil locations(:one) + end +end diff --git a/test/models/magic_test.rb b/test/models/magic_test.rb new file mode 100644 index 00000000..33f334e6 --- /dev/null +++ b/test/models/magic_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MagicTest < ActiveSupport::TestCase + test "magic exists" do + assert_not_nil magics(:one) + end +end diff --git a/test/unit/session_test.rb b/test/models/session_test.rb similarity index 59% rename from test/unit/session_test.rb rename to test/models/session_test.rb index 843028c8..59595f13 100644 --- a/test/unit/session_test.rb +++ b/test/models/session_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class SessionTest < ActiveSupport::TestCase test "session exists" do - assert_not_nil build(:session), "Sessions factory is returning nil" + assert_not_nil sessions(:one) end end diff --git a/test/models/universe_test.rb b/test/models/universe_test.rb new file mode 100644 index 00000000..7661765f --- /dev/null +++ b/test/models/universe_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UniverseTest < ActiveSupport::TestCase + test "universe exists" do + assert_not_nil universes(:one) + end +end diff --git a/test/unit/user_test.rb b/test/models/user_test.rb similarity index 59% rename from test/unit/user_test.rb rename to test/models/user_test.rb index ff561469..385ebdcb 100644 --- a/test/unit/user_test.rb +++ b/test/models/user_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase test "user exists" do - assert_not_nil build(:user), "Users factory is returning nil" + assert_not_nil users(:one) end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 9265dbf9..bf95f818 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,13 @@ -ENV["RAILS_ENV"] = "test" +ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase - include FactoryGirl::Syntax::Methods -end \ No newline at end of file + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/test/unit/helpers/characters_helper_test.rb b/test/unit/helpers/characters_helper_test.rb deleted file mode 100644 index 9d0b2c38..00000000 --- a/test/unit/helpers/characters_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class CharactersHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/generator_helper_test.rb b/test/unit/helpers/generator_helper_test.rb deleted file mode 100644 index 43e82461..00000000 --- a/test/unit/helpers/generator_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class GeneratorHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/main_helper_test.rb b/test/unit/helpers/main_helper_test.rb deleted file mode 100644 index 22da3c40..00000000 --- a/test/unit/helpers/main_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class MainHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/sessions_helper_test.rb b/test/unit/helpers/sessions_helper_test.rb deleted file mode 100644 index 7d44e096..00000000 --- a/test/unit/helpers/sessions_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class SessionsHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/users_helper_test.rb b/test/unit/helpers/users_helper_test.rb deleted file mode 100644 index 96af37a8..00000000 --- a/test/unit/helpers/users_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class UsersHelperTest < ActionView::TestCase -end diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep new file mode 100644 index 00000000..e69de29b From d0192b47a63a031e21bacf35ecc818c065840bc2 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 13 Jul 2014 17:37:59 -0500 Subject: [PATCH 02/33] Create Character tests --- app/controllers/characters_controller.rb | 5 +- app/models/character.rb | 12 ++++ app/models/equipment.rb | 3 + app/models/language.rb | 3 + app/models/location.rb | 3 + app/models/magic.rb | 3 + app/models/session.rb | 3 + app/models/universe.rb | 5 ++ app/models/user.rb | 3 + .../controllers/characters_controller_test.rb | 64 +++++++++++++++++++ test/fixtures/characters.yml | 3 + test/fixtures/universes.yml | 2 + test/helpers/characters_helper_test.rb | 4 ++ test/models/character_test.rb | 4 ++ 14 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 test/controllers/characters_controller_test.rb create mode 100644 test/helpers/characters_helper_test.rb diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index 256c70a5..b6a1e0ec 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -56,7 +56,7 @@ class CharactersController < ApplicationController # POST /characters # POST /characters.json def create - @character = Character.new(params[:character]) + @character = Character.create(params.require(:character).permit(:name, :age, :universe_id)) @character.user_id = session[:user] @character.universe = Universe.where(user_id: session[:user]).where(name: params[:character][:universe].strip).first @@ -96,8 +96,7 @@ class CharactersController < ApplicationController # DELETE /characters/1 # DELETE /characters/1.json def destroy - @character = Character.find(params[:id]) - @character.destroy + Character.find(params[:id]).delete respond_to do |format| format.html { redirect_to character_list_url } diff --git a/app/models/character.rb b/app/models/character.rb index 9d52c188..b35fd68a 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,2 +1,14 @@ class Character < ActiveRecord::Base + def new + Character.new + end + + def create + Character.create(params.require(:character).permit!) + end + + + + belongs_to :user + belongs_to :universe end diff --git a/app/models/equipment.rb b/app/models/equipment.rb index 0cd8d98b..5358ca80 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -1,2 +1,5 @@ class Equipment < ActiveRecord::Base + def create + Equipment.create(params.permit!) + end end diff --git a/app/models/language.rb b/app/models/language.rb index addcdda6..59c8f038 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,2 +1,5 @@ class Language < ActiveRecord::Base + def create + Language.create(params.permit!) + end end diff --git a/app/models/location.rb b/app/models/location.rb index e3acd900..2df928b7 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,2 +1,5 @@ class Location < ActiveRecord::Base + def create + Location.create(params.permit!) + end end diff --git a/app/models/magic.rb b/app/models/magic.rb index 2ab3d408..05970422 100644 --- a/app/models/magic.rb +++ b/app/models/magic.rb @@ -1,2 +1,5 @@ class Magic < ActiveRecord::Base + def create + Magic.create(params.permit!) + end end diff --git a/app/models/session.rb b/app/models/session.rb index 54fee45a..0a65a2c7 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -1,2 +1,5 @@ class Session < ActiveRecord::Base + def create + Session.create(params.permit!) + end end diff --git a/app/models/universe.rb b/app/models/universe.rb index 47c1fe6a..79fa4ade 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -1,2 +1,7 @@ class Universe < ActiveRecord::Base + def create + Universe.create(params.permit!) + end + + belongs_to :user end diff --git a/app/models/user.rb b/app/models/user.rb index 4a57cf07..187020e3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,2 +1,5 @@ class User < ActiveRecord::Base + def create + User.create(params.permit!) + end end diff --git a/test/controllers/characters_controller_test.rb b/test/controllers/characters_controller_test.rb new file mode 100644 index 00000000..2fe5efea --- /dev/null +++ b/test/controllers/characters_controller_test.rb @@ -0,0 +1,64 @@ +require 'test_helper' + +class CharactersControllerTest < ActionController::TestCase + setup do + @user = users(:one) + @session = sessions(:one) + @universe = universes(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:characters) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create character" do + @character = characters(:one) + + assert_difference('Character.count') do + post :create, character: { age: @character.age, name: @character.name, universe: @universe} + end + + assert_redirected_to character_path(assigns(:character)) + end + + test "should show character" do + @character = characters(:one) + + get :show, id: @character.id + assert_response :success + end + + test "should get edit" do + @character = characters(:one) + get :edit, id: @character.id + assert_response 302 + assert_redirected_to character_edit_path(@character) + end + + test "should update character" do + @character = characters(:one) + put :update, id: @character, character: { age: @character.age, name: @character.name, universe: @universe } + + assert_response 302 + assert_redirected_to character_path(@character) + end + + test "should destroy character" do + @character = characters(:one) + assert_difference('Character.count', -1) do + delete :destroy, id: @character.id + end + + get :show, id: @character + assert_response 404 + + assert_redirected_to characters_path + end +end diff --git a/test/fixtures/characters.yml b/test/fixtures/characters.yml index f227f68d..e871720f 100644 --- a/test/fixtures/characters.yml +++ b/test/fixtures/characters.yml @@ -1,2 +1,5 @@ one: name: Test + age: Test + user: one + universe: one diff --git a/test/fixtures/universes.yml b/test/fixtures/universes.yml index f227f68d..1ca3520a 100644 --- a/test/fixtures/universes.yml +++ b/test/fixtures/universes.yml @@ -1,2 +1,4 @@ one: name: Test + user: one + privacy: public \ No newline at end of file diff --git a/test/helpers/characters_helper_test.rb b/test/helpers/characters_helper_test.rb new file mode 100644 index 00000000..9d0b2c38 --- /dev/null +++ b/test/helpers/characters_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class CharactersHelperTest < ActionView::TestCase +end diff --git a/test/models/character_test.rb b/test/models/character_test.rb index 6749ea6d..287f4b40 100644 --- a/test/models/character_test.rb +++ b/test/models/character_test.rb @@ -4,4 +4,8 @@ class CharacterTest < ActiveSupport::TestCase test "character exists" do assert_not_nil characters(:one) end + + test "get columns" do + assert_equal "Test", characters(:one).name + end end From ccad5e6d1f50430563d0042afb6811224d47d8e1 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 13 Jul 2014 22:37:51 -0500 Subject: [PATCH 03/33] Fix Character model and tests --- app/controllers/characters_controller.rb | 18 ++++++++++++++++-- app/models/character.rb | 10 ---------- app/models/user.rb | 2 +- test/controllers/characters_controller_test.rb | 18 ++++++------------ test/fixtures/sessions.yml | 4 ++-- test/fixtures/users.yml | 6 +++--- test/models/character_test.rb | 5 +++++ 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index b6a1e0ec..9504d547 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -56,7 +56,7 @@ class CharactersController < ApplicationController # POST /characters # POST /characters.json def create - @character = Character.create(params.require(:character).permit(:name, :age, :universe_id)) + @character = Character.create(character_params) @character.user_id = session[:user] @character.universe = Universe.where(user_id: session[:user]).where(name: params[:character][:universe].strip).first @@ -83,7 +83,7 @@ class CharactersController < ApplicationController end respond_to do |format| - if @character.update_attributes(params[:character]) + if @character.update_attributes(character_params) format.html { redirect_to @character, notice: 'Character was successfully updated.' } format.json { head :no_content } else @@ -103,4 +103,18 @@ class CharactersController < ApplicationController format.json { head :no_content } end end + + private + def character_params + params.require(:character).permit( + :universe_id, :user_id, + :name, :age, :role, :gender, :age, + :height, :weight, :haircolor, :facialhair, :eyecolor, :race, :skintone, :bodytype, :identmarks, + :bestfriend, :religion, :politics, :prejudices, :occupation, :pets, + :mannerisms, + :birthday, :birthplace, :education, :background, + :fave_color, :fave_food, :fave_possession, :fave_weapon, :fave_animal, + :father, :mother, :spouse, :siblings, :archenemy, + :notes, :private_notes) + end end diff --git a/app/models/character.rb b/app/models/character.rb index b35fd68a..d2821992 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,14 +1,4 @@ class Character < ActiveRecord::Base - def new - Character.new - end - - def create - Character.create(params.require(:character).permit!) - end - - - belongs_to :user belongs_to :universe end diff --git a/app/models/user.rb b/app/models/user.rb index 187020e3..ac1810cb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ class User < ActiveRecord::Base - def create + def create User.create(params.permit!) end end diff --git a/test/controllers/characters_controller_test.rb b/test/controllers/characters_controller_test.rb index 2fe5efea..a7ffdc23 100644 --- a/test/controllers/characters_controller_test.rb +++ b/test/controllers/characters_controller_test.rb @@ -3,8 +3,9 @@ require 'test_helper' class CharactersControllerTest < ActionController::TestCase setup do @user = users(:one) - @session = sessions(:one) @universe = universes(:one) + + session[:user] = users(:one).id end test "should get index" do @@ -19,10 +20,8 @@ class CharactersControllerTest < ActionController::TestCase end test "should create character" do - @character = characters(:one) - assert_difference('Character.count') do - post :create, character: { age: @character.age, name: @character.name, universe: @universe} + post :create, character: { age: "Created Age", name: "Created Name", universe: @universe} end assert_redirected_to character_path(assigns(:character)) @@ -38,8 +37,7 @@ class CharactersControllerTest < ActionController::TestCase test "should get edit" do @character = characters(:one) get :edit, id: @character.id - assert_response 302 - assert_redirected_to character_edit_path(@character) + assert_response :success end test "should update character" do @@ -51,14 +49,10 @@ class CharactersControllerTest < ActionController::TestCase end test "should destroy character" do - @character = characters(:one) assert_difference('Character.count', -1) do - delete :destroy, id: @character.id + delete :destroy, id: characters(:one).id end - - get :show, id: @character - assert_response 404 - assert_redirected_to characters_path + assert_redirected_to character_list_url end end diff --git a/test/fixtures/sessions.yml b/test/fixtures/sessions.yml index 72e00171..e7f46d08 100644 --- a/test/fixtures/sessions.yml +++ b/test/fixtures/sessions.yml @@ -1,3 +1,3 @@ one: - username: Test - password: Test \ No newline at end of file + username: TestUser + password: TestPassword diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 5f9df600..d6c8a18a 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,4 +1,4 @@ one: - name: Test - email: Test - password: Test + name: TestUser + email: TestEmail + password: TestPassword diff --git a/test/models/character_test.rb b/test/models/character_test.rb index 287f4b40..b394e86c 100644 --- a/test/models/character_test.rb +++ b/test/models/character_test.rb @@ -8,4 +8,9 @@ class CharacterTest < ActiveSupport::TestCase test "get columns" do assert_equal "Test", characters(:one).name end + + test "get associated tables" do + assert_equal users(:one), characters(:one).user + assert_equal universes(:one), characters(:one).universe + end end From dae7a2e2279e278690e54e2c5916337555ef3abd Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 13 Jul 2014 22:49:49 -0500 Subject: [PATCH 04/33] Remove experimental Ruby 2.1.0 build Gemfile --- .travis.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b3f0652..2141c774 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,2 @@ language: ruby -rvm: 2.0.0 -services: mongodb - -matrix: - include: - - rvm: 2.1.0 - gemfile: gemfiles/Gemfile.ruby-2.1.0 - allow_failures: - - rvm: 2.1.0 - gemfile: gemfiles/Gemfile.ruby-2.1.0 - - +rvm: 2.1.2 From 2a0c37ee3d3a41e8d7f5414cbeae9acbd9573bea Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 13 Jul 2014 22:52:10 -0500 Subject: [PATCH 05/33] Fix Travis's Ruby version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2141c774..f73b0668 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,2 @@ language: ruby -rvm: 2.1.2 +rvm: 2.1.1 From c8d671782b46f84e3c7ffdfe4456910c31c48185 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 13 Jul 2014 22:57:04 -0500 Subject: [PATCH 06/33] Update README to mention Ruby 2.1.2 --- README.rdoc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README.rdoc b/README.rdoc index cf3a5d6e..5a5834b4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -41,26 +41,16 @@ Install rvm source ~/.rvm/scripts/rvm -Install ruby 2.0.0 +Install ruby 2.1.2 - rvm install ruby 2.0.0 + rvm install ruby 2.1.2 - rvm use 2.0.0 + rvm use 2.1.2 Install rails 4.0.1 gem install rails -v 4.0.1 -Install mongodb - - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 - - echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list - - sudo apt-get update - - sudo apt-get install mongodb-10gen - Install necessary libraries sudo apt-get install imagemagick libmagickwand-dev From c251f50f2b7c9dd8e2a87c7d79b69271b06a10ec Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Mon, 14 Jul 2014 21:03:35 -0500 Subject: [PATCH 07/33] Create tests for models, and add associations to models --- app/models/equipment.rb | 5 ++--- app/models/language.rb | 5 ++--- app/models/location.rb | 5 ++--- app/models/magic.rb | 5 ++--- app/models/session.rb | 4 +--- app/models/universe.rb | 19 +++++++++++++++---- app/models/user.rb | 29 +++++++++++++++++++++++++++-- test/fixtures/equipment.yml | 2 ++ test/fixtures/languages.yml | 2 ++ test/fixtures/locations.yml | 2 ++ test/fixtures/magics.yml | 2 ++ test/models/character_test.rb | 6 +----- test/models/equipment_test.rb | 7 ++++++- test/models/language_test.rb | 5 +++++ test/models/location_test.rb | 5 +++++ test/models/magic_test.rb | 5 +++++ test/models/universe_test.rb | 16 ++++++++++++++++ test/models/user_test.rb | 15 +++++++++++++++ 18 files changed, 112 insertions(+), 27 deletions(-) diff --git a/app/models/equipment.rb b/app/models/equipment.rb index 5358ca80..74a68be1 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -1,5 +1,4 @@ class Equipment < ActiveRecord::Base - def create - Equipment.create(params.permit!) - end + belongs_to :user + belongs_to :universe end diff --git a/app/models/language.rb b/app/models/language.rb index 59c8f038..196c7e09 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,5 +1,4 @@ class Language < ActiveRecord::Base - def create - Language.create(params.permit!) - end + belongs_to :user + belongs_to :universe end diff --git a/app/models/location.rb b/app/models/location.rb index 2df928b7..6a9c22c0 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,5 +1,4 @@ class Location < ActiveRecord::Base - def create - Location.create(params.permit!) - end + belongs_to :user + belongs_to :universe end diff --git a/app/models/magic.rb b/app/models/magic.rb index 05970422..d5a285ef 100644 --- a/app/models/magic.rb +++ b/app/models/magic.rb @@ -1,5 +1,4 @@ class Magic < ActiveRecord::Base - def create - Magic.create(params.permit!) - end + belongs_to :user + belongs_to :universe end diff --git a/app/models/session.rb b/app/models/session.rb index 0a65a2c7..619022a7 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -1,5 +1,3 @@ class Session < ActiveRecord::Base - def create - Session.create(params.permit!) - end + validates_presence_of :username, :password end diff --git a/app/models/universe.rb b/app/models/universe.rb index 79fa4ade..cdf7a8b8 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -1,7 +1,18 @@ class Universe < ActiveRecord::Base - def create - Universe.create(params.permit!) - end - belongs_to :user + has_many :characters + has_many :equipment + has_many :languages + has_many :locations + has_many :magics + + def content_count + [ + characters.length, + equipment.length, + languages.length, + locations.length, + magics.length, + ].sum + end end diff --git a/app/models/user.rb b/app/models/user.rb index ac1810cb..9de326eb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,30 @@ class User < ActiveRecord::Base - def create - User.create(params.permit!) + has_many :characters + has_many :equipment + has_many :languages + has_many :locations + has_many :magics + has_many :universes + + def content + { + :characters => characters, + :equipment => equipment, + :languages => languages, + :locations => locations, + :magics => magics, + :universes => universes + } + end + + def content_count + [ + characters.length, + equipment.length, + languages.length, + locations.length, + magics.length, + universes.length + ].sum end end diff --git a/test/fixtures/equipment.yml b/test/fixtures/equipment.yml index f227f68d..6a551869 100644 --- a/test/fixtures/equipment.yml +++ b/test/fixtures/equipment.yml @@ -1,2 +1,4 @@ one: name: Test + user: one + universe: one diff --git a/test/fixtures/languages.yml b/test/fixtures/languages.yml index f227f68d..6a551869 100644 --- a/test/fixtures/languages.yml +++ b/test/fixtures/languages.yml @@ -1,2 +1,4 @@ one: name: Test + user: one + universe: one diff --git a/test/fixtures/locations.yml b/test/fixtures/locations.yml index f227f68d..6a551869 100644 --- a/test/fixtures/locations.yml +++ b/test/fixtures/locations.yml @@ -1,2 +1,4 @@ one: name: Test + user: one + universe: one diff --git a/test/fixtures/magics.yml b/test/fixtures/magics.yml index f227f68d..6a551869 100644 --- a/test/fixtures/magics.yml +++ b/test/fixtures/magics.yml @@ -1,2 +1,4 @@ one: name: Test + user: one + universe: one diff --git a/test/models/character_test.rb b/test/models/character_test.rb index b394e86c..9e71b502 100644 --- a/test/models/character_test.rb +++ b/test/models/character_test.rb @@ -5,11 +5,7 @@ class CharacterTest < ActiveSupport::TestCase assert_not_nil characters(:one) end - test "get columns" do - assert_equal "Test", characters(:one).name - end - - test "get associated tables" do + test "character belongs to user and universe" do assert_equal users(:one), characters(:one).user assert_equal universes(:one), characters(:one).universe end diff --git a/test/models/equipment_test.rb b/test/models/equipment_test.rb index e4f5a89f..2c026309 100644 --- a/test/models/equipment_test.rb +++ b/test/models/equipment_test.rb @@ -1,7 +1,12 @@ require 'test_helper' class EquipmentTest < ActiveSupport::TestCase - test "equipement exists" do + test "equipment exists" do assert_not_nil equipment(:one) end + + test "equipement belongs to user and universe" do + assert_equal users(:one), equipment(:one).user + assert_equal universes(:one), equipment(:one).universe + end end diff --git a/test/models/language_test.rb b/test/models/language_test.rb index d9cd552c..abc0cba4 100644 --- a/test/models/language_test.rb +++ b/test/models/language_test.rb @@ -4,4 +4,9 @@ class LanguageTest < ActiveSupport::TestCase test "language exists" do assert_not_nil languages(:one) end + + test "language belongs to user and universe" do + assert_equal users(:one), languages(:one).user + assert_equal universes(:one), languages(:one).universe + end end diff --git a/test/models/location_test.rb b/test/models/location_test.rb index 16d8b64f..528405e0 100644 --- a/test/models/location_test.rb +++ b/test/models/location_test.rb @@ -4,4 +4,9 @@ class LocationTest < ActiveSupport::TestCase test "location exists" do assert_not_nil locations(:one) end + + test "location belongs to user and universe" do + assert_equal users(:one), locations(:one).user + assert_equal universes(:one), locations(:one).universe + end end diff --git a/test/models/magic_test.rb b/test/models/magic_test.rb index 33f334e6..0264f379 100644 --- a/test/models/magic_test.rb +++ b/test/models/magic_test.rb @@ -4,4 +4,9 @@ class MagicTest < ActiveSupport::TestCase test "magic exists" do assert_not_nil magics(:one) end + + test "magic belongs to user and universe" do + assert_equal users(:one), magics(:one).user + assert_equal universes(:one), magics(:one).universe + end end diff --git a/test/models/universe_test.rb b/test/models/universe_test.rb index 7661765f..9674559d 100644 --- a/test/models/universe_test.rb +++ b/test/models/universe_test.rb @@ -4,4 +4,20 @@ class UniverseTest < ActiveSupport::TestCase test "universe exists" do assert_not_nil universes(:one) end + + test "universe belongs to user" do + assert_equal users(:one), universes(:one).user + end + + test "associations associate" do + assert_not_nil universes(:one).characters + assert_not_nil universes(:one).equipment + assert_not_nil universes(:one).languages + assert_not_nil universes(:one).locations + assert_not_nil universes(:one).magics + end + + test "can count content" do + assert_equal 5, universes(:one).content_count + end end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 385ebdcb..3b3907ed 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -4,4 +4,19 @@ class UserTest < ActiveSupport::TestCase test "user exists" do assert_not_nil users(:one) end + + test "can get user content" do + content = users(:one).content + + assert_includes content[:characters], characters(:one) + assert_includes content[:equipment], equipment(:one) + assert_includes content[:languages], languages(:one) + assert_includes content[:locations], locations(:one) + assert_includes content[:magics], magics(:one) + assert_includes content[:universes], universes(:one) + end + + test "can count content" do + assert_equal 6, users(:one).content_count + end end From e661f692a9eaa775c3dd97b83b5c071e0f74c089 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Mon, 14 Jul 2014 21:34:54 -0500 Subject: [PATCH 08/33] Create equipment controller tests and update Equipment controller to use Rails 4 strong parameters --- app/controllers/equipment_controller.rb | 15 +++++- app/helpers/equipment_helper.rb | 2 + .../controllers/characters_controller_test.rb | 2 +- test/controllers/equipment_controller_test.rb | 51 +++++++++++++++++++ test/helpers/equipment_helper_test.rb | 4 ++ test/test_helper.rb | 8 ++- 6 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 app/helpers/equipment_helper.rb create mode 100644 test/controllers/equipment_controller_test.rb create mode 100644 test/helpers/equipment_helper_test.rb diff --git a/app/controllers/equipment_controller.rb b/app/controllers/equipment_controller.rb index 05b9028e..4aa300d6 100644 --- a/app/controllers/equipment_controller.rb +++ b/app/controllers/equipment_controller.rb @@ -41,7 +41,7 @@ class EquipmentController < ApplicationController end def create - @equipment = Equipment.new(params[:equipment]) + @equipment = Equipment.create(equipment_params) @equipment.user_id = session[:user] @equipment.universe = Universe.where(user_id: session[:user]).where(name: params[:equipment][:universe].strip).first @@ -66,7 +66,7 @@ class EquipmentController < ApplicationController end respond_to do |format| - if @equipment.update_attributes(params[:equipment]) + if @equipment.update_attributes(equipment_params) format.html { redirect_to @equipment, notice: 'Equipment was successfully updated.' } format.json { head :no_content } else @@ -85,4 +85,15 @@ class EquipmentController < ApplicationController format.json { head :no_content } end end + + private + def equipment_params + params.require(:equipment).permit( + :universe_id, :user_id, + :name, :equip_type, + :description, :weight, + :original_owner, :current_owner, :made_by, :materials, :year_made, + :magic, + :notes, :private_notes) + end end diff --git a/app/helpers/equipment_helper.rb b/app/helpers/equipment_helper.rb new file mode 100644 index 00000000..b3ce05f9 --- /dev/null +++ b/app/helpers/equipment_helper.rb @@ -0,0 +1,2 @@ +module EquipmentHelper +end diff --git a/test/controllers/characters_controller_test.rb b/test/controllers/characters_controller_test.rb index a7ffdc23..3a01bbba 100644 --- a/test/controllers/characters_controller_test.rb +++ b/test/controllers/characters_controller_test.rb @@ -5,7 +5,7 @@ class CharactersControllerTest < ActionController::TestCase @user = users(:one) @universe = universes(:one) - session[:user] = users(:one).id + log_in_user(:one) end test "should get index" do diff --git a/test/controllers/equipment_controller_test.rb b/test/controllers/equipment_controller_test.rb new file mode 100644 index 00000000..aad962df --- /dev/null +++ b/test/controllers/equipment_controller_test.rb @@ -0,0 +1,51 @@ +require 'test_helper' + +class EquipmentControllerTest < ActionController::TestCase + setup do + log_in_user(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:equipment) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create equipment" do + assert_difference('Equipment.count') do + post :create, equipment: { name: "Created Equipment", universe: universes(:one)} + end + + assert_redirected_to equipment_path(assigns(:equipment)) + end + + test "should show equipment" do + get :show, id: equipment(:one).id + assert_response :success + end + + test "should get edit" do + get :edit, id: equipment(:one).id + assert_response :success + end + + test "should update equipment" do + put :update, id: equipment(:one).id, equipment: { name: "Updated Equipment Name", universe: universes(:one) } + + assert_response 302 + assert_redirected_to equipment_path(equipment(:one)) + end + + test "should destroy equipment" do + assert_difference('Equipment.count', -1) do + delete :destroy, id: equipment(:one).id + end + + assert_redirected_to equipment_list_url + end +end diff --git a/test/helpers/equipment_helper_test.rb b/test/helpers/equipment_helper_test.rb new file mode 100644 index 00000000..f23c6206 --- /dev/null +++ b/test/helpers/equipment_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class EquipmentHelperTest < ActionView::TestCase +end diff --git a/test/test_helper.rb b/test/test_helper.rb index bf95f818..bdb166a2 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,11 +3,9 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting fixtures :all - # Add more helper methods to be used by all tests here... + def log_in_user(user_fixture) + session[:user] = users(user_fixture).id + end end From b91b53412ee22e916f030f0fa2f5a34a18fb1508 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Mon, 14 Jul 2014 21:55:02 -0500 Subject: [PATCH 09/33] Created Languages controller tests, and updated Languages controller to use Rails 4 strong parameters --- app/assets/javascripts/languages.js.coffee | 3 ++ app/assets/stylesheets/languages.css.scss | 3 ++ app/controllers/languages_controller.rb | 16 +++++- app/helpers/languages_helper.rb | 2 + test/controllers/languages_controller_test.rb | 50 +++++++++++++++++++ test/helpers/languages_helper_test.rb | 4 ++ 6 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/languages.js.coffee create mode 100644 app/assets/stylesheets/languages.css.scss create mode 100644 app/helpers/languages_helper.rb create mode 100644 test/controllers/languages_controller_test.rb create mode 100644 test/helpers/languages_helper_test.rb diff --git a/app/assets/javascripts/languages.js.coffee b/app/assets/javascripts/languages.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/languages.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/languages.css.scss b/app/assets/stylesheets/languages.css.scss new file mode 100644 index 00000000..32d25fab --- /dev/null +++ b/app/assets/stylesheets/languages.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the languages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index 92bc1e6f..01a1df51 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -41,7 +41,7 @@ class LanguagesController < ApplicationController end def create - @language = Language.new(params[:language]) + @language = Language.new(language_params) @language.user_id = session[:user] @language.universe = Universe.where(user_id: session[:user]).where(name: params[:language][:universe].strip).first @@ -65,7 +65,7 @@ class LanguagesController < ApplicationController end respond_to do |format| - if @language.update_attributes(params[:language]) + if @language.update_attributes(language_params) format.html { redirect_to @language, notice: 'Language was successfully updated.' } format.json { head :no_content } else @@ -84,4 +84,16 @@ class LanguagesController < ApplicationController format.json { head :no_content } end end + + private + def language_params + params.require(:language).permit( + :user_id, :universe_id, + :name, + :words, + :established_year, :established_location, + :characters, :locations, + :notes) + end + end diff --git a/app/helpers/languages_helper.rb b/app/helpers/languages_helper.rb new file mode 100644 index 00000000..24686681 --- /dev/null +++ b/app/helpers/languages_helper.rb @@ -0,0 +1,2 @@ +module LanguagesHelper +end diff --git a/test/controllers/languages_controller_test.rb b/test/controllers/languages_controller_test.rb new file mode 100644 index 00000000..2518aef8 --- /dev/null +++ b/test/controllers/languages_controller_test.rb @@ -0,0 +1,50 @@ +require 'test_helper' + +class LanguagesControllerTest < ActionController::TestCase + setup do + log_in_user(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:languages) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create language" do + assert_difference('Language.count', 1) do + post :create, language: { name: "Created Language", universe: universes(:one)} + end + + assert_redirected_to language_path(assigns(:language)) + end + + test "should show language" do + get :show, id: languages(:one).id + assert_response :success + end + + test "should get edit" do + get :edit, id: languages(:one).id + assert_response :success + end + + test "should update language" do + put :update, id: languages(:one).id, language: { name: "Updated Language Name", universe: universes(:one) } + + assert_redirected_to language_path(languages(:one)) + end + + test "should destroy language" do + assert_difference('Language.count', -1) do + delete :destroy, id: languages(:one).id + end + + assert_redirected_to language_list_url + end +end diff --git a/test/helpers/languages_helper_test.rb b/test/helpers/languages_helper_test.rb new file mode 100644 index 00000000..3bc9dd9d --- /dev/null +++ b/test/helpers/languages_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class LanguagesHelperTest < ActionView::TestCase +end From 2609a882a16fab992946f4773b471bb72b24deaf Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 20 Jul 2014 18:33:02 -0500 Subject: [PATCH 10/33] Set eager_load configs as per Rake's recommendation --- config/environments/development.rb | 1 + config/environments/production.rb | 1 + config/environments/test.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/config/environments/development.rb b/config/environments/development.rb index f0cef644..051d4065 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,6 +12,7 @@ PlanCharacters::Application.configure do # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.eager_load = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false diff --git a/config/environments/production.rb b/config/environments/production.rb index d2e49ed6..251225a7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -7,6 +7,7 @@ Rails.application.configure do # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true + config.eager_load = true # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static_assets = false diff --git a/config/environments/test.rb b/config/environments/test.rb index 10109e20..dbf48793 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,6 +10,7 @@ Rails.application.configure do # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" + config.eager_load = false # Log error messages when you accidentally call methods on nil config.whiny_nils = true From a02ab0e735e75418494823d9a9d668b45c1b8adb Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 20 Jul 2014 18:34:21 -0500 Subject: [PATCH 11/33] Add tests for validations, and the validations as per schema --- app/models/character.rb | 2 ++ app/models/equipment.rb | 2 ++ app/models/language.rb | 2 ++ app/models/location.rb | 2 ++ app/models/magic.rb | 2 ++ app/models/universe.rb | 2 ++ app/models/user.rb | 2 ++ test/models/character_test.rb | 16 +++++++++----- test/models/equipment_test.rb | 9 +++++++- test/models/language_test.rb | 9 +++++++- test/models/location_test.rb | 16 +++++++++----- test/models/magic_test.rb | 13 +++++++----- test/models/session_test.rb | 19 +++++++++++++++-- test/models/universe_test.rb | 23 +++++++++----------- test/models/user_test.rb | 40 +++++++++++++++++++++++++++-------- 15 files changed, 118 insertions(+), 41 deletions(-) diff --git a/app/models/character.rb b/app/models/character.rb index d2821992..88814168 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,4 +1,6 @@ class Character < ActiveRecord::Base + validates_presence_of :name + belongs_to :user belongs_to :universe end diff --git a/app/models/equipment.rb b/app/models/equipment.rb index 74a68be1..78783cd2 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -1,4 +1,6 @@ class Equipment < ActiveRecord::Base + validates_presence_of :name + belongs_to :user belongs_to :universe end diff --git a/app/models/language.rb b/app/models/language.rb index 196c7e09..6cf232b8 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,4 +1,6 @@ class Language < ActiveRecord::Base + validates_presence_of :name + belongs_to :user belongs_to :universe end diff --git a/app/models/location.rb b/app/models/location.rb index 6a9c22c0..3efaae82 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,4 +1,6 @@ class Location < ActiveRecord::Base + validates_presence_of :name + belongs_to :user belongs_to :universe end diff --git a/app/models/magic.rb b/app/models/magic.rb index d5a285ef..7f47797e 100644 --- a/app/models/magic.rb +++ b/app/models/magic.rb @@ -1,4 +1,6 @@ class Magic < ActiveRecord::Base + validates_presence_of :name + belongs_to :user belongs_to :universe end diff --git a/app/models/universe.rb b/app/models/universe.rb index cdf7a8b8..38c6b810 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -1,4 +1,6 @@ class Universe < ActiveRecord::Base + validates_presence_of :name + belongs_to :user has_many :characters has_many :equipment diff --git a/app/models/user.rb b/app/models/user.rb index 9de326eb..18b88903 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,6 @@ class User < ActiveRecord::Base + validates_presence_of :name, :password, :email + has_many :characters has_many :equipment has_many :languages diff --git a/test/models/character_test.rb b/test/models/character_test.rb index 9e71b502..2742f3cf 100644 --- a/test/models/character_test.rb +++ b/test/models/character_test.rb @@ -1,12 +1,18 @@ require 'test_helper' class CharacterTest < ActiveSupport::TestCase - test "character exists" do - assert_not_nil characters(:one) + test "character not valid without a name" do + character = characters(:one) + character.name = nil + + refute character.valid?, "Character name not being validated for presence" end - test "character belongs to user and universe" do - assert_equal users(:one), characters(:one).user - assert_equal universes(:one), characters(:one).universe + test "characters fixture assumptions" do + assert_not_nil characters(:one), "Characters fixture :one is not available" + assert characters(:one).valid?, "Characters fixture :one is not valid" + + assert_equal users(:one), characters(:one).user, "Characters fixture :one is not associated with Users fixture :one" + assert_equal universes(:one), characters(:one).universe, "Characters fixture :one is not associated with Universes fixture :one" end end diff --git a/test/models/equipment_test.rb b/test/models/equipment_test.rb index 2c026309..1c0ce348 100644 --- a/test/models/equipment_test.rb +++ b/test/models/equipment_test.rb @@ -1,7 +1,14 @@ require 'test_helper' class EquipmentTest < ActiveSupport::TestCase - test "equipment exists" do + test "equipment not valid without a name" do + equipment = equipment(:one) + equipment.name = nil + + refute equipment.valid?, "Name is not being validated for presence" + end + + test "equipment fixture exists" do assert_not_nil equipment(:one) end diff --git a/test/models/language_test.rb b/test/models/language_test.rb index abc0cba4..d27cf03d 100644 --- a/test/models/language_test.rb +++ b/test/models/language_test.rb @@ -1,7 +1,14 @@ require 'test_helper' class LanguageTest < ActiveSupport::TestCase - test "language exists" do + test "language not valid without a name" do + language = languages(:one) + language.name = nil + + refute language.valid?, "Language name not being validated for presence" + end + + test "language fixture exists" do assert_not_nil languages(:one) end diff --git a/test/models/location_test.rb b/test/models/location_test.rb index 528405e0..3845e935 100644 --- a/test/models/location_test.rb +++ b/test/models/location_test.rb @@ -1,12 +1,18 @@ require 'test_helper' class LocationTest < ActiveSupport::TestCase - test "location exists" do - assert_not_nil locations(:one) + test "location not valid without a name" do + location = locations(:one) + location.name = nil + + refute location.valid?, "Location name is not being validated for presence" end - test "location belongs to user and universe" do - assert_equal users(:one), locations(:one).user - assert_equal universes(:one), locations(:one).universe + test "location fixture assumptions" do + assert_not_nil locations(:one), "Locations fixture :one not available" + assert locations(:one).valid?, "Locations fixture :one not valid" + + assert_equal users(:one), locations(:one).user, "Locations fixture :one not associated with Users fixture :one" + assert_equal universes(:one), locations(:one).universe, "Locations fixture :one not associated with Universes fixture :one" end end diff --git a/test/models/magic_test.rb b/test/models/magic_test.rb index 0264f379..e5dfc588 100644 --- a/test/models/magic_test.rb +++ b/test/models/magic_test.rb @@ -1,12 +1,15 @@ require 'test_helper' class MagicTest < ActiveSupport::TestCase - test "magic exists" do - assert_not_nil magics(:one) + test "magic not valid without a name" do + magic = magics(:one) + magic.name = nil + + refute magic.valid?, "Magic name is not being validated for presence" end - test "magic belongs to user and universe" do - assert_equal users(:one), magics(:one).user - assert_equal universes(:one), magics(:one).universe + test "magic fixture assumptions" do + assert_not_nil magics(:one), "Magics fixture :one is unavailable" + assert magics(:one).valid?, "Magics fixture :one is not valid" end end diff --git a/test/models/session_test.rb b/test/models/session_test.rb index 59595f13..22862c5c 100644 --- a/test/models/session_test.rb +++ b/test/models/session_test.rb @@ -1,7 +1,22 @@ require 'test_helper' class SessionTest < ActiveSupport::TestCase - test "session exists" do - assert_not_nil sessions(:one) + test "session not valid without a username" do + session = sessions(:one) + session.username = nil + + refute session.valid?, "Session username is not being validated for presence" + end + + test "session not valid without a password" do + session = sessions(:one) + session.password = nil + + refute session.valid?, "Session password is not being validated for presence" + end + + test "session fixture assumptions" do + assert_not_nil sessions(:one), "Sessions fixture :one is not available" + assert sessions(:one).valid?, "Sessions fixture :one is not a valid session" end end diff --git a/test/models/universe_test.rb b/test/models/universe_test.rb index 9674559d..b50fe25b 100644 --- a/test/models/universe_test.rb +++ b/test/models/universe_test.rb @@ -1,23 +1,20 @@ require 'test_helper' class UniverseTest < ActiveSupport::TestCase - test "universe exists" do - assert_not_nil universes(:one) + test "universe not valid without a name" do + universe = universes(:one) + universe.name = nil + + refute universe.valid?, "Universe name is not being validated for presence" end - test "universe belongs to user" do - assert_equal users(:one), universes(:one).user - end - - test "associations associate" do - assert_not_nil universes(:one).characters - assert_not_nil universes(:one).equipment - assert_not_nil universes(:one).languages - assert_not_nil universes(:one).locations - assert_not_nil universes(:one).magics + test "universe fixture assumptions" do + assert_not_nil universes(:one), "Universes fixture :one is not available" + assert universes(:one).valid?, "Universes fixture :one is not a valid universe" + assert_equal users(:one), universes(:one).user, "Universe fixture :one not associated with User fixture :one" end test "can count content" do - assert_equal 5, universes(:one).content_count + assert_equal 5, universes(:one).content_count, "Universe didn't count its content properly" end end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 3b3907ed..e9ba169d 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,22 +1,44 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase - test "user exists" do - assert_not_nil users(:one) + test "user not valid without a name" do + user = users(:one) + user.name = nil + + refute user.valid?, "Name is not being validated for presence" + end + + test "user not valid without a password" do + user = users(:one) + user.password = nil + + refute user.valid?, "Password is not being validated for presence" + end + + test "user not valid without an email address" do + user = users(:one) + user.email = nil + + refute user.valid?, "Email address is not being validated for presence" + end + + test "user fixture assumptions" do + assert_not_nil users(:one), "User fixture :one is unavailable" + assert users(:one).valid?, "User fixture :one is not a valid user" end test "can get user content" do content = users(:one).content - assert_includes content[:characters], characters(:one) - assert_includes content[:equipment], equipment(:one) - assert_includes content[:languages], languages(:one) - assert_includes content[:locations], locations(:one) - assert_includes content[:magics], magics(:one) - assert_includes content[:universes], universes(:one) + assert_includes content[:characters], characters(:one), "User content doesn't include characters" + assert_includes content[:equipment], equipment(:one), "User content doesn't include equipment" + assert_includes content[:languages], languages(:one), "User content doesn't include languages" + assert_includes content[:locations], locations(:one), "User content doesn't include locations" + assert_includes content[:magics], magics(:one), "User content doesn't include magics" + assert_includes content[:universes], universes(:one), "User content doesn't include universes" end test "can count content" do - assert_equal 6, users(:one).content_count + assert_equal 6, users(:one).content_count, "User didn't count its content properly" end end From 1cab3282ff45851a2435c5df3950039dc9c49bb1 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 3 Aug 2014 11:45:31 -0500 Subject: [PATCH 12/33] Add all the remaining tests and code to get the site functional --- Gemfile | 1 + Gemfile.lock | 9 ++++++++- app/controllers/locations_controller.rb | 17 +++++++++++++++-- app/controllers/magic_controller.rb | 16 ++++++++++++++-- app/controllers/sessions_controller.rb | 8 ++++++-- app/controllers/universes_controller.rb | 14 ++++++++++++-- app/controllers/users_controller.rb | 9 +++++++-- app/models/location.rb | 2 ++ config/routes.rb | 14 +++++++------- test/controllers/application_controller_test.rb | 5 +++++ test/controllers/generator_controller_test.rb | 5 +++++ test/controllers/locations_controller_test.rb | 5 +++++ test/controllers/magic_controller_test.rb | 5 +++++ test/controllers/main_controller_test.rb | 9 +++++++++ test/controllers/sessions_controller_test.rb | 5 +++++ test/controllers/universes_controller_test.rb | 0 test/controllers/users_controller_test.rb | 5 +++++ 17 files changed, 111 insertions(+), 18 deletions(-) create mode 100644 test/controllers/application_controller_test.rb create mode 100644 test/controllers/generator_controller_test.rb create mode 100644 test/controllers/locations_controller_test.rb create mode 100644 test/controllers/magic_controller_test.rb create mode 100644 test/controllers/main_controller_test.rb create mode 100644 test/controllers/sessions_controller_test.rb create mode 100644 test/controllers/universes_controller_test.rb create mode 100644 test/controllers/users_controller_test.rb diff --git a/Gemfile b/Gemfile index 7c7e8090..dd5be59d 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ gem 'rails', '4.1.0' gem 'sqlite3' gem 'paperclip', '~> 4.2.0' gem 'rmagick' +gem 'aws-sdk', '~> 1.50' gem 'sass-rails', '~> 4.0.3' gem 'less-rails' diff --git a/Gemfile.lock b/Gemfile.lock index b229183f..d451aae9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,9 @@ GEM thread_safe (~> 0.1) tzinfo (~> 1.1) arel (5.0.1.20140414130214) + aws-sdk (1.50.0) + json (~> 1.4) + nokogiri (>= 1.4.4) bootplus-rails (1.0.0) builder (3.2.2) climate_control (0.0.3) @@ -60,8 +63,11 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) + mini_portile (0.6.0) minitest (5.4.0) multi_json (1.10.1) + nokogiri (1.6.3.1) + mini_portile (= 0.6.0) paperclip (4.2.0) activemodel (>= 3.0.0) activesupport (>= 3.0.0) @@ -124,6 +130,7 @@ PLATFORMS ruby DEPENDENCIES + aws-sdk (~> 1.50) bootplus-rails coffee-rails (~> 4.0.0) jquery-rails @@ -135,4 +142,4 @@ DEPENDENCIES sass-rails (~> 4.0.3) sqlite3 therubyracer - uglifier (>= 1.3.0) \ No newline at end of file + uglifier (>= 1.3.0) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 5a3896bc..1ccfdae3 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -41,7 +41,7 @@ class LocationsController < ApplicationController end def create - @location = Location.new(params[:location]) + @location = Location.new(location_params) @location.user_id = session[:user] @location.universe = Universe.where(user_id: session[:user]).where(name: params[:location][:universe].strip).first @@ -80,7 +80,7 @@ class LocationsController < ApplicationController respond_to do |format| begin - if @location.update_attributes(params[:location]) + if @location.update_attributes(location_params) format.html { redirect_to @location, notice: 'Location was successfully updated.' } format.json { head :no_content } else @@ -105,4 +105,17 @@ class LocationsController < ApplicationController format.json { head :no_content } end end + + private + def location_params + params.require(:location).permit( + :universe_id, :user_id, + :name, :type_of, :description, + :map, + :population, :currency, :motto, + :capital, :largest_city, :notable_cities, + :area, :crops, :located_at, + :stablishment_year, :notable_wars, + :notes, :private_notes) + end end diff --git a/app/controllers/magic_controller.rb b/app/controllers/magic_controller.rb index e7b862b4..c0c22f6b 100644 --- a/app/controllers/magic_controller.rb +++ b/app/controllers/magic_controller.rb @@ -41,7 +41,7 @@ class MagicController < ApplicationController end def create - @magic = Magic.new(params[:magic]) + @magic = Magic.new(magic_params) @magic.user_id = session[:user] @magic.universe = Universe.where(user_id: session[:user]).where(name: params[:magic][:universe].strip).first @@ -66,7 +66,7 @@ class MagicController < ApplicationController end respond_to do |format| - if @magic.update_attributes(params[:magic]) + if @magic.update_attributes(magic_params) format.html { redirect_to @magic, notice: 'Magic was successfully updated.' } format.json { head :no_content } else @@ -85,4 +85,16 @@ class MagicController < ApplicationController format.json { head :no_content } end end + + private + def magic_params + params.require(:magic).permit( + :universe_id, :user_id, + :name, :type_of, + :manifestation, :symptoms, + :element, :diety, + :harmfulness, :helpfulness, :neutralness, + :resource, :skill_level, :limitations, + :notes, :private_notes) + end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 329657ec..0f90b414 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -14,8 +14,7 @@ class SessionsController < ApplicationController # POST /sessions.json def create require 'digest' - login = Session.new(params[:session]) - + login = Session.new(session_params) hash = Digest::MD5.hexdigest(login.username + "'s password IS... " + login.password + " (lol!)") user = User.where(name: login.username, password: hash) if user.length < 1 @@ -42,4 +41,9 @@ class SessionsController < ApplicationController format.json { head :no_content } end end + + private + def session_params + params.require(:session).permit(:username, :password) + end end diff --git a/app/controllers/universes_controller.rb b/app/controllers/universes_controller.rb index da3b6226..8e6b4934 100644 --- a/app/controllers/universes_controller.rb +++ b/app/controllers/universes_controller.rb @@ -41,7 +41,7 @@ class UniversesController < ApplicationController end def create - @universe = Universe.new(params[:universe]) + @universe = Universe.new(universe_params) @universe.user_id = session[:user] respond_to do |format| @@ -59,7 +59,7 @@ class UniversesController < ApplicationController @universe = Universe.find(params[:id]) respond_to do |format| - if @universe.update_attributes(params[:universe]) + if @universe.update_attributes(universe_params) format.html { redirect_to @universe, notice: 'Universe was successfully updated.' } format.json { head :no_content } else @@ -78,4 +78,14 @@ class UniversesController < ApplicationController format.json { head :no_content } end end + + private + def universe_params + params.require(:universe).permit( + :user_id, + :name, :description, + :history, + :privacy, + :notes, :private_notes) + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 987f5ec2..431aef30 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -20,7 +20,7 @@ class UsersController < ApplicationController # POST /users # POST /users.json def create - @user = User.new(params[:user]) + @user = User.new(user_params) respond_to do |format| if @user.save session[:user] = @user.id @@ -57,7 +57,7 @@ class UsersController < ApplicationController @user = User.find(session[:user]) respond_to do |format| - if @user.update_attributes(params[:user]) + if @user.update_attributes(user_params) session[:anon_user] = false format.html { redirect_to homepage_path, notice: 'Successfully updated.' } format.json { head :no_content } @@ -70,4 +70,9 @@ class UsersController < ApplicationController def anonymous end + + private + def user_params + params.require(:user).permit(:name, :password, :email) + end end diff --git a/app/models/location.rb b/app/models/location.rb index 3efaae82..1506f04c 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,4 +1,6 @@ class Location < ActiveRecord::Base + has_attached_file :map, :styles => { :original => "1920x1080>", :thumb => "200x200>" } + validates_attachment_content_type :map, :content_type => /\Aimage\/.*\Z/ validates_presence_of :name belongs_to :user diff --git a/config/routes.rb b/config/routes.rb index 53448484..401fa71e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,7 +25,7 @@ PlanCharacters::Application.routes.draw do get '/register', :to => 'users#new', :as => :signup post '/register', :to => 'users#create', :as => :signup_process get '/account', :to => 'users#edit', :as => :account - put '/register', :to => 'users#update', :as => :account_process + patch '/register', :to => 'users#update', :as => :account_process get '/be-anonymous', :to => 'users#anonymous', :as => :anonymous get '/anon-login', :to => 'users#anonymous_login', :as => :anonymous_login @@ -38,7 +38,7 @@ PlanCharacters::Application.routes.draw do post '/character/new', :to => 'characters#create', :as => :character_create_process get '/character/:id', :to => 'characters#show', :as => :character get '/character/:id/edit', :to => 'characters#edit', :as => :character_edit - put '/character/:id', :to => 'characters#update', :as => :character_edit_process + patch '/character/:id', :to => 'characters#update', :as => :character_edit_process delete '/character/:id', :to => 'characters#destroy', :as => :character_destroy # Equipment @@ -49,7 +49,7 @@ PlanCharacters::Application.routes.draw do post '/equipment/new', :to => 'equipment#create', :as => :equipment_create_process get '/equipment/:id', :to => 'equipment#show', :as => :equipment get '/equipment/:id/edit', :to => 'equipment#edit', :as => :equipment_edit - put '/equipment/:id', :to => 'equipment#update', :as => :equipment_edit_process + patch '/equipment/:id', :to => 'equipment#update', :as => :equipment_edit_process delete '/equipment/:id', :to => 'equipment#destroy', :as => :equipment_destroy # Languages @@ -59,7 +59,7 @@ PlanCharacters::Application.routes.draw do post '/language/new', :to => 'languages#create', :as => :language_create_process get '/language/:id', :to => 'languages#show', :as => :language get '/language/:id/edit', :to => 'languages#edit', :as => :language_edit - put '/language/:id', :to => 'languages#update', :as => :language_edit_process + patch '/language/:id', :to => 'languages#update', :as => :language_edit_process delete '/language/:id', :to => 'languages#destroy', :as => :language_destroy # Locations @@ -70,7 +70,7 @@ PlanCharacters::Application.routes.draw do get '/location/new/:type_of', :to => 'locations#new', :as => :location_create_type get '/location/:id', :to => 'locations#show', :as => :location get '/location/:id/edit', :to => 'locations#edit', :as => :location_edit - put '/location/:id', :to => 'locations#update', :as => :location_edit_process + patch '/location/:id', :to => 'locations#update', :as => :location_edit_process delete '/location/:id', :to => 'locations#destroy', :as => :location_destroy # Magic @@ -81,7 +81,7 @@ PlanCharacters::Application.routes.draw do get '/magic/new/:type_of', :to => 'magic#new', :as => :magic_create_type get '/magic/:id', :to => 'magic#show', :as => :magic get '/magic/:id/edit', :to => 'magic#edit', :as => :magic_edit - put '/magic/:id', :to => 'magic#update', :as => :magic_edit_process + patch '/magic/:id', :to => 'magic#update', :as => :magic_edit_process delete '/magic/:id', :to => 'magic#destroy', :as => :magic_destroy # Universes @@ -90,7 +90,7 @@ PlanCharacters::Application.routes.draw do post '/universe/new', :to => 'universes#create', :as => :universe_create_process get '/universe/:id', :to => 'universes#show', :as => :universe get '/universe/:id/edit', :to => 'universes#edit', :as => :universe_edit - put '/universe/:id', :to => 'universes#update', :as => :universe_edit_process + patch '/universe/:id', :to => 'universes#update', :as => :universe_edit_process delete '/universe/:id', :to => 'universes#destroy', :as => :universe_destroy # Coming Soon TM diff --git a/test/controllers/application_controller_test.rb b/test/controllers/application_controller_test.rb new file mode 100644 index 00000000..81906ca0 --- /dev/null +++ b/test/controllers/application_controller_test.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class ApplicationControllerTest < ActionController::TestCase + +end \ No newline at end of file diff --git a/test/controllers/generator_controller_test.rb b/test/controllers/generator_controller_test.rb new file mode 100644 index 00000000..8c4f01de --- /dev/null +++ b/test/controllers/generator_controller_test.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class GeneratorControllerTest < ActionController::TestCase + +end \ No newline at end of file diff --git a/test/controllers/locations_controller_test.rb b/test/controllers/locations_controller_test.rb new file mode 100644 index 00000000..831fe51b --- /dev/null +++ b/test/controllers/locations_controller_test.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class LocationsControllerTest < ActionController::TestCase + +end \ No newline at end of file diff --git a/test/controllers/magic_controller_test.rb b/test/controllers/magic_controller_test.rb new file mode 100644 index 00000000..ac6f4486 --- /dev/null +++ b/test/controllers/magic_controller_test.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class MagicControllerTest < ActionController::TestCase + +end \ No newline at end of file diff --git a/test/controllers/main_controller_test.rb b/test/controllers/main_controller_test.rb new file mode 100644 index 00000000..464b7b14 --- /dev/null +++ b/test/controllers/main_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class MainControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end \ No newline at end of file diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 00000000..515511a5 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class SessionsControllerTest < ActionController::TestCase + +end \ No newline at end of file diff --git a/test/controllers/universes_controller_test.rb b/test/controllers/universes_controller_test.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb new file mode 100644 index 00000000..3b0897f2 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class UsersControllerTest < ActionController::TestCase + +end From 29c0e6727fd6335eeb654b70c225b9c8c613665d Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 3 Aug 2014 16:18:35 -0500 Subject: [PATCH 13/33] Set up Capybara functional testing, and write our first functional test! --- Gemfile | 4 +++- Gemfile.lock | 20 ++++++++++++++++++++ test/integration/user_stories_test.rb | 14 ++++++++++++++ test/test_helper.rb | 6 ++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 test/integration/user_stories_test.rb diff --git a/Gemfile b/Gemfile index dd5be59d..e71e2633 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,7 @@ gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'therubyracer', platforms: :ruby gem 'bootplus-rails' - gem 'jquery-rails' + +gem 'capybara' +gem 'selenium-webdriver' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index d451aae9..7b3841d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,6 +33,14 @@ GEM nokogiri (>= 1.4.4) bootplus-rails (1.0.0) builder (3.2.2) + capybara (2.4.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + childprocess (0.5.3) + ffi (~> 1.0, >= 1.0.11) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.4) @@ -47,6 +55,7 @@ GEM commonjs (0.2.7) erubis (2.7.0) execjs (2.2.1) + ffi (1.9.3) hike (1.2.3) i18n (0.6.11) jquery-rails (3.1.1) @@ -95,12 +104,18 @@ GEM rake (10.3.2) ref (1.0.5) rmagick (2.13.2) + rubyzip (1.1.6) sass (3.2.19) sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0) + selenium-webdriver (2.42.0) + childprocess (>= 0.5.0) + multi_json (~> 1.0) + rubyzip (~> 1.0) + websocket (~> 1.0.4) sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) @@ -125,6 +140,9 @@ GEM uglifier (2.5.1) execjs (>= 0.3.0) json (>= 1.8.0) + websocket (1.0.7) + xpath (2.0.0) + nokogiri (~> 1.3) PLATFORMS ruby @@ -132,6 +150,7 @@ PLATFORMS DEPENDENCIES aws-sdk (~> 1.50) bootplus-rails + capybara coffee-rails (~> 4.0.0) jquery-rails less-rails @@ -140,6 +159,7 @@ DEPENDENCIES rails (= 4.1.0) rmagick sass-rails (~> 4.0.3) + selenium-webdriver sqlite3 therubyracer uglifier (>= 1.3.0) diff --git a/test/integration/user_stories_test.rb b/test/integration/user_stories_test.rb new file mode 100644 index 00000000..c6075d79 --- /dev/null +++ b/test/integration/user_stories_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class UserStoriesTest < ActionDispatch::IntegrationTest + test 'creating a new user' do + visit homepage_path + click_on 'Register' + fill_in 'Name', :with => 'tester' + fill_in 'Email', :with => 'test@example.com' + fill_in 'Password', :with => 'password' + click_on 'Create User' + + assert_equal dashboard_path, current_path, 'New user was not redirected to their dashboard after creating an account' + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index bdb166a2..fa1a1383 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'capybara/rails' class ActiveSupport::TestCase fixtures :all @@ -9,3 +10,8 @@ class ActiveSupport::TestCase session[:user] = users(user_fixture).id end end + +class ActionDispatch::IntegrationTest + # Make the Capybara DSL available in all integration tests + include Capybara::DSL +end \ No newline at end of file From 9ade889a35163967513fa063d4e1d2bb95d337de Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 3 Aug 2014 22:25:58 -0500 Subject: [PATCH 14/33] Change Mongo reference to ActiveRecord reference --- app/views/layouts/_session_protection.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_session_protection.html.erb b/app/views/layouts/_session_protection.html.erb index d962cd88..c06a1175 100644 --- a/app/views/layouts/_session_protection.html.erb +++ b/app/views/layouts/_session_protection.html.erb @@ -2,7 +2,7 @@ # Destroy old sessions if a user has been deleted begin User.find(session[:user]) if session[:user] - rescue Mongoid::Errors::DocumentNotFound + rescue ActiveRecord::RecordNotFound session = {} %> diff --git a/app/views/layouts/_future_navbar.html b/app/views/layouts/_future_navbar.html deleted file mode 100644 index df85578d..00000000 --- a/app/views/layouts/_future_navbar.html +++ /dev/null @@ -1,78 +0,0 @@ - diff --git a/app/views/layouts/_login_box.html.erb b/app/views/layouts/_login_box.html.erb index 46cefeb0..8a1712db 100644 --- a/app/views/layouts/_login_box.html.erb +++ b/app/views/layouts/_login_box.html.erb @@ -1,27 +1,20 @@ - +<% if session[:user] %> + Logged in as + + <%= User.find(session[:user]).name %> + + + +<% else %> + +<% end %> diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index 31aaf30e..e985dea3 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -1,29 +1,78 @@ - + \ No newline at end of file diff --git a/app/views/layouts/_notices.html.erb b/app/views/layouts/_notices.html.erb new file mode 100644 index 00000000..d8872f0b --- /dev/null +++ b/app/views/layouts/_notices.html.erb @@ -0,0 +1,15 @@ +<% if flash[:notice] %> +
+
+ <%= flash[:notice] %> +
+
+<% end %> + +<% if flash[:alert] %> +
+
+ <%= flash[:alert] %> +
+
+<% end %> diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index b6df5d89..ac43e9a2 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -1,60 +1,34 @@ -<% if flash[:notice] %> -
-
-
- <%= flash[:notice] %> -
-
-
-<% end %> +<% if session[:user] %> -<% if flash[:alert] %> -
-
-
- <%= flash[:alert] %> -
-
-
-<% end %> - -<% if session[:anon_user] and session[:user] and User.find(session[:user]).content_count > 0 && !current_page?(account_path) %> -
-
Anonymous accounts
-
- You are currently using an anonymous account. In order to save the brilliant things you have created with it, please click here to give yourself a username and password. -
-
-
-<% end %> - -<% unless session[:user] %> +<% else %>
-

Get started instantly

+

Get started instantly

Nobody likes creating accounts just to try things out. You can get started making things immediately and create your account later if you want.
-

- If you jump right in to creating things, an account will be created for you. As you flesh out characters and worlds, your ideas will be safe and sound under this account, which does not ever expire unless you delete it yourself. -

-

- At any time, you can change the account's login information, so if you make some good progress you can just create an account and tada! all of your ideas are private to your new account, always there for you. -

-

- - Collapse card - -

+
+
+

+ If you jump right in to creating things, an account will be created for you. As you flesh out characters and worlds, your ideas will be safe and sound under this account, which does not ever expire unless you delete it yourself. +

+

+ At any time, you can change the account's login information, so if you make some good progress you can just create an account and tada! all of your ideas are private to your new account, always there for you. +

+

+ + Collapse card + +

+
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 56481aee..7e720860 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,27 +7,28 @@ <%= csrf_meta_tags %> <%= render 'layouts/session_protection' %> - <%= render 'layouts/bootstrap_includes' %> <%= render 'layouts/navbar' %> +<%= render 'layouts/anon_notice' %> <%= render 'layouts/noscript_notice' %> -
+
+ <%= render 'layouts/notices' %>
-
- <%= yield %> +
+ <%= yield %>
-
+
<%= render 'layouts/sidebar' %>
-