diff --git a/Gemfile b/Gemfile index f50478e8..2b8a0719 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,10 @@ source 'http://rubygems.org' ruby '2.3.1' -gem 'slack-ruby-client', github: 'slack-ruby/slack-ruby-client' -gem 'slack-ruby-bot-server', github: 'dblock/slack-ruby-bot-server' +gem 'slack-ruby-client' +gem 'slack-ruby-bot-server' +gem 'roar', '~> 1.0.4' +gem 'mongoid', '~> 5.1.4' gem 'ruby-enum' gem 'mongoid-scroll' gem 'time_ago_in_words' @@ -12,6 +14,8 @@ gem 'wannabe_bool' gem 'newrelic_rpm' gem 'rack-server-pages' gem 'stripe' +gem 'kaminari-grape' +gem 'giphy' group :development, :test do gem 'rake', '~> 10.4' diff --git a/Gemfile.lock b/Gemfile.lock index 629ff649..28cb04d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,51 +1,6 @@ -GIT - remote: git://github.com/dblock/slack-ruby-bot-server.git - revision: cfa14a9046cdef9f51a005b8203abd4104c31830 - specs: - slack-ruby-bot-server (0.4.0) - celluloid-io - foreman - grape - grape-roar - grape-swagger - kaminari-mongoid - mongoid - mongoid-scroll - rack-cors - rack-rewrite - rack-server-pages - slack-ruby-bot - unicorn - -GIT - remote: git://github.com/slack-ruby/slack-ruby-client.git - revision: b2e6d92dab0da9f4d576b1e711a94bc7b2c5f593 - specs: - slack-ruby-client (0.7.7) - activesupport - faraday - faraday_middleware - gli - hashie - json - websocket-driver - GEM remote: http://rubygems.org/ specs: - actionpack (4.2.7.1) - actionview (= 4.2.7.1) - activesupport (= 4.2.7.1) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.7.1) - activesupport (= 4.2.7.1) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) activemodel (4.2.7.1) activesupport (= 4.2.7.1) builder (~> 3.1) @@ -55,7 +10,8 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.4.0) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) ast (2.3.0) astrolabe (1.3.1) parser (~> 2.2) @@ -63,9 +19,9 @@ GEM descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) - bson (4.1.1) - builder (3.2.2) - capybara (2.8.1) + bson (4.2.1) + builder (3.2.3) + capybara (2.7.1) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -93,7 +49,7 @@ GEM timers (>= 4.1.1) celluloid-supervision (0.20.6) timers (>= 4.1.1) - childprocess (0.5.9) + childprocess (0.6.1) ffi (~> 1.0, >= 1.0.11) coercible (1.0.0) descendants_tracker (~> 0.0.1) @@ -103,15 +59,13 @@ GEM database_cleaner (1.5.3) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - diff-lcs (1.2.5) - domain_name (0.5.20160615) + diff-lcs (1.3) + domain_name (0.5.20161129) unf (>= 0.0.5, < 1.0.0) - enumerable-lazy (0.0.1) equalizer (0.0.11) - erubis (2.7.0) - excon (0.52.0) - fabrication (2.15.2) - faker (1.6.6) + excon (0.54.0) + fabrication (2.16.0) + faker (1.7.2) i18n (~> 0.5) faraday (0.9.2) multipart-post (>= 1.2, < 3) @@ -126,8 +80,8 @@ GEM faraday (~> 0.9.0) faraday_middleware (~> 0.9.1) oj (~> 2.0) - ffi (1.9.14) - foreman (0.82.0) + ffi (1.9.17) + foreman (0.83.0) thor (~> 0.19.1) futuroscope (0.1.11) giphy (2.0.2) @@ -135,28 +89,28 @@ GEM faraday_middleware (~> 0.9) faraday_middleware-parse_oj (~> 0.3) launchy (~> 2.4) - gli (2.14.0) - grape (0.17.0) + gli (2.15.0) + grape (0.19.1) activesupport builder hashie (>= 2.1.0) multi_json (>= 1.3.2) multi_xml (>= 0.5.2) - mustermann19 (~> 0.4.3) + mustermann-grape (~> 0.4.0) rack (>= 1.3.0) rack-accept virtus (>= 1.0.0) grape-roar (0.3.0) grape roar (>= 1.0) - grape-swagger (0.23.0) - grape (>= 0.12.0) - hashdiff (0.3.0) - hashie (3.4.4) + grape-swagger (0.26.0) + grape (>= 0.16.2) + hashdiff (0.3.2) + hashie (3.4.6) hitimes (1.2.4) - http-cookie (1.0.2) + http-cookie (1.0.3) domain_name (~> 0.5) - hyperclient (0.8.1) + hyperclient (0.8.2) faraday faraday-digestauth faraday_hal_middleware @@ -166,33 +120,33 @@ GEM uri_template i18n (0.7.0) ice_nine (0.11.2) - json (1.8.3) - kaminari (0.17.0) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - kaminari-mongoid (0.1.2) - kaminari - kgio (2.10.0) + json (1.8.6) + kaminari-core (1.0.1) + kaminari-grape (1.0.1) + grape + kaminari-core (~> 1.0) + kaminari-mongoid (1.0.1) + kaminari-core (~> 1.0) + mongoid + kgio (2.11.0) launchy (2.4.3) addressable (~> 2.3) - loofah (2.0.3) - nokogiri (>= 1.5.9) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - minitest (5.9.0) - mongo (2.3.0) - bson (~> 4.1) - mongoid (5.1.4) + minitest (5.10.1) + mongo (2.4.1) + bson (>= 4.2.1, < 5.0.0) + mongoid (5.1.6) activemodel (~> 4.0) mongo (~> 2.1) origin (~> 2.2) tzinfo (>= 0.3.37) - mongoid-compatibility (0.4.0) + mongoid-compatibility (0.4.1) activesupport mongoid (>= 2.0) - mongoid-scroll (0.3.4) + mongoid-scroll (0.3.5) i18n mongoid (>= 3.0) mongoid-compatibility @@ -201,43 +155,36 @@ GEM mongoid (>= 3.0.0) mongoid-compatibility multi_json (1.12.1) - multi_xml (0.5.5) + multi_xml (0.6.0) multipart-post (2.0.0) - mustermann19 (0.4.4) - enumerable-lazy + mustermann (0.4.0) + tool (~> 0.2) + mustermann-grape (0.4.0) + mustermann (= 0.4.0) net-http-digest_auth (1.4) netrc (0.11.0) - newrelic_rpm (3.16.2.321) - nio4r (1.2.1) - nokogiri (1.6.8) + newrelic_rpm (3.18.0.329) + nio4r (2.0.0) + nokogiri (1.7.0.1) mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) oj (2.17.3) - origin (2.2.0) - parser (2.3.1.2) + origin (2.3.0) + parser (2.3.3.1) ast (~> 2.2) - pkg-config (1.1.7) powerpack (0.1.1) - rack (1.6.4) + public_suffix (2.0.5) + rack (2.0.1) rack-accept (0.4.5) rack (>= 0.4) rack-cors (0.4.0) rack-rewrite (1.5.1) rack-robotz (0.0.4) rack - rack-server-pages (0.0.6) + rack-server-pages (0.1.0) rack rack-test (0.6.3) rack (>= 1.0) - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - rainbow (2.1.0) + rainbow (2.2.1) raindrops (0.17.0) rake (10.5.0) representable (2.3.0) @@ -252,7 +199,7 @@ GEM rspec-core (~> 3.5.0) rspec-expectations (~> 3.5.0) rspec-mocks (~> 3.5.0) - rspec-core (3.5.2) + rspec-core (3.5.4) rspec-support (~> 3.5.0) rspec-expectations (3.5.0) diff-lcs (>= 1.2.0, < 2.0) @@ -267,7 +214,7 @@ GEM powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.4) - ruby-enum (0.5.0) + ruby-enum (0.6.0) i18n ruby-progressbar (1.8.1) rubyzip (1.2.0) @@ -276,28 +223,50 @@ GEM childprocess (~> 0.5) rubyzip (~> 1.0) websocket (~> 1.0) - slack-ruby-bot (0.8.2) - giphy (~> 2.0.2) + slack-ruby-bot (0.9.0) hashie slack-ruby-client (>= 0.6.0) - stripe (1.50.1) - rest-client (>= 1.4, < 3.0) - stripe-ruby-mock (2.3.1) + slack-ruby-bot-server (0.4.0) + celluloid-io + foreman + grape + grape-roar + grape-swagger + kaminari-mongoid + mongoid + mongoid-scroll + rack-cors + rack-rewrite + rack-server-pages + slack-ruby-bot + unicorn + slack-ruby-client (0.7.8) + activesupport + faraday (>= 0.9) + faraday_middleware + gli + hashie + json + websocket-driver + stripe (1.58.0) + rest-client (>= 1.4, < 4.0) + stripe-ruby-mock (2.4.0) dante (>= 0.2.0) multi_json (~> 1.0) stripe (~> 1.31) - thor (0.19.1) + thor (0.19.4) thread_safe (0.3.5) time_ago_in_words (0.1.1) - timers (4.1.1) + timers (4.1.2) hitimes + tool (0.2.3) tzinfo (1.2.2) thread_safe (~> 0.1) uber (0.0.15) unf (0.1.4) unf_ext unf_ext (0.0.7.2) - unicorn (5.1.0) + unicorn (5.2.0) kgio (~> 2.6) raindrops (~> 0.7) uri_template (0.7.0) @@ -308,12 +277,12 @@ GEM descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) wannabe_bool (0.6.0) - webmock (2.1.0) + webmock (2.3.2) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff websocket (1.2.3) - websocket-driver (0.6.4) + websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) xpath (2.0.0) @@ -329,7 +298,10 @@ DEPENDENCIES fabrication faker foreman + giphy hyperclient + kaminari-grape + mongoid (~> 5.1.4) mongoid-scroll mongoid-shell newrelic_rpm @@ -337,12 +309,13 @@ DEPENDENCIES rack-server-pages rack-test rake (~> 10.4) + roar (~> 1.0.4) rspec rubocop (= 0.34.2) ruby-enum selenium-webdriver - slack-ruby-bot-server! - slack-ruby-client! + slack-ruby-bot-server + slack-ruby-client stripe stripe-ruby-mock time_ago_in_words @@ -354,4 +327,4 @@ RUBY VERSION ruby 2.3.1p112 BUNDLED WITH - 1.12.5 + 1.14.0 diff --git a/spec/integration/upgrade_spec.rb b/spec/integration/upgrade_spec.rb index 79092b3b..590f134c 100644 --- a/spec/integration/upgrade_spec.rb +++ b/spec/integration/upgrade_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'Subscribe', js: true, type: :feature do + let!(:game) { Fabricate(:game, name: 'pong') } context 'without team_id' do before do visit '/upgrade' @@ -21,7 +22,7 @@ end end context 'for a premium team' do - let!(:team) { Fabricate(:team, premium: true) } + let!(:team) { Fabricate(:team, game: game, premium: true) } before do visit "/upgrade?team_id=#{team.team_id}&game=#{team.game.name}" end @@ -45,11 +46,11 @@ stripe_iframe = all('iframe[name=stripe_checkout_app]').last Capybara.within_frame stripe_iframe do - page.execute_script("$('input#email').val('foo@bar.com');") - page.execute_script("$('input#card_number').val('4242 4242 4242 4242');") - page.execute_script("$('input#cc-exp').val('12/16');") - page.execute_script("$('input#cc-csc').val('123');") - page.execute_script("$('#submitButton').click();") + page.find_field('Email').set 'foo@bar.com' + page.find_field('Card number').set '4242 4242 4242 4242' + page.find_field('MM / YY').set '12/42' + page.find_field('CVC').set '123' + find('button[type="submit"]').click end sleep 5 @@ -70,21 +71,21 @@ ENV.delete 'STRIPE_API_PUBLISHABLE_KEY' end context 'a team' do - let!(:team) { Fabricate(:team) } + let!(:team) { Fabricate(:team, game: game) } it_behaves_like 'upgrades to premium' end context 'a team with two games' do - let!(:team) { Fabricate(:team) } + let!(:team) { Fabricate(:team, game: game) } let!(:team2) { Fabricate(:team, team_id: team.team_id, game: Fabricate(:game)) } it_behaves_like 'upgrades to premium' end context 'a second team with two games' do - let!(:team2) { Fabricate(:team) } - let!(:team) { Fabricate(:team, team_id: team2.team_id, game: Fabricate(:game)) } + let!(:team2) { Fabricate(:team, game: Fabricate(:game)) } + let!(:team) { Fabricate(:team, game: game, team_id: team2.team_id) } it_behaves_like 'upgrades to premium' end context 'with a coupon' do - let!(:team) { Fabricate(:team) } + let!(:team) { Fabricate(:team, game: game) } it 'applies the coupon' do coupon = double(Stripe::Coupon, id: 'coupon-id', amount_off: 1200) expect(Stripe::Coupon).to receive(:retrieve).with('coupon-id').and_return(coupon) @@ -101,11 +102,11 @@ stripe_iframe = all('iframe[name=stripe_checkout_app]').last Capybara.within_frame stripe_iframe do - page.execute_script("$('input#email').val('foo@bar.com');") - page.execute_script("$('input#card_number').val('4242 4242 4242 4242');") - page.execute_script("$('input#cc-exp').val('12/16');") - page.execute_script("$('input#cc-csc').val('123');") - page.execute_script("$('#submitButton').click();") + page.find_field('Email').set 'foo@bar.com' + page.find_field('Card number').set '4242 4242 4242 4242' + page.find_field('MM / YY').set '12/42' + page.find_field('CVC').set '123' + find('button[type="submit"]').click end sleep 5