Skip to content

Instantly share code, notes, and snippets.

@astery
Last active July 1, 2016 18:17
Show Gist options
  • Select an option

  • Save astery/7961e88a108e7513a430094b25e0c628 to your computer and use it in GitHub Desktop.

Select an option

Save astery/7961e88a108e7513a430094b25e0c628 to your computer and use it in GitHub Desktop.

Revisions

  1. astery revised this gist Jul 1, 2016. 2 changed files with 5 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions passenger_fixtures.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    pasha:
    mobile_number: 404040
    3 changes: 3 additions & 0 deletions team_fixtures.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    bus:
    id: 1
    name: bus
  2. astery created this gist Jul 1, 2016.
    1 change: 1 addition & 0 deletions call.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    rake test:integration
    35 changes: 35 additions & 0 deletions pbx_test.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    class PbxTest < ActionDispatch::IntegrationTest
    include JsonHelper

    def setup
    @pasha = passengers(:pasha)
    @bus = teams(:bus)
    end

    test "generate ticket code for pasha and use it" do
    post '/pbx/ticket_codes/generate', pasha_call_params
    assert json_response['code']
    assert json_response['registred'] == true

    get "/tickets", pasha_call_params
    assert_equal 1, json_response.count
    assert json_response[0]['usable']

    post "/tickets/use_available_or_buy_and_use", conductor_check_pasha_params
    assert json_response['ok']

    get "/tickets", pasha_call_params
    assert_equal 1, json_response.count

    get "/tickets/has_right_to_ride_in_team", conductor_check_pasha_params
    assert_equal 1, json_response.count
    end

    def pasha_call_params
    {
    mobile_number: @pasha.mobile_number,
    source: '101010'
    }
    end

    end