Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 72 additions & 70 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
actionmailer (4.2.7)
actionpack (= 4.2.7)
actionview (= 4.2.7)
activejob (= 4.2.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.6)
actionview (= 4.2.6)
activesupport (= 4.2.6)
actionpack (4.2.7)
actionview (= 4.2.7)
activesupport (= 4.2.7)
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.6)
activesupport (= 4.2.6)
actionview (4.2.7)
activesupport (= 4.2.7)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.6)
activesupport (= 4.2.6)
activejob (4.2.7)
activesupport (= 4.2.7)
globalid (>= 0.3.0)
activemodel (4.2.6)
activesupport (= 4.2.6)
activemodel (4.2.7)
activesupport (= 4.2.7)
builder (~> 3.1)
activerecord (4.2.6)
activemodel (= 4.2.6)
activesupport (= 4.2.6)
activerecord (4.2.7)
activemodel (= 4.2.7)
activesupport (= 4.2.7)
arel (~> 6.0)
activesupport (4.2.6)
activesupport (4.2.7)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
autoprefixer-rails (6.3.6)
autoprefixer-rails (6.3.7)
execjs
awesome_print (1.6.1)
awesome_print (1.7.0)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bourbon (4.2.6)
bourbon (4.2.7)
sass (~> 3.4)
thor (~> 0.19)
builder (3.2.2)
bullet (5.0.0)
bullet (5.1.1)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.9.0)
uniform_notifier (~> 1.10.0)
bundler-audit (0.5.0)
bundler (~> 1.2)
thor (~> 0.18)
byebug (8.2.4)
capybara (2.7.0)
byebug (9.0.5)
capybara (2.7.1)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.10.1)
capybara-webkit (1.11.1)
capybara (>= 2.3.0, < 2.8.0)
json
coderay (1.1.1)
Expand All @@ -76,15 +76,15 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.1)
concurrent-ruby (1.0.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
database_cleaner (1.5.1)
database_cleaner (1.5.3)
debug_inspector (0.0.2)
delayed_job (4.1.1)
activesupport (>= 3.0, < 5.0)
delayed_job_active_record (4.1.0)
activerecord (>= 3.0, < 5)
delayed_job (4.1.2)
activesupport (>= 3.0, < 5.1)
delayed_job_active_record (4.1.1)
activerecord (>= 3.0, < 5.1)
delayed_job (>= 3.0, < 5)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
Expand All @@ -96,7 +96,7 @@ GEM
railties (>= 4.0, < 5.1)
equalizer (0.0.11)
erubis (2.7.0)
execjs (2.6.0)
execjs (2.7.0)
factory_girl (4.7.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.7.0)
Expand All @@ -112,7 +112,7 @@ GEM
globalid (0.3.6)
activesupport (>= 4.1.0)
hashdiff (0.3.0)
high_voltage (2.4.0)
high_voltage (3.0.0)
i18n (0.7.0)
ice_nine (0.11.2)
jquery-rails (4.1.1)
Expand All @@ -128,49 +128,51 @@ GEM
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0221)
mini_portile2 (2.0.0)
minitest (5.8.4)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
multipart-post (2.0.0)
neat (1.7.4)
bourbon (>= 4.0)
sass (>= 3.3)
newrelic_rpm (3.15.1.316)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
newrelic_rpm (3.16.0.318)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
normalize-rails (3.0.3)
pg (0.18.4)
pry (0.10.3)
pkg-config (1.1.7)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (3.3.0)
byebug (~> 8.0)
pry-byebug (3.4.0)
byebug (~> 9.0)
pry (~> 0.10)
pry-rails (0.3.4)
pry (>= 0.9.10)
puma (3.4.0)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.4)
rack-canonical-host (0.2.1)
rack-canonical-host (0.2.2)
addressable (> 0, < 3)
rack (>= 1.0.0, < 3)
rack-test (0.6.3)
rack (>= 1.0)
rack-timeout (0.4.2)
rails (4.2.6)
actionmailer (= 4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
activemodel (= 4.2.6)
activerecord (= 4.2.6)
activesupport (= 4.2.6)
rails (4.2.7)
actionmailer (= 4.2.7)
actionpack (= 4.2.7)
actionview (= 4.2.7)
activejob (= 4.2.7)
activemodel (= 4.2.7)
activerecord (= 4.2.7)
activesupport (= 4.2.7)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.6)
railties (= 4.2.7)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
Expand All @@ -180,12 +182,12 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.6)
actionpack (= 4.2.6)
activesupport (= 4.2.6)
railties (4.2.7)
actionpack (= 4.2.7)
activesupport (= 4.2.7)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.1.2)
rake (11.2.2)
recipient_interceptor (0.1.2)
mail
refills (0.1.0)
Expand All @@ -208,8 +210,8 @@ GEM
rspec-support (3.4.1)
safe_yaml (1.0.4)
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass-rails (5.0.5)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
Expand All @@ -219,47 +221,47 @@ GEM
simple_form (3.2.1)
actionpack (> 4, < 5.1)
activemodel (> 4, < 5.1)
simplecov (0.11.2)
simplecov (0.12.0)
docile (~> 1.1.0)
json (~> 1.8)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
spring (1.7.1)
spring (1.7.2)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (3.6.0)
sprockets (3.6.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
sprockets-rails (3.1.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
telegram-bot-ruby (0.5.0)
telegram-bot-ruby (0.5.2)
faraday
virtus
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.2)
tilt (2.0.5)
timecop (0.8.1)
title (0.0.5)
title (0.0.7)
i18n
rails (>= 3.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
uniform_notifier (1.9.0)
uniform_notifier (1.10.0)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
web-console (3.1.1)
web-console (3.3.0)
activemodel (>= 4.2)
debug_inspector
railties (>= 4.2)
webmock (1.24.3)
webmock (2.1.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
Expand Down
16 changes: 16 additions & 0 deletions app/operations/attendance/attendance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require_relative "../../models/attendance"

class Attendance
class Create < Operation::Base
# def self.run(game, player)
# pp 'we here'
# new(game, player).run
# end

def run(&block)
pp "attendance run"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah yeah, wip 👯


Attendance.create(game: @game, player: @player)
end
end
end
15 changes: 15 additions & 0 deletions app/operations/operation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Operation
class Base
def self.run(game, player, &block)
new(game, player).run(&block)
end

def initialize(game, player)
@game = game
@player = player
end
end

require "attendance/attendance"
require "player/player"
end
13 changes: 13 additions & 0 deletions app/operations/player/player.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require_relative "../../models/player"

class Player
class Create < Operation::Base
def self.run(telegram_user)
new(telegram_user).run
end

def run(telegram_user)
Player.find_or_create_by(telegram_user_id: telegram_user.id)
end
end
end
10 changes: 8 additions & 2 deletions lib/pickup_bot/commands/join.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Commands
include Operation
class Join
def self.run(telegram_bot, message)
new(telegram_bot, message).run
Expand All @@ -12,8 +13,13 @@ def initialize(telegram_bot, message)
def run
if game_exists?
current_player = Player.find_or_create_by(telegram_user_id: message.from.id)
attendence = Attendance.new(game: current_game, player: current_player)
attendence.save
current_player.first_name = message.from.first_name
current_player.last_name = message.from.last_name
current_player.username = message.from.username
current_player.save

Attendance::Create.run(current_game, current_player)

telegram_bot.api.send_message(
chat_id: message.chat.id,
text: I18n.t(
Expand Down
1 change: 1 addition & 0 deletions spec/lib/pickup_bot/commands/join_game_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
)).to have_been_made.times(1)
expect(Player.count).to eq 1
expect(Game.last.attendances.count).to eq 1
expect(Player.last.first_name).to eq message.from.first_name
end

scenario "existing player joins game" do
Expand Down