Skip to content

Commit

Permalink
Fix #34: season incorrectly reports no seasons after reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Oct 6, 2015
1 parent d6cb040 commit e1bf444
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Changelog

* [#34](https://github.com/dblock/slack-gamebot/issues/34): Fix: `season` incorrectly reports no seasons after reset - [@dblock](https://github.com/dblock).
* Fix: correctly handle `user_change` event - [@dblock](https://github.com/dblock).
* [#29](https://github.com/dblock/slack-gamebot/issues/29): Fix: `season` incorrectly reports number of players - [@dblock](https://github.com/dblock).
* [#24](https://github.com/dblock/slack-gamebot/issues/24): Record game scores - [@dblock](https://github.com/dblock).
Expand Down
6 changes: 4 additions & 2 deletions slack-gamebot/commands/season.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module SlackGamebot
module Commands
class Season < SlackRubyBot::Commands::Base
def self.call(client, data, _match)
current_season = ::Season.new
if current_season.valid?
if ::Season.count > 0 && !::Challenge.current.any?
send_message_with_gif client, data.channel, 'No matches have been recorded.', 'history'
elsif ::Challenge.current.any?
current_season = ::Season.new
send_message client, data.channel, current_season.to_s
else
send_message_with_gif client, data.channel, "There're no seasons.", %w(winter summer fall spring).sample
Expand Down
10 changes: 9 additions & 1 deletion spec/slack-gamebot/commands/season_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@
before do
2.times.map { Fabricate(:match) }
end
it 'returns past seasons and current season' do
it 'returns current season' do
current_season = Season.new
expect(message: "#{SlackRubyBot.config.user} season").to respond_with_slack_message current_season.to_s
end
context 'after reset' do
before do
::Season.create!(created_by: User.first)
end
it 'returns current season' do
expect(message: "#{SlackRubyBot.config.user} season").to respond_with_slack_message 'No matches have been recorded.'
end
end
end
end

0 comments on commit e1bf444

Please sign in to comment.