Skip to content

Commit

Permalink
first tests are working...
Browse files Browse the repository at this point in the history
  • Loading branch information
drhenner committed Dec 8, 2011
0 parents commit 7cc6b1f
Show file tree
Hide file tree
Showing 87 changed files with 1,202 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm use ruby-1.9.2-p290@survey
25 changes: 25 additions & 0 deletions Gemfile
@@ -0,0 +1,25 @@
source "http://rubygems.org"

# Declare your gem's dependencies in survey_says.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# jquery-rails is used by the dummy application
gem "jquery-rails"

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use debugger
gem 'ruby-debug19', :require => 'ruby-debug'
gem "nifty-generators", :git => 'git://github.com/drhenner/nifty-generators.git'
gem 'twitter-bootstrap-rails'
gem "mocha", :group => :test

group :test do
gem 'factory_girl_rails', "~> 1.1.0"

end
150 changes: 150 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,150 @@
GIT
remote: git://github.com/drhenner/nifty-generators.git
revision: fd658e6d67251d7c714ac6a32edfd3b7807f7475
specs:
nifty-generators (0.4.2)

PATH
remote: .
specs:
survey_says (0.0.1pre)
nifty-generators
rails (~> 3.1.3)
twitter-bootstrap-rails

GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.3)
actionpack (= 3.1.3)
mail (~> 2.3.0)
actionpack (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.5)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.3)
activemodel (3.1.3)
activesupport (= 3.1.3)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
archive-tar-minitar (0.5.2)
arel (2.2.1)
builder (3.0.0)
columnize (0.3.5)
commonjs (0.2.0)
therubyracer (~> 0.9.9)
erubis (2.7.0)
factory_girl (2.0.5)
factory_girl_rails (1.1.0)
factory_girl (~> 2.0.0)
railties (>= 3.0.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.3)
less (2.0.8)
commonjs (~> 0.2.0)
therubyracer (~> 0.9.9)
less-rails (2.1.1)
actionpack (~> 3.1.1)
less (~> 2.0.7)
libv8 (3.3.10.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.17.2)
mocha (0.10.0)
metaclass (~> 0.0.1)
multi_json (1.0.4)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.3)
actionmailer (= 3.1.3)
actionpack (= 3.1.3)
activerecord (= 3.1.3)
activeresource (= 3.1.3)
activesupport (= 3.1.3)
bundler (~> 1.0)
railties (= 3.1.3)
railties (3.1.3)
actionpack (= 3.1.3)
activesupport (= 3.1.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
therubyracer (0.9.9)
libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
twitter-bootstrap-rails (1.4.1)
actionpack
jquery-rails (~> 1.0)
less
less-rails (~> 2.1.0)
railties
tzinfo (0.3.31)

PLATFORMS
ruby

DEPENDENCIES
factory_girl_rails (~> 1.1.0)
jquery-rails
mocha
nifty-generators!
ruby-debug19
sqlite3
survey_says!
twitter-bootstrap-rails
20 changes: 20 additions & 0 deletions MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright 2011 David Henner

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.rdoc
@@ -0,0 +1,3 @@
= SurveySays

This project rocks and uses MIT-LICENSE.
39 changes: 39 additions & 0 deletions Rakefile
@@ -0,0 +1,39 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'SurveySays'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'


Bundler::GemHelper.install_tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end


task :default => :test
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions app/assets/javascripts/bootstrap.js.coffee
@@ -0,0 +1,21 @@
$ ->
$("body > .topbar").scrollSpy()
$ ->
$(".tabs").tabs()
$ ->
$("a[rel=twipsy]").twipsy live: true
$ ->
$("a[rel=popover]").popover offset: 10
$ ->
$(".topbar-wrapper").dropdown()
$ ->
$(".alert-message").alert()
$ ->
domModal = $(".modal").modal(
backdrop: true
closeOnEscape: true
)
$(".open-modal").click ->
domModal.toggle()
$ ->
$(".btn").button "complete"
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions app/assets/stylesheets/bootstrap.css.less
@@ -0,0 +1,5 @@
@import "twitter/bootstrap";

// Baseline grid
@basefont: 13px;
@baseline: 18px;
Empty file.
Empty file added app/controllers/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions app/controllers/survey_admin/base_controller.rb
@@ -0,0 +1,14 @@
class SurveyAdmin::BaseController < ApplicationController
before_filter :require_survey_admin

private

def require_survey_admin
true
#redirect_to login_url and return unless survey_admin?
end

def survey_admin?
current_user && current_user.survey_admin?
end
end
55 changes: 55 additions & 0 deletions app/controllers/survey_admin/questions_controller.rb
@@ -0,0 +1,55 @@
class SurveyAdmin::QuestionsController < SurveyAdmin::BaseController
def index
@questions = Question.all
end

def show
@question = Question.find(params[:id])
end

def new
form_info
@question = Question.new
end

def create
@question = Question.new(params[:question])
if @question.save
flash[:notice] = "Successfully created question."
redirect_to survey_admin_question_url(@question)
else
form_info
render :action => 'new'
end
end

def edit
form_info
@question = Question.find(params[:id])
end

def update
@question = Question.find(params[:id])
if @question.update_attributes(params[:question])
flash[:notice] = "Successfully updated question."
redirect_to survey_admin_question_url(@question)
else
form_info
render :action => 'edit'
end
end

def destroy
@question = Question.find(params[:id])
@question.active = false
@question.save
flash[:notice] = "Successfully inactivated."
redirect_to survey_admin_questions_url
end

private

def form_info

end
end
Empty file added app/helpers/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions app/helpers/survey_admin/questions_helper.rb
@@ -0,0 +1,2 @@
module SurveyAdmin::QuestionsHelper
end
Empty file added app/mailers/.gitkeep
Empty file.
Empty file added app/models/.gitkeep
Empty file.
7 changes: 7 additions & 0 deletions app/models/answer.rb
@@ -0,0 +1,7 @@
class Answer < ActiveRecord::Base
belongs_to :question
has_many :scores

validates :question_id, :presence => true
validates :details, :presence => true
end
8 changes: 8 additions & 0 deletions app/models/question.rb
@@ -0,0 +1,8 @@
class Question < ActiveRecord::Base
has_many :answers, :order => 'answers.position desc'
has_many :active_answers, :class_name => 'Answer',
:conditions => ["answers.active = ?", true],
:order => 'answers.position desc'

validates :details, :presence => true
end
12 changes: 12 additions & 0 deletions app/models/score.rb
@@ -0,0 +1,12 @@
class Score < ActiveRecord::Base
belongs_to :answer
belongs_to :survey_property

validates :value, :presence => true
validates :survey_property_id, :presence => true,
:uniqueness => {
:scope => :answer_id,
:message => "should have one score per property"
}
validates :answer_id, :presence => true
end
5 changes: 5 additions & 0 deletions app/models/survey_property.rb
@@ -0,0 +1,5 @@
class SurveyProperty < ActiveRecord::Base
has_many :scores

validates :name, :presence => true
end
Empty file added app/views/.gitkeep
Empty file.

0 comments on commit 7cc6b1f

Please sign in to comment.