Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update app to support Rails 4. Don't include attr_accessible if the R…

…ails version is 4 or greater. Update specs to eliminate deprecations, use more modern FactoryGirl syntax. Change default rake task to use built-in RSpec task.
  • Loading branch information...
commit dc4b9e624df82744d2948e2a841e144294af26fc 1 parent b461b1c
@petergoldstein petergoldstein authored
View
13 Gemfile
@@ -1,3 +1,14 @@
-source :rubygems
+source 'http://rubygems.org'
gemspec
+
+rails_version = ENV["RAILS_VERSION"] || "default"
+
+rails = case rails_version
+when "master"
+ {github: "rails/rails"}
+when "default"
+ "~> 4.0.0"
+else
+ "~> #{rails_version}"
+end
View
147 Gemfile.lock
@@ -9,105 +9,102 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.2.3)
- actionpack (= 3.2.3)
- mail (~> 2.4.4)
- actionpack (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
- builder (~> 3.0.0)
+ actionmailer (4.0.0)
+ actionpack (= 4.0.0)
+ mail (~> 2.5.3)
+ actionpack (4.0.0)
+ activesupport (= 4.0.0)
+ builder (~> 3.1.0)
erubis (~> 2.7.0)
- journey (~> 1.0.1)
- rack (~> 1.4.0)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.1.2)
- activemodel (3.2.3)
- activesupport (= 3.2.3)
- builder (~> 3.0.0)
- activerecord (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activeresource (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
- activesupport (3.2.3)
- i18n (~> 0.6)
- multi_json (~> 1.0)
- arel (3.0.2)
- builder (3.0.4)
- diff-lcs (1.2.3)
+ rack (~> 1.5.2)
+ rack-test (~> 0.6.2)
+ activemodel (4.0.0)
+ activesupport (= 4.0.0)
+ builder (~> 3.1.0)
+ activerecord (4.0.0)
+ activemodel (= 4.0.0)
+ activerecord-deprecated_finders (~> 1.0.2)
+ activesupport (= 4.0.0)
+ arel (~> 4.0.0)
+ activerecord-deprecated_finders (1.0.3)
+ activesupport (4.0.0)
+ i18n (~> 0.6, >= 0.6.4)
+ minitest (~> 4.2)
+ multi_json (~> 1.3)
+ thread_safe (~> 0.1)
+ tzinfo (~> 0.3.37)
+ arel (4.0.0)
+ atomic (1.1.10)
+ builder (3.1.4)
+ diff-lcs (1.2.4)
erubis (2.7.0)
- factory_girl (3.2.0)
+ factory_girl (4.2.0)
activesupport (>= 3.0.0)
- hike (1.2.2)
- i18n (0.6.0)
- journey (1.0.4)
- json (1.7.7)
+ hike (1.2.3)
+ i18n (0.6.4)
lockfile (2.1.0)
- mail (2.4.4)
- i18n (>= 0.4.0)
+ mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
- mime-types (1.22)
- mocha (0.11.4)
+ mime-types (1.23)
+ mini_portile (0.5.1)
+ minitest (4.7.5)
+ mocha (0.14.0)
metaclass (~> 0.0.1)
- multi_json (1.3.4)
- nokogiri (1.5.9)
+ multi_json (1.7.7)
+ nokogiri (1.6.0)
+ mini_portile (~> 0.5.0)
polyglot (0.3.3)
- rack (1.4.5)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-ssl (1.3.3)
- rack
+ rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
- rails (3.2.3)
- actionmailer (= 3.2.3)
- actionpack (= 3.2.3)
- activerecord (= 3.2.3)
- activeresource (= 3.2.3)
- activesupport (= 3.2.3)
- bundler (~> 1.0)
- railties (= 3.2.3)
- railties (3.2.3)
- actionpack (= 3.2.3)
- activesupport (= 3.2.3)
- rack-ssl (~> 1.3.2)
+ rails (4.0.0)
+ actionmailer (= 4.0.0)
+ actionpack (= 4.0.0)
+ activerecord (= 4.0.0)
+ activesupport (= 4.0.0)
+ bundler (>= 1.3.0, < 2.0)
+ railties (= 4.0.0)
+ sprockets-rails (~> 2.0.0)
+ railties (4.0.0)
+ actionpack (= 4.0.0)
+ activesupport (= 4.0.0)
rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (~> 0.14.6)
- rake (10.0.4)
- rdoc (3.12.2)
- json (~> 1.4)
+ thor (>= 0.18.1, < 2.0)
+ rake (10.1.0)
rest-client (1.6.7)
mime-types (>= 1.16)
- rspec-core (2.13.1)
- rspec-expectations (2.13.0)
+ rspec-core (2.14.3)
+ rspec-expectations (2.14.0)
diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.13.1)
- rspec-rails (2.13.0)
+ rspec-mocks (2.14.1)
+ rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec-core (~> 2.13.0)
- rspec-expectations (~> 2.13.0)
- rspec-mocks (~> 2.13.0)
- rturk (2.10.1)
+ rspec-core (~> 2.14.0)
+ rspec-expectations (~> 2.14.0)
+ rspec-mocks (~> 2.14.0)
+ rturk (2.10.2)
nokogiri (>= 1.4.1)
rest-client (>= 1.4.0)
spork (0.9.2)
- sprockets (2.1.3)
+ sprockets (2.10.0)
hike (~> 1.2)
+ multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.6)
- thor (0.14.6)
- tilt (1.3.7)
- treetop (1.4.12)
+ sprockets-rails (2.0.0)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ sprockets (~> 2.8)
+ sqlite3 (1.3.7)
+ thor (0.18.1)
+ thread_safe (0.1.0)
+ atomic
+ tilt (1.4.1)
+ treetop (1.4.14)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
View
13 Rakefile
@@ -1,13 +1,16 @@
require 'rubygems'
require 'rake'
require 'bundler'
+require 'rspec/core/rake_task'
Bundler::GemHelper.install_tasks
$:.push File.expand_path("../lib", __FILE__)
-task :default do
- sh "rspec spec/"
-end
+desc "Run specs"
+RSpec::Core::RakeTask.new(:spec)
+
+desc 'Default: run specs.'
+task :default => :spec
begin
INSTALL_MESSAGE = %q{
@@ -35,8 +38,8 @@ begin
gem.email = "jjones@aantix.com"
gem.homepage = "http://github.com/aantix/turkee"
gem.authors = ["Jim Jones"]
- gem.add_dependency(%q<rails>, [">= 3.0.7"])
- gem.add_dependency(%q<rturk>, [">= 2.3.0"])
+ gem.add_dependency(%q<rails>, [">= 3.1.1"])
+ gem.add_dependency(%q<rturk>, [">= 2.4.0"])
gem.add_dependency(%q<lockfile>, [">= 1.4.3"])
gem.post_install_message = INSTALL_MESSAGE
View
2  lib/models/turkee_imported_assignment.rb
@@ -2,7 +2,7 @@
module Turkee
class TurkeeImportedAssignment < ActiveRecord::Base
- attr_accessible :assignment_id, :turkee_task_id, :worker_id, :result_id
+ attr_accessible :assignment_id, :turkee_task_id, :worker_id, :result_id if ActiveRecord::VERSION::MAJOR < 4
def self.record_imported_assignment(assignment, result, turk)
TurkeeImportedAssignment.create!(:assignment_id => assignment.id,
View
2  lib/models/turkee_study.rb
@@ -1,7 +1,7 @@
module Turkee
class TurkeeStudy < ActiveRecord::Base
GOLD_RESPONSE_INDEX = 3
- attr_accessible :turkee_task_id, :feedback, :gold_response
+ attr_accessible :turkee_task_id, :feedback, :gold_response if ActiveRecord::VERSION::MAJOR < 4
def approve?
words = feedback.split(/\W+/)
View
2  lib/models/turkee_task.rb
@@ -10,7 +10,7 @@ module Turkee
class TurkeeTask < ActiveRecord::Base
attr_accessible :sandbox, :hit_title, :hit_description, :hit_reward, :hit_num_assignments, :hit_lifetime, :hit_duration,
- :form_url, :hit_url, :hit_id, :task_type, :complete
+ :form_url, :hit_url, :hit_id, :task_type, :complete if ActiveRecord::VERSION::MAJOR < 4
HIT_FRAMEHEIGHT = 1000
View
3  spec/dummy/config/environments/development.rb
@@ -6,8 +6,7 @@
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
- # Log error messages when you accidentally call methods on nil.
- config.whiny_nils = true
+ config.eager_load = false if Rails::VERSION::MAJOR >= 4
# Show full error reports and disable caching
config.consider_all_requests_local = true
View
3  spec/dummy/config/environments/test.rb
@@ -11,8 +11,7 @@
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
- # Log error messages when you accidentally call methods on nil
- config.whiny_nils = true
+ config.eager_load = false if Rails::VERSION::MAJOR >= 4
# Show full error reports and disable caching
config.consider_all_requests_local = true
View
4 spec/helpers/turkee_forms_helper_spec.rb
@@ -14,7 +14,7 @@
describe "turkee_study" do
before do
- @task = Factory(:turkee_task)
+ @task = create(:turkee_task)
RTurk.stub(:sandbox?).and_return true
helper.stub(:params).and_return({:assignmentId => '123456', :workerId => '987654'})
@@ -42,7 +42,7 @@
describe "turkee_form_for" do
before do
- @survey = Factory(:survey)
+ @survey = create(:survey)
RTurk.stub(:sandbox?).and_return true
params = {:assignmentId => '123456', :workerId => '987654'}
View
2  spec/spec_helper.rb
@@ -60,6 +60,8 @@
FactoryGirl.find_definitions
RSpec.configure do |config|
+ config.include FactoryGirl::Syntax::Methods
+
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
Please sign in to comment.
Something went wrong with that request. Please try again.