mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
Refactor style using the Rubocop auto-correct
This commit is contained in:
parent
dfd80d9539
commit
00e793bf1e
@ -1,16 +1,16 @@
|
||||
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])
|
||||
|
||||
@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.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -50,7 +50,7 @@ class EquipmentController < ApplicationController
|
||||
format.html { redirect_to @equipment, notice: 'Equipment was successfully created.' }
|
||||
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
|
||||
@ -70,7 +70,7 @@ class EquipmentController < ApplicationController
|
||||
format.html { redirect_to @equipment, notice: 'Equipment was successfully updated.' }
|
||||
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
|
||||
@ -85,15 +85,16 @@ 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
|
||||
end
|
||||
|
||||
@ -1,42 +1,41 @@
|
||||
class GeneratorController < ApplicationController
|
||||
|
||||
# Character
|
||||
|
||||
def character_age
|
||||
@upper_limit = 100
|
||||
@lower_limit = 2
|
||||
|
||||
render :json => rand(@upper_limit - @lower_limit + 1) + @lower_limit
|
||||
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
render json: @possible_styles[rand(@possible_styles.length)]
|
||||
end
|
||||
|
||||
def character_height
|
||||
@ -45,175 +44,165 @@ class GeneratorController < ApplicationController
|
||||
@upper_inch_limit = 11
|
||||
@lower_inch_limit = 0
|
||||
|
||||
render :json => [
|
||||
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
|
||||
].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"]
|
||||
@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 => [
|
||||
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"]
|
||||
@male_first_names = %w(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 = %w(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 = %w(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 => [
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@possible_tones = ['Albino', 'Light', 'Pale white', 'Fair', 'White', 'Medium', 'Olive', 'Moderate brown', 'Brown', 'Dark brown', 'Black']
|
||||
|
||||
render :json => @possible_tones[rand(@possible_tones.length)]
|
||||
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
|
||||
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"]
|
||||
|
||||
@prefixes = ['New', 'Los', 'Fort', 'City of', 'El', 'Saint', 'Des', 'Little', 'Big', 'North', 'East', 'South', 'West', 'Round', 'The', 'Broken', 'Santa']
|
||||
@postfixes = %w(Port City Grove Pines Falls Heights Oaks Rapids Valley Mountains Peaks Arbor Mesa Gardens Palms Beach Bend Ruins)
|
||||
@syllables = %w(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 = ""
|
||||
@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)]
|
||||
syllables.times do |_i|
|
||||
@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
|
||||
@root_name = @prefixes[rand(@prefixes.length)] + ' ' + @root_name
|
||||
end
|
||||
|
||||
|
||||
trigger = rand(100)
|
||||
if trigger <= @postfix_occurrence * 100 and not added
|
||||
if trigger <= @postfix_occurrence * 100 && !added
|
||||
added = true
|
||||
@root_name = @root_name + " " + @postfixes[rand(@postfixes.length)]
|
||||
@root_name = @root_name + ' ' + @postfixes[rand(@postfixes.length)]
|
||||
end
|
||||
|
||||
render :json => @root_name
|
||||
|
||||
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 => {}
|
||||
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"]
|
||||
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)]
|
||||
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"]
|
||||
# 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)]
|
||||
render json: @weapon_types[rand(@weapon_types.length)]
|
||||
end
|
||||
|
||||
def equipment_weapon_axe
|
||||
@axe_types = ["Bardiche", "Battleaxe", "Broadaxe", "Handaxe", "Hatchet", "Long-bearded axe", "Tomahawk"]
|
||||
@axe_types = ['Bardiche', 'Battleaxe', 'Broadaxe', 'Handaxe', 'Hatchet', 'Long-bearded axe', 'Tomahawk']
|
||||
|
||||
render :json => @axe_types[rand(@axe_types.length)]
|
||||
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"]
|
||||
@bow_types = ['Longbow', 'Sling', 'Blowgun', 'Flatbow', 'Composite bow', 'Yumi', 'Gungdo', 'Shortbow', 'Arbalest', 'Crossbow', 'Repeating crossbow']
|
||||
|
||||
render :json => @bow_types[rand(@bow_types.length)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@flexible_types = ['Bullwhip', "Cat o' nine tails", 'Chain whip', 'Lasso', 'Nunchaku', 'Flail', 'Meteor hammer']
|
||||
|
||||
render :json => @flexible_types[rand(@flexible_types.length)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
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"]
|
||||
@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)]
|
||||
render json: @sword_types[rand(@sword_types.length)]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
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])
|
||||
|
||||
@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 = @languages.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@ -50,7 +50,7 @@ class LanguagesController < ApplicationController
|
||||
format.html { redirect_to @language, notice: 'Language was successfully created.' }
|
||||
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
|
||||
@ -69,7 +69,7 @@ class LanguagesController < ApplicationController
|
||||
format.html { redirect_to @language, notice: 'Language was successfully updated.' }
|
||||
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
|
||||
@ -84,16 +84,16 @@ class LanguagesController < ApplicationController
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def language_params
|
||||
params.require(:language).permit(
|
||||
:user_id, :universe_id,
|
||||
:name,
|
||||
:words,
|
||||
:established_year, :established_location,
|
||||
:characters, :locations,
|
||||
:notes)
|
||||
end
|
||||
|
||||
|
||||
def language_params
|
||||
params.require(:language).permit(
|
||||
:user_id, :universe_id,
|
||||
:name,
|
||||
:words,
|
||||
:established_year, :established_location,
|
||||
:characters, :locations,
|
||||
:notes)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
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 }
|
||||
|
||||
respond_to do |format|
|
||||
@ -57,7 +57,7 @@ class LocationsController < ApplicationController
|
||||
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
|
||||
@ -84,7 +84,7 @@ class LocationsController < ApplicationController
|
||||
format.html { redirect_to @location, notice: 'Location was successfully updated.' }
|
||||
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
|
||||
@ -105,17 +105,18 @@ 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
|
||||
end
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
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])
|
||||
|
||||
@magics = Magic.where(user_id: session[:user])
|
||||
|
||||
if @magics.size == 0
|
||||
@magics = []
|
||||
end
|
||||
|
||||
|
||||
@magics = @magics.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
|
||||
respond_to do |format|
|
||||
@ -50,7 +50,7 @@ class MagicController < ApplicationController
|
||||
format.html { redirect_to @magic, notice: 'Magic was successfully created.' }
|
||||
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
|
||||
@ -70,7 +70,7 @@ class MagicController < ApplicationController
|
||||
format.html { redirect_to @magic, notice: 'Magic was successfully updated.' }
|
||||
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 +85,17 @@ 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
|
||||
end
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
def comingsoon
|
||||
end
|
||||
|
||||
@ -15,7 +15,7 @@ class MainController < ApplicationController
|
||||
|
||||
def attribution
|
||||
end
|
||||
|
||||
|
||||
def dashboard
|
||||
@characters = Character.where(user_id: session[:user])
|
||||
@equipment = Equipment.where(user_id: session[:user])
|
||||
@ -23,8 +23,8 @@ class MainController < ApplicationController
|
||||
@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
|
||||
|
||||
@things = [@characters.length, @equipment.length, @languages.length,
|
||||
@locations.length, @magics.length, @universes.length].sum
|
||||
end
|
||||
end
|
||||
|
||||
@ -20,7 +20,7 @@ class SessionsController < ApplicationController
|
||||
redirect_to login_path, notice: 'Username or password incorrect'
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
session[:user] = user[0].id
|
||||
session.delete(:anon_user)
|
||||
|
||||
@ -28,7 +28,6 @@ class SessionsController < ApplicationController
|
||||
format.html { redirect_to dashboard_path, notice: 'Login successful.' }
|
||||
format.json { render json: true, status: :created }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# GET /logout
|
||||
@ -41,14 +40,15 @@ class SessionsController < ApplicationController
|
||||
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 session_params
|
||||
params.require(:session).permit(:username, :password)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
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])
|
||||
|
||||
@universes = Universe.where(user_id: session[:user])
|
||||
|
||||
if @universes.size == 0
|
||||
@universes = []
|
||||
end
|
||||
|
||||
|
||||
@universes = @universes.sort { |a, b| a.name.downcase <=> b.name.downcase }
|
||||
|
||||
respond_to do |format|
|
||||
@ -49,7 +49,7 @@ class UniversesController < ApplicationController
|
||||
format.html { redirect_to @universe, notice: 'Universe was successfully created.' }
|
||||
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
|
||||
@ -63,7 +63,7 @@ class UniversesController < ApplicationController
|
||||
format.html { redirect_to @universe, notice: 'Universe was successfully updated.' }
|
||||
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 +78,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,6 @@
|
||||
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
|
||||
@ -27,7 +27,7 @@ class UsersController < ApplicationController
|
||||
format.html { redirect_to homepage_path, notice: 'User was successfully created.' }
|
||||
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
|
||||
@ -35,8 +35,8 @@ class UsersController < ApplicationController
|
||||
|
||||
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)
|
||||
id = rand(10_000_000).to_s + rand(10_000_000).to_s
|
||||
@user = User.new(name: 'Anonymous-' + id.to_s, email: id.to_s + '@localhost', password: id.to_s)
|
||||
|
||||
respond_to do |format|
|
||||
if @user.save
|
||||
@ -45,7 +45,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 +62,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,43 @@
|
||||
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)
|
||||
unless session[:user]
|
||||
return name
|
||||
end
|
||||
|
||||
# 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
|
||||
result = nil
|
||||
type = type.downcase
|
||||
|
||||
result = nil
|
||||
type = type.downcase
|
||||
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
|
||||
|
||||
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
|
||||
if result && result.length > 0
|
||||
return link_to name, result.first
|
||||
else
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
||||
if result and result.length > 0
|
||||
return link_to name, result.first
|
||||
else
|
||||
return name
|
||||
end
|
||||
end
|
||||
def print_property(title, value, type = '')
|
||||
return unless value && value.length > 0
|
||||
|
||||
def print_property(title, value, type = "")
|
||||
return unless value and value.length > 0
|
||||
|
||||
return [
|
||||
"<dt><strong>", title, ":</strong></dt>",
|
||||
"<dd>", simple_format(link_if_present(value, type)), "</dd>"
|
||||
].join("").to_s.html_safe
|
||||
end
|
||||
[
|
||||
'<dt><strong>', title, ':</strong></dt>',
|
||||
'<dd>', simple_format(link_if_present(value, type)), '</dd>'
|
||||
].join('').to_s.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,15 +3,15 @@ module FormHelper
|
||||
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 +23,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
|
||||
|
||||
@ -18,15 +18,15 @@ 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 +34,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,21 +1,21 @@
|
||||
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,16 +1,16 @@
|
||||
class Character < ActiveRecord::Base
|
||||
include Comparable
|
||||
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
|
||||
|
||||
def <=>(anOther)
|
||||
name.downcase <=> anOther.name.downcase
|
||||
end
|
||||
|
||||
|
||||
def nil_blank_universe
|
||||
self.universe = nil if self.universe.blank?
|
||||
self.universe = nil if universe.blank?
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class Equipment < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class Language < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
class Location < ActiveRecord::Base
|
||||
has_attached_file :map, :styles => { :original => "1920x1080>", :thumb => "200x200>" }
|
||||
validates_attachment_content_type :map, :content_type => /\Aimage\/.*\Z/
|
||||
has_attached_file :map, styles: { original: '1920x1080>', thumb: '200x200>' }
|
||||
validates_attachment_content_type :map, content_type: /\Aimage\/.*\Z/
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class Magic < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :universe
|
||||
end
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
class Universe < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
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,6 @@
|
||||
class User < ActiveRecord::Base
|
||||
validates_presence_of :name, :password, :email
|
||||
|
||||
|
||||
before_save :hash_password
|
||||
|
||||
has_many :characters
|
||||
@ -9,30 +9,30 @@ 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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -65,16 +65,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,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
|
||||
|
||||
@ -7,4 +7,3 @@
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json]
|
||||
end
|
||||
|
||||
|
||||
235
config/routes.rb
235
config/routes.rb
@ -1,184 +1,183 @@
|
||||
PlanCharacters::Application.routes.draw do
|
||||
|
||||
# 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: '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'
|
||||
end
|
||||
|
||||
|
||||
# Location information
|
||||
scope '/location' do
|
||||
get '/name', :to => 'generator#location_name'
|
||||
get '/name', to: 'generator#location_name'
|
||||
end
|
||||
|
||||
# Equipment location
|
||||
scope '/equipment' do
|
||||
scope '/weapon' do
|
||||
get '/', :to => 'generator#equipment_weapon'
|
||||
get '/', to: 'generator#equipment_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: '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
|
||||
|
||||
scope '/armor' do
|
||||
get '/', :to => 'generator#equipment_armor'
|
||||
get '/', to: 'generator#equipment_armor'
|
||||
|
||||
get '/shield', :to => 'generator#equipment_armor_shield'
|
||||
get '/shield', to: 'generator#equipment_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
|
||||
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'})
|
||||
middleearth = Universe.create(name: 'Middle-Earth',
|
||||
user: tolkien,
|
||||
privacy: 'public')
|
||||
|
||||
frodo = Character.create({
|
||||
:name => 'Frodo Baggins',
|
||||
:user => tolkien,
|
||||
:universe => middleearth,
|
||||
:age => '50'})
|
||||
frodo = Character.create(name: 'Frodo Baggins',
|
||||
user: tolkien,
|
||||
universe: middleearth,
|
||||
age: '50')
|
||||
|
||||
sting = Equipment.create({
|
||||
:name => 'Sting',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
sting = Equipment.create(name: 'Sting',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
shire = Location.create({
|
||||
:name => 'The Shire',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
shire = Location.create(name: 'The Shire',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
sindarin = Language.create({
|
||||
:name => 'Sindarin',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
sindarin = Language.create(name: 'Sindarin',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
wizard = Magic.create({
|
||||
:name => 'Wizard Magic',
|
||||
:user => tolkien,
|
||||
:universe => middleearth})
|
||||
wizard = Magic.create(name: 'Wizard Magic',
|
||||
user: tolkien,
|
||||
universe: middleearth)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ApplicationControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,51 +4,51 @@ 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 }
|
||||
|
||||
|
||||
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
|
||||
|
||||
@ -4,44 +4,44 @@ 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
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class GeneratorControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,43 +4,43 @@ 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
|
||||
|
||||
@ -4,78 +4,78 @@ 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 }
|
||||
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 }
|
||||
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 }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MagicControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
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,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SessionsControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UsersControllerTest < ActionController::TestCase
|
||||
|
||||
end
|
||||
|
||||
@ -2,57 +2,57 @@ require 'test_helper'
|
||||
|
||||
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
|
||||
|
||||
@ -2,32 +2,32 @@ require 'test_helper'
|
||||
|
||||
class CharacterStoriesTest < ActionDispatch::IntegrationTest
|
||||
fixtures :characters
|
||||
|
||||
|
||||
test 'a user can click the characters button from the dashboard to open the 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
|
||||
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
|
||||
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
|
||||
log_in_as_user
|
||||
visit character_path(characters(:frodo))
|
||||
click_on 'Edit'
|
||||
assert_equal character_edit_path(characters(:frodo)), current_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -2,45 +2,45 @@ require 'test_helper'
|
||||
|
||||
class LocationStoriesTest < ActionDispatch::IntegrationTest
|
||||
fixtures :locations
|
||||
|
||||
|
||||
test 'a user can click the locations button from the dashboard to open the 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
|
||||
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
|
||||
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
|
||||
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 +50,4 @@ class LocationStoriesTest < ActionDispatch::IntegrationTest
|
||||
click_on 'Update Location'
|
||||
assert_equal location_path(locations(:shire)), current_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -5,30 +5,30 @@ class UserStoriesTest < ActionDispatch::IntegrationTest
|
||||
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'
|
||||
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'
|
||||
end
|
||||
|
||||
|
||||
test 'logging in anonymously goes into an empty dashboard' do
|
||||
log_in_as_anon
|
||||
|
||||
|
||||
assert_equal dashboard_path, current_path, 'Anonymous user was not directed to their dashboard after logging in'
|
||||
end
|
||||
|
||||
|
||||
# Regression test for 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'
|
||||
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
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
require 'test_helper'
|
||||
|
||||
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 has been disabled due to conflicts during the database migration. We are considering removing this validation entirely'
|
||||
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,19 @@
|
||||
require 'test_helper'
|
||||
|
||||
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 has been disabled due to conflicts during the database migration. We are considering removing this validation entirely'
|
||||
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,18 @@
|
||||
require 'test_helper'
|
||||
|
||||
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 :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'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
require 'test_helper'
|
||||
|
||||
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 has been disabled due to conflicts during the database migration. We are considering removing this validation entirely'
|
||||
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 :one is unavailable'
|
||||
assert magics(:wizard).valid?, 'Magics fixture :one is not valid'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
require 'test_helper'
|
||||
|
||||
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 :one is not available'
|
||||
assert sessions(:tolkien).valid?, 'Sessions fixture :one is not a valid session'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
require 'test_helper'
|
||||
|
||||
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 has been disabled due to conflicts during the database migration. We are considering removing this validation entirely'
|
||||
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 :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'
|
||||
end
|
||||
|
||||
test "can count content" do
|
||||
|
||||
test 'can count content' do
|
||||
assert_equal 5, universes(:middleearth).content_count, "Universe didn't count its content properly"
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,35 +1,35 @@
|
||||
require 'test_helper'
|
||||
|
||||
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 :one is unavailable'
|
||||
assert users(:tolkien).valid?, 'User fixture :one 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"
|
||||
@ -37,8 +37,8 @@ class UserTest < ActiveSupport::TestCase
|
||||
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
|
||||
|
||||
test 'can count content' do
|
||||
assert_equal 6, users(:tolkien).content_count, "User didn't count its content properly"
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,43 +19,43 @@ 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
|
||||
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
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user