Initial article text code

Added model annotations
This commit is contained in:
Luke Barratt 2014-03-26 11:09:39 +00:00
parent a0e46f8c76
commit 4199062a9c
49 changed files with 778 additions and 0 deletions

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: articles
#
# id :integer not null, primary key
# title :string(255)
# status :integer not null
# category_id :integer
# text :text
# user_id :integer
# created_at :datetime
# updated_at :datetime
# version :integer
# text_parsed :text
# text_coding :integer default(0), not null
#
require File.join(Rails.root, 'vendor', 'plugins', 'has_view_count', 'init.rb') require File.join(Rails.root, 'vendor', 'plugins', 'has_view_count', 'init.rb')
require 'rbbcode' require 'rbbcode'

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: bans
#
# id :integer not null, primary key
# steamid :string(255)
# user_id :integer
# addr :string(255)
# server_id :integer
# expiry :datetime
# reason :string(255)
# created_at :datetime
# updated_at :datetime
# ban_type :integer
# ip :string(255)
#
class Ban < ActiveRecord::Base class Ban < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: brackets
#
# id :integer not null, primary key
# contest_id :integer
# slots :integer
# created_at :datetime
# updated_at :datetime
# name :string(255)
#
class Bracket < ActiveRecord::Base class Bracket < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: bracketers
#
# id :integer not null, primary key
# bracket_id :integer
# column :integer
# row :integer
# match_id :integer
# team_id :integer
# created_at :datetime
# updated_at :datetime
#
class Bracketer < ActiveRecord::Base class Bracketer < ActiveRecord::Base
include Exceptions include Exceptions
include Extra include Extra

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: categories
#
# id :integer not null, primary key
# name :string(255)
# sort :integer
# created_at :datetime
# updated_at :datetime
# domain :integer
#
class Category < ActiveRecord::Base class Category < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,24 @@
# == Schema Information
#
# Table name: challenges
#
# id :integer not null, primary key
# contester1_id :integer
# contester2_id :integer
# match_time :datetime
# default_time :datetime
# mandatory :boolean
# server_id :integer
# user_id :integer
# details :string(255)
# response :string(255)
# created_at :datetime
# updated_at :datetime
# map1_id :string(255)
# map2_id :string(255)
# status :integer default(0), not null
#
class Challenge < ActiveRecord::Base class Challenge < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# text :text
# user_id :integer
# commentable_type :string(255)
# commentable_id :integer
# created_at :datetime
# updated_at :datetime
# text_parsed :text
#
require 'rbbcode' require 'rbbcode'
class Comment < ActiveRecord::Base class Comment < ActiveRecord::Base

View file

@ -1,3 +1,27 @@
# == Schema Information
#
# Table name: contests
#
# id :integer not null, primary key
# name :string(255)
# start :datetime
# end :datetime
# status :integer
# created_at :datetime
# updated_at :datetime
# default_time :time
# contest_type :integer default(0), not null
# winner_id :integer
# demos_id :integer
# short_name :string(255)
# weight :integer
# modulus_base :integer
# modulus_even :float
# modulus_3to1 :float
# modulus_4to0 :float
# rules_id :integer
#
class Contest < ActiveRecord::Base class Contest < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,21 @@
# == Schema Information
#
# Table name: contesters
#
# id :integer not null, primary key
# team_id :integer
# created_at :datetime
# updated_at :datetime
# score :integer default(0), not null
# win :integer default(0), not null
# loss :integer default(0), not null
# draw :integer default(0), not null
# contest_id :integer
# trend :integer not null
# extra :integer not null
# active :boolean default(TRUE), not null
#
class Contester < ActiveRecord::Base class Contester < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: data_files
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# path :string(255)
# size :integer not null
# md5 :string(255)
# created_at :datetime
# updated_at :datetime
# directory_id :integer
# related_id :integer
# article_id :integer
#
require File.join(Rails.root, 'vendor', 'plugins', 'acts_as_rateable', 'init.rb') require File.join(Rails.root, 'vendor', 'plugins', 'acts_as_rateable', 'init.rb')
require 'digest/md5' require 'digest/md5'

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: directories
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# path :string(255)
# created_at :datetime
# updated_at :datetime
# parent_id :integer
# hidden :boolean default(FALSE), not null
#
class Directory < ActiveRecord::Base class Directory < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: forums
#
# id :integer not null, primary key
# title :string(255)
# description :string(255)
# category_id :integer
# created_at :datetime
# updated_at :datetime
# position :integer
#
class Forum < ActiveRecord::Base class Forum < ActiveRecord::Base
include Extra include Extra
BANS = 8 BANS = 8

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: forumers
#
# id :integer not null, primary key
# forum_id :integer
# group_id :integer
# access :integer
# created_at :datetime
# updated_at :datetime
#
class Forumer < ActiveRecord::Base class Forumer < ActiveRecord::Base
ACCESS_READ = 0 ACCESS_READ = 0
ACCESS_REPLY = 1 ACCESS_REPLY = 1

View file

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: gathers
#
# id :integer not null, primary key
# status :integer
# captain1_id :integer
# captain2_id :integer
# map1_id :integer
# map2_id :integer
# server_id :integer
# created_at :datetime
# updated_at :datetime
# turn :integer
# lastpick1 :datetime
# lastpick2 :datetime
# votes :integer default(0), not null
# category_id :integer
#
class Gather < ActiveRecord::Base class Gather < ActiveRecord::Base
STATE_RUNNING = 0 STATE_RUNNING = 0
STATE_VOTING = 3 STATE_VOTING = 3

View file

@ -1,3 +1,13 @@
# == Schema Information
#
# Table name: gather_maps
#
# id :integer not null, primary key
# gather_id :integer
# map_id :integer
# votes :integer
#
class GatherMap < ActiveRecord::Base class GatherMap < ActiveRecord::Base
scope :ordered, :order => "votes DESC, id DESC" scope :ordered, :order => "votes DESC, id DESC"

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: gather_servers
#
# id :integer not null, primary key
# gather_id :integer
# server_id :integer
# votes :integer
# created_at :datetime
# updated_at :datetime
#
class GatherServer < ActiveRecord::Base class GatherServer < ActiveRecord::Base
scope :ordered, :order => "votes DESC" scope :ordered, :order => "votes DESC"

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: gatherers
#
# id :integer not null, primary key
# user_id :integer
# gather_id :integer
# team :integer
# created_at :datetime
# updated_at :datetime
# votes :integer default(0), not null
#
class Gatherer < ActiveRecord::Base class Gatherer < ActiveRecord::Base
IDLE_TIME = 600 IDLE_TIME = 600
EJECT_VOTES = 4 EJECT_VOTES = 4

View file

@ -1,3 +1,14 @@
# == Schema Information
#
# Table name: groups
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
# founder_id :integer
#
class Group < ActiveRecord::Base class Group < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: groupers
#
# id :integer not null, primary key
# group_id :integer
# user_id :integer
# task :string(255)
# created_at :datetime
# updated_at :datetime
#
class Grouper < ActiveRecord::Base class Grouper < ActiveRecord::Base
attr_protected :id, :created_at, :updated_at attr_protected :id, :created_at, :updated_at
attr_accessor :username attr_accessor :username

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: issues
#
# id :integer not null, primary key
# title :string(255)
# status :integer
# assigned_id :integer
# category_id :integer
# text :text
# author_id :integer
# created_at :datetime
# updated_at :datetime
# solution :text
# text_parsed :text
#
require File.join(Rails.root, 'vendor', 'plugins', 'acts-as-readable', 'init.rb') require File.join(Rails.root, 'vendor', 'plugins', 'acts-as-readable', 'init.rb')
require 'rbbcode' require 'rbbcode'

View file

@ -1,3 +1,14 @@
# == Schema Information
#
# Table name: locks
#
# id :integer not null, primary key
# lockable_id :integer
# lockable_type :string(255)
# created_at :datetime
# updated_at :datetime
#
class Lock < ActiveRecord::Base class Lock < ActiveRecord::Base
include Extra include Extra
belongs_to :lockable, :polymorphic => true belongs_to :lockable, :polymorphic => true

View file

@ -1,3 +1,21 @@
# == Schema Information
#
# Table name: logs
#
# id :integer not null, primary key
# server_id :integer
# text :text
# domain :integer
# created_at :datetime
# round_id :integer
# details :string(255)
# actor_id :integer
# target_id :integer
# specifics1 :string(255)
# specifics2 :string(255)
# log_file_id :integer
#
class Log < ActiveRecord::Base class Log < ActiveRecord::Base
include Extra include Extra
attr_accessor :text attr_accessor :text

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: log_events
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# team :integer
# created_at :datetime
# updated_at :datetime
#
class LogEvent < ActiveRecord::Base class LogEvent < ActiveRecord::Base
def self.get search, team = nil def self.get search, team = nil
if f = first({:conditions => {:name => search}}) if f = first({:conditions => {:name => search}})

View file

@ -1,4 +1,16 @@
# encoding: US-ASCII # encoding: US-ASCII
# == Schema Information
#
# Table name: log_files
#
# id :integer not null, primary key
# name :string(255)
# md5 :string(255)
# size :integer
# server_id :integer
# updated_at :datetime
#
require 'digest/md5' require 'digest/md5'

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: maps
#
# id :integer not null, primary key
# name :string(255)
# download :string(255)
# created_at :datetime
# updated_at :datetime
# deleted :boolean default(FALSE), not null
# picture :string(255)
# category_id :integer
#
class Map < ActiveRecord::Base class Map < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,32 @@
# == Schema Information
#
# Table name: matches
#
# id :integer not null, primary key
# contester1_id :integer
# contester2_id :integer
# score1 :integer
# score2 :integer
# match_time :datetime
# challenge_id :integer
# contest_id :integer
# report :text
# created_at :datetime
# updated_at :datetime
# map1_id :integer
# map2_id :integer
# server_id :integer
# motm_id :integer
# demo_id :integer
# week_id :integer
# referee_id :integer
# forfeit :boolean
# diff :integer
# points1 :integer
# points2 :integer
# hltv_id :integer
#
class Match < ActiveRecord::Base class Match < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: matchers
#
# id :integer not null, primary key
# match_id :integer not null
# user_id :integer not null
# contester_id :integer not null
# created_at :datetime
# updated_at :datetime
# merc :boolean not null
#
class Matcher < ActiveRecord::Base class Matcher < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,19 @@
# == Schema Information
#
# Table name: messages
#
# id :integer not null, primary key
# sender_type :string(255)
# sender_id :integer
# recipient_type :string(255)
# recipient_id :integer
# title :string(255)
# text :text
# created_at :datetime
# updated_at :datetime
# text_parsed :text
#
require 'rbbcode' require 'rbbcode'
class Message < ActiveRecord::Base class Message < ActiveRecord::Base

View file

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: movies
#
# id :integer not null, primary key
# name :string(255)
# content :string(255)
# format :string(255)
# user_id :integer
# file_id :integer
# created_at :datetime
# updated_at :datetime
# picture :string(255)
# preview_id :integer
# length :integer
# match_id :integer
# status :integer
# category_id :integer
#
require 'data_file' require 'data_file'
class Movie < ActiveRecord::Base class Movie < ActiveRecord::Base

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: options
#
# id :integer not null, primary key
# option :string(255)
# poll_id :integer
# created_at :datetime
# updated_at :datetime
# votes :integer default(0), not null
#
class Option < ActiveRecord::Base class Option < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: polls
#
# id :integer not null, primary key
# question :string(255)
# end_date :datetime
# user_id :integer
# created_at :datetime
# updated_at :datetime
# votes :integer default(0), not null
#
class Poll < ActiveRecord::Base class Poll < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# text :text
# topic_id :integer
# user_id :integer
# created_at :datetime
# updated_at :datetime
# text_parsed :text
#
require 'rbbcode' require 'rbbcode'
require 'bb-ruby' require 'bb-ruby'

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: predictions
#
# id :integer not null, primary key
# match_id :integer
# user_id :integer
# score1 :integer
# score2 :integer
# created_at :datetime
# updated_at :datetime
# result :integer
#
class Prediction < ActiveRecord::Base class Prediction < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,59 @@
# == Schema Information
#
# Table name: profiles
#
# id :integer not null, primary key
# user_id :integer
# msn :string(255)
# icq :string(255)
# irc :string(255)
# web :string(255)
# town :string(255)
# singleplayer :string(255)
# multiplayer :string(255)
# food :string(255)
# beverage :string(255)
# hobby :string(255)
# music :string(255)
# book :string(255)
# movie :string(255)
# tvseries :string(255)
# res :string(255)
# sensitivity :string(255)
# monitor_hz :string(255)
# scripts :string(255)
# cpu :string(255)
# gpu :string(255)
# ram :string(255)
# psu :string(255)
# motherboard :string(255)
# soundcard :string(255)
# hdd :string(255)
# case :string(255)
# monitor :string(255)
# mouse :string(255)
# mouse_pad :string(255)
# keyboard :string(255)
# head_phones :string(255)
# speakers :string(255)
# achievements :text
# updated_at :datetime
# signature :string(255)
# avatar :string(255)
# clan_search :string(255)
# notify_news :boolean
# notify_articles :boolean
# notify_movies :boolean
# notify_gather :boolean
# notify_own_match :boolean
# notify_any_match :boolean
# notify_pms :boolean default(TRUE), not null
# notify_challenge :boolean default(TRUE), not null
# steam_profile :string(255)
# achievements_parsed :string(255)
# signature_parsed :string(255)
#
require 'rbbcode' require 'rbbcode'
class Profile < ActiveRecord::Base class Profile < ActiveRecord::Base

View file

@ -1,3 +1,20 @@
# == Schema Information
#
# Table name: rounds
#
# id :integer not null, primary key
# server_id :integer
# start :datetime
# end :datetime
# winner :integer
# match_id :integer
# commander_id :integer
# team1_id :integer
# team2_id :integer
# map_name :string(255)
# map_id :integer
#
class Round < ActiveRecord::Base class Round < ActiveRecord::Base
scope :basic, :include => [:commander, :map, :server, :team1, :team2], :order => "start DESC" scope :basic, :include => [:commander, :map, :server, :team1, :team2], :order => "start DESC"
scope :team_stats, scope :team_stats,

View file

@ -1,3 +1,19 @@
# == Schema Information
#
# Table name: rounders
#
# id :integer not null, primary key
# round_id :integer
# user_id :integer
# team :integer
# roles :string(255)
# kills :integer
# deaths :integer
# name :string(255)
# steamid :string(255)
# team_id :integer
#
class Rounder < ActiveRecord::Base class Rounder < ActiveRecord::Base
attr_accessor :lifeform attr_accessor :lifeform

View file

@ -1,3 +1,36 @@
# == Schema Information
#
# Table name: servers
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# dns :string(255)
# ip :string(255)
# port :string(255)
# rcon :string(255)
# password :string(255)
# irc :string(255)
# user_id :integer
# official :boolean
# created_at :datetime
# updated_at :datetime
# map :string(255)
# players :integer
# max_players :integer
# ping :string(255)
# version :integer
# domain :integer default(0), not null
# reservation :string(255)
# recording :string(255)
# idle :datetime
# default_id :integer
# active :boolean default(TRUE), not null
# recordable_type :string(255)
# recordable_id :integer
# category_id :integer
#
require "rcon" require "rcon"
require "yaml" require "yaml"

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: shoutmsgs
#
# id :integer not null, primary key
# user_id :integer
# text :string(255)
# created_at :datetime
# updated_at :datetime
# shoutable_type :string(255)
# shoutable_id :integer
#
class Shoutmsg < ActiveRecord::Base class Shoutmsg < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,22 @@
# == Schema Information
#
# Table name: teams
#
# id :integer not null, primary key
# name :string(255)
# irc :string(255)
# web :string(255)
# tag :string(255)
# country :string(255)
# comment :string(255)
# created_at :datetime
# updated_at :datetime
# logo :string(255)
# founder_id :integer
# active :boolean default(TRUE), not null
# recruiting :string(255)
#
class Team < ActiveRecord::Base class Team < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: teamers
#
# id :integer not null, primary key
# team_id :integer not null
# user_id :integer not null
# comment :string(255)
# rank :integer not null
# created_at :datetime
# updated_at :datetime
#
class Teamer < ActiveRecord::Base class Teamer < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,16 @@
# == Schema Information
#
# Table name: topics
#
# id :integer not null, primary key
# title :string(255)
# user_id :integer
# forum_id :integer
# created_at :datetime
# updated_at :datetime
# state :integer default(0), not null
#
class Topic < ActiveRecord::Base class Topic < ActiveRecord::Base
POSTS_PAGE = 30 POSTS_PAGE = 30
STATE_NORMAL = 0 STATE_NORMAL = 0

View file

@ -1,3 +1,14 @@
# == Schema Information
#
# Table name: tweets
#
# id :integer not null, primary key
# msg :string(255)
# link :string(255)
# created_at :datetime
# updated_at :datetime
#
class Tweet < ActiveRecord::Base class Tweet < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,26 @@
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# username :string(255)
# password :string(255)
# firstname :string(255)
# lastname :string(255)
# email :string(255)
# steamid :string(255)
# team_id :integer
# lastvisit :datetime
# created_at :datetime
# updated_at :datetime
# lastip :string(255)
# country :string(255)
# birthdate :date
# time_zone :string(255)
# version :integer
# public_email :boolean default(FALSE), not null
#
require 'country_code_select/countries' require 'country_code_select/countries'
require 'digest/md5' require 'digest/md5'
require File.join(Rails.root, 'vendor', 'plugins', 'acts_as_versioned', 'lib', 'acts_as_versioned.rb') require File.join(Rails.root, 'vendor', 'plugins', 'acts_as_versioned', 'lib', 'acts_as_versioned.rb')

View file

@ -1,3 +1,15 @@
# == Schema Information
#
# Table name: view_counts
#
# id :integer not null, primary key
# viewable_id :integer
# viewable_type :string(255)
# ip_address :string(255)
# logged_in :boolean
# created_at :date
#
class ViewCount < ActiveRecord::Base class ViewCount < ActiveRecord::Base
belongs_to :viewable, :polymorphic => true belongs_to :viewable, :polymorphic => true
validates_uniqueness_of :ip_address, :scope => [ :viewable_id, :viewable_type ] validates_uniqueness_of :ip_address, :scope => [ :viewable_id, :viewable_type ]

View file

@ -1,3 +1,14 @@
# == Schema Information
#
# Table name: votes
#
# id :integer not null, primary key
# user_id :integer
# votable_id :integer
# poll_id :integer
# votable_type :string(255)
#
class Vote < ActiveRecord::Base class Vote < ActiveRecord::Base
include Extra include Extra

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: weeks
#
# id :integer not null, primary key
# name :string(255)
# start_date :date
# contest_id :integer
# map1_id :integer
# map2_id :integer
# created_at :datetime
# updated_at :datetime
#
class Week < ActiveRecord::Base class Week < ActiveRecord::Base
include Extra include Extra

View file

@ -79,6 +79,8 @@ en:
weeks_create: "Week was successfully created." weeks_create: "Week was successfully created."
weeks_update: "Week was successfully updated." weeks_update: "Week was successfully updated."
votes_success: "Voted successfully." votes_success: "Voted successfully."
error: "error"
prohibited: "prohibited"
errors: errors:
template: template:
header: "Please review the following errors:" header: "Please review the following errors:"

14
spec/factories/article.rb Normal file
View file

@ -0,0 +1,14 @@
FactoryGirl.define do
sequence :title do |n|
"Article #{n}"
end
sequence :text do |n|
(0..100).map{ (0...8).map { (65 + rand(26)).chr }.join }.join(" ")
end
factory :article do
title
text
end
end

View file

@ -0,0 +1,14 @@
require 'spec_helper'
feature 'User creates new article' do
let(:user) { create(:user) }
let(:article) { attributes_for(:article) }
before do
visit new_article_path
end
describe 'with valid Title, Content: ' do
describe ''
end
end