Feature: Trial plans

  Background:
    Given the following plan exists:
      | name    | price | trial |
      | Temp    | 0     | true  |
      | Eternal | 0     | false |
    And the following limits exist:
      | plan          | name  | value | value_type |
      | name: Temp    | users | 2     | number     |
      | name: Eternal | users | 2     | number     |

  Scenario: Sign up for a trial plan
    When I go to the list of plans page
    And I follow "Temp"
    Then I should see "Free"
    And I should see "Trial"
    And I should see "Your trial will expire after 30 days"
    But I should not see "users"
    When I fill in "Email" with "email@person.com"
    And I fill in "Password" with "password"
    And I fill in "Confirm password" with "password"
    And I fill in "Your name" with "Robot"
    And I fill in "Company Name" with "Robots, Inc"
    And I fill in "Keyword" with "robotsinc"
    And I press "Sign up"
    Then I should see "created"

  Scenario: use an account during the trial
    Given a "Temp" account exists with a name of "Test" created 29 days ago
    And I am signed in as an admin of the "Test" account
    When I go to the projects page for the "Test" account
    Then I should see "Test"
    And I should not see "expired"

  Scenario: Try to use an expired trial plan
    Given a "Temp" account exists with a name of "Test" created 30 days ago
    And I am signed in as an admin of the "Test" account
    When I go to the projects page for the "Test" account
    Then I should be on the upgrade plan page for the "Test" account
    And I should see "expired"
    And the "Temp" plan should be disabled

  Scenario: Sign up for a non-trial plan
    When I go to the list of plans page
    And I follow "Eternal"
    Then I should see "users"
    But I should not see "Trial"
    And I should not see "expire"

  Scenario: Use a non-trial plan forever
    Given an "Eternal" account exists with a name of "Test" created 30 days ago
    And I am signed in as an admin of the "Test" account
    When I go to the projects page for the "Test" account
    Then I should see "Test"
    And I should not see "expired"