Merge pull request #410 from drusepth/sqlrails4

Merge SQLite + Rails 4 into master!
This commit is contained in:
Andrew Brown 2015-03-16 02:26:17 -05:00
commit bbdf921dcb
110 changed files with 1326 additions and 764 deletions

1
.coveralls.yml Normal file
View File

@ -0,0 +1 @@
service_name: travis-ci

3
.gitignore vendored
View File

@ -14,6 +14,9 @@
/log/*.log
/tmp
# Ignore generated coverage folder
/coverage
# Ignore assets
/public/assets

View File

@ -1,13 +1,6 @@
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.1
before_script:
- cp config/database.yml.travis config/database.yml
- psql -c 'create database travis_ci_test;' -U postgres

62
Gemfile
View File

@ -1,53 +1,21 @@
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'
gem 'aws-sdk', '~> 1.50'
gem 'pg'
# 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'
gem 'capybara'
gem 'selenium-webdriver'
gem 'coveralls', require: false

View File

@ -1,70 +1,71 @@
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)
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)
aws-sdk (1.50.0)
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)
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.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)
coveralls (0.7.1)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
docile (1.1.5)
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)
ffi (1.9.3)
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)
@ -73,103 +74,116 @@ GEM
less-rails (2.4.2)
actionpack (>= 3.1)
less (~> 2.4.0)
less-rails-fontawesome (0.8.0)
less-rails (~> 2.4.2)
libv8 (3.16.14.3)
mail (2.5.4)
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)
mini_portile (0.6.0)
minitest (5.4.0)
multi_json (1.10.1)
netrc (0.8.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
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
pg (0.17.1)
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)
rest-client (1.7.2)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
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)
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)
simplecov (0.9.1)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.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)
term-ansicolor (1.3.0)
tins (~> 1.0)
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)
tins (1.3.3)
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)
websocket (1.0.7)
xpath (2.0.0)
nokogiri (~> 1.3)
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
aws-sdk (~> 1.50)
bootplus-rails
capybara
coffee-rails (~> 4.0.0)
coveralls
jquery-rails
less-rails
mongo (= 1.6.0)
mongoid
mongoid-paperclip
rails (= 3.2.13)
less-rails-fontawesome
paperclip (~> 4.2.0)
pg
rails (= 4.1.0)
rmagick
sass-rails (~> 3.2.3)
therubyracer (~> 0.12.1)
uglifier (>= 1.0.3)
sass-rails (~> 4.0.3)
selenium-webdriver
sqlite3
therubyracer
uglifier (>= 1.3.0)

View File

@ -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

View File

@ -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

View File

@ -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/

View File

@ -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/

View File

@ -56,7 +56,7 @@ class CharactersController < ApplicationController
# POST /characters
# POST /characters.json
def create
@character = Character.new(params[:character])
@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
@ -96,12 +96,25 @@ 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 }
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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -36,10 +35,16 @@ class SessionsController < ApplicationController
# GET /logout
def destroy
session.delete(:user)
session.delete(:anon_user)
respond_to do |format|
format.html { redirect_to homepage_path, notice: 'Logged out!' }
format.json { head :no_content }
end
end
private
def session_params
params.require(:session).permit(:username, :password)
end
end

View File

@ -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

View File

@ -20,10 +20,10 @@ 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
session[:user] = @user.id
format.html { redirect_to homepage_path, notice: 'User was successfully created.' }
format.json { render json: @user, status: :created }
else
@ -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

View File

@ -0,0 +1,2 @@
module EquipmentHelper
end

View File

@ -0,0 +1,2 @@
module LanguagesHelper
end

View File

@ -1,71 +1,6 @@
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?
class Character < ActiveRecord::Base
#validates_presence_of :name
# 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
end

View File

@ -1,28 +1,6 @@
class Equipment
include Mongoid::Document
class Equipment < ActiveRecord::Base
#validates_presence_of :name
# 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
end

View File

@ -1,23 +1,6 @@
class Language
include Mongoid::Document
class Language < ActiveRecord::Base
#validates_presence_of :name
# 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
end

View File

@ -1,50 +1,8 @@
class Location
include Mongoid::Document
include Mongoid::Paperclip
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
# 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
end

View File

@ -1,32 +1,6 @@
class Magic
include Mongoid::Document
class Magic < ActiveRecord::Base
#validates_presence_of :name
# 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
end

View File

@ -1,7 +1,3 @@
class Session
include Mongoid::Document
field :username, :type => String
field :password, :type => String
class Session < ActiveRecord::Base
validates_presence_of :username, :password
end

View File

@ -1,22 +1,13 @@
class Universe
include Mongoid::Document
# General
field :name, :type => String
field :description, :type => String
class Universe < ActiveRecord::Base
#validates_presence_of :name
# 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
has_many :characters
has_many :equipment
has_many :languages
has_many :locations
has_many :magics
def content_count
[
characters.length,
@ -26,30 +17,4 @@ class Universe
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
end

View File

@ -1,18 +1,20 @@
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
class User < ActiveRecord::Base
validates_presence_of :name, :password, :email
before_save :hash_password
has_many :characters
has_many :equipment
has_many :languages
has_many :locations
has_many :magics
has_many :universes
def hash_password
require 'digest'
self.password = Digest::MD5.hexdigest(self.name + "'s password IS... " + self.password + " (lol!)")
end
def content
{
:characters => characters,
@ -23,7 +25,7 @@ class User
:universes => universes
}
end
def content_count
[
characters.length,
@ -34,29 +36,4 @@ class User
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
end

View File

@ -7,7 +7,7 @@
<div class="card-body">
<p>
<strong>
<% if character.role.length > 0 %>
<% if character.role.present? %>
<%= character.role %><% if character.age.length > 0 %>, <%= character.age %><% end %>
<% end %>
</strong>

View File

@ -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 = {}
%>
<script type="text/javascript">

View File

@ -1,23 +1,24 @@
<%= form_for @session, :url => login_path, :html => { :class => 'form-horizontal' } do |f| %>
<div class="control-group">
<%= f.label :username, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :username, :class => 'text_field' %>
<div class="card-body">
<div class="control-group">
<%= f.label :username, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :username, :class => 'text_field' %>
</div>
</div>
</div>
<div class="control-group">
<%= f.label :password, :class => 'control-label' %>
<div class="controls">
<%= f.password_field :password, :class => 'text_field' %>
<div class="control-group">
<%= f.label :password, :class => 'control-label' %>
<div class="controls">
<%= f.password_field :password, :class => 'text_field' %>
</div>
</div>
</div>
</div>
<div class="card-comments"> <!-- dear god what have I done -->
<div class="form-actions">
<%= f.submit 'Log in', :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
homepage_path, :class => 'btn' %>
<div class="card-comments">
<div class="form-actions" id="session-actions">
<%= f.submit 'Log in', :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")), homepage_path, :class => 'btn' %>
</div>
</div>
<% end %>

View File

@ -6,8 +6,6 @@
<li><a href="/register">Sign up</a></li>
<li><a href="/be-anonymous">Be Anonymous</a></li>
</ul>
<div class="card-body">
<%- model_class = @session.class -%>
<%= render :partial => 'form' %>
</div>
<%= render :partial => 'form' %>
</div>

View File

@ -1,48 +1,49 @@
<%= form_for @user, :url => signup_process_path, :html => { :class => 'form-horizontal' } do |f| %>
<% if @user.errors.messages.length > 0 %>
<div class="alert">
<strong>Oops!</strong> There was a problem. See the high-tech bug report below and please try again!<br />
<ul>
<% @user.errors.messages.keys.each do |key| %>
<li><%= key.capitalize %>: <%= @user.errors.messages[key] %></li>
<div class="card-body">
<% if @user.errors.messages.length > 0 %>
<div class="alert">
<strong>Oops!</strong> There was a problem. See the high-tech bug report below and please try again!<br />
<ul>
<% @user.errors.messages.keys.each do |key| %>
<li><%= key.capitalize %>: <%= @user.errors.messages[key] %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="control-group">
<%= f.label :name, :class => 'control-label' %>
<div class="controls">
<% if session[:anon_user] %>
<%= f.text_field :name, :class => 'text_field', :value => '' %>
<% else %>
<%= f.text_field :name, :class => 'text_field' %>
<% end %>
</ul>
<span class="help-inline muted">This is the username you will log in with. Spaces are allowed.</span>
</div>
</div>
<% end %>
<div class="control-group">
<%= f.label :name, :class => 'control-label' %>
<div class="controls">
<% if session[:anon_user] %>
<%= f.text_field :name, :class => 'text_field', :value => '' %>
<% else %>
<%= f.text_field :name, :class => 'text_field' %>
<% end %>
<span class="help-inline muted">This is the username you will log in with. Spaces are allowed.</span>
<div class="control-group">
<%= f.label :email, :class => 'control-label' %>
<div class="controls">
<% if session[:anon_user] %>
<%= f.text_field :email, :class => 'text_field', :value => '' %>
<% else %>
<%= f.text_field :email, :class => 'text_field' %>
<% end %>
</div>
</div>
</div>
<div class="control-group">
<%= f.label :email, :class => 'control-label' %>
<div class="controls">
<% if session[:anon_user] %>
<%= f.text_field :email, :class => 'text_field', :value => '' %>
<% else %>
<%= f.text_field :email, :class => 'text_field' %>
<% end %>
<div class="control-group">
<%= f.label :password, :class => 'control-label' %>
<div class="controls">
<%= f.password_field :password, :class => 'text_field' %>
</div>
</div>
</div>
<div class="control-group">
<%= f.label :password, :class => 'control-label' %>
<div class="controls">
<%= f.password_field :password, :class => 'text_field' %>
</div>
</div>
</div>
<div class="card-comments">
</div>
<div class="card-comments">
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
homepage_path, :class => 'btn' %>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")), homepage_path, :class => 'btn' %>
</div>
</div>
<% end %>

3
bin/bundle Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

8
bin/rails Executable file
View File

@ -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'

8
bin/rake Executable file
View File

@ -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

18
bin/spring Executable file
View File

@ -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

View File

@ -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

View File

@ -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'])

25
config/database.yml Normal file
View File

@ -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

View File

@ -0,0 +1,9 @@
##
# Following Travis's recommendation on maintaing a separate Travis test database:
#
# http://docs.travis-ci.com/user/using-postgresql/
test:
adapter: postgresql
database: travis_ci_test
username: postgres

View File

@ -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!

View File

@ -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

View File

@ -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
@ -7,12 +7,14 @@ PlanCharacters::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
# 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 +22,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 +32,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 +76,6 @@ PlanCharacters::Application.configure do
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

View File

@ -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
@ -10,6 +10,7 @@ PlanCharacters::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

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -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]

View File

@ -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'] %>

View File

@ -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

22
config/secrets.yml Normal file
View File

@ -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"] %>

View File

@ -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

155
db/schema.rb Normal file
View File

@ -0,0 +1,155 @@
# 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.text "name"
t.text "role"
t.text "gender"
t.text "age"
t.text "height"
t.text "weight"
t.text "race"
t.text "haircolor"
t.text "hairstyle"
t.text "facialhair"
t.text "eyecolor"
t.text "skintone"
t.text "bodytype"
t.text "identmarks"
t.text "bestfriend"
t.text "religion"
t.text "politics"
t.text "prejudices"
t.text "occupation"
t.text "mannerisms"
t.text "birthday"
t.text "birthplace"
t.text "education"
t.text "fave_color"
t.text "fave_food"
t.text "fave_possession"
t.text "fave_weapon"
t.text "fave_animal"
t.text "father"
t.text "mother"
t.text "spouse"
t.text "siblings"
t.text "archenemy"
t.integer "user_id"
t.integer "universe_id"
t.text "notes"
t.text "private_notes"
t.text "pets"
t.text "background"
end
create_table "equipment", force: true do |t|
t.text "description"
t.text "equip_type"
t.text "made_by"
t.text "magic"
t.text "materials"
t.text "name"
t.text "original_owner"
t.text "weight"
t.integer "user_id"
t.integer "universe_id"
t.text "current_owner"
t.text "notes"
t.text "private_notes"
t.text "year_made"
end
create_table "languages", force: true do |t|
t.text "name"
t.text "words"
t.text "established_year"
t.text "established_location"
t.text "characters"
t.text "locations"
t.text "notes"
t.integer "user_id"
t.integer "universe_id"
end
create_table "locations", force: true do |t|
t.text "name"
t.text "type_of"
t.text "located_at"
t.text "population"
t.text "language"
t.text "currency"
t.text "motto"
t.text "capital"
t.text "largest_city"
t.text "notable_cities"
t.text "area"
t.text "crops"
t.text "established_year"
t.text "notable_wars"
t.text "description"
t.integer "universe_id"
t.integer "user_id"
t.text "notes"
t.text "private_notes"
t.text "map_file_name"
t.text "map_content_size"
t.integer "map_file_size"
t.integer "map_updated_at"
end
create_table "magics", force: true do |t|
t.text "name"
t.text "type_of"
t.text "manifestation"
t.text "symptoms"
t.text "element"
t.text "diety"
t.text "harmfulness"
t.text "helpfulness"
t.text "neutralness"
t.text "resource"
t.text "skill_level"
t.text "limitations"
t.integer "user_id"
t.text "notes"
t.text "private_notes"
t.integer "universe_id"
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.text "name"
t.text "description"
t.text "history"
t.text "notes"
t.text "private_notes"
t.text "privacy"
t.integer "user_id"
end
create_table "users", force: true do |t|
t.text "name"
t.text "email"
t.text "password"
end
end

View File

@ -1,7 +0,0 @@
namespace :db do
namespace :test do
task :prepare do
# Stub out for MongoDB
end
end
end

View File

@ -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'

View File

@ -0,0 +1,5 @@
require 'test_helper'
class ApplicationControllerTest < ActionController::TestCase
end

View File

@ -2,14 +2,10 @@ 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
@user = users(:one)
@universe = universes(:one)
log_in_user(:one)
end
test "should get index" do
@ -25,27 +21,27 @@ class CharactersControllerTest < ActionController::TestCase
test "should create character" do
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))
end
test "should show character" do
@character.save
get :show, id: @character
@character = characters(:one)
get :show, id: @character.id
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)
@character = characters(:one)
get :edit, id: @character.id
assert_response :success
end
test "should update character" do
@character.save
@character = characters(:one)
put :update, id: @character, character: { age: @character.age, name: @character.name, universe: @universe }
assert_response 302
@ -53,15 +49,10 @@ class CharactersControllerTest < ActionController::TestCase
end
test "should destroy character" do
@character.save
assert_difference('Character.count', -1) do
delete :destroy, id: @character
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

View File

@ -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

View File

@ -1,7 +1,5 @@
require 'test_helper'
class GeneratorControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
end

View File

@ -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

View File

@ -0,0 +1,5 @@
require 'test_helper'
class LocationsControllerTest < ActionController::TestCase
end

View File

@ -0,0 +1,5 @@
require 'test_helper'
class MagicControllerTest < ActionController::TestCase
end

View File

@ -6,4 +6,4 @@ class MainControllerTest < ActionController::TestCase
assert_response :success
end
end
end

View File

@ -0,0 +1,5 @@
require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
end

View File

@ -1,4 +1,5 @@
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
end

View File

@ -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

0
test/fixtures/.keep vendored Normal file
View File

5
test/fixtures/characters.yml vendored Normal file
View File

@ -0,0 +1,5 @@
one:
name: Test
age: Test
user: one
universe: one

4
test/fixtures/equipment.yml vendored Normal file
View File

@ -0,0 +1,4 @@
one:
name: Test
user: one
universe: one

4
test/fixtures/languages.yml vendored Normal file
View File

@ -0,0 +1,4 @@
one:
name: Test
user: one
universe: one

4
test/fixtures/locations.yml vendored Normal file
View File

@ -0,0 +1,4 @@
one:
name: Test
user: one
universe: one

4
test/fixtures/magics.yml vendored Normal file
View File

@ -0,0 +1,4 @@
one:
name: Test
user: one
universe: one

3
test/fixtures/sessions.yml vendored Normal file
View File

@ -0,0 +1,3 @@
one:
username: TestUser
password: TestPassword

4
test/fixtures/universes.yml vendored Normal file
View File

@ -0,0 +1,4 @@
one:
name: Test
user: one
privacy: public

6
test/fixtures/users.yml vendored Normal file
View File

@ -0,0 +1,6 @@
<% require 'digest' %>
one:
name: TestUser
email: TestEmail
password: <%= Digest::MD5.hexdigest("TestUser's password IS... TestPassword (lol!)") %> # = 918ce1f12a9d36f7b6e28f179188a004

View File

@ -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

0
test/helpers/.keep Normal file
View File

View File

@ -0,0 +1,4 @@
require 'test_helper'
class EquipmentHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class LanguagesHelperTest < ActionView::TestCase
end

0
test/integration/.keep Normal file
View File

View File

@ -0,0 +1,32 @@
require 'test_helper'
class UserStoriesTest < ActionDispatch::IntegrationTest
fixtures :users
test 'creating a new user ends at the new user\'s dashboard' do
register_as 'tester', 'test@example.com', 'password'
assert_equal dashboard_path, current_path, 'New user was not directed to their dashboard after creating an account'
end
test 'logging in as an existing user goes to the users dashboard' do
log_in_as 'TestUser', 'TestPassword'
assert_equal dashboard_path, current_path, 'Existing user was not directed to their dashboard after logging in'
end
test 'logging in anonymously goes into an empty dashboard' do
log_in_as_anon
assert_equal dashboard_path, current_path, 'Anonymous user was not directed to their dashboard after logging in'
end
##
# Regression test for bug #366
test 'Anonymous flag is reset on user logins' do
log_in_as_anon
log_out
log_in_as 'TestUser', 'TestPassword'
refute page.has_content?('You are currently using an anonymous account'), 'Logged-in user was told they were using an anonymous account, regression of #366'
end
end

0
test/mailers/.keep Normal file
View File

0
test/models/.keep Normal file
View File

View File

@ -0,0 +1,18 @@
require 'test_helper'
class CharacterTest < ActiveSupport::TestCase
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 "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

View File

@ -0,0 +1,19 @@
require 'test_helper'
class EquipmentTest < ActiveSupport::TestCase
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
test "equipement belongs to user and universe" do
assert_equal users(:one), equipment(:one).user
assert_equal universes(:one), equipment(:one).universe
end
end

View File

@ -0,0 +1,19 @@
require 'test_helper'
class LanguageTest < ActiveSupport::TestCase
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
test "language belongs to user and universe" do
assert_equal users(:one), languages(:one).user
assert_equal universes(:one), languages(:one).universe
end
end

View File

@ -0,0 +1,18 @@
require 'test_helper'
class LocationTest < ActiveSupport::TestCase
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 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

15
test/models/magic_test.rb Normal file
View File

@ -0,0 +1,15 @@
require 'test_helper'
class MagicTest < ActiveSupport::TestCase
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 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

View File

@ -0,0 +1,22 @@
require 'test_helper'
class SessionTest < ActiveSupport::TestCase
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

View File

@ -0,0 +1,20 @@
require 'test_helper'
class UniverseTest < ActiveSupport::TestCase
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 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, "Universe didn't count its content properly"
end
end

44
test/models/user_test.rb Normal file
View File

@ -0,0 +1,44 @@
require 'test_helper'
class UserTest < ActiveSupport::TestCase
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), "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, "User didn't count its content properly"
end
end

Some files were not shown because too many files have changed in this diff Show More