mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
Merge branch 'master' of https://github.com/drusepth/Indent
This commit is contained in:
commit
0a8edfd2c7
17
.rubocop.yml
Normal file
17
.rubocop.yml
Normal file
@ -0,0 +1,17 @@
|
||||
AllCops:
|
||||
RunRailsCops: true
|
||||
Exclude:
|
||||
- "bin/**/*"
|
||||
- "db/migrate/**/*"
|
||||
- "db/schema.rb"
|
||||
- "vendor/**/*"
|
||||
- "gemfiles/vendor/**/*"
|
||||
|
||||
Metrics/LineLength:
|
||||
Max: 90
|
||||
|
||||
Metrics/AbcSize:
|
||||
Max: 20
|
||||
|
||||
Metrics/MethodLength:
|
||||
Max: 17
|
||||
@ -30,4 +30,6 @@ before_script:
|
||||
- cp config/database.yml.travis config/database.yml
|
||||
- psql -c 'create database travis_ci_test;' -U postgres
|
||||
|
||||
script: "bundle exec rake test:$TEST_SUITE"
|
||||
script:
|
||||
- bundle exec rake test:$TEST_SUITE
|
||||
- bundle exec rubocop
|
||||
|
||||
7
Gemfile
7
Gemfile
@ -4,7 +4,7 @@ source 'https://rubygems.org'
|
||||
|
||||
gem 'rails', '4.1.0'
|
||||
gem 'jquery-rails'
|
||||
gem 'sass-rails', '~> 4.0.3', :require => 'sass'
|
||||
gem 'sass-rails', '~> 4.0.3', require: 'sass'
|
||||
gem 'coffee-rails', '~> 4.0.0'
|
||||
gem 'paperclip', '~> 4.2.0'
|
||||
gem 'rmagick'
|
||||
@ -25,8 +25,9 @@ end
|
||||
group :test, :development do
|
||||
gem 'capybara'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'coveralls', :require => false
|
||||
gem 'simplecov', :require => false
|
||||
gem 'coveralls', require: false
|
||||
gem 'simplecov', require: false
|
||||
gem 'rubocop', require: false
|
||||
gem 'sqlite3'
|
||||
gem 'tzinfo-data' # addresses a bug when working on Windows
|
||||
end
|
||||
|
||||
15
Gemfile.lock
15
Gemfile.lock
@ -28,6 +28,9 @@ GEM
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (5.0.1.20140414130214)
|
||||
ast (2.0.0)
|
||||
astrolabe (1.3.0)
|
||||
parser (>= 2.2.0.pre.3, < 3.0)
|
||||
aws-sdk (1.63.0)
|
||||
aws-sdk-v1 (= 1.63.0)
|
||||
aws-sdk-v1 (1.63.0)
|
||||
@ -97,9 +100,12 @@ GEM
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.3)
|
||||
mime-types
|
||||
parser (2.2.0.3)
|
||||
ast (>= 1.1, < 3.0)
|
||||
pg (0.18.1)
|
||||
pg (0.18.1-x86-mingw32)
|
||||
polyglot (0.3.5)
|
||||
powerpack (0.1.0)
|
||||
rack (1.5.2)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
@ -118,6 +124,7 @@ GEM
|
||||
activesupport (= 4.1.0)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rainbow (2.0.0)
|
||||
rake (10.4.2)
|
||||
ref (1.0.5)
|
||||
rest-client (1.7.3)
|
||||
@ -128,6 +135,13 @@ GEM
|
||||
mime-types (>= 1.16, < 3.0)
|
||||
netrc (~> 0.7)
|
||||
rmagick (2.13.4)
|
||||
rubocop (0.29.1)
|
||||
astrolabe (~> 1.3)
|
||||
parser (>= 2.2.0.1, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 1.99.1, < 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
ruby-progressbar (1.7.1)
|
||||
rubyzip (1.1.7)
|
||||
sass (3.2.19)
|
||||
sass-rails (4.0.5)
|
||||
@ -196,6 +210,7 @@ DEPENDENCIES
|
||||
pg
|
||||
rails (= 4.1.0)
|
||||
rmagick
|
||||
rubocop
|
||||
sass-rails (~> 4.0.3)
|
||||
selenium-webdriver
|
||||
simplecov
|
||||
|
||||
3
Rakefile
3
Rakefile
@ -1,5 +1,6 @@
|
||||
# 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.
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically
|
||||
# be available to Rake.
|
||||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
|
||||
|
||||
@ -1,160 +1,143 @@
|
||||
# Superclass for all model controllers
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
helper :html
|
||||
helper :my_content
|
||||
|
||||
|
||||
helper_method :nl2br
|
||||
|
||||
|
||||
helper_method :universe_filter
|
||||
|
||||
# Rails changed cookie format in rails 4, so log out all old users so they get the new version
|
||||
# Rails changed cookie format in rails 4, so log out all old users so that
|
||||
# they get the new version
|
||||
rescue_from JSON::ParserError, with: :force_user_logout
|
||||
def force_user_logout
|
||||
reset_session
|
||||
redirect_to login_path
|
||||
end
|
||||
|
||||
|
||||
# View Helpers
|
||||
def nl2br(string)
|
||||
#simple_format string
|
||||
string.gsub("\n\r","<br>").gsub("\r", "").gsub("\n", "<br />").html_safe
|
||||
# simple_format string
|
||||
string.gsub("\n\r", '<br>').gsub("\r", '').gsub("\n", '<br />').html_safe
|
||||
end
|
||||
|
||||
def universe_filter
|
||||
universes = Universe.where(user_id: session[:user])
|
||||
return if universes.length == 0
|
||||
|
||||
unless @selected_universe_filter
|
||||
@selected_universe_filter = 'All universes'
|
||||
end
|
||||
|
||||
html = '<span class="btn-group input-append help-inline">'
|
||||
html << '<button class="btn dropdown-toggle" data-toggle="dropdown">'
|
||||
html << '<i class="icon-globe"></i> ' + @selected_universe_filter + ' '
|
||||
html << '<span class="caret"></span>'
|
||||
html << '</button>'
|
||||
html << '<ul class="dropdown-menu dropdown-picker">'
|
||||
html << '<li><a href="/plan/characters">All universes</a></li>'
|
||||
universes.each do |i|
|
||||
html << '<li><a href="/plan/characters/from/' + i.name.strip + '">' + i.name + '</a></li>'
|
||||
end
|
||||
html << '</ul>'
|
||||
html << '</span>'
|
||||
|
||||
return html.html_safe
|
||||
def universe_filter
|
||||
return if Universe.where(user_id: session[:user]).length.zero?
|
||||
return if @selected_universe_filter
|
||||
@selected_universe_filter = t(:all_universes)
|
||||
end
|
||||
|
||||
|
||||
# Authentication
|
||||
def is_logged_in?
|
||||
def log_in(user)
|
||||
session[:user] = user.id
|
||||
end
|
||||
|
||||
def logged_in?
|
||||
session && session[:user]
|
||||
end
|
||||
|
||||
|
||||
def redirect_if_not_logged_in
|
||||
unless is_logged_in?
|
||||
redirect_to signup_path, :notice => "You must be logged in to do that!"
|
||||
end
|
||||
return if logged_in?
|
||||
redirect_to signup_path, notice: t(:must_be_logged_in)
|
||||
end
|
||||
|
||||
def create_anonymous_account_if_not_logged_in
|
||||
unless is_logged_in?
|
||||
id = rand(10000000).to_s + rand(10000000).to_s # lol
|
||||
@user = User.new(:name => 'Anonymous-' + id.to_s, :email => id.to_s + '@localhost', :password => id.to_s)
|
||||
return if logged_in?
|
||||
|
||||
if @user.save
|
||||
session[:user] = @user.id
|
||||
session[:anon_user] = true
|
||||
else
|
||||
create_anonymous_account_if_not_logged_in
|
||||
end
|
||||
@user = create_anonymous_user
|
||||
|
||||
if @user.save
|
||||
session[:user] = @user.id
|
||||
session[:anon_user] = true
|
||||
else
|
||||
# layman's collision detection
|
||||
create_anonymous_account_if_not_logged_in
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Require ownership
|
||||
|
||||
def require_ownership_of_character
|
||||
character = Character.find(params[:id])
|
||||
unless session[:user] and session[:user] == character.user.id
|
||||
redirect_to character_list_path, :notice => "You don't have permission to do that!"
|
||||
end
|
||||
redirect_if_not_owned Character.find(params[:id]), character_list_path
|
||||
end
|
||||
|
||||
|
||||
def require_ownership_of_equipment
|
||||
equipment = Equipment.find(params[:id])
|
||||
unless session[:user] and session[:user] == equipment.user.id
|
||||
redirect_to equipment_list_path, :notice => "You don't have permission to do that!"
|
||||
end
|
||||
redirect_if_not_owned Equipment.find(params[:id]), equipment_list_path
|
||||
end
|
||||
|
||||
|
||||
def require_ownership_of_language
|
||||
language = Language.find(params[:id])
|
||||
unless session[:user] and session[:user] == language.user.id
|
||||
redirect_to language_list_path, :notice => "You don't have permission to do that!"
|
||||
end
|
||||
redirect_if_not_owned Language.find(params[:id]), language_list_path
|
||||
end
|
||||
|
||||
|
||||
def require_ownership_of_location
|
||||
location = Location.find(params[:id])
|
||||
unless session[:user] and session[:user] == location.user.id
|
||||
redirect_to location_list_path, :notice => "You don't have permission to do that!"
|
||||
end
|
||||
redirect_if_not_owned Location.find(params[:id]), location_list_path
|
||||
end
|
||||
|
||||
|
||||
def require_ownership_of_magic
|
||||
magic = Magic.find(params[:id])
|
||||
unless session[:user] and session[:user] == magic.user.id
|
||||
redirect_to magic_list_path, :notice => "You don't have permission to do that!"
|
||||
end
|
||||
redirect_if_not_owned Magic.find(params[:id]), magic_list_path
|
||||
end
|
||||
|
||||
|
||||
def require_ownership_of_universe
|
||||
universe = Universe.find(params[:id])
|
||||
unless session[:user] and session[:user] == universe.user.id
|
||||
redirect_to universe_list_path, :notice => "You don't have permission to do that!"
|
||||
end
|
||||
redirect_if_not_owned Universe.find(params[:id]), universe_list_path
|
||||
end
|
||||
|
||||
# Hide, if private
|
||||
|
||||
def hide_private_universe
|
||||
universe = Universe.find(params[:id])
|
||||
unless (session[:user] and session[:user] == universe.user.id) or universe.privacy.downcase == 'public'
|
||||
redirect_to universe_list_path, :notice => "You don't have permission to view that!"
|
||||
end
|
||||
return if Universe.find(params[:id]).privacy.downcase == 'public'
|
||||
redirect_to universe_list_path, notice: t(:no_view_permission)
|
||||
end
|
||||
|
||||
def hide_private_character
|
||||
character = Character.find(params[:id])
|
||||
unless (session[:user] and session[:user] == character.user.id) or (character.universe and character.universe.privacy.downcase == 'public')
|
||||
redirect_to character_list_path, :notice => "You don't have permission to view that!"
|
||||
end
|
||||
redirect_if_private Character.find(params[:id]), character_list_path
|
||||
end
|
||||
|
||||
def hide_private_equipment
|
||||
equipment = Equipment.find(params[:id])
|
||||
unless (session[:user] and session[:user] == equipment.user.id) or (equipment.universe and equipment.universe.privacy.downcase == 'public')
|
||||
redirect_to equipment_list_path, :notice => "You don't have permission to view that!"
|
||||
end
|
||||
redirect_if_private Equipment.find(params[:id]), equipment_list_path
|
||||
end
|
||||
|
||||
def hide_private_language
|
||||
language = Language.find(params[:id])
|
||||
unless (session[:user] and session[:user] == language.user.id) or (language.universe and language.universe.privacy.downcase == 'public')
|
||||
redirect_to language_list_path, :notice => "You don't have permission to view that!"
|
||||
end
|
||||
redirect_if_private Language.find(params[:id]), language_list_path
|
||||
end
|
||||
|
||||
def hide_private_location
|
||||
location = Location.find(params[:id])
|
||||
unless (session[:user] and session[:user] == location.user.id) or (location.universe and location.universe.privacy.downcase == 'public')
|
||||
redirect_to location_list_path, :notice => "You don't have permission to view that!"
|
||||
end
|
||||
redirect_if_private Location.find(params[:id]), location_list_path
|
||||
end
|
||||
|
||||
def hide_private_magic
|
||||
magic = Magic.find(params[:id])
|
||||
unless (session[:user] and session[:user] == magic.user.id) or (magic.universe and magic.universe.privacy.downcase == 'public')
|
||||
redirect_to magic_list_path, :notice => "You don't have permission to view that!"
|
||||
end
|
||||
redirect_if_private Magic.find(params[:id]), magic_list_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_anonymous_user
|
||||
# TODO: guarantee anonymous id is random (or just let db assign it?)
|
||||
id = rand(10_000_000).to_s + rand(10_000_000).to_s # lol
|
||||
|
||||
User.new(
|
||||
name: 'Anonymous-' + id.to_s,
|
||||
email: id.to_s + '@localhost',
|
||||
password: id.to_s)
|
||||
end
|
||||
|
||||
def redirect_if_not_owned(object_to_check, redirect_path)
|
||||
return if owned_by_current_user? object_to_check
|
||||
redirect_to redirect_path, notice: t(:no_do_permission)
|
||||
end
|
||||
|
||||
def redirect_if_private(object_to_check, redirect_path)
|
||||
return if public? object_to_check
|
||||
redirect_to redirect_path, notice: t(:no_view_permission)
|
||||
end
|
||||
|
||||
def owned_by_current_user?(object)
|
||||
session[:user] && session[:user] == object.user.id
|
||||
end
|
||||
|
||||
def public?(object)
|
||||
(owned_by_current_user? object) || \
|
||||
(object.universe && object.universe.privacy.downcase == 'public')
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,24 +1,17 @@
|
||||
# Controller for the Character model
|
||||
class CharactersController < ApplicationController
|
||||
before_filter :create_anonymous_account_if_not_logged_in, :only => [:edit, :create, :update]
|
||||
before_filter :require_ownership_of_character, :only => [:update, :edit, :destroy]
|
||||
before_filter :hide_private_character, :only => [:show]
|
||||
before_action :create_anonymous_account_if_not_logged_in,
|
||||
only: [:edit, :create, :update]
|
||||
before_action :require_ownership_of_character,
|
||||
only: [:update, :edit, :destroy]
|
||||
before_action :hide_private_character, only: [:show]
|
||||
|
||||
# GET /characters
|
||||
# GET /characters.json
|
||||
def index
|
||||
@characters = Character.where(user_id: session[:user])
|
||||
|
||||
if @characters.length == 0
|
||||
@characters = []
|
||||
end
|
||||
|
||||
if params[:universe]
|
||||
@universe = Universe.where(user_id: session[:user]).where(name: params[:universe].strip).first
|
||||
@characters = @characters.where(universe_id: @universe.id) if @characters.length > 0
|
||||
@selected_universe_filter = @universe.name
|
||||
end
|
||||
|
||||
@characters = @characters.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
.order(:name).presence || []
|
||||
populate_universe_fields if params[:universe]
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -56,42 +49,38 @@ class CharactersController < ApplicationController
|
||||
# POST /characters
|
||||
# POST /characters.json
|
||||
def create
|
||||
@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
|
||||
@character = create_character_from_params
|
||||
|
||||
# rubocop:disable LineLength, AbcSize
|
||||
respond_to do |format|
|
||||
if @character.save
|
||||
format.html { redirect_to @character, notice: 'Character was successfully created.' }
|
||||
format.html { render_html_success t(:create_success, model_name: Character.model_name.human) }
|
||||
format.json { render json: @character, status: :created, location: @character }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @character.errors, status: :unprocessable_entity }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render_json_error_unprocessable }
|
||||
end
|
||||
end
|
||||
# rubocop:enable LineLength, AbcSize
|
||||
end
|
||||
|
||||
# PUT /characters/1
|
||||
# PUT /characters/1.json
|
||||
# rubocop:disable LineLength, AbcSize
|
||||
def update
|
||||
@character = Character.find(params[:id])
|
||||
|
||||
if params[:character][:universe].empty?
|
||||
params[:character][:universe] = nil
|
||||
else
|
||||
params[:character][:universe] = Universe.where(user_id: session[:user]).where(name: params[:character][:universe].strip).first
|
||||
end
|
||||
@character = update_character_from_params
|
||||
|
||||
respond_to do |format|
|
||||
if @character.update_attributes(character_params)
|
||||
format.html { redirect_to @character, notice: 'Character was successfully updated.' }
|
||||
format.html { render_html_success t(:update_success, model_name: Character.model_name.human) }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @character.errors, status: :unprocessable_entity }
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render_json_error_unprocessable }
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable LineLength, AbcSize
|
||||
|
||||
# DELETE /characters/1
|
||||
# DELETE /characters/1.json
|
||||
@ -103,18 +92,50 @@ 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
|
||||
|
||||
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
|
||||
|
||||
def populate_universe_fields
|
||||
@universe = Universe.where(user_id: session[:user],
|
||||
name: params[:universe].strip).first
|
||||
@characters =
|
||||
@characters.where(universe_id: @universe.id) if @characters.blank?
|
||||
@selected_universe_filter = @universe.name
|
||||
end
|
||||
|
||||
def universe_from_character_params
|
||||
Universe.where(user_id: session[:user],
|
||||
name: params[:character][:universe].strip).first.presence
|
||||
end
|
||||
|
||||
def create_character_from_params
|
||||
character = Character.create(character_params)
|
||||
character.user_id = session[:user]
|
||||
character.universe = universe_from_character_params
|
||||
character
|
||||
end
|
||||
|
||||
def update_character_from_params
|
||||
params[:character][:universe] = universe_from_character_params
|
||||
Character.find(params[:id])
|
||||
end
|
||||
|
||||
def render_json_error_unprocessable
|
||||
render json: @character.errors, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def render_html_success(notice)
|
||||
redirect_to @character, notice: notice
|
||||
end
|
||||
end
|
||||
|
||||
90
app/controllers/characters_generator_controller.rb
Normal file
90
app/controllers/characters_generator_controller.rb
Normal file
@ -0,0 +1,90 @@
|
||||
# Generates random Character values
|
||||
class CharactersGeneratorController < ApplicationController
|
||||
def age
|
||||
@upper_limit = 100
|
||||
@lower_limit = 2
|
||||
|
||||
render json: rand(@lower_limit...@upper_limit)
|
||||
end
|
||||
|
||||
def bodytype
|
||||
@possible_types = t(:body_types)
|
||||
|
||||
render json: @possible_types.sample
|
||||
end
|
||||
|
||||
def eyecolor
|
||||
@possible_colors = t(:eye_colors)
|
||||
|
||||
render json: @possible_colors.sample
|
||||
end
|
||||
|
||||
def facialhair
|
||||
@possible_styles = t(:facial_hair_styles)
|
||||
|
||||
render json: @possible_styles.sample
|
||||
end
|
||||
|
||||
def haircolor
|
||||
@possible_colors = t(:hair_colors)
|
||||
|
||||
render json: @possible_colors.sample
|
||||
end
|
||||
|
||||
def hairstyle
|
||||
@possible_styles = t(:hair_styles)
|
||||
|
||||
render json: @possible_styles.sample
|
||||
end
|
||||
|
||||
def height
|
||||
@upper_foot_limit = 6
|
||||
@lower_foot_limit = 2
|
||||
@upper_inch_limit = 11
|
||||
@lower_inch_limit = 0
|
||||
|
||||
render json: [
|
||||
rand(@lower_foot_limit...@upper_foot_limit), "'",
|
||||
rand(@lower_inch_limit...@upper_inch_limit), '"'
|
||||
].join
|
||||
end
|
||||
|
||||
def identifyingmark
|
||||
@possible_marks = t(:identifying_marks)
|
||||
@possible_locations = t(:identifying_mark_locations)
|
||||
|
||||
render json: [
|
||||
@possible_marks.sample, t(:on_the), @possible_locations.sample
|
||||
].join(' ') .capitalize
|
||||
end
|
||||
|
||||
def name
|
||||
@male_first_names = t(:male_first_names)
|
||||
@female_first_names = t(:female_first_names)
|
||||
@last_names = t(:last_names)
|
||||
|
||||
@all_first_names = [] + @male_first_names + @female_first_names
|
||||
@all_last_names = [] + @last_names
|
||||
|
||||
render json: [@all_first_names.sample, @all_last_names.sample].join(' ')
|
||||
end
|
||||
|
||||
def race
|
||||
@possible_races = t(:character_races)
|
||||
|
||||
render json: @possible_races.sample
|
||||
end
|
||||
|
||||
def skintone
|
||||
@possible_tones = t(:skin_tones)
|
||||
|
||||
render json: @possible_tones.sample
|
||||
end
|
||||
|
||||
def weight
|
||||
@upper_limit = 240
|
||||
@lower_limit = 80
|
||||
|
||||
render json: rand(@lower_limit...@upper_limit)
|
||||
end
|
||||
end
|
||||
@ -1,16 +1,17 @@
|
||||
# Controller for the Equipment model
|
||||
class EquipmentController < ApplicationController
|
||||
before_filter :create_anonymous_account_if_not_logged_in, :only => [:edit, :create, :update]
|
||||
before_filter :require_ownership_of_equipment, :only => [:update, :edit, :destroy]
|
||||
before_filter :hide_private_equipment, :only => [:show]
|
||||
before_action :create_anonymous_account_if_not_logged_in,
|
||||
only: [:edit, :create, :update]
|
||||
|
||||
before_action :require_ownership_of_equipment,
|
||||
only: [:update, :edit, :destroy]
|
||||
|
||||
before_action :hide_private_equipment, only: [:show]
|
||||
|
||||
def index
|
||||
@equipment = Equipment.where(user_id: session[:user])
|
||||
|
||||
if @equipment.size == 0
|
||||
@equipment = []
|
||||
end
|
||||
|
||||
@equipment = @equipment.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
@equipment = Equipment
|
||||
.where(user_id: session[:user])
|
||||
.order(:name).presence || []
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -41,39 +42,35 @@ class EquipmentController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@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
|
||||
@equipment = create_equipment_from_params
|
||||
|
||||
# rubocop:disable LineLength
|
||||
respond_to do |format|
|
||||
if @equipment.save
|
||||
format.html { redirect_to @equipment, notice: 'Equipment was successfully created.' }
|
||||
format.html { redirect_to @equipment, notice: t(:create_success, model_name: Equipment.model_name.human) }
|
||||
format.json { render json: @equipment, status: :created, location: @equipment }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @equipment.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
# rubocop:enable LineLength
|
||||
end
|
||||
|
||||
def update
|
||||
@equipment = Equipment.find(params[:id])
|
||||
|
||||
if params[:equipment][:universe].empty?
|
||||
params[:equipment][:universe] = nil
|
||||
else
|
||||
params[:equipment][:universe] = Universe.where(user_id: session[:user]).where(name: params[:equipment][:universe].strip).first
|
||||
end
|
||||
@equipment = update_equipment_from_params
|
||||
|
||||
# rubocop:disable LineLength
|
||||
respond_to do |format|
|
||||
if @equipment.update_attributes(equipment_params)
|
||||
format.html { redirect_to @equipment, notice: 'Equipment was successfully updated.' }
|
||||
format.html { redirect_to @equipment, notice: t(:update_success, model_name: Equipment.model_name.human) }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @equipment.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
# rubocop:enable LineLength
|
||||
end
|
||||
|
||||
def destroy
|
||||
@ -85,15 +82,48 @@ 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
|
||||
|
||||
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
|
||||
|
||||
def populate_universe_fields
|
||||
@universe = Universe.where(user_id: session[:user],
|
||||
name: params[:universe].strip).first
|
||||
@equipment =
|
||||
@equipment.where(universe_id: @universe.id) if @equipment.blank?
|
||||
end
|
||||
|
||||
def universe_from_equipment_params
|
||||
Equipment.where(user_id: session[:user],
|
||||
name: params[:equipment][:universe].strip).first.presence
|
||||
end
|
||||
|
||||
def create_equipment_from_params
|
||||
equipment = Equipment.create(equipment_params)
|
||||
equipment.user_id = session[:user]
|
||||
equipment.universe = universe_from_equipment_params
|
||||
equipment
|
||||
end
|
||||
|
||||
def update_equipment_from_params
|
||||
params[:equipment][:universe] = universe_from_equipment_params
|
||||
Equipment.find(params[:id])
|
||||
end
|
||||
|
||||
def render_json_error_unprocessable
|
||||
render json: @equipment.errors, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def render_html_success(notice)
|
||||
redirect_to @equipment, notice: notice
|
||||
end
|
||||
end
|
||||
|
||||
76
app/controllers/equipment_generator_controller.rb
Normal file
76
app/controllers/equipment_generator_controller.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# Generates random Equipment values
|
||||
class EquipmentGeneratorController < ApplicationController
|
||||
def armor
|
||||
# TODO: just make this an aggregate of armor, and
|
||||
# pick randomly from the different ones
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def armor_shield
|
||||
@shield_types = t(:shield_types)
|
||||
|
||||
render json: @shield_types.sample
|
||||
end
|
||||
|
||||
def weapon
|
||||
# TODO: just make this an aggregate, and
|
||||
# pick randomly from the different weapon generators
|
||||
@weapon_types = t(:weapon_types)
|
||||
|
||||
render json: @weapon_types.sample
|
||||
end
|
||||
|
||||
def weapon_axe
|
||||
@axe_types = t(:axe_types)
|
||||
|
||||
render json: @axe_types.sample
|
||||
end
|
||||
|
||||
def weapon_bow
|
||||
@bow_types = t(:bow_types)
|
||||
|
||||
render json: @bow_types.sample
|
||||
end
|
||||
|
||||
def weapon_club
|
||||
@club_types = t(:club_types)
|
||||
|
||||
render json: @club_types.sample
|
||||
end
|
||||
|
||||
def weapon_fist
|
||||
@fist_weapon_types = t(:fist_weapon_types)
|
||||
|
||||
render json: @fist_weapon_types.sample
|
||||
end
|
||||
|
||||
def weapon_flexible
|
||||
@flexible_types = t(:flexible_weapon_types)
|
||||
|
||||
render json: @flexible_types.sample
|
||||
end
|
||||
|
||||
def weapon_thrown
|
||||
@thrown_types = t(:thrown_weapon_types)
|
||||
|
||||
render json: @thrown_types.sample
|
||||
end
|
||||
|
||||
def weapon_polearm
|
||||
@polearm_types = t(:polearm_types)
|
||||
|
||||
render json: @polearm_types.sample
|
||||
end
|
||||
|
||||
def weapon_shortsword
|
||||
@shortsword_types = t(:shortsword_types)
|
||||
|
||||
render json: @shortsword_types.sample
|
||||
end
|
||||
|
||||
def weapon_sword
|
||||
@sword_types = t(:sword_types)
|
||||
|
||||
render json: @sword_types.sample
|
||||
end
|
||||
end
|
||||
@ -1,219 +0,0 @@
|
||||
class GeneratorController < ApplicationController
|
||||
|
||||
# Character
|
||||
|
||||
def character_age
|
||||
@upper_limit = 100
|
||||
@lower_limit = 2
|
||||
|
||||
render :json => rand(@upper_limit - @lower_limit + 1) + @lower_limit
|
||||
end
|
||||
|
||||
def character_bodytype
|
||||
@possible_types = ["Delicate", "Flat", "Fragile", "Lean", "Lightly muscled", "Small-shouldered", "Thin", "Athletic", "Hourglass", "Bodybuilder", "Rectangular", "Muscular", "Thick-skinned", "Big-boned", "Round physique", "Pear-shaped"]
|
||||
|
||||
render :json => @possible_types[rand(@possible_types.length)]
|
||||
end
|
||||
|
||||
def character_eyecolor
|
||||
@possible_colors = ["Amber", "Black", "Arctic blue", "Baby blue", "China blue", "Cornflower blue", "Crystal blue", "Denim blue", "Electric blue", "Indigo", "Sapphire blue", "Sky blue", "Champagne brown", "Chestnut brown", "Chocolate brown", "Golden brown", "Honey brown", "Topaz", "Charcoal grey", "Cloudy grey", "Steel grey", "Chartreuse", "Emerald green", "Forest green", "Grass green", "Jade green", "Leaf green", "Sea green", "Hazel", "Amethyst", "Hyacinth", "Ultramarine blue", "One green, one blue", "One blue, one brown", "One brown, one blue", "One brown, one green", "Light violet", "Dark violet"]
|
||||
|
||||
render :json => @possible_colors[rand(@possible_colors.length)]
|
||||
end
|
||||
|
||||
def character_facialhair
|
||||
@possible_styles = ["Beard, long", "Beard, short", "Chin curtain", "Chinstrap", "Fu Manchu, short", "Fu Manchu, long", "Goatee", "Handlebar mustache", "Horseshoe mustache", "Mustache", "Mutton chops, thin", "Mutton chops, thick", "Neckbeard", "Pencil mustache", "Shenandoah", "Sideburns", "Soul patch", "Light stubble", "Thick stubble", "Toothbrush mustache", "Van Dyke beard", "Patchy beard", "Patchy mustache"]
|
||||
|
||||
render :json => @possible_styles[rand(@possible_styles.length)]
|
||||
end
|
||||
|
||||
def character_haircolor
|
||||
@possible_colors = ["Blonde", "Black", "Brown", "Red", "Bald", "White", "Grey", "Balding", "Greying", "Bleached", "Blue", "Green", "Purple", "Orange", "Auburn", "Strawberry", "Chestnut", "Dirty Blonde", "Rainbow", "Black tips", "Jet black", "Raven black"]
|
||||
|
||||
render :json => @possible_colors[rand(@possible_colors.length)]
|
||||
end
|
||||
|
||||
def character_hairstyle
|
||||
@possible_styles = ["Afro", "Bald", "Balding", "Bob cut", "Bowl cut", "Bouffant", "Braided", "Bun", "Butch", "Buzz cut", "Chignon", "Chonmage", "Comb over", "Cornrows", "Crew cut", "Dreadlocks", "Emo", "Fauxhawk", "Feathered", "Flattop", "Fringe", "Liberty Spikes", "Long hair, straight", "Long hair, curly", "Long hair, wavy", "Mohawk", "Mop-top", "Odango", "Pageboy", "Parted", "Pigtails", "Pixie cut", "Pompadour", "Ponytail", "Rattail", "Rocker", "Slicked back", "Spiky, short", "Spiky, long", "Short, curly", "Short, wavy", "Short, thin", "Short, straight"]
|
||||
|
||||
render :json => @possible_styles[rand(@possible_styles.length)]
|
||||
end
|
||||
|
||||
def character_height
|
||||
@upper_foot_limit = 6
|
||||
@lower_foot_limit = 2
|
||||
@upper_inch_limit = 11
|
||||
@lower_inch_limit = 0
|
||||
|
||||
render :json => [
|
||||
rand(@upper_foot_limit - @lower_foot_limit + 1) + @lower_foot_limit,
|
||||
"'",
|
||||
rand(@upper_inch_limit - @lower_inch_limit + 1) + @lower_inch_limit,
|
||||
'"'
|
||||
].join
|
||||
end
|
||||
|
||||
def character_identifyingmark
|
||||
@possible_marks = ["minor scar", "large scar", "mole", "fleshy growth", "tattoo", "discoloration"]
|
||||
@possible_locations = ["left eye", "right eye", "left thigh", "right thigh", "left shin", "right shin", "left foot", "right foot", "big toe", "hip", "stomach", "lower back", "chest", "upper back", "left shoulder", "right shoulder", "left bicep", "right bicep", "left tricep", "right tricep", "left hand", "right hand", "pointer finger", "thumb", "neck", "scalp", "above lip", "nose", "left ear", "right ear", "forehead", "left cheek", "right cheek", "left temple", "right temple", "chin", "beneath chin"]
|
||||
|
||||
render :json => [
|
||||
@possible_marks[rand(@possible_marks.length)],
|
||||
@possible_locations[rand(@possible_locations.length)]
|
||||
].join(' on the ').capitalize
|
||||
end
|
||||
|
||||
def character_name
|
||||
@male_first_names = ["James", "John", "Robert", "Michael", "William", "David", "Richard", "Charles", "Joseph", "Thomas", "Christopher", "Daniel", "Paul", "Mark", "Donald", "George", "Kenneth", "Steven", "Edward", "Brian", "Ronald", "Anthony", "Kevin", "Jason", "Matthew", "Gary", "Timothy", "Jose", "Larry", "Jeffrey", "Frank", "Scott", "Eric", "Stephen", "Andrew", "Raymond", "Gregory"]
|
||||
@female_first_names = ["Mary", "Patricia", "Linda", "Barbara", "Elizabeth", "Jennifer", "Maria", "Susan", "Margaret", "Margret", "Dorothy", "Lisa", "Nancy", "Karen", "Betty", "Helen", "Sandra", "Donna", "Carol", "Ruth", "Sharon", "Michelle", "Laura", "Sarah", "Kimberly", "Deborah", "Jessica", "Shirley", "Cynthia", "Angela", "Melissa", "Brenda", "Amy", "Anna", "Rebecca", "Virginia", "Kathleen", "Pamela"]
|
||||
@last_names = ["Smith", "Brown", "Lee", "Wilson", "Martin", "Patel", "Taylor", "Wong", "Campbell", "Williams", "Thompson", "Jones", "Johnson", "Miller", "Davis", "Garcia", "Rodriguez", "Martinez", "Anderson", "Jackson", "White", "Green", "Lee", "Harris", "Clark", "Lewis", "Robinson", "Walker", "Hall", "Young", "Allen", "Sanchez", "Wright", "King", "Scott", "Roberts", "Carter", "Phillips", "Evans", "Turner", "Torres", "Parker", "Collins", "Stewart", "Flores", "Morris", "Nguyen", "Murphy", "Rivera", "Cook", "Morgan", "Peterson", "Cooper", "Gomez", "Ward"]
|
||||
|
||||
@all_first_names = [] + @male_first_names + @female_first_names
|
||||
@all_last_names = [] + @last_names
|
||||
|
||||
render :json => [
|
||||
@all_first_names[rand(@all_first_names.length)],
|
||||
@all_last_names[rand(@all_last_names.length)]
|
||||
].join(' ')
|
||||
end
|
||||
|
||||
def character_race
|
||||
@possible_races = ["Android", "Angel", "Animal", "Arachnoid", "Bird", "Construct", "Dark Elf", "Dwarf", "Elemental", "Elf", "Fairy", "Fey", "Genie", "Gnome", "Half-Dwarf", "Half-Elf", "Half-Orc", "Halfling", "Human", "Insectoid", "Orc", "Reptilian", "Robot", "Spirit", "Vampire", "Werewolf"]
|
||||
|
||||
render :json => @possible_races[rand(@possible_races.length)]
|
||||
end
|
||||
|
||||
def character_skintone
|
||||
@possible_tones = ["Albino", "Light", "Pale white", "Fair", "White", "Medium", "Olive", "Moderate brown", "Brown", "Dark brown", "Black"]
|
||||
|
||||
render :json => @possible_tones[rand(@possible_tones.length)]
|
||||
end
|
||||
|
||||
def character_weight
|
||||
@upper_limit = 240
|
||||
@lower_limit = 80
|
||||
|
||||
render :json => rand(@upper_limit - @lower_limit + 1) + @lower_limit
|
||||
end
|
||||
|
||||
# Location
|
||||
|
||||
def location_name
|
||||
@prefixes = ["New", "Los", "Fort", "City of", "El", "Saint", "Des", "Little", "Big", "North", "East", "South", "West", "Round", "The", "Broken", "Santa"]
|
||||
@postfixes = ["Port", "City", "Grove", "Pines", "Falls", "Heights", "Oaks", "Rapids", "Valley", "Mountains", "Peaks", "Arbor", "Mesa", "Gardens", "Palms", "Beach", "Bend", "Ruins"]
|
||||
@syllables = ["lo", "chi", "ca", "go", "hou", "ston", "nix", "pho", "an", "ant", "ton", "io", "san", "die", "dia", "dal", "las", "son", "vil", "pol", "ral", "polis", "na", "aus", "tin", "fran", "cis", "co", "col", "umb", "bus", "cha", "mem", "phis", "sea", "wor", "the", "tha", "den", "was", "bal", "ti", "mo", "ash", "wau", "kee", "ki", "ru", "lu", "cest", "pro", "ora", "ode", "mu", "ill", "ville", "vil"]
|
||||
|
||||
@prefix_occurrence = 0.15
|
||||
@postfix_occurrence = 0.15
|
||||
@syllables_upper_limit = 4
|
||||
@syllables_lower_limit = 2
|
||||
|
||||
# Generate root name
|
||||
@root_name = ""
|
||||
syllables = rand(@syllables_upper_limit - @syllables_lower_limit + 1) + @syllables_lower_limit
|
||||
syllables.times do |i|
|
||||
@root_name = @root_name + @syllables[rand(@syllables.length)]
|
||||
end
|
||||
@root_name = @root_name.titleize
|
||||
|
||||
# Add prefix/postfix
|
||||
added = false
|
||||
trigger = rand(100)
|
||||
if trigger <= @prefix_occurrence * 100
|
||||
added = true
|
||||
@root_name = @prefixes[rand(@prefixes.length)] + " " + @root_name
|
||||
end
|
||||
|
||||
trigger = rand(100)
|
||||
if trigger <= @postfix_occurrence * 100 and not added
|
||||
added = true
|
||||
@root_name = @root_name + " " + @postfixes[rand(@postfixes.length)]
|
||||
end
|
||||
|
||||
render :json => @root_name
|
||||
end
|
||||
|
||||
# Equipment
|
||||
|
||||
def equipment_armor
|
||||
# TODO just make this an aggregate of armor and pick randomly from the different ones
|
||||
render :json => {}
|
||||
end
|
||||
|
||||
def equipment_armor_shield
|
||||
@shield_types = ["Greek aspis", "Buckler", "Heater shield", "Heraldic shield", "Leather shield", "Hide shield", "Hoplon shield", "Kite shield", "Scutum", "Targe"]
|
||||
|
||||
render :json => @shield_types[rand(@shield_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon
|
||||
#TODO just make this an aggregate and pick randomly from the different weapon generators
|
||||
@weapon_types = ["Bastard sword", "Battleaxe", "Bolas", "Bow & Arrow", "Bowstaff", "Brass knuckles", "Broom", "Chainsaw", "Club", "Dagger", "Darts", "Falchion", "Flail", "Gauntlet", "Glaive", "Greataxe", "Greatsword", "Halberd", "Handaxe", "Hand crossbow", "Heavy crossbow", "Javelin", "Kama", "Kukri", "Lance", "Longbow", "Longsword", "Madu", "Morningstar", "Net", "Nunchaku", "Pocket knife", "Quarterstaff", "Ranseur", "Rapier", "Repeating crossbow", "Sai", "Sap", "Scimitar", "Scythe", "Shortsword", "Shortbow", "Shortspear", "Shuriken", "Siangham", "Sickle", "Sling", "Spear", "Throwing axe", "Trident", "Warhammer", "Whip"]
|
||||
|
||||
render :json => @weapon_types[rand(@weapon_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_axe
|
||||
@axe_types = ["Bardiche", "Battleaxe", "Broadaxe", "Handaxe", "Hatchet", "Long-bearded axe", "Tomahawk"]
|
||||
|
||||
render :json => @axe_types[rand(@axe_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_bow
|
||||
@bow_types = ["Longbow", "Sling", "Blowgun", "Flatbow", "Composite bow", "Yumi", "Gungdo", "Shortbow", "Arbalest", "Crossbow", "Repeating crossbow"]
|
||||
|
||||
render :json => @bow_types[rand(@bow_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_club
|
||||
@club_types = ["Boomerang", "Frying pan", "Hammer", "Brick", "Mace", "Morningstar", "Sai", "Scepter", "Sledgehammer", "Lamp", "Glass bottle", "Warhammer", "Wrench", "Crowbar"]
|
||||
|
||||
render :json => @club_types[rand(@club_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_fist
|
||||
@fist_weapon_types = ["Bahh nakh, tiger claws", "Brass knuckles", "Cestus", "Deer horn knives", "Finger knife", "Gauntlets", "Katar", "Korean fan", "Madu, buckhorn stick", "Pata sword gauntlet", "Push dagger", "Roman scissor", "War fan", "Wind and fire wheels", "Emei daggers", "Large stone", "Brick"]
|
||||
|
||||
render :json => @fist_weapon_types[rand(@fist_weapon_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_flexible
|
||||
@flexible_types = ["Bullwhip", "Cat o' nine tails", "Chain whip", "Lasso", "Nunchaku", "Flail", "Meteor hammer"]
|
||||
|
||||
render :json => @flexible_types[rand(@flexible_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_thrown
|
||||
@thrown_types = ["Harpoon", "Bolas", "Javelin", "Pilum", "Woomera", "Angon", "Chakram", "Kunai", "Boomerang", "Throwing knife", "Thrown darts", "Swiss arrow", "Francisca", "Tomahawk", "Shuriken", "Stones"]
|
||||
|
||||
render :json => @thrown_types[rand(@thrown_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_polearm
|
||||
@polearm_types = ["Bo", "Taiji staff", "Quarterstaff", "Staff", "Spear", "Lance", "Pike", "Pitchfork", "Qiang", "Ranseur", "Spetum", "Swordstaff", "Trident", "Bardiche", "Bill", "Glaive", "Halberd", "Lochaber axe", "Naginata", "Partizan", "Scythe", "Voulge", "War scythe"]
|
||||
|
||||
render :json => @polearm_types[rand(@polearm_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_shortsword
|
||||
@shortsword_types = ["Dagger", "Fireplace poker", "Small sword", "Xiphos shortsword", "Aikuchi shortsword", "Kodachi shortsword", "Pinuti shortsword", "Wakizashi shortsword"]
|
||||
|
||||
render :json => @shortsword_types[rand(@shortsword_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_sword
|
||||
@sword_types = ["Cutlass", "Dao", "Dha", "Falchion", "Hunting sword", "Kukri", "Pulwar", "Sabre", "Scimitar", "Shamshir", "Talwar", "Epee", "Flamberge", "Longsword", "Ninjato", "Rapier", "Katana", "Claymore", "Dadao", "Executioner's sword", "Flambard", "Greatsword", "Nodachi", "Falcata", "Machete", "Yatagan"]
|
||||
|
||||
render :json => @sword_types[rand(@sword_types.length)]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
# Controller for the Language model
|
||||
class LanguagesController < ApplicationController
|
||||
before_filter :create_anonymous_account_if_not_logged_in, :only => [:edit, :create, :update]
|
||||
before_filter :require_ownership_of_language, :only => [:update, :edit, :destroy]
|
||||
before_filter :hide_private_language, :only => [:show]
|
||||
before_action :create_anonymous_account_if_not_logged_in,
|
||||
only: [:edit, :create, :update]
|
||||
|
||||
before_action :require_ownership_of_language,
|
||||
only: [:update, :edit, :destroy]
|
||||
|
||||
before_action :hide_private_language, only: [:show]
|
||||
|
||||
def index
|
||||
@languages = Language.where(user_id: session[:user])
|
||||
|
||||
if @languages.size == 0
|
||||
@languages = []
|
||||
end
|
||||
|
||||
@languages = @languages.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
@languages = Language.where(user_id: session[:user])
|
||||
.order(:name).presence || []
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -41,59 +41,72 @@ class LanguagesController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@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
|
||||
@language = create_language_from_params
|
||||
|
||||
# rubocop:disable LineLength
|
||||
respond_to do |format|
|
||||
if @language.save
|
||||
format.html { redirect_to @language, notice: 'Language was successfully created.' }
|
||||
notice = t :create_success, model_name: Language.model_name.human
|
||||
format.html { redirect_to @language, notice: notice }
|
||||
format.json { render json: @language, status: :created, location: @language }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @language.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
# rubocop:enable LineLength
|
||||
end
|
||||
|
||||
def update
|
||||
@language = Language.find(params[:id])
|
||||
if params[:language][:universe].empty?
|
||||
params[:language][:universe] = nil
|
||||
else
|
||||
params[:language][:universe] = Universe.where(user_id: session[:user]).where(name: params[:language][:universe].strip).first
|
||||
end
|
||||
@language = update_language_from_params
|
||||
|
||||
respond_to do |format|
|
||||
if @language.update_attributes(language_params)
|
||||
format.html { redirect_to @language, notice: 'Language was successfully updated.' }
|
||||
notice = t :update_success, model_name: Language.model_name.human
|
||||
format.html { redirect_to @language, notice: notice }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @language.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@language = Language.find(params[:id])
|
||||
@language.destroy
|
||||
@language = Language.find(params[:id]).destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to language_list_url }
|
||||
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
|
||||
|
||||
|
||||
def language_params
|
||||
params.require(:language).permit(
|
||||
:user_id, :universe_id,
|
||||
:name,
|
||||
:words,
|
||||
:established_year, :established_location,
|
||||
:characters, :locations,
|
||||
:notes)
|
||||
end
|
||||
|
||||
def update_language_from_params
|
||||
params[:language][:universe] = universe_from_language_params
|
||||
Language.find(params[:id])
|
||||
end
|
||||
|
||||
def create_language_from_params
|
||||
language = Language.create(language_params)
|
||||
language.user_id = session[:user]
|
||||
language.universe = universe_from_language_params
|
||||
language
|
||||
end
|
||||
|
||||
def universe_from_language_params
|
||||
Universe.where(user_id: session[:user],
|
||||
name: params[:language][:universe].strip).first.presence
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
# Controller for the Location model
|
||||
class LocationsController < ApplicationController
|
||||
before_filter :create_anonymous_account_if_not_logged_in, :only => [:edit, :create, :update]
|
||||
before_filter :require_ownership_of_location, :only => [:update, :edit, :destroy]
|
||||
before_filter :hide_private_location, :only => [:show]
|
||||
before_action :create_anonymous_account_if_not_logged_in,
|
||||
only: [:edit, :create, :update]
|
||||
|
||||
before_action :require_ownership_of_location,
|
||||
only: [:update, :edit, :destroy]
|
||||
|
||||
before_action :hide_private_location, only: [:show]
|
||||
|
||||
def index
|
||||
@locations = Location.where(user_id: session[:user])
|
||||
|
||||
if @locations.size == 0
|
||||
@locations = []
|
||||
end
|
||||
|
||||
@locations = @locations.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
.order(:name).presence || []
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -40,61 +40,55 @@ class LocationsController < ApplicationController
|
||||
@location = Location.find(params[:id])
|
||||
end
|
||||
|
||||
# rubocop:disable LineLength
|
||||
def create
|
||||
@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
|
||||
|
||||
notice = ''
|
||||
@location = create_location_from_params
|
||||
|
||||
respond_to do |format|
|
||||
begin
|
||||
if @location.save
|
||||
if notice == ''
|
||||
notice = 'Location was successfully created.'
|
||||
end
|
||||
|
||||
notice = t(:create_success, model_name: Location.model_name.human) if notice.blank?
|
||||
format.html { redirect_to @location, notice: notice }
|
||||
format.json { render json: @location, status: :created, location: @location }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @location.errors, status: :unprocessable_entity }
|
||||
end
|
||||
rescue Errno::ECONNRESET
|
||||
# Connection was reset, probably because of the file upload. Try again without it.
|
||||
# Connection was reset, probably because of the file upload.
|
||||
# Try again without it.
|
||||
@location.map = nil
|
||||
notice = 'Location was created, but your map did not upload. Please try again.'
|
||||
notice = t :location_create_upload_map_error
|
||||
retry
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable LineLength
|
||||
|
||||
# rubocop:disable LineLength
|
||||
def update
|
||||
@location = Location.find(params[:id])
|
||||
|
||||
if params[:location][:universe].empty?
|
||||
params[:location][:universe] = nil
|
||||
else
|
||||
params[:location][:universe] = Universe.where(user_id: session[:user]).where(name: params[:location][:universe].strip).first
|
||||
end
|
||||
@location = update_location_from_params
|
||||
|
||||
respond_to do |format|
|
||||
begin
|
||||
if @location.update_attributes(location_params)
|
||||
format.html { redirect_to @location, notice: 'Location was successfully updated.' }
|
||||
notice = t :update_success, model_name: Location.model_name.human if notice.blank?
|
||||
format.html { redirect_to @location, notice: notice }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @location.errors, status: :unprocessable_entity }
|
||||
end
|
||||
rescue Errno::ECONNRESET
|
||||
# Connection was reset, probably because of the file upload. Try again without it.
|
||||
# Connection was reset, probably because of the file upload.
|
||||
# Try again without it.
|
||||
@location.map = nil
|
||||
notice = 'Location was created, but your map did not upload. Please try again.'
|
||||
notice = t :location_update_upload_map_error
|
||||
retry
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable LineLength
|
||||
|
||||
def destroy
|
||||
@location = Location.find(params[:id])
|
||||
@ -105,17 +99,31 @@ 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
|
||||
|
||||
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
|
||||
|
||||
def create_location_from_params
|
||||
location = Location.new(location_params)
|
||||
location.user_id = session[:user]
|
||||
location.universe = universe_from_location_params
|
||||
location
|
||||
end
|
||||
|
||||
def update_location_from_params
|
||||
params[:location][:universe] = universe_from_location_params
|
||||
Location.find(params[:id])
|
||||
end
|
||||
|
||||
def universe_from_location_params
|
||||
Universe.where(user_id: session[:user],
|
||||
name: params[:location][:universe].strip).first
|
||||
end
|
||||
end
|
||||
|
||||
38
app/controllers/locations_generator_controller.rb
Normal file
38
app/controllers/locations_generator_controller.rb
Normal file
@ -0,0 +1,38 @@
|
||||
# Generates random Location values
|
||||
class LocationsGeneratorController < ApplicationController
|
||||
before_action :load_common_fields
|
||||
|
||||
def name
|
||||
@root_name = add_fixes_to base_name
|
||||
|
||||
render json: @root_name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def base_name
|
||||
@syllables
|
||||
.sample(rand(@syllables_lower_limit...@syllables_upper_limit))
|
||||
.join
|
||||
end
|
||||
|
||||
def add_fixes_to(base)
|
||||
if rand <= @prefix_occurrence
|
||||
return @prefixes.sample + ' ' + base
|
||||
elsif rand <= @postfix_occurrence
|
||||
return base + ' ' + @postfixes.sample
|
||||
else
|
||||
return base
|
||||
end
|
||||
end
|
||||
|
||||
def load_common_fields
|
||||
@prefix_occurrence = 0.15
|
||||
@postfix_occurrence = 0.15
|
||||
@syllables_upper_limit = 4
|
||||
@syllables_lower_limit = 2
|
||||
@prefixes = t(:location_name_prefixes)
|
||||
@postfixes = t(:location_name_suffixes)
|
||||
@syllables = t(:location_name_syllables)
|
||||
end
|
||||
end
|
||||
@ -1,16 +1,15 @@
|
||||
# Controller for the Magic model
|
||||
class MagicController < ApplicationController
|
||||
before_filter :create_anonymous_account_if_not_logged_in, :only => [:edit, :create, :update]
|
||||
before_filter :require_ownership_of_magic, :only => [:edit, :destroy]
|
||||
before_filter :hide_private_magic, :only => [:show]
|
||||
before_action :create_anonymous_account_if_not_logged_in,
|
||||
only: [:edit, :create, :update]
|
||||
|
||||
before_action :require_ownership_of_magic,
|
||||
only: [:edit, :destroy]
|
||||
|
||||
before_action :hide_private_magic, only: [:show]
|
||||
|
||||
def index
|
||||
@magics = Magic.where(user_id: session[:user])
|
||||
|
||||
if @magics.size == 0
|
||||
@magics = []
|
||||
end
|
||||
|
||||
@magics = @magics.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
@magics = Magic.where(user_id: session[:user]).order(:name).presence || []
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -41,16 +40,15 @@ class MagicController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@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
|
||||
@magic = create_magic_from_params
|
||||
|
||||
respond_to do |format|
|
||||
if @magic.save
|
||||
format.html { redirect_to @magic, notice: 'Magic was successfully created.' }
|
||||
notice = t :create_success, model_name: Magic.model_name.human
|
||||
format.html { redirect_to @magic, notice: notice }
|
||||
format.json { render json: @magic, status: :created, location: @magic }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @magic.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@ -59,18 +57,13 @@ class MagicController < ApplicationController
|
||||
def update
|
||||
@magic = Magic.find(params[:id])
|
||||
|
||||
if params[:magic][:universe].empty?
|
||||
params[:magic][:universe] = nil
|
||||
else
|
||||
params[:magic][:universe] = Universe.where(user_id: session[:user]).where(name: params[:magic][:universe].strip).first
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @magic.update_attributes(magic_params)
|
||||
format.html { redirect_to @magic, notice: 'Magic was successfully updated.' }
|
||||
notice = t :update_success, model_name: Magic.model_name.human
|
||||
format.html { redirect_to @magic, notice: notice }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @magic.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@ -85,16 +78,29 @@ 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
|
||||
|
||||
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
|
||||
|
||||
def create_magic_from_params
|
||||
magic = Magic.new(magic_params)
|
||||
magic.user_id = session[:user]
|
||||
magic.universe = universe_from_magic_params
|
||||
magic
|
||||
end
|
||||
|
||||
def universe_from_magic_params
|
||||
Universe.where(user_id: session[:user],
|
||||
name: params[:magic][:universe].strip).first
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
# Controller for top-level pages of the site that do not have
|
||||
# an associated model
|
||||
class MainController < ApplicationController
|
||||
before_filter :redirect_if_not_logged_in, :only => [:dashboard]
|
||||
|
||||
before_action :redirect_if_not_logged_in, only: [:dashboard]
|
||||
def index
|
||||
if session && session[:user]
|
||||
redirect_to :dashboard
|
||||
end
|
||||
redirect_to :dashboard if session && session[:user]
|
||||
end
|
||||
|
||||
|
||||
def comingsoon
|
||||
end
|
||||
|
||||
@ -15,16 +14,17 @@ class MainController < ApplicationController
|
||||
|
||||
def attribution
|
||||
end
|
||||
|
||||
|
||||
def dashboard
|
||||
@characters = Character.where(user_id: session[:user])
|
||||
@equipment = Equipment.where(user_id: session[:user])
|
||||
@languages = Language.where(user_id: session[:user])
|
||||
@locations = Location.where(user_id: session[:user])
|
||||
@magics = Magic.where(user_id: session[:user])
|
||||
@universes = Universe.where(user_id: session[:user])
|
||||
|
||||
@things = [ @characters.length, @equipment.length, @languages.length,
|
||||
@locations.length, @magics.length, @universes.length ].sum
|
||||
user = User.where(id: session[:user]).first
|
||||
|
||||
@characters = user.characters
|
||||
@equipment = user.equipment
|
||||
@languages = user.languages
|
||||
@locations = user.locations
|
||||
@magics = user.magics
|
||||
@universes = user.universes
|
||||
|
||||
@things = user.content_count
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# Controller for user Sessions
|
||||
class SessionsController < ApplicationController
|
||||
# GET /sessions/new
|
||||
# GET /sessions/new.json
|
||||
@ -13,22 +14,19 @@ class SessionsController < ApplicationController
|
||||
# POST /sessions
|
||||
# POST /sessions.json
|
||||
def create
|
||||
login = Session.new(session_params)
|
||||
hash = SessionsController.create_password_digest login.username, login.password
|
||||
user = User.where(name: login.username, password: hash)
|
||||
if user.length < 1
|
||||
redirect_to login_path, notice: 'Username or password incorrect'
|
||||
user = user_from_params
|
||||
|
||||
if user.nil?
|
||||
redirect_to login_path, notice: t(:username_password_incorrect)
|
||||
return
|
||||
end
|
||||
|
||||
session[:user] = user[0].id
|
||||
session.delete(:anon_user)
|
||||
|
||||
build_session_for user
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to dashboard_path, notice: 'Login successful.' }
|
||||
format.html { redirect_to dashboard_path, notice: t(:login_successful) }
|
||||
format.json { render json: true, status: :created }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# GET /logout
|
||||
@ -37,18 +35,32 @@ class SessionsController < ApplicationController
|
||||
session.delete(:anon_user)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to homepage_path, notice: 'Logged out!' }
|
||||
format.html { redirect_to homepage_path, notice: t(:logged_out) }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.create_password_digest(username, password)
|
||||
require 'digest'
|
||||
return Digest::MD5.hexdigest(username + "'s password IS... " + password + " (lol!)")
|
||||
Digest::MD5.hexdigest(
|
||||
username + "'s password IS... " + password + ' (lol!)')
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def session_params
|
||||
params.require(:session).permit(:username, :password)
|
||||
end
|
||||
|
||||
def user_from_params
|
||||
login = Session.new(session_params)
|
||||
hash = SessionsController.create_password_digest(login.username,
|
||||
login.password)
|
||||
User.where(name: login.username, password: hash).first
|
||||
end
|
||||
|
||||
def build_session_for(user)
|
||||
session[:user] = user.id
|
||||
session.delete(:anon_user)
|
||||
end
|
||||
|
||||
def session_params
|
||||
params.require(:session).permit(:username, :password)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
# Controller for the Universe model
|
||||
class UniversesController < ApplicationController
|
||||
before_filter :create_anonymous_account_if_not_logged_in, :only => [:edit, :create, :update]
|
||||
before_filter :require_ownership_of_universe, :only => [:edit, :update, :destroy]
|
||||
before_filter :hide_private_universe, :only => [:show]
|
||||
before_action :create_anonymous_account_if_not_logged_in,
|
||||
only: [:edit, :create, :update]
|
||||
|
||||
before_action :require_ownership_of_universe,
|
||||
only: [:edit, :update, :destroy]
|
||||
|
||||
before_action :hide_private_universe, only: [:show]
|
||||
|
||||
def index
|
||||
@universes = Universe.where(user_id: session[:user])
|
||||
|
||||
if @universes.size == 0
|
||||
@universes = []
|
||||
end
|
||||
|
||||
@universes = @universes.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
@universes = Universe.where(user_id: session[:user]).order(:name).presence || []
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -46,10 +45,11 @@ class UniversesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @universe.save
|
||||
format.html { redirect_to @universe, notice: 'Universe was successfully created.' }
|
||||
notice = t :create_success, model_name: Universe.model_name.human
|
||||
format.html { redirect_to @universe, notice: notice }
|
||||
format.json { render json: @universe, status: :created, location: @universe }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @universe.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@ -60,10 +60,11 @@ class UniversesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @universe.update_attributes(universe_params)
|
||||
format.html { redirect_to @universe, notice: 'Universe was successfully updated.' }
|
||||
notice = t :update_success, model_name: Universe.model_name.human
|
||||
format.html { redirect_to @universe, notice: notice }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @universe.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@ -78,14 +79,15 @@ 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
|
||||
|
||||
def universe_params
|
||||
params.require(:universe).permit(
|
||||
:user_id,
|
||||
:name, :description,
|
||||
:history,
|
||||
:privacy,
|
||||
:notes, :private_notes)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Controller for the User model
|
||||
class UsersController < ApplicationController
|
||||
before_filter :redirect_if_not_logged_in, :only => [:edit, :update]
|
||||
|
||||
before_action :redirect_if_not_logged_in, only: [:edit, :update]
|
||||
|
||||
# GET /users/new
|
||||
# GET /users/new.json
|
||||
def new
|
||||
@ -21,22 +22,22 @@ class UsersController < ApplicationController
|
||||
# POST /users.json
|
||||
def create
|
||||
@user = User.new(user_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @user.save
|
||||
session[:user] = @user.id
|
||||
format.html { redirect_to homepage_path, notice: 'User was successfully created.' }
|
||||
log_in @user
|
||||
notice = t(:create_success, model_name: User.model_name.human)
|
||||
format.html { redirect_to homepage_path, notice: notice }
|
||||
format.json { render json: @user, status: :created }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def anonymous_login
|
||||
# todo guarantee anonymous id is random (or just let db assign it?)
|
||||
id = rand(10000000).to_s + rand(10000000).to_s
|
||||
@user = User.new(:name => 'Anonymous-' + id.to_s, :email => id.to_s + '@localhost', :password => id.to_s)
|
||||
@user = create_anonymous_user
|
||||
|
||||
respond_to do |format|
|
||||
if @user.save
|
||||
@ -45,7 +46,7 @@ class UsersController < ApplicationController
|
||||
format.html { redirect_to dashboard_path }
|
||||
format.json { render json: @user, status: :created }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@ -62,17 +63,18 @@ class UsersController < ApplicationController
|
||||
format.html { redirect_to homepage_path, notice: 'Successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def anonymous
|
||||
end
|
||||
|
||||
private
|
||||
def user_params
|
||||
params.require(:user).permit(:name, :password, :email)
|
||||
end
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:name, :password, :email)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,44 +1,40 @@
|
||||
# Helps generate HTML constructs for object owned by the user
|
||||
module ApplicationHelper
|
||||
# Will output a link to the item if it exists and is owned by the
|
||||
# current logged-in user. Otherwise will just print a text title
|
||||
def link_if_present(name, type)
|
||||
return name unless session[:user]
|
||||
userid = User.where(id: session[:user]).first.id
|
||||
|
||||
# Will output a link to the item if it exists and is owned by the current logged-in user
|
||||
# Otherwise will just print a text title
|
||||
def link_if_present(name, type)
|
||||
if not session[:user]
|
||||
return name
|
||||
end
|
||||
type = type.downcase
|
||||
result = find_by_name_and_type name, type, userid
|
||||
|
||||
result = nil
|
||||
type = type.downcase
|
||||
result.nil? ? name : link_to(name, result)
|
||||
end
|
||||
|
||||
case type
|
||||
when "character"
|
||||
result = Character.where(:name => name, :user_id => session[:user])
|
||||
when "equipment"
|
||||
result = Equipment.where(:name => name, :user_id => session[:user])
|
||||
when "language"
|
||||
result = Language.where(:name => name, :user_id => session[:user])
|
||||
when "location"
|
||||
result = Location.where(:name => name, :user_id => session[:user])
|
||||
when "magic"
|
||||
result = Magic.where(:name => name, :user_id => session[:user])
|
||||
# Plot stuff
|
||||
when "universe"
|
||||
result = Universe.where(:name => name, :user_id => session[:user])
|
||||
end
|
||||
def find_by_name_and_type(name, type, userid)
|
||||
model = find_model_by_type type
|
||||
|
||||
if result and result.length > 0
|
||||
return link_to name, result.first
|
||||
else
|
||||
return name
|
||||
end
|
||||
end
|
||||
model.where(name: name, user_id: userid).first unless model.nil?
|
||||
end
|
||||
|
||||
def print_property(title, value, type = "")
|
||||
return unless value and value.length > 0
|
||||
def find_model_by_type(type) # rubocop:disable Metrics/CyclomaticComplexity
|
||||
case type
|
||||
when 'character' then return Character
|
||||
when 'equipment' then return Equipment
|
||||
when 'language' then return Language
|
||||
when 'location' then return Location
|
||||
when 'magic' then return Magic
|
||||
when 'universe' then return Universe
|
||||
end
|
||||
end
|
||||
|
||||
return [
|
||||
"<dt><strong>", title, ":</strong></dt>",
|
||||
"<dd>", simple_format(link_if_present(value, type)), "</dd>"
|
||||
].join("").to_s.html_safe
|
||||
end
|
||||
def print_property(title, value, type = '')
|
||||
return unless value && value.length > 0
|
||||
|
||||
[
|
||||
'<dt><strong>', title, ':</strong></dt>',
|
||||
'<dd>', simple_format(link_if_present(value, type)), '</dd>'
|
||||
].join('').to_s.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
module CharactersHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module EquipmentHelper
|
||||
end
|
||||
@ -1,17 +1,18 @@
|
||||
# Helps to generate forms and buttons
|
||||
module FormHelper
|
||||
def generate_form_row_for(form_handler, field, label_override = nil, toolbox = {})
|
||||
label = (label_override.nil? ? field : label_override.titleize)
|
||||
[
|
||||
'<div class="row">',
|
||||
'<div class="col-xs-2" style="text-align: right;">',
|
||||
form_handler.label(label, :class => 'control-label'),
|
||||
'</div>',
|
||||
'<div class="col-xs-9">',
|
||||
form_handler.text_field(field, :class => 'form-control'),
|
||||
'</div>',
|
||||
'<div class="col-xs-1">',
|
||||
toolbox.map { |config| toolbox_button_for(config) },
|
||||
'</div>',
|
||||
'<div class="col-xs-2" style="text-align: right;">',
|
||||
form_handler.label(label, class: 'control-label'),
|
||||
'</div>',
|
||||
'<div class="col-xs-9">',
|
||||
form_handler.text_field(field, class: 'form-control'),
|
||||
'</div>',
|
||||
'<div class="col-xs-1">',
|
||||
toolbox.map { |config| toolbox_button_for(config) },
|
||||
'</div>',
|
||||
'</div>'
|
||||
].join("\n").html_safe
|
||||
end
|
||||
@ -23,10 +24,9 @@ module FormHelper
|
||||
else
|
||||
[
|
||||
"<button type='button' class='btn btn-default #{config[:action]}'>",
|
||||
"<span class='glyphicon glyphicon-#{config[:icon]}'></span>",
|
||||
"</button>"
|
||||
"<span class='glyphicon glyphicon-#{config[:icon]}'></span>",
|
||||
'</button>'
|
||||
].join("\n").html_safe
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
module GeneratorHelper
|
||||
end
|
||||
@ -1,3 +1,4 @@
|
||||
# Helps generate small HTML constructs
|
||||
module HtmlHelper
|
||||
def picker_from_type(content_type)
|
||||
case content_type
|
||||
@ -18,15 +19,16 @@ module HtmlHelper
|
||||
return if content_array.length == 0
|
||||
[
|
||||
'<span class="dropdown-picker">',
|
||||
'<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',
|
||||
'<span class="glyphicon glyphicon-'+glyphicon_id+'"></span>',
|
||||
'<span class="caret"></span>',
|
||||
'</button>',
|
||||
'<ul class="dropdown-menu">',
|
||||
content_array.map { |content|
|
||||
'<li><a href="#">' + content.name + '</a></li>'
|
||||
},
|
||||
'</ul>',
|
||||
'<button type="button" class="btn btn-default dropdown-toggle" \
|
||||
data-toggle="dropdown">',
|
||||
'<span class="glyphicon glyphicon-' + glyphicon_id + '"></span>',
|
||||
'<span class="caret"></span>',
|
||||
'</button>',
|
||||
'<ul class="dropdown-menu">',
|
||||
content_array.map do |content|
|
||||
'<li><a href="#">' + content.name + '</a></li>'
|
||||
end,
|
||||
'</ul>',
|
||||
'</span>'
|
||||
].join("\n").html_safe
|
||||
end
|
||||
@ -34,21 +36,20 @@ module HtmlHelper
|
||||
def character_picker
|
||||
generate_picker_code_for(my_characters, 'user')
|
||||
end
|
||||
|
||||
|
||||
def universe_picker
|
||||
generate_picker_code_for(my_universes, 'globe')
|
||||
end
|
||||
|
||||
|
||||
def equipment_picker
|
||||
generate_picker_code_for(my_equipment, 'gift')
|
||||
end
|
||||
|
||||
|
||||
def language_picker
|
||||
generate_picker_code_for(my_languages, 'comment')
|
||||
end
|
||||
|
||||
|
||||
def location_picker
|
||||
generate_picker_code_for(my_locations, 'road')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
module LanguagesHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module MainHelper
|
||||
end
|
||||
@ -1,21 +1,22 @@
|
||||
# Helps to get content owned by the current user
|
||||
module MyContentHelper
|
||||
def my_characters
|
||||
return Character.where(user_id: session[:user])
|
||||
Character.where(user_id: session[:user])
|
||||
end
|
||||
|
||||
def my_universes
|
||||
return Universe.where(user_id: session[:user])
|
||||
Universe.where(user_id: session[:user])
|
||||
end
|
||||
|
||||
|
||||
def my_equipment
|
||||
return Equipment.where(user_id: session[:user])
|
||||
Equipment.where(user_id: session[:user])
|
||||
end
|
||||
|
||||
|
||||
def my_languages
|
||||
return Language.where(user_id: session[:user])
|
||||
Language.where(user_id: session[:user])
|
||||
end
|
||||
|
||||
|
||||
def my_locations
|
||||
return Location.where(user_id: session[:user])
|
||||
Location.where(user_id: session[:user])
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
module SessionsHelper
|
||||
end
|
||||
@ -1,2 +0,0 @@
|
||||
module UsersHelper
|
||||
end
|
||||
@ -1,6 +1,21 @@
|
||||
##
|
||||
# = char-ac-ter
|
||||
# == /'kerekter/
|
||||
# _noun_
|
||||
#
|
||||
# 1. a person in a User's story.
|
||||
#
|
||||
# exists within a Universe.
|
||||
class Character < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
include Comparable
|
||||
include NilsBlankUniverse
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
|
||||
def <=>(other)
|
||||
name.downcase <=> other.name.downcase
|
||||
end
|
||||
end
|
||||
|
||||
14
app/models/concerns/nils_blank_universe.rb
Normal file
14
app/models/concerns/nils_blank_universe.rb
Normal file
@ -0,0 +1,14 @@
|
||||
require 'active_support/concern'
|
||||
|
||||
# Model will set its Universe attribute to nil if the string is blank
|
||||
module NilsBlankUniverse
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_save :nil_blank_universe
|
||||
end
|
||||
|
||||
def nil_blank_universe
|
||||
self.universe = nil if blank?
|
||||
end
|
||||
end
|
||||
@ -1,6 +1,21 @@
|
||||
##
|
||||
# = e-quip-ment
|
||||
# == /e'kwipment/
|
||||
# _noun_
|
||||
#
|
||||
# 1. the necessary items for a particular purpose.
|
||||
#
|
||||
# exists within a Universe.
|
||||
class Equipment < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
include Comparable
|
||||
include NilsBlankUniverse
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
|
||||
def <=>(other)
|
||||
name.downcase <=> other.name.downcase
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,6 +1,17 @@
|
||||
##
|
||||
# = lang-guage
|
||||
# == /'laNGgqwij/
|
||||
# _noun_
|
||||
#
|
||||
# 1. the method of communication, either spoken or written, consisting of the
|
||||
# use of words in a structured and conventional way.
|
||||
#
|
||||
# spoken within a Universe
|
||||
class Language < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
include NilsBlankUniverse
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
|
||||
@ -1,8 +1,19 @@
|
||||
##
|
||||
# = lo-ca-tion
|
||||
# == /lo'kaSH(e)n/
|
||||
# _noun_
|
||||
#
|
||||
# 1. a particular place or position
|
||||
#
|
||||
# exists within a Universe
|
||||
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
|
||||
|
||||
include NilsBlankUniverse
|
||||
|
||||
has_attached_file :map, styles: { original: '1920x1080>', thumb: '200x200>' }
|
||||
validates_attachment_content_type :map, content_type: /\Aimage\/.*\Z/
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
##
|
||||
# = mag-ic
|
||||
# == /'majik/
|
||||
# _noun_
|
||||
#
|
||||
# 1. the power of apparently influencing the course of events by using
|
||||
# mysterious or supernatural forces.
|
||||
#
|
||||
# used within a universe
|
||||
#
|
||||
# "do you believe in magic?"
|
||||
class Magic < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
include NilsBlankUniverse
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
##
|
||||
# A currently-logged-in User
|
||||
class Session < ActiveRecord::Base
|
||||
validates_presence_of :username, :password
|
||||
validates :username, presence: true
|
||||
validates :password, presence: true
|
||||
end
|
||||
|
||||
@ -1,20 +1,27 @@
|
||||
##
|
||||
# = u-ni-verse
|
||||
# == /'yoone,vers/
|
||||
#
|
||||
# 1. a particular sphere of activity, interest, or experience
|
||||
#
|
||||
# contains all canonically-related content created by Users
|
||||
class Universe < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
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,
|
||||
magics.length
|
||||
].sum
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
##
|
||||
# a person using the Indent web application. Owns all other content.
|
||||
class User < ActiveRecord::Base
|
||||
validates_presence_of :name, :password, :email
|
||||
|
||||
validates :name, presence: true
|
||||
validates :password, presence: true
|
||||
validates :email, presence: true
|
||||
|
||||
before_save :hash_password
|
||||
|
||||
has_many :characters
|
||||
@ -9,30 +13,31 @@ class User < ActiveRecord::Base
|
||||
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!)")
|
||||
self.password = Digest::MD5.hexdigest(
|
||||
name + "'s password IS... " + password + ' (lol!)')
|
||||
end
|
||||
|
||||
|
||||
def content
|
||||
{
|
||||
:characters => characters,
|
||||
:equipment => equipment,
|
||||
:languages => languages,
|
||||
:locations => locations,
|
||||
:magics => magics,
|
||||
:universes => universes
|
||||
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,
|
||||
characters.length,
|
||||
equipment.length,
|
||||
languages.length,
|
||||
locations.length,
|
||||
magics.length,
|
||||
universes.length
|
||||
].sum
|
||||
end
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<h1 class="card-heading simple">
|
||||
Your characters
|
||||
<% if Universe.where(user_id: session[:user]).length > 0 %>
|
||||
<small>from <%= universe_filter %></small>
|
||||
<small>from <%= render 'universes/picker' %></small>
|
||||
<% end %>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<h3 class="card-heading simple">
|
||||
Your equipment
|
||||
<% if false and Universe.where(user_id: session[:user]).length > 0 %>
|
||||
<small>from <%= universe_filter %></small>
|
||||
<small>from <%= render 'universes/picker' %></small>
|
||||
<% end %>
|
||||
</h3>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<h3 class="card-heading simple">
|
||||
Languages
|
||||
<% if false and Universe.where(user_id: session[:user]).length > 0 %>
|
||||
<small>spoken in <%= universe_filter %></small>
|
||||
<small>spoken in <%= render 'universes/picker' %></small>
|
||||
<% end %>
|
||||
</h3>
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<h1 class="card-heading">
|
||||
Your locations
|
||||
<% if false and Universe.where(user_id: session[:user]).length > 0 %>
|
||||
<small>from <%= universe_filter %></small>
|
||||
<small>from <%= render 'universes/picker' %></small>
|
||||
<% end %>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<h1 class="card-heading">
|
||||
Magic
|
||||
<% if false and Universe.where(user_id: session[:user]).length > 0 %>
|
||||
<small>from <%= universe_filter %></small>
|
||||
<small>from <%= render 'universes/picker' %></small>
|
||||
<% end %>
|
||||
</h1>
|
||||
|
||||
|
||||
12
app/views/universes/_picker.html.erb
Normal file
12
app/views/universes/_picker.html.erb
Normal file
@ -0,0 +1,12 @@
|
||||
<span class="btn-group input-append help-inline">
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="icon-globe"></i><%= @selected_universe_filter || t(:all_universes) %>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-picker">
|
||||
<li><a href="/plan/characters"><%= t :all_universes %></a></li>
|
||||
<% Universe.where(user_id: session[:user]).each do |i| %>
|
||||
<li><a href="/plan/characters/from/<%= i.name.strip %>"><%= i.name %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</span>
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
begin
|
||||
load File.expand_path("../spring", __FILE__)
|
||||
load File.expand_path('../spring', __FILE__)
|
||||
rescue LoadError
|
||||
end
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
|
||||
2
bin/rake
2
bin/rake
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
begin
|
||||
load File.expand_path("../spring", __FILE__)
|
||||
load File.expand_path('../spring', __FILE__)
|
||||
rescue LoadError
|
||||
end
|
||||
require_relative '../config/boot'
|
||||
|
||||
12
bin/spring
12
bin/spring
@ -4,15 +4,15 @@
|
||||
# It gets overwritten when you run the `spring binstub` command
|
||||
|
||||
unless defined?(Spring)
|
||||
require "rubygems"
|
||||
require "bundler"
|
||||
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"] = ""
|
||||
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"
|
||||
gem 'spring', match[1]
|
||||
require 'spring/binstub'
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,16 +8,22 @@ Bundler.require(*Rails.groups)
|
||||
|
||||
module PlanCharacters
|
||||
class Application < Rails::Application
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Settings in config/environments/* take precedence over those
|
||||
# specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-
|
||||
# convert to this zone. Run "rake -D time" for a list of tasks for finding
|
||||
# time zone names. Default is UTC.
|
||||
#
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
# 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
|
||||
end
|
||||
end
|
||||
|
||||
@ -28,13 +28,12 @@ PlanCharacters::Application.configure do
|
||||
|
||||
# DEVELOPMENT S3 settings for Paperclip uploads ON DEVELOPMENT
|
||||
config.paperclip_defaults = {
|
||||
:storage => :s3,
|
||||
:s3_protocol => 'http',
|
||||
:s3_credentials => {
|
||||
:bucket => ENV['AWS_BUCKET'],
|
||||
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
|
||||
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
|
||||
storage: :s3,
|
||||
s3_protocol: 'http',
|
||||
s3_credentials: {
|
||||
bucket: ENV['AWS_BUCKET'],
|
||||
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
||||
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
@ -29,7 +29,8 @@ Rails.application.configure do
|
||||
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and
|
||||
# use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# Set to :debug to see everything in the log.
|
||||
@ -47,7 +48,8 @@ Rails.application.configure do
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
# Precompile additional assets (application.js, application.css, and all non-
|
||||
# JS/CSS are already added)
|
||||
# config.assets.precompile += %w( search.js )
|
||||
|
||||
# Disable delivery errors, bad email addresses will be ignored
|
||||
@ -65,16 +67,16 @@ Rails.application.configure do
|
||||
|
||||
# S3 settings for Paperclip uploads
|
||||
config.paperclip_defaults = {
|
||||
:storage => :s3,
|
||||
:s3_protocol => 'http',
|
||||
:s3_credentials => {
|
||||
:bucket => ENV['AWS_BUCKET'],
|
||||
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
|
||||
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
|
||||
storage: :s3,
|
||||
s3_protocol: 'http',
|
||||
s3_credentials: {
|
||||
bucket: ENV['AWS_BUCKET'],
|
||||
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
||||
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
||||
}
|
||||
}
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
#todo double check this
|
||||
# TODO: double check this
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
end
|
||||
|
||||
@ -9,7 +9,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.static_cache_control = 'public, max-age=3600'
|
||||
config.eager_load = false
|
||||
|
||||
# Log error messages when you accidentally call methods on nil
|
||||
@ -30,7 +30,6 @@ Rails.application.configure do
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
|
||||
|
||||
# Print deprecation notices to the stderr
|
||||
config.active_support.deprecation = :stderr
|
||||
end
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# You can add backtrace silencers for libraries that you're using but don't
|
||||
# wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# You can also remove all the silencers if you're trying to debug a problem
|
||||
# that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
|
||||
|
||||
@ -4,4 +4,6 @@
|
||||
# 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.
|
||||
PlanCharacters::Application.config.secret_token = 'c3e5363c63e6014335eb03ad9d295daf0fa8314fd588b076b9ed746f325da910d8225639c4bae290ca02b94888421060ebcfa3ebeb0f7555a1c0b37758a8c1ca'
|
||||
PlanCharacters::Application.config.secret_token =
|
||||
'c3e5363c63e6014335eb03ad9d295daf0fa8314fd588b076b9ed746f325da910d8225639c4ba\
|
||||
e290ca02b94888421060ebcfa3ebeb0f7555a1c0b37758a8c1ca'
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
PlanCharacters::Application.config.session_store :cookie_store, key: '_plan_characters_session'
|
||||
PlanCharacters::Application
|
||||
.config.session_store :cookie_store,
|
||||
key: '_plan_characters_session'
|
||||
|
||||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
# is enabled by default.
|
||||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format
|
||||
# to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json]
|
||||
end
|
||||
|
||||
|
||||
@ -1,9 +1,734 @@
|
||||
# Sample localization file for English. Add more files in this directory for other locales.
|
||||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
# Localization file for English.
|
||||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
|
||||
# for starting points.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
||||
|
||||
quote_1: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante."
|
||||
|
||||
quote_1: >
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere
|
||||
erat a ante.
|
||||
quote_author_1: "Someone famous"
|
||||
quote_source_1: "Source Title"
|
||||
|
||||
no_view_permission: "You don't have permission to view that!"
|
||||
no_do_permission: "You don't have permission to do that!"
|
||||
must_be_logged_in: "You must be logged-in to do that!"
|
||||
|
||||
username_password_incorrect: "Username or password incorrect"
|
||||
login_successful: "Login successful."
|
||||
logged_out: "Logged out!"
|
||||
|
||||
all_universes: "All universes"
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
character: "Character"
|
||||
equipment: "Equipment"
|
||||
language: "Language"
|
||||
location: "Location"
|
||||
magic: "Magic"
|
||||
session: "Session"
|
||||
universe: "Universe"
|
||||
user: "User"
|
||||
attributes:
|
||||
location:
|
||||
map: "Map"
|
||||
|
||||
create_success: "%{model_name} was successfully created."
|
||||
update_success: "%{model_name} was successfully updated."
|
||||
|
||||
location_create_upload_map_error: >
|
||||
Location was created, but your map did not upload. Please try again.
|
||||
|
||||
location_update_upload_map_error: >
|
||||
Location was updated, but your map did not upload. Please try again.
|
||||
|
||||
body_types:
|
||||
- "Delicate"
|
||||
- "Flat"
|
||||
- "Fragile"
|
||||
- "Lean"
|
||||
- "Lightly muscled"
|
||||
- "Small-shouldered"
|
||||
- "Thin"
|
||||
- "Athletic"
|
||||
- "Hourglass"
|
||||
- "Bodybuilder"
|
||||
- "Rectangular"
|
||||
- "Muscular"
|
||||
- "Thick-skinned"
|
||||
- "Big-boned"
|
||||
- "Round physique"
|
||||
- "Pear-shaped"
|
||||
|
||||
eye_colors:
|
||||
- "Amber"
|
||||
- "Black"
|
||||
- "Arctic blue"
|
||||
- "Baby blue"
|
||||
- "China blue"
|
||||
- "Cornflower blue"
|
||||
- "Crystal blue"
|
||||
- "Denim blue"
|
||||
- "Electric blue"
|
||||
- "Indigo"
|
||||
- "Sapphire blue"
|
||||
- "Sky blue"
|
||||
- "Champagne brown"
|
||||
- "Chestnut brown"
|
||||
- "Chocolate brown"
|
||||
- "Golden brown"
|
||||
- "Honey brown"
|
||||
- "Topaz"
|
||||
- "Charcoal grey"
|
||||
- "Cloudy grey"
|
||||
- "Steel grey"
|
||||
- "Chartreuse"
|
||||
- "Emerald green"
|
||||
- "Forest green"
|
||||
- "Grass green"
|
||||
- "Jade green"
|
||||
- "Leaf green"
|
||||
- "Sea green"
|
||||
- "Hazel"
|
||||
- "Amethyst"
|
||||
- "Hyacinth"
|
||||
- "Ultramarine blue"
|
||||
- "One green, one blue"
|
||||
- "One blue, one brown"
|
||||
- "One brown, one blue"
|
||||
- "One brown, one green"
|
||||
- "Light violet"
|
||||
- "Dark violet"
|
||||
|
||||
facial_hair_styles:
|
||||
- "Beard, long"
|
||||
- "Beard, short"
|
||||
- "Chin curtain"
|
||||
- "Chinstrap"
|
||||
- "Fu Manchu, short"
|
||||
- "Fu Manchu, long"
|
||||
- "Goatee"
|
||||
- "Handlebar mustache"
|
||||
- "Horseshoe mustache"
|
||||
- "Mustache"
|
||||
- "Mutton chops, thin"
|
||||
- "Mutton chops, thick"
|
||||
- "Neckbeard"
|
||||
- "Pencil mustache"
|
||||
- "Shenandoah"
|
||||
- "Sideburns"
|
||||
- "Soul patch"
|
||||
- "Light stubble"
|
||||
- "Thick stubble"
|
||||
- "Toothbrush mustache"
|
||||
- "Van Dyke beard"
|
||||
- "Patchy beard"
|
||||
- "Patchy mustache"
|
||||
|
||||
hair_colors:
|
||||
- "Blonde"
|
||||
- "Black"
|
||||
- "Brown"
|
||||
- "Red"
|
||||
- "Bald"
|
||||
- "White"
|
||||
- "Grey"
|
||||
- "Balding"
|
||||
- "Greying"
|
||||
- "Bleached"
|
||||
- "Blue"
|
||||
- "Green"
|
||||
- "Purple"
|
||||
- "Orange"
|
||||
- "Auburn"
|
||||
- "Strawberry"
|
||||
- "Chestnut"
|
||||
- "Dirty Blonde"
|
||||
- "Rainbow"
|
||||
- "Black tips"
|
||||
- "Jet black"
|
||||
- "Raven black"
|
||||
|
||||
hair_styles:
|
||||
- "Afro"
|
||||
- "Bald"
|
||||
- "Balding"
|
||||
- "Bob cut"
|
||||
- "Bowl cut"
|
||||
- "Bouffant"
|
||||
- "Braided"
|
||||
- "Bun"
|
||||
- "Butch"
|
||||
- "Buzz cut"
|
||||
- "Chignon"
|
||||
- "Chonmage"
|
||||
- "Comb over"
|
||||
- "Cornrows"
|
||||
- "Crew cut"
|
||||
- "Dreadlocks"
|
||||
- "Emo"
|
||||
- "Fauxhawk"
|
||||
- "Feathered"
|
||||
- "Flattop"
|
||||
- "Fringe"
|
||||
- "Liberty Spikes"
|
||||
- "Long hair, straight"
|
||||
- "Long hair, curly"
|
||||
- "Long hair, wavy"
|
||||
- "Mohawk"
|
||||
- "Mop-top"
|
||||
- "Odango"
|
||||
- "Pageboy"
|
||||
- "Parted"
|
||||
- "Pigtails"
|
||||
- "Pixie cut"
|
||||
- "Pompadour"
|
||||
- "Ponytail"
|
||||
- "Rattail"
|
||||
- "Rocker"
|
||||
- "Slicked back"
|
||||
- "Spiky, short"
|
||||
- "Spiky, long"
|
||||
- "Short, curly"
|
||||
- "Short, wavy"
|
||||
- "Short, thin"
|
||||
- "Short, straight"
|
||||
|
||||
identifying_marks:
|
||||
- "minor scar"
|
||||
- "large scar"
|
||||
- "mole"
|
||||
- "fleshy growth"
|
||||
- "tattoo"
|
||||
- "discoloration"
|
||||
|
||||
on_the: "on the"
|
||||
|
||||
identifying_mark_locations:
|
||||
- "left eye"
|
||||
- "right eye"
|
||||
- "left thigh"
|
||||
- "right thigh"
|
||||
- "left shin"
|
||||
- "right shin"
|
||||
- "left foot"
|
||||
- "right foot"
|
||||
- "big toe"
|
||||
- "hip"
|
||||
- "stomach"
|
||||
- "lower back"
|
||||
- "chest"
|
||||
- "upper back"
|
||||
- "left shoulder"
|
||||
- "right shoulder"
|
||||
- "left bicep"
|
||||
- "right bicep"
|
||||
- "left tricep"
|
||||
- "right tricep"
|
||||
- "left hand"
|
||||
- "right hand"
|
||||
- "pointer finger"
|
||||
- "thumb"
|
||||
- "neck"
|
||||
- "scalp"
|
||||
- "above lip"
|
||||
- "nose"
|
||||
- "left ear"
|
||||
- "right ear"
|
||||
- "forehead"
|
||||
- "left cheek"
|
||||
- "right cheek"
|
||||
- "left temple"
|
||||
- "right temple"
|
||||
- "chin"
|
||||
- "beneath chin"
|
||||
|
||||
male_first_names:
|
||||
- "James"
|
||||
- "John"
|
||||
- "Robert"
|
||||
- "Michael"
|
||||
- "William"
|
||||
- "David"
|
||||
- "Richard"
|
||||
- "Charles"
|
||||
- "Joseph"
|
||||
- "Thomas"
|
||||
- "Christopher"
|
||||
- "Daniel"
|
||||
- "Paul"
|
||||
- "Mark"
|
||||
- "Donald"
|
||||
- "George"
|
||||
- "Kenneth"
|
||||
- "Steven"
|
||||
- "Edward"
|
||||
- "Brian"
|
||||
- "Ronald"
|
||||
- "Anthony"
|
||||
- "Kevin"
|
||||
- "Jason"
|
||||
- "Matthew"
|
||||
- "Gary"
|
||||
- "Timothy"
|
||||
- "Jose"
|
||||
- "Larry"
|
||||
- "Jeffrey"
|
||||
- "Frank"
|
||||
- "Scott"
|
||||
- "Eric"
|
||||
- "Stephen"
|
||||
- "Andrew"
|
||||
- "Raymond"
|
||||
- "Gregory"
|
||||
|
||||
female_first_names:
|
||||
- "Mary"
|
||||
- "Patricia"
|
||||
- "Linda"
|
||||
- "Barbara"
|
||||
- "Elizabeth"
|
||||
- "Jennifer"
|
||||
- "Maria"
|
||||
- "Susan"
|
||||
- "Margaret"
|
||||
- "Margret"
|
||||
- "Dorothy"
|
||||
- "Lisa"
|
||||
- "Nancy"
|
||||
- "Karen"
|
||||
- "Betty"
|
||||
- "Helen"
|
||||
- "Sandra"
|
||||
- "Donna"
|
||||
- "Carol"
|
||||
- "Ruth"
|
||||
- "Sharon"
|
||||
- "Michelle"
|
||||
- "Laura"
|
||||
- "Sarah"
|
||||
- "Kimberly"
|
||||
- "Deborah"
|
||||
- "Jessica"
|
||||
- "Shirley"
|
||||
- "Cynthia"
|
||||
- "Angela"
|
||||
- "Melissa"
|
||||
- "Brenda"
|
||||
- "Amy"
|
||||
- "Anna"
|
||||
- "Rebecca"
|
||||
- "Virginia"
|
||||
- "Kathleen"
|
||||
- "Pamela"
|
||||
|
||||
last_names:
|
||||
- "Smith"
|
||||
- "Brown"
|
||||
- "Lee"
|
||||
- "Wilson"
|
||||
- "Martin"
|
||||
- "Patel"
|
||||
- "Taylor"
|
||||
- "Wong"
|
||||
- "Campbell"
|
||||
- "Williams"
|
||||
- "Thompson"
|
||||
- "Jones"
|
||||
- "Johnson"
|
||||
- "Miller"
|
||||
- "Davis"
|
||||
- "Garcia"
|
||||
- "Rodriguez"
|
||||
- "Martinez"
|
||||
- "Anderson"
|
||||
- "Jackson"
|
||||
- "White"
|
||||
- "Green"
|
||||
- "Lee"
|
||||
- "Harris"
|
||||
- "Clark"
|
||||
- "Lewis"
|
||||
- "Robinson"
|
||||
- "Walker"
|
||||
- "Hall"
|
||||
- "Young"
|
||||
- "Allen"
|
||||
- "Sanchez"
|
||||
- "Wright"
|
||||
- "King"
|
||||
- "Scott"
|
||||
- "Roberts"
|
||||
- "Carter"
|
||||
- "Phillips"
|
||||
- "Evans"
|
||||
- "Turner"
|
||||
- "Torres"
|
||||
- "Parker"
|
||||
- "Collins"
|
||||
- "Stewart"
|
||||
- "Flores"
|
||||
- "Morris"
|
||||
- "Nguyen"
|
||||
- "Murphy"
|
||||
- "Rivera"
|
||||
- "Cook"
|
||||
- "Morgan"
|
||||
- "Peterson"
|
||||
- "Cooper"
|
||||
- "Gomez"
|
||||
- "Ward"
|
||||
|
||||
character_races:
|
||||
- "Android"
|
||||
- "Angel"
|
||||
- "Animal"
|
||||
- "Arachnoid"
|
||||
- "Bird"
|
||||
- "Construct"
|
||||
- "Dark Elf"
|
||||
- "Dwarf"
|
||||
- "Elemental"
|
||||
- "Elf"
|
||||
- "Fairy"
|
||||
- "Fey"
|
||||
- "Genie"
|
||||
- "Gnome"
|
||||
- "Half-Dwarf"
|
||||
- "Half-Elf"
|
||||
- "Half-Orc"
|
||||
- "Halfling"
|
||||
- "Human"
|
||||
- "Insectoid"
|
||||
- "Orc"
|
||||
- "Reptilian"
|
||||
- "Robot"
|
||||
- "Spirit"
|
||||
- "Vampire"
|
||||
- "Werewolf"
|
||||
|
||||
skin_tones:
|
||||
- "Albino"
|
||||
- "Light"
|
||||
- "Pale white"
|
||||
- "Fair"
|
||||
- "White"
|
||||
- "Medium"
|
||||
- "Olive"
|
||||
- "Moderate brown"
|
||||
- "Brown"
|
||||
- "Dark brown"
|
||||
- "Black"
|
||||
|
||||
location_name_prefixes:
|
||||
- "New"
|
||||
- "Los"
|
||||
- "Fort"
|
||||
- "City of"
|
||||
- "El"
|
||||
- "Saint"
|
||||
- "Des"
|
||||
- "Little"
|
||||
- "Big"
|
||||
- "North"
|
||||
- "East"
|
||||
- "South"
|
||||
- "West"
|
||||
- "Round"
|
||||
- "The"
|
||||
- "Broken"
|
||||
- "Santa"
|
||||
|
||||
location_name_suffixes:
|
||||
- "Port"
|
||||
- "City"
|
||||
- "Grove"
|
||||
- "Pines"
|
||||
- "Falls"
|
||||
- "Heights"
|
||||
- "Oaks"
|
||||
- "Rapids"
|
||||
- "Valley"
|
||||
- "Mountains"
|
||||
- "Peaks"
|
||||
- "Arbor"
|
||||
- "Mesa"
|
||||
- "Gardens"
|
||||
- "Palms"
|
||||
- "Beach"
|
||||
- "Bend"
|
||||
- "Ruins"
|
||||
|
||||
location_name_syllables:
|
||||
- "lo"
|
||||
- "chi"
|
||||
- "ca"
|
||||
- "go"
|
||||
- "hou"
|
||||
- "ston"
|
||||
- "nix"
|
||||
- "pho"
|
||||
- "an"
|
||||
- "ant"
|
||||
- "ton"
|
||||
- "io"
|
||||
- "san"
|
||||
- "die"
|
||||
- "dia"
|
||||
- "dal"
|
||||
- "las"
|
||||
- "son"
|
||||
- "vil"
|
||||
- "pol"
|
||||
- "ral"
|
||||
- "polis"
|
||||
- "na"
|
||||
- "aus"
|
||||
- "tin"
|
||||
- "fran"
|
||||
- "cis"
|
||||
- "co"
|
||||
- "col"
|
||||
- "umb"
|
||||
- "bus"
|
||||
- "cha"
|
||||
- "mem"
|
||||
- "phis"
|
||||
- "sea"
|
||||
- "wor"
|
||||
- "the"
|
||||
- "tha"
|
||||
- "den"
|
||||
- "was"
|
||||
- "bal"
|
||||
- "ti"
|
||||
- "mo"
|
||||
- "ash"
|
||||
- "wau"
|
||||
- "kee"
|
||||
- "ki"
|
||||
- "ru"
|
||||
- "lu"
|
||||
- "cest"
|
||||
- "pro"
|
||||
- "ora"
|
||||
- "ode"
|
||||
- "mu"
|
||||
- "ill"
|
||||
- "ville"
|
||||
- "vil"
|
||||
|
||||
shield_types:
|
||||
- "Greek aspis"
|
||||
- "Buckler"
|
||||
- "Heater shield"
|
||||
- "Heraldic shield"
|
||||
- "Leather shield"
|
||||
- "Hide shield"
|
||||
- "Hoplon shield"
|
||||
- "Kite shield"
|
||||
- "Scutum"
|
||||
- "Targe"
|
||||
|
||||
weapon_types:
|
||||
- "Bastard sword"
|
||||
- "Battleaxe"
|
||||
- "Bolas"
|
||||
- "Bow & Arrow"
|
||||
- "Bowstaff"
|
||||
- "Brass knuckles"
|
||||
- "Broom"
|
||||
- "Chainsaw"
|
||||
- "Club"
|
||||
- "Dagger"
|
||||
- "Darts"
|
||||
- "Falchion"
|
||||
- "Flail"
|
||||
- "Gauntlet"
|
||||
- "Glaive"
|
||||
- "Greataxe"
|
||||
- "Greatsword"
|
||||
- "Halberd"
|
||||
- "Handaxe"
|
||||
- "Hand crossbow"
|
||||
- "Heavy crossbow"
|
||||
- "Javelin"
|
||||
- "Kama"
|
||||
- "Kukri"
|
||||
- "Lance"
|
||||
- "Longbow"
|
||||
- "Longsword"
|
||||
- "Madu"
|
||||
- "Morningstar"
|
||||
- "Net"
|
||||
- "Nunchaku"
|
||||
- "Pocket knife"
|
||||
- "Quarterstaff"
|
||||
- "Ranseur"
|
||||
- "Rapier"
|
||||
- "Repeating crossbow"
|
||||
- "Sai"
|
||||
- "Sap"
|
||||
- "Scimitar"
|
||||
- "Scythe"
|
||||
- "Shortsword"
|
||||
- "Shortbow"
|
||||
- "Shortspear"
|
||||
- "Shuriken"
|
||||
- "Siangham"
|
||||
- "Sickle"
|
||||
- "Sling"
|
||||
- "Spear"
|
||||
- "Throwing axe"
|
||||
- "Trident"
|
||||
- "Warhammer"
|
||||
- "Whip"
|
||||
|
||||
axe_types:
|
||||
- "Bardiche"
|
||||
- "Battleaxe"
|
||||
- "Broadaxe"
|
||||
- "Handaxe"
|
||||
- "Hatchet"
|
||||
- "Long-bearded axe"
|
||||
- "Tomahawk"
|
||||
|
||||
bow_types:
|
||||
- "Longbow"
|
||||
- "Sling"
|
||||
- "Blowgun"
|
||||
- "Flatbow"
|
||||
- "Composite bow"
|
||||
- "Yumi"
|
||||
- "Gungdo"
|
||||
- "Shortbow"
|
||||
- "Arbalest"
|
||||
- "Crossbow"
|
||||
- "Repeating crossbow"
|
||||
|
||||
club_types:
|
||||
- "Boomerang"
|
||||
- "Frying pan"
|
||||
- "Hammer"
|
||||
- "Brick"
|
||||
- "Mace"
|
||||
- "Morningstar"
|
||||
- "Sai"
|
||||
- "Scepter"
|
||||
- "Sledgehammer"
|
||||
- "Lamp"
|
||||
- "Glass bottle"
|
||||
- "Warhammer"
|
||||
- "Wrench"
|
||||
- "Crowbar"
|
||||
|
||||
fist_weapon_types:
|
||||
- "Bahh nakh, tiger claws"
|
||||
- "Brass knuckles"
|
||||
- "Cestus"
|
||||
- "Deer horn knives"
|
||||
- "Finger knife"
|
||||
- "Gauntlets"
|
||||
- "Katar"
|
||||
- "Korean fan"
|
||||
- "Madu, buckhorn stick"
|
||||
- "Pata sword gauntlet"
|
||||
- "Push dagger"
|
||||
- "Roman scissor"
|
||||
- "War fan"
|
||||
- "Wind and fire wheels"
|
||||
- "Emei daggers"
|
||||
- "Large stone"
|
||||
- "Brick"
|
||||
|
||||
flexible_weapon_types:
|
||||
- "Bullwhip"
|
||||
- "Cat o' nine tails"
|
||||
- "Chain whip"
|
||||
- "Lasso"
|
||||
- "Nunchaku"
|
||||
- "Flail"
|
||||
- "Meteor hammer"
|
||||
|
||||
thrown_weapon_types:
|
||||
- "Harpoon"
|
||||
- "Bolas"
|
||||
- "Javelin"
|
||||
- "Pilum"
|
||||
- "Woomera"
|
||||
- "Angon"
|
||||
- "Chakram"
|
||||
- "Kunai"
|
||||
- "Boomerang"
|
||||
- "Throwing knife"
|
||||
- "Thrown darts"
|
||||
- "Swiss arrow"
|
||||
- "Francisca"
|
||||
- "Tomahawk"
|
||||
- "Shuriken"
|
||||
- "Stones"
|
||||
|
||||
polearm_types:
|
||||
- "Bo"
|
||||
- "Taiji staff"
|
||||
- "Quarterstaff"
|
||||
- "Staff"
|
||||
- "Spear"
|
||||
- "Lance"
|
||||
- "Pike"
|
||||
- "Pitchfork"
|
||||
- "Qiang"
|
||||
- "Ranseur"
|
||||
- "Spetum"
|
||||
- "Swordstaff"
|
||||
- "Trident"
|
||||
- "Bardiche"
|
||||
- "Bill"
|
||||
- "Glaive"
|
||||
- "Halberd"
|
||||
- "Lochaber axe"
|
||||
- "Naginata"
|
||||
- "Partizan"
|
||||
- "Scythe"
|
||||
- "Voulge"
|
||||
- "War scythe"
|
||||
|
||||
shortsword_types:
|
||||
- "Dagger"
|
||||
- "Fireplace poker"
|
||||
- "Small sword"
|
||||
- "Xiphos shortsword"
|
||||
- "Aikuchi shortsword"
|
||||
- "Kodachi shortsword"
|
||||
- "Pinuti shortsword"
|
||||
- "Wakizashi shortsword"
|
||||
|
||||
sword_types:
|
||||
- "Cutlass"
|
||||
- "Dao"
|
||||
- "Dha"
|
||||
- "Falchion"
|
||||
- "Hunting sword"
|
||||
- "Kukri"
|
||||
- "Pulwar"
|
||||
- "Sabre"
|
||||
- "Scimitar"
|
||||
- "Shamshir"
|
||||
- "Talwar"
|
||||
- "Epee"
|
||||
- "Flamberge"
|
||||
- "Longsword"
|
||||
- "Ninjato"
|
||||
- "Rapier"
|
||||
- "Katana"
|
||||
- "Claymore"
|
||||
- "Dadao"
|
||||
- "Executioner's sword"
|
||||
- "Flambard"
|
||||
- "Greatsword"
|
||||
- "Nodachi"
|
||||
- "Falcata"
|
||||
- "Machete"
|
||||
- "Yatagan"
|
||||
|
||||
237
config/routes.rb
237
config/routes.rb
@ -1,184 +1,187 @@
|
||||
PlanCharacters::Application.routes.draw do
|
||||
# rubocop:disable LineLength
|
||||
|
||||
# Main pages
|
||||
root :to => 'main#index', :as => :homepage
|
||||
root to: 'main#index', as: :homepage
|
||||
|
||||
# Info pages
|
||||
scope '/about' do
|
||||
get '/anon-login', :to => 'main#anoninfo', :as => :anon_info
|
||||
get '/privacy', :to => 'main#privacyinfo', :as => :privacy_info
|
||||
get '/attribution', :to => 'main#attribution', :as => :attribution_info
|
||||
get '/anon-login', to: 'main#anoninfo', as: :anon_info
|
||||
get '/privacy', to: 'main#privacyinfo', as: :privacy_info
|
||||
get '/attribution', to: 'main#attribution', as: :attribution_info
|
||||
end
|
||||
|
||||
|
||||
# User-centric stuff
|
||||
scope '/my' do
|
||||
get '/content', :to => 'main#dashboard', :as => :dashboard
|
||||
get '/submissions', :to => 'main#comingsoon'
|
||||
get '/content', to: 'main#dashboard', as: :dashboard
|
||||
get '/submissions', to: 'main#comingsoon'
|
||||
end
|
||||
|
||||
|
||||
# Sessions
|
||||
get '/login', :to => 'sessions#new', :as => :login
|
||||
post '/login', :to => 'sessions#create', :as => :login_process
|
||||
get '/logout', :to => 'sessions#destroy', :as => :logout
|
||||
get '/login', to: 'sessions#new', as: :login
|
||||
post '/login', to: 'sessions#create', as: :login_process
|
||||
get '/logout', to: 'sessions#destroy', as: :logout
|
||||
|
||||
# Users
|
||||
get '/register', :to => 'users#new', :as => :signup
|
||||
post '/register', :to => 'users#create', :as => :signup_process
|
||||
get '/account', :to => 'users#edit', :as => :account
|
||||
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
|
||||
|
||||
get '/register', to: 'users#new', as: :signup
|
||||
post '/register', to: 'users#create', as: :signup_process
|
||||
get '/account', to: 'users#edit', as: :account
|
||||
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
|
||||
|
||||
# Planning
|
||||
scope '/plan' do
|
||||
# Characters
|
||||
get '/characters', :to => 'characters#index', :as => :character_list
|
||||
get '/characters/from/:universe', :to => 'characters#index', :as => :characters_by_universe
|
||||
get '/character/new', :to => 'characters#new', :as => :character_create
|
||||
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
|
||||
patch '/character/:id', :to => 'characters#update', :as => :character_edit_process
|
||||
delete '/character/:id', :to => 'characters#destroy', :as => :character_destroy
|
||||
get '/characters', to: 'characters#index', as: :character_list
|
||||
get '/characters/from/:universe', to: 'characters#index', as: :characters_by_universe
|
||||
get '/character/new', to: 'characters#new', as: :character_create
|
||||
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
|
||||
patch '/character/:id', to: 'characters#update', as: :character_edit_process
|
||||
delete '/character/:id', to: 'characters#destroy', as: :character_destroy
|
||||
|
||||
# Equipment
|
||||
get '/equipment', :to => 'equipment#index', :as => :equipment_list
|
||||
get '/equipment/from/:universe', :to => 'equipment#index', :as => :equipment_by_universe
|
||||
get '/equipment/new', :to => 'equipment#new', :as => :equipment_create
|
||||
get '/equipment/new/:type_of', :to => 'equipment#new', :as => :equipment_create_type
|
||||
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
|
||||
patch '/equipment/:id', :to => 'equipment#update', :as => :equipment_edit_process
|
||||
delete '/equipment/:id', :to => 'equipment#destroy', :as => :equipment_destroy
|
||||
get '/equipment', to: 'equipment#index', as: :equipment_list
|
||||
get '/equipment/from/:universe', to: 'equipment#index', as: :equipment_by_universe
|
||||
get '/equipment/new', to: 'equipment#new', as: :equipment_create
|
||||
get '/equipment/new/:type_of', to: 'equipment#new', as: :equipment_create_type
|
||||
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
|
||||
patch '/equipment/:id', to: 'equipment#update', as: :equipment_edit_process
|
||||
delete '/equipment/:id', to: 'equipment#destroy', as: :equipment_destroy
|
||||
|
||||
# Languages
|
||||
get '/languages', :to => 'languages#index', :as => :language_list
|
||||
get '/languages/from/:universe', :to => 'languages#index', :as => :languages_by_universe
|
||||
get '/language/new', :to => 'languages#new', :as => :language_create
|
||||
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
|
||||
patch '/language/:id', :to => 'languages#update', :as => :language_edit_process
|
||||
delete '/language/:id', :to => 'languages#destroy', :as => :language_destroy
|
||||
get '/languages', to: 'languages#index', as: :language_list
|
||||
get '/languages/from/:universe', to: 'languages#index', as: :languages_by_universe
|
||||
get '/language/new', to: 'languages#new', as: :language_create
|
||||
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
|
||||
patch '/language/:id', to: 'languages#update', as: :language_edit_process
|
||||
delete '/language/:id', to: 'languages#destroy', as: :language_destroy
|
||||
|
||||
# Locations
|
||||
get '/locations', :to => 'locations#index', :as => :location_list
|
||||
get '/locations/from/:universe', :to => 'locations#index', :as => :locations_by_universe
|
||||
get '/location/new', :to => 'locations#new', :as => :location_create
|
||||
post '/location/new', :to => 'locations#create', :as => :location_create_process
|
||||
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
|
||||
patch '/location/:id', :to => 'locations#update', :as => :location_edit_process
|
||||
delete '/location/:id', :to => 'locations#destroy', :as => :location_destroy
|
||||
get '/locations', to: 'locations#index', as: :location_list
|
||||
get '/locations/from/:universe', to: 'locations#index', as: :locations_by_universe
|
||||
get '/location/new', to: 'locations#new', as: :location_create
|
||||
post '/location/new', to: 'locations#create', as: :location_create_process
|
||||
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
|
||||
patch '/location/:id', to: 'locations#update', as: :location_edit_process
|
||||
delete '/location/:id', to: 'locations#destroy', as: :location_destroy
|
||||
|
||||
# Magic
|
||||
get '/magic', :to => 'magic#index', :as => :magic_list
|
||||
get '/magic/from/:universe', :to => 'magic#index', :as => :magic_by_universe
|
||||
get '/magic/new', :to => 'magic#new', :as => :magic_create
|
||||
post '/magic/new', :to => 'magic#create', :as => :magic_create_process
|
||||
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
|
||||
patch '/magic/:id', :to => 'magic#update', :as => :magic_edit_process
|
||||
delete '/magic/:id', :to => 'magic#destroy', :as => :magic_destroy
|
||||
get '/magic', to: 'magic#index', as: :magic_list
|
||||
get '/magic/from/:universe', to: 'magic#index', as: :magic_by_universe
|
||||
get '/magic/new', to: 'magic#new', as: :magic_create
|
||||
post '/magic/new', to: 'magic#create', as: :magic_create_process
|
||||
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
|
||||
patch '/magic/:id', to: 'magic#update', as: :magic_edit_process
|
||||
delete '/magic/:id', to: 'magic#destroy', as: :magic_destroy
|
||||
|
||||
# Universes
|
||||
get '/universes', :to => 'universes#index', :as => :universe_list
|
||||
get '/universe/new', :to => 'universes#new', :as => :universe_create
|
||||
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
|
||||
patch '/universe/:id', :to => 'universes#update', :as => :universe_edit_process
|
||||
delete '/universe/:id', :to => 'universes#destroy', :as => :universe_destroy
|
||||
get '/universes', to: 'universes#index', as: :universe_list
|
||||
get '/universe/new', to: 'universes#new', as: :universe_create
|
||||
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
|
||||
patch '/universe/:id', to: 'universes#update', as: :universe_edit_process
|
||||
delete '/universe/:id', to: 'universes#destroy', as: :universe_destroy
|
||||
|
||||
# Coming Soon TM
|
||||
get '/plots', :to => 'main#comingsoon'
|
||||
get '/plots', to: 'main#comingsoon'
|
||||
end
|
||||
|
||||
|
||||
# API Endpoints
|
||||
scope '/generate' do
|
||||
# General information
|
||||
|
||||
|
||||
# Character information
|
||||
scope '/character' do
|
||||
get '/age', :to => 'generator#character_age'
|
||||
get '/bodytype', :to => 'generator#character_bodytype'
|
||||
get '/eyecolor', :to => 'generator#character_eyecolor'
|
||||
get '/facial-hair', :to => 'generator#character_facialhair'
|
||||
get '/haircolor', :to => 'generator#character_haircolor'
|
||||
get '/hairstyle', :to => 'generator#character_hairstyle'
|
||||
get '/height', :to => 'generator#character_height'
|
||||
get '/identifying-mark', :to => 'generator#character_identifyingmark'
|
||||
get '/name', :to => 'generator#character_name'
|
||||
get '/race', :to => 'generator#character_race'
|
||||
get '/skintone', :to => 'generator#character_skintone'
|
||||
get '/weight', :to => 'generator#character_weight'
|
||||
get '/age', to: 'characters_generator#age'
|
||||
get '/bodytype', to: 'characters_generator#bodytype'
|
||||
get '/eyecolor', to: 'characters_generator#eyecolor'
|
||||
get '/facial-hair', to: 'characters_generator#facialhair'
|
||||
get '/haircolor', to: 'characters_generator#haircolor'
|
||||
get '/hairstyle', to: 'characters_generator#hairstyle'
|
||||
get '/height', to: 'characters_generator#height'
|
||||
get '/identifying-mark', to: 'characters_generator#identifyingmark'
|
||||
get '/name', to: 'characters_generator#name'
|
||||
get '/race', to: 'characters_generator#race'
|
||||
get '/skintone', to: 'characters_generator#skintone'
|
||||
get '/weight', to: 'characters_generator#weight'
|
||||
end
|
||||
|
||||
|
||||
# Location information
|
||||
scope '/location' do
|
||||
get '/name', :to => 'generator#location_name'
|
||||
get '/name', to: 'locations_generator#name'
|
||||
end
|
||||
|
||||
# Equipment location
|
||||
scope '/equipment' do
|
||||
scope '/weapon' do
|
||||
get '/', :to => 'generator#equipment_weapon'
|
||||
get '/', to: 'equipment_generator#weapon'
|
||||
|
||||
get '/axe', :to => 'generator#equipment_weapon_axe'
|
||||
get '/bow', :to => 'generator#equipment_weapon_bow'
|
||||
get '/club', :to => 'generator#equipment_weapon_club'
|
||||
get '/fist', :to => 'generator#equipment_weapon_fist'
|
||||
get '/flexible', :to => 'generator#equipment_weapon_flexible'
|
||||
#todo /gun
|
||||
get '/polearm', :to => 'generator#equipment_weapon_polearm'
|
||||
get '/shortsword', :to => 'generator#equipment_weapon_shortsword'
|
||||
get '/sword', :to => 'generator#equipment_weapon_sword'
|
||||
get '/thrown', :to => 'generator#equipment_weapon_thrown'
|
||||
end
|
||||
get '/axe', to: 'equipment_generator#weapon_axe'
|
||||
get '/bow', to: 'equipment_generator#weapon_bow'
|
||||
get '/club', to: 'equipment_generator#weapon_club'
|
||||
get '/fist', to: 'equipment_generator#weapon_fist'
|
||||
get '/flexible', to: 'equipment_generator#weapon_flexible'
|
||||
# TODO: /gun
|
||||
get '/polearm', to: 'equipment_generator#weapon_polearm'
|
||||
get '/shortsword', to: 'equipment_generator#weapon_shortsword'
|
||||
get '/sword', to: 'equipment_generator#weapon_sword'
|
||||
get '/thrown', to: 'equipment_generator#weapon_thrown'
|
||||
end
|
||||
|
||||
scope '/armor' do
|
||||
get '/', :to => 'generator#equipment_armor'
|
||||
get '/', to: 'equipment_generator#armor'
|
||||
|
||||
get '/shield', :to => 'generator#equipment_armor_shield'
|
||||
get '/shield', to: 'equipment_generator#armor_shield'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Adoption Agency
|
||||
scope '/adoption' do
|
||||
get '/', :to => 'main#comingsoon'
|
||||
get '/', to: 'main#comingsoon'
|
||||
end
|
||||
|
||||
# Idea Market
|
||||
scope '/market' do
|
||||
get '/', :to => 'main#comingsoon'
|
||||
get '/', to: 'main#comingsoon'
|
||||
end
|
||||
|
||||
|
||||
# Write
|
||||
scope '/write' do
|
||||
get '/lyrics', :to => 'main#comingsoon'
|
||||
get '/novel', :to => 'main#comingsoon'
|
||||
get '/nonfiction', :to => 'main#comingsoon'
|
||||
get '/poetry', :to => 'main#comingsoon'
|
||||
get '/screenplay', :to => 'main#comingsoon'
|
||||
get '/story', :to => 'main#comingsoon'
|
||||
get '/lyrics', to: 'main#comingsoon'
|
||||
get '/novel', to: 'main#comingsoon'
|
||||
get '/nonfiction', to: 'main#comingsoon'
|
||||
get '/poetry', to: 'main#comingsoon'
|
||||
get '/screenplay', to: 'main#comingsoon'
|
||||
get '/story', to: 'main#comingsoon'
|
||||
end
|
||||
|
||||
|
||||
# Revise
|
||||
scope '/revise' do
|
||||
get '/checklists', :to => 'main#comingsoon'
|
||||
get '/analytics', :to => 'main#comingsoon'
|
||||
get '/peer-critiques', :to => 'main#comingsoon'
|
||||
get '/professional-review', :to => 'main#comingsoon'
|
||||
get '/checklists', to: 'main#comingsoon'
|
||||
get '/analytics', to: 'main#comingsoon'
|
||||
get '/peer-critiques', to: 'main#comingsoon'
|
||||
get '/professional-review', to: 'main#comingsoon'
|
||||
end
|
||||
|
||||
|
||||
# Submit
|
||||
scope '/submit' do
|
||||
get '/blog', :to => 'main#comingsoon'
|
||||
get '/print-publishers', :to => 'main#comingsoon'
|
||||
get '/online-publishers', :to => 'main#comingsoon'
|
||||
get '/blog', to: 'main#comingsoon'
|
||||
get '/print-publishers', to: 'main#comingsoon'
|
||||
get '/online-publishers', to: 'main#comingsoon'
|
||||
end
|
||||
|
||||
# rubocop:enable LineLength
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
class CreateModels < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :characters do |t|
|
||||
t.string :name, :null => false
|
||||
t.string :name, null: false
|
||||
t.string :role
|
||||
t.string :gender
|
||||
t.string :age
|
||||
@ -25,25 +25,25 @@ class CreateModels < ActiveRecord::Migration
|
||||
t.text :prejudices
|
||||
t.text :occupation
|
||||
t.text :pets
|
||||
#How might others describe him?
|
||||
#What would others change about him?
|
||||
# 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?
|
||||
# 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?
|
||||
# What is his deepest secret?
|
||||
# Does he have a history of criminal activity?
|
||||
|
||||
# Favorites
|
||||
t.string :fave_color
|
||||
@ -51,7 +51,7 @@ class CreateModels < ActiveRecord::Migration
|
||||
t.string :fave_possession
|
||||
t.string :fave_weapon
|
||||
t.string :fave_animal
|
||||
#favorite leisure activities
|
||||
# favorite leisure activities
|
||||
|
||||
# Relationships
|
||||
t.text :father
|
||||
@ -63,16 +63,16 @@ class CreateModels < ActiveRecord::Migration
|
||||
# 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 :name, null: false
|
||||
t.string :equip_type
|
||||
|
||||
# Appearance
|
||||
@ -92,16 +92,16 @@ class CreateModels < ActiveRecord::Migration
|
||||
# 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
|
||||
t.string :name, null: false
|
||||
|
||||
# Vocabulary
|
||||
t.text :words
|
||||
@ -122,10 +122,10 @@ class CreateModels < ActiveRecord::Migration
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
create_table :locations do |t|
|
||||
# General
|
||||
t.string :name, :null => false
|
||||
t.string :name, null: false
|
||||
t.string :type_of
|
||||
t.text :description
|
||||
|
||||
@ -137,8 +137,8 @@ class CreateModels < ActiveRecord::Migration
|
||||
t.string :language
|
||||
t.string :currency
|
||||
t.string :motto
|
||||
#field :flag, :type => Image
|
||||
#field :seal, :type => Image
|
||||
# field :flag, :type => Image
|
||||
# field :seal, :type => Image
|
||||
|
||||
# Cities
|
||||
t.text :capital
|
||||
@ -163,10 +163,10 @@ class CreateModels < ActiveRecord::Migration
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
create_table :magics do |t|
|
||||
# General
|
||||
t.string :name, :null => false
|
||||
t.string :name, null: false
|
||||
t.string :type_of # "Type of": Spell, Ability, Enchantment, etc
|
||||
|
||||
# Appearance
|
||||
@ -177,7 +177,7 @@ class CreateModels < ActiveRecord::Migration
|
||||
t.string :element
|
||||
t.string :diety
|
||||
|
||||
# # Effects
|
||||
# # Effects
|
||||
t.text :harmfulness # Harmful effects
|
||||
t.text :helpfulness # Helpful effects
|
||||
t.text :neutralness # Neutral effects
|
||||
@ -196,18 +196,17 @@ class CreateModels < ActiveRecord::Migration
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
create_table :sessions do |t|
|
||||
|
||||
t.string :username, :unique => true, :null => false
|
||||
t.string :password, :null => false
|
||||
|
||||
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.string :name, null: false
|
||||
t.text :description
|
||||
|
||||
# History
|
||||
@ -224,11 +223,11 @@ class CreateModels < ActiveRecord::Migration
|
||||
|
||||
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.string :name, unique: true, null: false
|
||||
t.string :email, unique: true, null: false
|
||||
t.string :password, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
278
db/schema.rb
278
db/schema.rb
@ -11,159 +11,157 @@
|
||||
#
|
||||
# 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"
|
||||
ActiveRecord::Schema.define(version: 20_140_713_043_535) 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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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
|
||||
|
||||
51
db/seeds.rb
51
db/seeds.rb
@ -1,37 +1,30 @@
|
||||
# ruby encoding: utf-8
|
||||
|
||||
tolkien = User.create({
|
||||
:name => 'JRRTolkien',
|
||||
:email => 'tolkien@example.com',
|
||||
:password => 'Mellon'})
|
||||
tolkien = User.create(name: 'JRRTolkien',
|
||||
email: 'tolkien@example.com',
|
||||
password: 'Mellon')
|
||||
|
||||
middleearth = Universe.create({
|
||||
:name => 'Middle-Earth',
|
||||
:user => tolkien,
|
||||
:privacy => 'public'})
|
||||
Universe.create(name: 'Middle-Earth',
|
||||
user: tolkien,
|
||||
privacy: 'public')
|
||||
|
||||
frodo = Character.create({
|
||||
:name => 'Frodo Baggins',
|
||||
:user => tolkien,
|
||||
:universe => middleearth,
|
||||
:age => '50'})
|
||||
Character.create(name: 'Frodo Baggins',
|
||||
user: tolkien,
|
||||
universe: middleearth,
|
||||
age: '50')
|
||||
|
||||
sting = Equipment.create({
|
||||
:name => 'Sting',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
Equipment.create(name: 'Sting',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
shire = Location.create({
|
||||
:name => 'The Shire',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
Location.create(name: 'The Shire',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
sindarin = Language.create({
|
||||
:name => 'Sindarin',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
Language.create(name: 'Sindarin',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
wizard = Magic.create({
|
||||
:name => 'Wizard Magic',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
Magic.create(name: 'Wizard Magic',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
@ -27,6 +27,7 @@ group :test, :development do
|
||||
gem 'selenium-webdriver'
|
||||
gem 'coveralls', :require => false
|
||||
gem 'simplecov', :require => false
|
||||
gem 'rubocop', require: false
|
||||
gem 'sqlite3'
|
||||
gem 'tzinfo-data' # addresses a bug when working on Windows
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the ApplicationController
|
||||
class ApplicationControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,54 +1,64 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the CharactersController class
|
||||
class CharactersControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@user = users(:tolkien)
|
||||
@universe = universes(:middleearth)
|
||||
|
||||
|
||||
log_in_user(:tolkien)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
test 'should get index' do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:characters)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
test 'should get new' do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create character" do
|
||||
test 'should create character' do
|
||||
assert_difference('Character.count') do
|
||||
post :create, character: { age: "Created Age", name: "Created 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
|
||||
test 'should show character' do
|
||||
@character = characters(:frodo)
|
||||
|
||||
|
||||
get :show, id: @character.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
test 'should get edit' do
|
||||
@character = characters(:frodo)
|
||||
get :edit, id: @character.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update character" do
|
||||
test 'should update character' do
|
||||
@character = characters(:frodo)
|
||||
put :update, id: @character, character: { age: @character.age, name: @character.name, universe: @universe }
|
||||
|
||||
|
||||
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
|
||||
test 'should destroy character' do
|
||||
assert_difference('Character.count', -1) do
|
||||
delete :destroy, id: characters(:frodo).id
|
||||
end
|
||||
|
||||
71
test/controllers/characters_generator_controller_test.rb
Normal file
71
test/controllers/characters_generator_controller_test.rb
Normal file
@ -0,0 +1,71 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the CharactersGeneratorController
|
||||
class CharactersGeneratorControllerTest < ActionController::TestCase
|
||||
test 'age' do
|
||||
assert_assigns :age, [:upper_limit, :lower_limit]
|
||||
assert_operator assigns(:lower_limit), :<=, assigns(:upper_limit)
|
||||
end
|
||||
|
||||
test 'body type' do
|
||||
assert_assigns :bodytype, [:possible_types]
|
||||
end
|
||||
|
||||
test 'eye color' do
|
||||
assert_assigns :eyecolor, [:possible_colors]
|
||||
end
|
||||
|
||||
test 'facial hair' do
|
||||
assert_assigns :facialhair, [:possible_styles]
|
||||
end
|
||||
|
||||
test 'hair color' do
|
||||
assert_assigns :haircolor, [:possible_colors]
|
||||
end
|
||||
|
||||
test 'hair style' do
|
||||
assert_assigns :hairstyle, [:possible_styles]
|
||||
end
|
||||
|
||||
test 'height' do
|
||||
assert_assigns :height, [
|
||||
:lower_foot_limit,
|
||||
:upper_foot_limit,
|
||||
:lower_inch_limit,
|
||||
:upper_inch_limit
|
||||
]
|
||||
assert_operator assigns(:lower_foot_limit), :<=, assigns(:upper_foot_limit)
|
||||
assert_operator assigns(:lower_inch_limit), :<=, assigns(:upper_inch_limit)
|
||||
|
||||
assert_operator assigns(:lower_foot_limit), :>=, 0
|
||||
assert_operator assigns(:lower_inch_limit), :>=, 0
|
||||
end
|
||||
|
||||
test 'identifying mark' do
|
||||
assert_assigns :identifyingmark, [:possible_marks, :possible_locations]
|
||||
end
|
||||
|
||||
test 'name' do
|
||||
assert_assigns :name, [
|
||||
:male_first_names,
|
||||
:female_first_names,
|
||||
:last_names,
|
||||
:all_first_names,
|
||||
:all_last_names
|
||||
]
|
||||
end
|
||||
|
||||
test 'race' do
|
||||
assert_assigns :race, [:possible_races]
|
||||
end
|
||||
|
||||
test 'skin tone' do
|
||||
assert_assigns :skintone, [:possible_tones]
|
||||
end
|
||||
|
||||
test 'weight' do
|
||||
assert_assigns :weight, [:upper_limit, :lower_limit]
|
||||
assert_operator assigns(:lower_limit), :<=, assigns(:upper_limit)
|
||||
assert_operator assigns(:lower_limit), :>=, 0
|
||||
end
|
||||
end
|
||||
@ -1,47 +1,54 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the EquipmentController class
|
||||
class EquipmentControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
log_in_user(:tolkien)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
|
||||
test 'should get index' do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:equipment)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
test 'should get new' do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create equipment" do
|
||||
test 'should create equipment' do
|
||||
assert_difference('Equipment.count') do
|
||||
post :create, equipment: { name: "Created Equipment", universe: universes(:middleearth)}
|
||||
post :create, equipment: {
|
||||
name: 'Created Equipment',
|
||||
universe: universes(:middleearth)
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to equipment_path(assigns(:equipment))
|
||||
end
|
||||
|
||||
test "should show equipment" do
|
||||
test 'should show equipment' do
|
||||
get :show, id: equipment(:sting).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
test 'should get edit' do
|
||||
get :edit, id: equipment(:sting).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update equipment" do
|
||||
put :update, id: equipment(:sting).id, equipment: { name: "Updated Equipment Name", universe: universes(:middleearth) }
|
||||
|
||||
test 'should update equipment' do
|
||||
put :update, id: equipment(:sting).id, equipment: {
|
||||
name: 'Updated Equipment Name',
|
||||
universe: universes(:middleearth)
|
||||
}
|
||||
|
||||
assert_response 302
|
||||
assert_redirected_to equipment_path(equipment(:sting))
|
||||
end
|
||||
|
||||
test "should destroy equipment" do
|
||||
test 'should destroy equipment' do
|
||||
assert_difference('Equipment.count', -1) do
|
||||
delete :destroy, id: equipment(:sting).id
|
||||
end
|
||||
|
||||
52
test/controllers/equipment_generator_controller_test.rb
Normal file
52
test/controllers/equipment_generator_controller_test.rb
Normal file
@ -0,0 +1,52 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the EquipmentGeneratorController
|
||||
class EquipmentGeneratorControllerTest < ActionController::TestCase
|
||||
test 'armor' do
|
||||
skip 'method currently does nothing'
|
||||
end
|
||||
|
||||
test 'armor shield' do
|
||||
assert_assigns :armor_shield, [:shield_types]
|
||||
end
|
||||
|
||||
test 'weapon' do
|
||||
assert_assigns :weapon, [:weapon_types]
|
||||
end
|
||||
|
||||
test 'weapon axe' do
|
||||
assert_assigns :weapon_axe, [:axe_types]
|
||||
end
|
||||
|
||||
test 'weapon bow' do
|
||||
assert_assigns :weapon_bow, [:bow_types]
|
||||
end
|
||||
|
||||
test 'weapon club' do
|
||||
assert_assigns :weapon_club, [:club_types]
|
||||
end
|
||||
|
||||
test 'weapon fist' do
|
||||
assert_assigns :weapon_fist, [:fist_weapon_types]
|
||||
end
|
||||
|
||||
test 'weapon flexible' do
|
||||
assert_assigns :weapon_flexible, [:flexible_types]
|
||||
end
|
||||
|
||||
test 'weapon thrown' do
|
||||
assert_assigns :weapon_thrown, [:thrown_types]
|
||||
end
|
||||
|
||||
test 'weapon polearm' do
|
||||
assert_assigns :weapon_polearm, [:polearm_types]
|
||||
end
|
||||
|
||||
test 'weapon shortsword' do
|
||||
assert_assigns :weapon_shortsword, [:shortsword_types]
|
||||
end
|
||||
|
||||
test 'weapon sword' do
|
||||
assert_assigns :weapon_sword, [:sword_types]
|
||||
end
|
||||
end
|
||||
@ -1,5 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class GeneratorControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
@ -1,46 +1,53 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the LanguagesController class
|
||||
class LanguagesControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
log_in_user(:tolkien)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
|
||||
test 'should get index' do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:languages)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
test 'should get new' do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create language" do
|
||||
test 'should create language' do
|
||||
assert_difference('Language.count', 1) do
|
||||
post :create, language: { name: "Created Language", universe: universes(:middleearth)}
|
||||
post :create, language: {
|
||||
name: 'Created Language',
|
||||
universe: universes(:middleearth)
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to language_path(assigns(:language))
|
||||
end
|
||||
|
||||
test "should show language" do
|
||||
test 'should show language' do
|
||||
get :show, id: languages(:sindarin).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
test 'should get edit' do
|
||||
get :edit, id: languages(:sindarin).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update language" do
|
||||
put :update, id: languages(:sindarin).id, language: { name: "Updated Language Name", universe: universes(:middleearth) }
|
||||
|
||||
test 'should update language' do
|
||||
put :update, id: languages(:sindarin).id, language: {
|
||||
name: 'Updated Language Name',
|
||||
universe: universes(:middleearth)
|
||||
}
|
||||
|
||||
assert_redirected_to language_path(languages(:sindarin))
|
||||
end
|
||||
|
||||
test "should destroy language" do
|
||||
test 'should destroy language' do
|
||||
assert_difference('Language.count', -1) do
|
||||
delete :destroy, id: languages(:sindarin).id
|
||||
end
|
||||
|
||||
@ -1,81 +1,104 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the LocationsController class
|
||||
class LocationsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@user = users(:tolkien)
|
||||
@universe = universes(:middleearth)
|
||||
|
||||
|
||||
log_in_user(:tolkien)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
test 'should get index' do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:locations)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
test 'should get new' do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create location" do
|
||||
test 'should create location' do
|
||||
assert_difference('Location.count') do
|
||||
post :create, location: { name: "Isengard", universe: @universe, user: @user}
|
||||
post :create, location: {
|
||||
name: 'Isengard',
|
||||
universe: @universe,
|
||||
user: @user
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to location_path(assigns(:location))
|
||||
end
|
||||
|
||||
test "should show location" do
|
||||
test 'should show location' do
|
||||
@location = locations(:shire)
|
||||
|
||||
|
||||
get :show, id: @location.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
test 'should get edit' do
|
||||
@location = locations(:shire)
|
||||
get :edit, id: @location.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update location" do
|
||||
test 'should update location' do
|
||||
@location = locations(:shire)
|
||||
put :update, id: @location, location: { name: "Bag End", universe: @universe }
|
||||
|
||||
put :update, id: @location, location: {
|
||||
name: 'Bag End',
|
||||
universe: @universe
|
||||
}
|
||||
|
||||
assert_response 302
|
||||
assert_redirected_to location_path(@location)
|
||||
end
|
||||
|
||||
test "should destroy location" do
|
||||
test 'should destroy location' do
|
||||
assert_difference('Location.count', -1) do
|
||||
delete :destroy, id: locations(:shire).id
|
||||
end
|
||||
|
||||
assert_redirected_to location_list_url
|
||||
end
|
||||
|
||||
test "should create location with image" do
|
||||
|
||||
test 'should create location with image' do
|
||||
assert_difference('Location.count') do
|
||||
map = fixture_file_upload('mordor_map.jpg', 'image/jpeg')
|
||||
post :create, location: { name: 'Mordor', map: map, universe: @universe, user: @user }
|
||||
post :create, location: {
|
||||
name: 'Mordor',
|
||||
map: map,
|
||||
universe: @universe,
|
||||
user: @user
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
assert_redirected_to location_path(assigns(:location))
|
||||
end
|
||||
|
||||
test "should reject images with an invalid type" do
|
||||
|
||||
test 'should reject images with an invalid type' do
|
||||
assert_no_difference('Location.count') do
|
||||
map = fixture_file_upload('mordor_map.jpg', 'invalid/notanimage')
|
||||
post :create, location: { name: 'Mordor', map: map, universe: @universe, user: @user }
|
||||
post :create, location: {
|
||||
name: 'Mordor',
|
||||
map: map,
|
||||
universe: @universe,
|
||||
user: @user
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
test "should reject images with an empty type" do
|
||||
|
||||
test 'should reject images with an empty type' do
|
||||
assert_no_difference('Location.count') do
|
||||
map = fixture_file_upload('mordor_map.jpg', '')
|
||||
post :create, location: { name: 'Mordor', map: map, universe: @universe, user: @user }
|
||||
post :create, location: {
|
||||
name: 'Mordor',
|
||||
map: map,
|
||||
universe: @universe,
|
||||
user: @user
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
29
test/controllers/locations_generator_controller_test.rb
Normal file
29
test/controllers/locations_generator_controller_test.rb
Normal file
@ -0,0 +1,29 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the LocationsGeneratorController
|
||||
class LocationsGeneratorControllerTest < ActionController::TestCase
|
||||
test 'name' do
|
||||
assert_assigns :name, [
|
||||
:root_name,
|
||||
:prefix_occurrence,
|
||||
:postfix_occurrence,
|
||||
:syllables_upper_limit,
|
||||
:syllables_lower_limit,
|
||||
:prefixes,
|
||||
:postfixes,
|
||||
:syllables
|
||||
]
|
||||
assert_operator assigns(:prefix_occurrence), :<=, 1
|
||||
assert_operator assigns(:prefix_occurrence), :>=, 0
|
||||
|
||||
assert_operator assigns(:postfix_occurrence), :<=, 1
|
||||
assert_operator assigns(:postfix_occurrence), :>=, 0
|
||||
|
||||
assert_operator(
|
||||
assigns(:syllables_lower_limit),
|
||||
:<=,
|
||||
assigns(:syllables_upper_limit))
|
||||
|
||||
assert_operator assigns(:syllables_lower_limit), :>=, 0
|
||||
end
|
||||
end
|
||||
@ -1,5 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the MagicController class
|
||||
class MagicControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@user = users(:tolkien)
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the MainController class, which serves the model-non-specific
|
||||
# pages of the site, like the front page.
|
||||
class MainControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
test 'should get index' do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the SessionsController class
|
||||
class SessionsControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the UsersController class
|
||||
class UsersControllerTest < ActionController::TestCase
|
||||
test 'editing a user requires login' do
|
||||
get :edit, id: users(:tolkien).id
|
||||
|
||||
@ -1,58 +1,59 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the ApplicationHelper class
|
||||
class ApplicationHelperTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
|
||||
test "when user is logged-in, links character" do
|
||||
|
||||
test 'when user is logged-in, links character' do
|
||||
log_in_user(:tolkien)
|
||||
link = link_if_present "Frodo Baggins", "character"
|
||||
assert_equal link_to("Frodo Baggins", characters(:frodo)), link
|
||||
link = link_if_present 'Frodo Baggins', 'character'
|
||||
assert_equal link_to('Frodo Baggins', characters(:frodo)), link
|
||||
end
|
||||
|
||||
test "when user is logged-in, links equipment" do
|
||||
|
||||
test 'when user is logged-in, links equipment' do
|
||||
log_in_user(:tolkien)
|
||||
link = link_if_present "Sting", "equipment"
|
||||
assert_equal link_to("Sting", equipment(:sting)), link
|
||||
link = link_if_present 'Sting', 'equipment'
|
||||
assert_equal link_to('Sting', equipment(:sting)), link
|
||||
end
|
||||
|
||||
test "when user is logged-in, links language" do
|
||||
|
||||
test 'when user is logged-in, links language' do
|
||||
log_in_user(:tolkien)
|
||||
link = link_if_present "Sindarin", "language"
|
||||
assert_equal link_to("Sindarin", languages(:sindarin)), link
|
||||
link = link_if_present 'Sindarin', 'language'
|
||||
assert_equal link_to('Sindarin', languages(:sindarin)), link
|
||||
end
|
||||
|
||||
test "when user is logged-in, links location" do
|
||||
|
||||
test 'when user is logged-in, links location' do
|
||||
log_in_user(:tolkien)
|
||||
link = link_if_present "The Shire", "location"
|
||||
assert_equal link_to("The Shire", locations(:shire)), link
|
||||
link = link_if_present 'The Shire', 'location'
|
||||
assert_equal link_to('The Shire', locations(:shire)), link
|
||||
end
|
||||
|
||||
test "when user is logged-in, links magic" do
|
||||
|
||||
test 'when user is logged-in, links magic' do
|
||||
log_in_user(:tolkien)
|
||||
link = link_if_present "Wizard Magic", "magic"
|
||||
assert_equal link_to("Wizard Magic", magics(:wizard)), link
|
||||
link = link_if_present 'Wizard Magic', 'magic'
|
||||
assert_equal link_to('Wizard Magic', magics(:wizard)), link
|
||||
end
|
||||
|
||||
test "when user is logged-in, links universe" do
|
||||
|
||||
test 'when user is logged-in, links universe' do
|
||||
log_in_user(:tolkien)
|
||||
link = link_if_present "Middle-Earth", "universe"
|
||||
assert_equal link_to("Middle-Earth", universes(:middleearth)), link
|
||||
link = link_if_present 'Middle-Earth', 'universe'
|
||||
assert_equal link_to('Middle-Earth', universes(:middleearth)), link
|
||||
end
|
||||
|
||||
test "when user is not logged-in, just returns the given name" do
|
||||
link = link_if_present "Frodo Baggins", "character"
|
||||
assert_equal "Frodo Baggins", link
|
||||
|
||||
test 'when user is not logged-in, just returns the given name' do
|
||||
link = link_if_present 'Frodo Baggins', 'character'
|
||||
assert_equal 'Frodo Baggins', link
|
||||
end
|
||||
|
||||
test "when name is not found, just return the given name" do
|
||||
|
||||
test 'when name is not found, just return the given name' do
|
||||
log_in_user(:tolkien)
|
||||
link = link_if_present "Princess Zelda", "character"
|
||||
assert_equal "Princess Zelda", link
|
||||
link = link_if_present 'Princess Zelda', 'character'
|
||||
assert_equal 'Princess Zelda', link
|
||||
end
|
||||
|
||||
test "print_property makes a link" do
|
||||
|
||||
test 'print_property makes a link' do
|
||||
log_in_user(:tolkien)
|
||||
property = print_property "The Ring-Bearer", "Frodo Baggins", "character"
|
||||
assert property.include? link_to("Frodo Baggins", characters(:frodo))
|
||||
property = print_property 'The Ring-Bearer', 'Frodo Baggins', 'character'
|
||||
assert property.include? link_to('Frodo Baggins', characters(:frodo))
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the CharacterHelper class
|
||||
class CharactersHelperTest < ActionView::TestCase
|
||||
end
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the EquipmentHelper class
|
||||
class EquipmentHelperTest < ActionView::TestCase
|
||||
end
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the LanguagesHelper class
|
||||
class LanguagesHelperTest < ActionView::TestCase
|
||||
end
|
||||
|
||||
@ -1,33 +1,34 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests scenarios related to interacting with Characters
|
||||
class CharacterStoriesTest < ActionDispatch::IntegrationTest
|
||||
fixtures :characters
|
||||
|
||||
test 'a user can click the characters button from the dashboard to open the characters list' do
|
||||
|
||||
test 'characters button shows characters list' do
|
||||
log_in_as_user
|
||||
visit dashboard_path
|
||||
click_on 'Characters'
|
||||
assert_equal character_list_path, current_path
|
||||
end
|
||||
|
||||
test 'a user can click edit from the characters list to open the character editor' do
|
||||
|
||||
test 'character list edit button edits character' do
|
||||
log_in_as_user
|
||||
visit character_list_path
|
||||
click_on 'Edit'
|
||||
assert_equal character_edit_path(characters(:frodo)), current_path
|
||||
end
|
||||
|
||||
test 'a user can click view from the characters list to open the character view' do
|
||||
|
||||
test 'view button shows character list' do
|
||||
log_in_as_user
|
||||
visit character_list_path
|
||||
click_on 'View'
|
||||
assert_equal character_path(characters(:frodo)), current_path
|
||||
end
|
||||
|
||||
test 'a user can click the edit button from character view to open the character editor' do
|
||||
|
||||
test 'character view edit button edits character' do
|
||||
log_in_as_user
|
||||
visit character_path(characters(:frodo))
|
||||
click_on 'Edit'
|
||||
assert_equal character_edit_path(characters(:frodo)), current_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,46 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests scenarios related to interacting with Locations
|
||||
class LocationStoriesTest < ActionDispatch::IntegrationTest
|
||||
fixtures :locations
|
||||
|
||||
test 'a user can click the locations button from the dashboard to open the locations list' do
|
||||
|
||||
test 'locations button shows locations list' do
|
||||
log_in_as_user
|
||||
visit dashboard_path
|
||||
click_on 'Locations'
|
||||
assert_equal location_list_path, current_path
|
||||
end
|
||||
|
||||
test 'a user can click edit from the locations list to open the location editor' do
|
||||
|
||||
test 'location list edit button edits location' do
|
||||
log_in_as_user
|
||||
visit location_list_path
|
||||
click_on 'Edit'
|
||||
assert_equal location_edit_path(locations(:shire)), current_path
|
||||
end
|
||||
|
||||
test 'a user can click view from the locations list to open the location view' do
|
||||
|
||||
test 'location list view button shows location' do
|
||||
log_in_as_user
|
||||
visit location_list_path
|
||||
click_on 'View'
|
||||
assert_equal location_path(locations(:shire)), current_path
|
||||
end
|
||||
|
||||
test 'a user can click the edit button from location view to open the location editor' do
|
||||
|
||||
test 'location view edit button edits location' do
|
||||
log_in_as_user
|
||||
visit location_path(locations(:shire))
|
||||
click_on 'Edit'
|
||||
assert_equal location_edit_path(locations(:shire)), current_path
|
||||
end
|
||||
|
||||
|
||||
test 'a user can create a new location' do
|
||||
log_in_as_user
|
||||
visit location_list_path
|
||||
click_on 'New location'
|
||||
fill_in 'location_name', :with => 'Mordor'
|
||||
fill_in 'location_universe', :with => 'Middle-Earth'
|
||||
fill_in 'location_name', with: 'Mordor'
|
||||
fill_in 'location_universe', with: 'Middle-Earth'
|
||||
click_on 'Create Location'
|
||||
assert_equal location_path(Location.where(:name => 'Mordor').first), current_path
|
||||
|
||||
assert_equal location_path(Location.where(name: 'Mordor').first),
|
||||
current_path
|
||||
end
|
||||
|
||||
|
||||
test 'a user can upload a map to an existing location' do
|
||||
log_in_as_user
|
||||
visit location_list_path
|
||||
@ -50,4 +53,4 @@ class LocationStoriesTest < ActionDispatch::IntegrationTest
|
||||
click_on 'Update Location'
|
||||
assert_equal location_path(locations(:shire)), current_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,38 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests scenarios related to users and their accounts
|
||||
class UserStoriesTest < ActionDispatch::IntegrationTest
|
||||
test 'creating a new user ends at the new user\'s dashboard' do
|
||||
register_as 'Christopher Tolkien', 'tolkienjr@example.com', 'HiDad'
|
||||
assert_equal dashboard_path, current_path, 'New user was not directed to their dashboard after creating an account'
|
||||
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_user
|
||||
|
||||
assert_equal dashboard_path, current_path, 'Existing user was not directed to their dashboard after logging in'
|
||||
|
||||
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'
|
||||
|
||||
assert_equal dashboard_path, current_path,
|
||||
'Anonymous user was not directed to their dashboard \
|
||||
after logging in'
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# Regression test for https://github.com/drusepth/Indent/issues/366
|
||||
|
||||
test 'Anonymous flag is reset on user logins' do
|
||||
log_in_as_anon
|
||||
log_out
|
||||
log_in_as_user
|
||||
refute page.has_content?('You are currently using an anonymous account'), 'Logged-in user was told they were using an anonymous account, regression of https://github.com/drusepth/Indent/issues/366'
|
||||
refute page.has_content?('You are currently using an anonymous account'),
|
||||
'Logged-in user was told they were using an anonymous account, \
|
||||
regression of https://github.com/drusepth/Indent/issues/366'
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# Regression test for https://github.com/drusepth/Indent/issues/378
|
||||
|
||||
test 'user can log in to new accounts' do
|
||||
register_as 'Christopher Tolkien', 'tolkienjr@example.com', 'HiDad'
|
||||
log_out
|
||||
log_in_as 'Christopher Tolkien', 'HiDad'
|
||||
assert_equal dashboard_path, current_path, 'Users cannot log in to new accounts, regression of https://github.com/drusepth/Indent/issues/378'
|
||||
assert_equal dashboard_path, current_path,
|
||||
'Users cannot log in to new accounts, \
|
||||
regression of https://github.com/drusepth/Indent/issues/378'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,19 +1,27 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the model class Character
|
||||
class CharacterTest < ActiveSupport::TestCase
|
||||
test "character not valid without a name" do
|
||||
skip "Validation has been disabled due to conflicts during the database migration. We are considering removing this validation"
|
||||
test 'character not valid without a name' do
|
||||
skip 'Validation disabled due to database migration conflicts.'
|
||||
character = characters(:frodo)
|
||||
character.name = nil
|
||||
|
||||
refute character.valid?, "Character name not being validated for presence"
|
||||
|
||||
refute character.valid?, 'Character name not being validated for presence'
|
||||
end
|
||||
|
||||
test "characters fixture assumptions" do
|
||||
assert_not_nil characters(:frodo), "Characters fixture :one is not available"
|
||||
assert characters(:frodo).valid?, "Characters fixture :one is not valid"
|
||||
|
||||
assert_equal users(:tolkien), characters(:frodo).user, "Characters fixture :one is not associated with Users fixture :one"
|
||||
assert_equal universes(:middleearth), characters(:frodo).universe, "Characters fixture :one is not associated with Universes fixture :one"
|
||||
|
||||
test 'characters fixture assumptions' do
|
||||
assert_not_nil characters(:frodo), 'Characters fixture is not available'
|
||||
assert characters(:frodo).valid?, 'Characters fixture is not valid'
|
||||
|
||||
assert_equal(
|
||||
users(:tolkien),
|
||||
characters(:frodo).user,
|
||||
'Characters fixture is not associated with Users fixture')
|
||||
|
||||
assert_equal(
|
||||
universes(:middleearth),
|
||||
characters(:frodo).universe,
|
||||
'Characters fixture is not associated with Universes fixture')
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the Equipment model class
|
||||
class EquipmentTest < ActiveSupport::TestCase
|
||||
test "equipment not valid without a name" do
|
||||
skip "Validation has been disabled due to conflicts during the database migration. We are considering removing this validation entirely"
|
||||
test 'equipment not valid without a name' do
|
||||
skip 'Validation disabled due to database migration conflicts.'
|
||||
equipment = equipment(:sting)
|
||||
equipment.name = nil
|
||||
|
||||
refute equipment.valid?, "Name is not being validated for presence"
|
||||
|
||||
refute equipment.valid?, 'Name is not being validated for presence'
|
||||
end
|
||||
|
||||
test "equipment fixture exists" do
|
||||
|
||||
test 'equipment fixture exists' do
|
||||
assert_not_nil equipment(:sting)
|
||||
end
|
||||
|
||||
test "equipement belongs to user and universe" do
|
||||
|
||||
test 'equipement belongs to user and universe' do
|
||||
assert_equal users(:tolkien), equipment(:sting).user
|
||||
assert_equal universes(:middleearth), equipment(:sting).universe
|
||||
end
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the Language model class
|
||||
class LanguageTest < ActiveSupport::TestCase
|
||||
test "language not valid without a name" do
|
||||
skip "Validation has been disabled due to conflicts during the database migration. We are considering removing this validation entirely"
|
||||
test 'language not valid without a name' do
|
||||
skip 'Validation disabled due to database migration conflicts.'
|
||||
language = languages(:sindarin)
|
||||
language.name = nil
|
||||
|
||||
refute language.valid?, "Language name not being validated for presence"
|
||||
|
||||
refute language.valid?, 'Language name not being validated for presence'
|
||||
end
|
||||
|
||||
test "language fixture exists" do
|
||||
|
||||
test 'language fixture exists' do
|
||||
assert_not_nil languages(:sindarin)
|
||||
end
|
||||
|
||||
test "language belongs to user and universe" do
|
||||
|
||||
test 'language belongs to user and universe' do
|
||||
assert_equal users(:tolkien), languages(:sindarin).user
|
||||
assert_equal universes(:middleearth), languages(:sindarin).universe
|
||||
end
|
||||
|
||||
@ -1,18 +1,25 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the Location model class
|
||||
class LocationTest < ActiveSupport::TestCase
|
||||
test "location not valid without a name" do
|
||||
test 'location not valid without a name' do
|
||||
location = locations(:shire)
|
||||
location.name = nil
|
||||
|
||||
refute location.valid?, "Location name is not being validated for presence"
|
||||
|
||||
refute location.valid?, 'Location name is not being validated for presence'
|
||||
end
|
||||
|
||||
test "location fixture assumptions" do
|
||||
assert_not_nil locations(:shire), "Locations fixture :one not available"
|
||||
assert locations(:shire).valid?, "Locations fixture :one not valid"
|
||||
|
||||
assert_equal users(:tolkien), locations(:shire).user, "Locations fixture :one not associated with Users fixture :one"
|
||||
assert_equal universes(:middleearth), locations(:shire).universe, "Locations fixture :one not associated with Universes fixture :one"
|
||||
|
||||
test 'location fixture assumptions' do
|
||||
assert_not_nil locations(:shire),
|
||||
'Locations fixture not available'
|
||||
|
||||
assert locations(:shire).valid?,
|
||||
'Locations fixture not valid'
|
||||
|
||||
assert_equal users(:tolkien), locations(:shire).user,
|
||||
'Locations fixture associated with Users fixture'
|
||||
|
||||
assert_equal universes(:middleearth), locations(:shire).universe,
|
||||
'Locations fixture not associated with Universes fixture'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the Magic model class
|
||||
class MagicTest < ActiveSupport::TestCase
|
||||
test "magic not valid without a name" do
|
||||
skip "Validation has been disabled due to conflicts during the database migration. We are considering removing this validation entirely"
|
||||
test 'magic not valid without a name' do
|
||||
skip 'Validation disabled due to database migration conflicts.'
|
||||
magic = magics(:wizard)
|
||||
magic.name = nil
|
||||
|
||||
refute magic.valid?, "Magic name is not being validated for presence"
|
||||
|
||||
refute magic.valid?, 'Magic name is not being validated for presence'
|
||||
end
|
||||
|
||||
test "magic fixture assumptions" do
|
||||
assert_not_nil magics(:wizard), "Magics fixture :one is unavailable"
|
||||
assert magics(:wizard).valid?, "Magics fixture :one is not valid"
|
||||
|
||||
test 'magic fixture assumptions' do
|
||||
assert_not_nil magics(:wizard), 'Magics fixture is unavailable'
|
||||
assert magics(:wizard).valid?, 'Magics fixture is not valid'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,22 +1,28 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the Session model class
|
||||
class SessionTest < ActiveSupport::TestCase
|
||||
test "session not valid without a username" do
|
||||
test 'session not valid without a username' do
|
||||
session = sessions(:tolkien)
|
||||
session.username = nil
|
||||
|
||||
refute session.valid?, "Session username is not being validated for presence"
|
||||
|
||||
refute session.valid?,
|
||||
'Session username is not being validated for presence'
|
||||
end
|
||||
|
||||
test "session not valid without a password" do
|
||||
|
||||
test 'session not valid without a password' do
|
||||
session = sessions(:tolkien)
|
||||
session.password = nil
|
||||
|
||||
refute session.valid?, "Session password is not being validated for presence"
|
||||
|
||||
refute session.valid?,
|
||||
'Session password is not being validated for presence'
|
||||
end
|
||||
|
||||
test "session fixture assumptions" do
|
||||
assert_not_nil sessions(:tolkien), "Sessions fixture :one is not available"
|
||||
assert sessions(:tolkien).valid?, "Sessions fixture :one is not a valid session"
|
||||
|
||||
test 'session fixture assumptions' do
|
||||
assert_not_nil sessions(:tolkien),
|
||||
'Sessions fixture is not available'
|
||||
|
||||
assert sessions(:tolkien).valid?,
|
||||
'Sessions fixture :one is not a valid session'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,21 +1,28 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the Universe model class
|
||||
class UniverseTest < ActiveSupport::TestCase
|
||||
test "universe not valid without a name" do
|
||||
skip "Validation has been disabled due to conflicts during the database migration. We are considering removing this validation entirely"
|
||||
test 'universe not valid without a name' do
|
||||
skip 'Validation disabled due to database migration conflicts.'
|
||||
universe = universes(:middleearth)
|
||||
universe.name = nil
|
||||
|
||||
refute universe.valid?, "Universe name is not being validated for presence"
|
||||
|
||||
refute universe.valid?, 'Universe name is not being validated for presence'
|
||||
end
|
||||
|
||||
test "universe fixture assumptions" do
|
||||
assert_not_nil universes(:middleearth), "Universes fixture :one is not available"
|
||||
assert universes(:middleearth).valid?, "Universes fixture :one is not a valid universe"
|
||||
assert_equal users(:tolkien), universes(:middleearth).user, "Universe fixture :one not associated with User fixture :one"
|
||||
|
||||
test 'universe fixture assumptions' do
|
||||
assert_not_nil universes(:middleearth),
|
||||
'Universes fixture is not available'
|
||||
|
||||
assert universes(:middleearth).valid?,
|
||||
'Universes fixture is not a valid universe'
|
||||
|
||||
assert_equal users(:tolkien), universes(:middleearth).user,
|
||||
'Universe fixture not associated with User fixture'
|
||||
end
|
||||
|
||||
test "can count content" do
|
||||
assert_equal 5, universes(:middleearth).content_count, "Universe didn't count its content properly"
|
||||
|
||||
test 'can count content' do
|
||||
assert_equal 5, universes(:middleearth).content_count,
|
||||
"Universe didn't count its content properly"
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,44 +1,57 @@
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for the User model class
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
test "user not valid without a name" do
|
||||
test 'user not valid without a name' do
|
||||
user = users(:tolkien)
|
||||
user.name = nil
|
||||
|
||||
refute user.valid?, "Name is not being validated for presence"
|
||||
|
||||
refute user.valid?, 'Name is not being validated for presence'
|
||||
end
|
||||
|
||||
test "user not valid without a password" do
|
||||
|
||||
test 'user not valid without a password' do
|
||||
user = users(:tolkien)
|
||||
user.password = nil
|
||||
|
||||
refute user.valid?, "Password is not being validated for presence"
|
||||
|
||||
refute user.valid?, 'Password is not being validated for presence'
|
||||
end
|
||||
|
||||
test "user not valid without an email address" do
|
||||
|
||||
test 'user not valid without an email address' do
|
||||
user = users(:tolkien)
|
||||
user.email = nil
|
||||
|
||||
refute user.valid?, "Email address is not being validated for presence"
|
||||
|
||||
refute user.valid?, 'Email address is not being validated for presence'
|
||||
end
|
||||
|
||||
test "user fixture assumptions" do
|
||||
assert_not_nil users(:tolkien), "User fixture :one is unavailable"
|
||||
assert users(:tolkien).valid?, "User fixture :one is not a valid user"
|
||||
|
||||
test 'user fixture assumptions' do
|
||||
assert_not_nil users(:tolkien), 'User fixture is unavailable'
|
||||
assert users(:tolkien).valid?, 'User fixture is not a valid user'
|
||||
end
|
||||
|
||||
test "can get user content" do
|
||||
|
||||
test 'can get user content' do
|
||||
content = users(:tolkien).content
|
||||
|
||||
assert_includes content[:characters], characters(:frodo), "User content doesn't include characters"
|
||||
assert_includes content[:equipment], equipment(:sting), "User content doesn't include equipment"
|
||||
assert_includes content[:languages], languages(:sindarin), "User content doesn't include languages"
|
||||
assert_includes content[:locations], locations(:shire), "User content doesn't include locations"
|
||||
assert_includes content[:magics], magics(:wizard), "User content doesn't include magics"
|
||||
assert_includes content[:universes], universes(:middleearth), "User content doesn't include universes"
|
||||
|
||||
assert_includes content[:characters], characters(:frodo),
|
||||
"User content doesn't include characters"
|
||||
|
||||
assert_includes content[:equipment], equipment(:sting),
|
||||
"User content doesn't include equipment"
|
||||
|
||||
assert_includes content[:languages], languages(:sindarin),
|
||||
"User content doesn't include languages"
|
||||
|
||||
assert_includes content[:locations], locations(:shire),
|
||||
"User content doesn't include locations"
|
||||
|
||||
assert_includes content[:magics], magics(:wizard),
|
||||
"User content doesn't include magics"
|
||||
|
||||
assert_includes content[:universes], universes(:middleearth),
|
||||
"User content doesn't include universes"
|
||||
end
|
||||
|
||||
test "can count content" do
|
||||
assert_equal 6, users(:tolkien).content_count, "User didn't count its content properly"
|
||||
|
||||
test 'can count content' do
|
||||
assert_equal 6, users(:tolkien).content_count,
|
||||
"User didn't count its content properly"
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
require 'test_helper'
|
||||
require 'rails/performance_test_help'
|
||||
|
||||
# Tests performance by browsing the site
|
||||
# Refer to the documentation for all available options
|
||||
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
|
||||
# :output => 'tmp/performance', :formats => [:flat] }
|
||||
class BrowsingTest < ActionDispatch::PerformanceTest
|
||||
# Refer to the documentation for all available options
|
||||
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
|
||||
# :output => 'tmp/performance', :formats => [:flat] }
|
||||
|
||||
def test_homepage
|
||||
get '/'
|
||||
end
|
||||
|
||||
@ -8,56 +8,75 @@ require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rails/test_help'
|
||||
require 'capybara/rails'
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
fixtures :all
|
||||
module ActiveSupport
|
||||
# Helper methods for unit tests
|
||||
class TestCase
|
||||
fixtures :all
|
||||
|
||||
def log_in_user(user_fixture)
|
||||
session[:user] = users(user_fixture).id
|
||||
def log_in_user(user_fixture)
|
||||
session[:user] = users(user_fixture).id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ActionDispatch::IntegrationTest
|
||||
# Make the Capybara DSL available in all integration tests
|
||||
include Capybara::DSL
|
||||
|
||||
def register_as(name, email, password)
|
||||
visit homepage_path
|
||||
click_on 'Register'
|
||||
fill_in 'user_name', :with => name
|
||||
fill_in 'user_email', :with => email
|
||||
fill_in 'user_password', :with => password
|
||||
click_on 'Create User'
|
||||
end
|
||||
|
||||
def log_in_as(user, password)
|
||||
visit homepage_path
|
||||
click_on 'Login'
|
||||
within('#new_session') do
|
||||
fill_in 'session[username]', :with => user
|
||||
fill_in 'session[password]', :with => password
|
||||
module ActionController
|
||||
# Helper methods for controller tests
|
||||
class TestCase
|
||||
def assert_assigns(method, assigned = {})
|
||||
get method
|
||||
assert_response :success
|
||||
assigned.each do |val|
|
||||
assert_not assigns(val).blank?, "#{method} did not assign #{val}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ActionDispatch
|
||||
# Helper methods for integration tests
|
||||
class IntegrationTest
|
||||
# Make the Capybara DSL available in all integration tests
|
||||
include Capybara::DSL
|
||||
|
||||
def register_as(name, email, password)
|
||||
visit homepage_path
|
||||
click_on 'Register'
|
||||
fill_in 'user_name', with: name
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on 'Create User'
|
||||
end
|
||||
|
||||
def log_in_as(user, password)
|
||||
visit homepage_path
|
||||
click_on 'Login'
|
||||
within('#new_session') do
|
||||
fill_in 'session[username]', with: user
|
||||
fill_in 'session[password]', with: password
|
||||
end
|
||||
within('#session-actions') do
|
||||
click_on 'Log in'
|
||||
end
|
||||
end
|
||||
|
||||
def log_in_as_user
|
||||
log_in_as 'JRRTolkien', 'Mellon'
|
||||
end
|
||||
|
||||
def log_in_as_anon
|
||||
visit homepage_path
|
||||
click_on 'Login'
|
||||
click_on 'Be Anonymous'
|
||||
click_on 'I understand, create an account for me'
|
||||
end
|
||||
|
||||
def log_out
|
||||
visit logout_path
|
||||
end
|
||||
|
||||
def teardown
|
||||
Capybara.reset_sessions!
|
||||
Capybara.use_default_driver
|
||||
end
|
||||
within('#session-actions') do
|
||||
click_on 'Log in'
|
||||
end
|
||||
end
|
||||
|
||||
def log_in_as_user
|
||||
log_in_as 'JRRTolkien', 'Mellon'
|
||||
end
|
||||
|
||||
def log_in_as_anon
|
||||
visit homepage_path
|
||||
click_on 'Login'
|
||||
click_on 'Be Anonymous'
|
||||
click_on 'I understand, create an account for me'
|
||||
end
|
||||
|
||||
def log_out
|
||||
visit logout_path
|
||||
end
|
||||
|
||||
def teardown
|
||||
Capybara.reset_sessions!
|
||||
Capybara.use_default_driver
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user