Commit 11abaf99 by Alex Dusenbery

EDUCATOR-313: Bump ruby to 2.4.1; Use latest newrelic_rpm package; Add…

EDUCATOR-313: Bump ruby to 2.4.1; Use latest newrelic_rpm package;  Add test-forum docker-compose service.
parent f02a05e8
...@@ -31,3 +31,5 @@ log/ ...@@ -31,3 +31,5 @@ log/
.redcar/ .redcar/
/nbproject /nbproject
.idea/ .idea/
.ruby-version
\ No newline at end of file
...@@ -5,10 +5,10 @@ services: ...@@ -5,10 +5,10 @@ services:
language: ruby language: ruby
rvm: rvm:
- "1.9.3" - "2.4.1"
install: install:
- docker-compose -f ./.travis/docker-compose-travis.yml up -d - docker-compose -f ./.travis/docker-compose-travis.yml build test-forum
script: script:
- docker exec forum_testing /edx/app/forum/cs_comments_service/.travis/run_tests.sh - docker-compose -f ./.travis/docker-compose-travis.yml run --rm test-forum
...@@ -8,13 +8,21 @@ services: ...@@ -8,13 +8,21 @@ services:
mongo: mongo:
image: mongo:3.0.14 image: mongo:3.0.14
container_name: "mongo.edx" container_name: "mongo.edx"
forum: forum-base:
image: edxops/forum:latest image: edxops/forum:ruby2.4.1 # TODO: switch back to latest after configuration release
container_name: forum_testing container_name: forum_testing
volumes: volumes:
- ..:/edx/app/forum/cs_comments_service - ..:/edx/app/forum/cs_comments_service
forum:
extends: forum-base
command: tail -f /dev/null command: tail -f /dev/null
depends_on: depends_on:
- "elasticsearch" - "elasticsearch"
- "mongo" - "mongo"
test-forum:
extends: forum-base
command: /edx/app/forum/cs_comments_service/.travis/run_tests.sh
depends_on:
- "elasticsearch"
- "mongo"
\ No newline at end of file
source 'https://rubygems.org' source 'https://rubygems.org'
ruby "1.9.3" ruby "2.4.1"
gem 'pry' gem 'pry'
gem 'pry-nav' gem 'pry-nav'
...@@ -16,9 +16,8 @@ gem 'sinatra-param', '~> 1.4' ...@@ -16,9 +16,8 @@ gem 'sinatra-param', '~> 1.4'
gem 'yajl-ruby' gem 'yajl-ruby'
gem 'mongoid', '~> 5.0.0' gem 'mongoid', '~> 5.0.0'
gem 'bson', '~>3.1' gem 'bson', '~> 3.1'
gem 'bson_ext' gem 'bson_ext'
gem 'protected_attributes' gem 'protected_attributes'
...@@ -49,12 +48,13 @@ group :test do ...@@ -49,12 +48,13 @@ group :test do
gem 'guard' gem 'guard'
gem 'guard-unicorn' gem 'guard-unicorn'
gem 'rack-test', :require => 'rack/test' gem 'rack-test', :require => 'rack/test'
gem 'rspec', '~> 2.11.0' gem 'rspec', '~> 3.6.0'
gem 'webmock', '~> 1.22' gem 'rspec-its'
gem 'rspec-collection_matchers'
gem 'webmock', '~> 3.0.1'
end end
# FIXME Remove version restriction once ruby upgraded to 2.x gem 'newrelic_rpm'
gem 'newrelic_rpm', '~> 3.16.0'
gem 'unicorn' gem 'unicorn'
gem "rack-timeout" gem "rack-timeout"
gem "i18n" gem "i18n"
......
...@@ -23,36 +23,36 @@ GIT ...@@ -23,36 +23,36 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activemodel (4.2.4) activemodel (4.2.8)
activesupport (= 4.2.4) activesupport (= 4.2.8)
builder (~> 3.1) builder (~> 3.1)
activesupport (4.2.4) activesupport (4.2.8)
i18n (~> 0.7) i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4) thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.4.0) addressable (2.5.1)
bson (3.2.4) public_suffix (~> 2.0, >= 2.0.2)
bson (3.2.6)
bson_ext (1.5.1) bson_ext (1.5.1)
builder (3.2.2) builder (3.2.3)
codecov (0.1.2) codecov (0.1.10)
json json
simplecov simplecov
url url
coderay (1.0.7) coderay (1.1.1)
crack (0.4.3) crack (0.4.3)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
dalli (2.1.0) dalli (2.7.6)
delayed_job (4.1.1) delayed_job (4.1.3)
activesupport (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.2)
delayed_job_mongoid (2.2.0) delayed_job_mongoid (2.3.0)
delayed_job (>= 3.0, < 5) delayed_job (>= 3.0, < 5)
mongoid (>= 3.0, < 6) mongoid (>= 3.0, < 7)
mongoid-compatibility mongoid-compatibility (>= 0.4.0)
diff-lcs (1.1.3) diff-lcs (1.3)
docile (1.1.5) docile (1.1.5)
domain_name (0.5.24) domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
elasticsearch (1.1.2) elasticsearch (1.1.2)
elasticsearch-api (= 1.1.2) elasticsearch-api (= 1.1.2)
...@@ -66,39 +66,53 @@ GEM ...@@ -66,39 +66,53 @@ GEM
elasticsearch-transport (1.1.2) elasticsearch-transport (1.1.2)
faraday faraday
multi_json multi_json
enumerize (0.11.0) enumerize (2.1.2)
activesupport (>= 3.2) activesupport (>= 3.2)
factory_girl (4.5.0) factory_girl (4.8.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
faker (1.6.1) faker (1.7.3)
i18n (~> 0.5) i18n (~> 0.5)
faraday (0.11.0) faraday (0.12.1)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
guard (1.3.2) ffi (1.9.18)
listen (>= 0.4.2) formatador (0.2.5)
thor (>= 0.14.6) guard (2.14.1)
guard-unicorn (0.0.7) formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-unicorn (0.2.0)
guard (>= 1.1) guard (>= 1.1)
hashdiff (0.2.3) hashdiff (0.3.4)
hashie (3.4.6) hashie (3.5.5)
http-cookie (1.0.2) http-cookie (1.0.3)
domain_name (~> 0.5) domain_name (~> 0.5)
i18n (0.7.0) i18n (0.8.4)
json (1.8.3) json (2.1.0)
kgio (2.10.0) kgio (2.11.0)
listen (0.5.0) listen (3.1.5)
method_source (0.8) rb-fsevent (~> 0.9, >= 0.9.4)
mime-types (2.6.1) rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.12)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0) mini_portile2 (2.1.0)
minitest (5.8.1) minitest (5.10.2)
mongo (2.1.1) mongo (2.1.2)
bson (~> 3.0) bson (~> 3.0)
mongoid (5.0.0) mongoid (5.0.0)
activemodel (~> 4.0) activemodel (~> 4.0)
mongo (~> 2.1) mongo (~> 2.1)
origin (~> 2.1) origin (~> 2.1)
tzinfo (>= 0.3.37) tzinfo (>= 0.3.37)
mongoid-compatibility (0.3.1) mongoid-compatibility (0.4.1)
activesupport activesupport
mongoid (>= 2.0) mongoid (>= 2.0)
mongoid_cleaner (1.2.0) mongoid_cleaner (1.2.0)
...@@ -108,77 +122,94 @@ GEM ...@@ -108,77 +122,94 @@ GEM
rake rake
multi_json (1.12.1) multi_json (1.12.1)
multipart-post (2.0.0) multipart-post (2.0.0)
netrc (0.10.3) nenv (0.3.0)
newrelic_rpm (3.16.0.318) netrc (0.11.0)
nokogiri (1.6.8) newrelic_rpm (3.16.3.323)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7) notiffany (0.1.1)
origin (2.1.1) nenv (~> 0.1)
pkg-config (1.1.7) shellany (~> 0.0)
protected_attributes (1.1.3) origin (2.3.1)
protected_attributes (1.1.4)
activemodel (>= 4.0.1, < 5.0) activemodel (>= 4.0.1, < 5.0)
pry (0.9.10) pry (0.10.4)
coderay (~> 1.0.5) coderay (~> 1.1.0)
method_source (~> 0.8) method_source (~> 0.8.1)
slop (~> 3.3.1) slop (~> 3.4)
pry-nav (0.2.2) pry-nav (0.2.4)
pry (~> 0.9.10) pry (>= 0.9.10, < 0.11.0)
rack (1.6.4) public_suffix (2.0.5)
rack-protection (1.2.0) rack (1.6.8)
rack-protection (1.5.3)
rack rack
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rack-timeout (0.3.2) rack-timeout (0.4.2)
raindrops (0.15.0) raindrops (0.18.0)
rake (10.4.2) rake (12.0.0)
rdiscount (1.6.8) rb-fsevent (0.9.8)
rest-client (1.8.0) rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rdiscount (2.2.0.1)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0) mime-types (>= 1.16, < 4.0)
netrc (~> 0.7) netrc (~> 0.8)
rspec (2.11.0) rspec (3.6.0)
rspec-core (~> 2.11.0) rspec-core (~> 3.6.0)
rspec-expectations (~> 2.11.0) rspec-expectations (~> 3.6.0)
rspec-mocks (~> 2.11.0) rspec-mocks (~> 3.6.0)
rspec-core (2.11.1) rspec-collection_matchers (1.1.3)
rspec-expectations (2.11.2) rspec-expectations (>= 2.99.0.beta1)
diff-lcs (~> 1.1.3) rspec-core (3.6.0)
rspec-mocks (2.11.2) rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
ruby_dep (1.5.0)
safe_yaml (1.0.4) safe_yaml (1.0.4)
simplecov (0.11.1) shellany (0.0.1)
simplecov (0.14.1)
docile (~> 1.1.0) docile (~> 1.1.0)
json (~> 1.8) json (>= 1.8, < 3)
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.0) simplecov-html (0.10.1)
sinatra (1.3.3) sinatra (1.4.8)
rack (~> 1.3, >= 1.3.6) rack (~> 1.5)
rack-protection (~> 1.2) rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.3) tilt (>= 1.3, < 3)
sinatra-param (1.4.0) sinatra-param (1.4.0)
sinatra (~> 1.3) sinatra (~> 1.3)
slop (3.3.2) slop (3.6.0)
thor (0.16.0) thor (0.19.4)
thread_safe (0.3.5) thread_safe (0.3.6)
tilt (1.3.3) tilt (2.0.7)
tzinfo (1.2.2) tzinfo (1.2.3)
thread_safe (~> 0.1) thread_safe (~> 0.1)
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.7.1) unf_ext (0.0.7.4)
unicorn (4.9.0) unicorn (5.3.0)
kgio (~> 2.6) kgio (~> 2.6)
rack
raindrops (~> 0.7) raindrops (~> 0.7)
url (0.3.2) url (0.3.2)
webmock (1.22.3) webmock (3.0.1)
addressable (>= 2.3.6) addressable (>= 2.3.6)
crack (>= 0.3.2) crack (>= 0.3.2)
hashdiff hashdiff
will_paginate (3.0.7) will_paginate (3.1.6)
will_paginate_mongoid (2.0.1) will_paginate_mongoid (2.0.1)
mongoid mongoid
will_paginate (~> 3.0) will_paginate (~> 3.0)
yajl-ruby (1.2.1) yajl-ruby (1.3.0)
PLATFORMS PLATFORMS
ruby ruby
...@@ -203,7 +234,7 @@ DEPENDENCIES ...@@ -203,7 +234,7 @@ DEPENDENCIES
mongoid-tree! mongoid-tree!
mongoid_cleaner (~> 1.2.0) mongoid_cleaner (~> 1.2.0)
mongoid_magic_counter_cache mongoid_magic_counter_cache
newrelic_rpm (~> 3.16.0) newrelic_rpm
nokogiri (~> 1.6.8) nokogiri (~> 1.6.8)
protected_attributes protected_attributes
pry pry
...@@ -215,13 +246,15 @@ DEPENDENCIES ...@@ -215,13 +246,15 @@ DEPENDENCIES
rdiscount rdiscount
rest-client rest-client
rs_voteable_mongo! rs_voteable_mongo!
rspec (~> 2.11.0) rspec (~> 3.6.0)
rspec-collection_matchers
rspec-its
sinatra sinatra
sinatra-param (~> 1.4) sinatra-param (~> 1.4)
unicorn unicorn
webmock (~> 1.22) webmock (~> 3.0.1)
will_paginate_mongoid (~> 2.0) will_paginate_mongoid (~> 2.0)
yajl-ruby yajl-ruby
BUNDLED WITH BUNDLED WITH
1.12.5 1.15.2
...@@ -104,6 +104,17 @@ If you'd like to view additional options for the command, append the `--help` op ...@@ -104,6 +104,17 @@ If you'd like to view additional options for the command, append the `--help` op
__ http://rspec.info/ __ http://rspec.info/
Running Tests with Docker
---------------------
You can also use docker-compose to run your tests as follows (assuming you have
docker-compose installed):
.. code-block::
$ docker-compose -f .travis/docker-compose-travis.yml run --rm test-forum
Internationalization (i18n) and Localization (l10n) Internationalization (i18n) and Localization (l10n)
--------------------------------------------------- ---------------------------------------------------
......
require 'task_helpers' require_relative '../task_helpers'
namespace :search do namespace :search do
desc 'Indexes content updated in the last N minutes.' desc 'Indexes content updated in the last N minutes.'
......
...@@ -12,7 +12,7 @@ describe 'Comment API' do ...@@ -12,7 +12,7 @@ describe 'Comment API' do
comment = thread.comments.first comment = thread.comments.first
get "/api/v1/comments/#{comment.id}" get "/api/v1/comments/#{comment.id}"
last_response.should be_ok last_response.should be_ok
last_response.content_type.should == 'application/json;charset=utf-8' last_response.content_type.should == 'application/json'
end end
it 'retrieves information of a single comment' do it 'retrieves information of a single comment' do
......
...@@ -439,7 +439,7 @@ describe 'app' do ...@@ -439,7 +439,7 @@ describe 'app' do
it { should be_ok } it { should be_ok }
it 'returns JSON' do it 'returns JSON' do
expect(subject.content_type).to eq 'application/json;charset=utf-8' expect(subject.content_type).to eq 'application/json'
end end
it 'get information of a single comment thread' do it 'get information of a single comment thread' do
...@@ -697,7 +697,7 @@ describe 'app' do ...@@ -697,7 +697,7 @@ describe 'app' do
changed_thread.comment_count.should == orig_count + 1 changed_thread.comment_count.should == orig_count + 1
comment = changed_thread.comments.select { |c| c["body"] == "new comment" }.first comment = changed_thread.comments.select { |c| c["body"] == "new comment" }.first
comment.should_not be_nil comment.should_not be_nil
comment.anonymous.should be_true comment.anonymous.should be true
end end
it "returns 400 when the thread does not exist" do it "returns 400 when the thread does not exist" do
post "/api/v1/threads/does_not_exist/comments", default_params post "/api/v1/threads/does_not_exist/comments", default_params
......
...@@ -166,7 +166,7 @@ describe 'app' do ...@@ -166,7 +166,7 @@ describe 'app' do
thread = CommentThread.find(body['id']) thread = CommentThread.find(body['id'])
expect(thread).to_not be_nil expect(thread).to_not be_nil
expect(thread['anonymous']).to be_true expect(thread['anonymous']).to be true
end end
it 'returns error when title, body or course id does not exist' do it 'returns error when title, body or course id does not exist' do
......
...@@ -82,7 +82,7 @@ describe "app" do ...@@ -82,7 +82,7 @@ describe "app" do
it "does not contain cohort group_id if not defined" do it "does not contain cohort group_id if not defined" do
thread_notification = get_thread_notification("dummy comment content") thread_notification = get_thread_notification("dummy comment content")
thread_notification.has_key?("group_id").should be_false thread_notification.has_key?("group_id").should be false
end end
it "returns only threads subscribed to by user" do it "returns only threads subscribed to by user" do
......
...@@ -5,7 +5,7 @@ describe "search:rebuild_index" do ...@@ -5,7 +5,7 @@ describe "search:rebuild_index" do
include_context "rake" include_context "rake"
before do before do
TaskHelpers::ElasticsearchHelper.stub!(:rebuild_index) TaskHelpers::ElasticsearchHelper.stub(:rebuild_index)
end end
its(:prerequisites) { should include("environment") } its(:prerequisites) { should include("environment") }
...@@ -34,7 +34,7 @@ describe "search:catchup" do ...@@ -34,7 +34,7 @@ describe "search:catchup" do
include_context "rake" include_context "rake"
before do before do
TaskHelpers::ElasticsearchHelper.stub!(:catchup_index) TaskHelpers::ElasticsearchHelper.stub(:catchup_index)
end end
its(:prerequisites) { should include("environment") } its(:prerequisites) { should include("environment") }
...@@ -63,4 +63,4 @@ describe "search:catchup" do ...@@ -63,4 +63,4 @@ describe "search:catchup" do
subject.invoke(minutes, index_name, batch_size, sleep_time) subject.invoke(minutes, index_name, batch_size, sleep_time)
end end
end end
\ No newline at end of file
...@@ -50,14 +50,14 @@ describe Comment do ...@@ -50,14 +50,14 @@ describe Comment do
context 'with standalone_thread' do context 'with standalone_thread' do
it 'returns false' do it 'returns false' do
comment = make_comment(author, standalone_thread, "comment") comment = make_comment(author, standalone_thread, "comment")
expect(comment.course_context?).to be_false expect(comment.course_context?).to be false
end end
end end
context 'with course_thread' do context 'with course_thread' do
it 'returns true' do it 'returns true' do
comment = make_comment(author, course_thread, "comment") comment = make_comment(author, course_thread, "comment")
expect(comment.course_context?).to be_true expect(comment.course_context?).to be true
end end
end end
...@@ -65,7 +65,7 @@ describe Comment do ...@@ -65,7 +65,7 @@ describe Comment do
it 'returns false' do it 'returns false' do
comment = make_comment(author, course_thread, "comment") comment = make_comment(author, course_thread, "comment")
comment.comment_thread_id = 'not a thread' comment.comment_thread_id = 'not a thread'
expect(comment.course_context?).to be_false expect(comment.course_context?).to be false
end end
end end
end end
...@@ -74,14 +74,14 @@ describe Comment do ...@@ -74,14 +74,14 @@ describe Comment do
context 'with standalone_thread' do context 'with standalone_thread' do
it 'returns true' do it 'returns true' do
comment = make_comment(author, standalone_thread, "comment") comment = make_comment(author, standalone_thread, "comment")
expect(comment.standalone_context?).to be_true expect(comment.standalone_context?).to be true
end end
end end
context 'with course_thread' do context 'with course_thread' do
it 'returns false' do it 'returns false' do
comment = make_comment(author, course_thread, "comment") comment = make_comment(author, course_thread, "comment")
expect(comment.standalone_context?).to be_false expect(comment.standalone_context?).to be false
end end
end end
...@@ -89,7 +89,7 @@ describe Comment do ...@@ -89,7 +89,7 @@ describe Comment do
it 'returns false' do it 'returns false' do
comment = make_comment(author, course_thread, "comment") comment = make_comment(author, course_thread, "comment")
comment.comment_thread_id = 'not a thread' comment.comment_thread_id = 'not a thread'
expect(comment.standalone_context?).to be_false expect(comment.standalone_context?).to be false
end end
end end
......
...@@ -85,11 +85,11 @@ describe ThreadPresenter do ...@@ -85,11 +85,11 @@ describe ThreadPresenter do
# with response=false and recursive=false # with response=false and recursive=false
hash = ThreadPresenter.new(thread, @reader, false, num_comments, is_endorsed).to_hash(false, 0, nil, false) hash = ThreadPresenter.new(thread, @reader, false, num_comments, is_endorsed).to_hash(false, 0, nil, false)
check_thread_result(@reader, thread, hash) check_thread_result(@reader, thread, hash)
['children', 'resp_skip', 'resp_limit', 'resp_total'].each {|k| (hash.has_key? k).should be_false } ['children', 'resp_skip', 'resp_limit', 'resp_total'].each {|k| (hash.has_key? k).should be false }
# with response=false and recursive=true # with response=false and recursive=true
hash = ThreadPresenter.new(thread, @reader, false, num_comments, is_endorsed).to_hash(false, 0, nil, true) hash = ThreadPresenter.new(thread, @reader, false, num_comments, is_endorsed).to_hash(false, 0, nil, true)
check_thread_result(@reader, thread, hash) check_thread_result(@reader, thread, hash)
['children', 'resp_skip', 'resp_limit', 'resp_total'].each {|k| (hash.has_key? k).should be_false } ['children', 'resp_skip', 'resp_limit', 'resp_total'].each {|k| (hash.has_key? k).should be false }
end end
end end
......
...@@ -10,6 +10,8 @@ end ...@@ -10,6 +10,8 @@ end
require File.join(File.dirname(__FILE__), '..', 'app') require File.join(File.dirname(__FILE__), '..', 'app')
require 'rack/test' require 'rack/test'
require 'rspec/its'
require 'rspec/collection_matchers'
require 'sinatra' require 'sinatra'
require 'yajl' require 'yajl'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment