diff --git a/app/assets/javascripts/components/player.js.jsx b/app/assets/javascripts/components/player.js.jsx index 06f314d6..fd090611 100644 --- a/app/assets/javascripts/components/player.js.jsx +++ b/app/assets/javascripts/components/player.js.jsx @@ -7,7 +7,7 @@ var Player = React.createClass({ render: function() { return (
-
{this.props.email}
+
{this.props.email || "Guest" + this.props.soft_token.substr(0,6)}
{this.props.game.is_started ?
Inventory count: {this.props.inventory_count}
diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index 0c13d036..678a3d3e 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -17,6 +17,7 @@ json.players @game.players do |player| json.email player.user.try(:email) json.inventory_count player.inventory.count json.user_id player.user.try(:id) + json.soft_token player.soft_token if player.user == current_user json.inventory player.inventory diff --git a/spec/features/visitors/game_join_spec.rb b/spec/features/visitors/game_join_spec.rb new file mode 100644 index 00000000..2eba27a5 --- /dev/null +++ b/spec/features/visitors/game_join_spec.rb @@ -0,0 +1,23 @@ +# Feature: Join Game +# As a visitor +# I want to join a game +# So I can play +feature 'Join game', :devise do + # Scenario: Visitor can join a game + # Given I am not signed in + # When I visit a joinable game + # Then I see a join button + scenario 'visitor can join a game', js: true do + visit new_game_path + fill_in 'game_title', with: 'Test Game' + click_button 'Create Game' + expect(page).to have_button("Join") + click_button 'Join' + #TODO: Fix this asynchronous race condition + visit current_path + @game = Game.find(current_path.split('/').last) + @player = @game.players.last + @playerComponent = page.find("#player-1") + expect(@playerComponent.text).to have_content("Guest#{@player.soft_token[0..5]}") + end +end