Feature: Admin settings

  Scenario: Go to admin settings page
    Given I authenticated as admin
    When I visit admin settings page
    Then I should be redirected to the first admin settings page

  Scenario: Go to Business Units page
    Given I authenticated as admin
    Given the following Business Units
      | name  | is_active |
      | unit1 | Yes       |
      | unit2 | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Business Units"
    Then I should see the following "Business Units" user details items
      | name  | is_active |
      | unit1 | Yes       |
      | unit2 | Yes       |

  Scenario: Add new Business Unit
    Given I authenticated as admin
    Given the following Business Units
      | name  | is_active |
      | unit1 | Yes       |
      | unit2 | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Business Units"
    Then I should see the following "Business Units" user details items
      | name  | is_active |
      | unit1 | Yes       |
      | unit2 | No        |
    When I add new user settings item with "name" "unit3"
    Then I should be redirected and follow
    Then I should see the following "Business Units" user details items
      | name  | is_active |
      | unit1 | Yes       |
      | unit2 | Yes       |
      | unit3 | Yes       |

  Scenario: Search Business Units
    Given I authenticated as admin
    Given the following Business Units
      | name  | is_active |
      | unit1 | Yes       |
      | unit2 | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Business Units"
    Then I should see the following "Business Units" user details items
      | name  | is_active |
      | unit1 | Yes       |
      | unit2 | No        |
    When I search the following "Business Units" item "unit1"
    Then I should see the exact "Business Units" user details items
      | name  | is_active |
      | unit1 | Yes       |

  Scenario: Go to Job Categories page
    Given I authenticated as admin
    And the following Job Categories
      | name      | is_active |
      | Developer | Yes       |
      | Artist    | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Job Categories"
    Then I should see the following "Job Categories" user details items
      | name      | is_active |
      | Developer | Yes       |
      | Artist    | Yes       |

  Scenario: Search Job Categories
    Given I authenticated as admin
    And the following Job Categories
      | name      | is_active |
      | Developer | Yes       |
      | Artist    | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Job Categories"
    Then I should see the following "Job Categories" user details items
      | name      | is_active |
      | Developer | Yes       |
      | Artist    | Yes       |
    When I search the following "Job Categories" item "Artist"
    Then I should see the exact "Job Categories" user details items
      | name   | is_active |
      | Artist | Yes       |

  Scenario: Add new Job Category
    Given I authenticated as admin
    And the following Job Categories
      | name      | is_active |
      | Developer | Yes       |
      | Artist    | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Job Categories"
    Then I should see the following "Job Categories" user details items
      | name      | is_active |
      | Developer | Yes       |
      | Artist    | No        |
    When I add new user settings item with "name" "Designer"
    Then I should be redirected and follow
    Then I should see the following "Job Categories" user details items
      | name      | is_active |
      | Developer | Yes       |
      | Artist    | Yes       |
      | Designer  | Yes       |

  Scenario: Go to Personnel Types page
    Given I authenticated as admin
    And the following Personnel Types
      | name       | is_active |
      | Full-time  | Yes       |
      | Contractor | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Personnel Types"
    Then I should see the following "Personnel Types" user details items
      | name       | is_active |
      | Full-time  | Yes       |
      | Contractor | Yes       |

  Scenario: Search Personnel Types
    Given I authenticated as admin
    And the following Personnel Types
      | name       | is_active |
      | Full-time  | Yes       |
      | Contractor | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Personnel Types"
    Then I should see the following "Personnel Types" user details items
      | name       | is_active |
      | Full-time  | Yes       |
      | Contractor | Yes       |
    When I search the following "Personnel Types" item "Contractor"
    Then I should see the exact "Personnel Types" user details items
      | name       | is_active |
      | Contractor | Yes       |

  Scenario: Add new Personnel Type
    Given I authenticated as admin
    And the following Personnel Types
      | name       | is_active |
      | Full-time  | Yes       |
      | Contractor | Yes       |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "User Details"
    Then I should be redirected and follow
    When I follow the link containing "Personnel Types"
    Then I should see the following "Personnel Types" user details items
      | name       | is_active |
      | Full-time  | Yes       |
      | Contractor | Yes       |
    When I add new user settings item with "name" "Temp"
    Then I should be redirected and follow
    Then I should see the following "Personnel Types" user details items
      | name       | is_active |
      | Full-time  | Yes       |
      | Contractor | Yes       |
      | Temp       | Yes       |

  Scenario: Go to Resource Groups page
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Resource Groups"
    Then I should see the following Resource groups items
      | resource_group |
      | Apollo         |

  Scenario: Search Resource Groups
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
      | Decibel        | Role               | User, Superuser | No    |
      | Decibel        | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Resource Groups"
    Then I should see the following Resource groups items
      | resource_group |
      | Apollo         |
      | Decibel        |
    When I search the following "Resource Groups" item "Decibel"
    Then I should see the exact "Resource Groups" user details items
      | name    | is_active |
      | Decibel | Yes       |

  Scenario: Add new Resource Group
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Resource Groups"
    Then I should see the following Resource groups items
      | resource_group |
      | Apollo         |
    When I add new user settings item with "name" "Decibel"
    Then I should be redirected and follow
    Then I should see the following Resource groups items
      | resource_group |
      | Apollo         |
      | Decibel        |


  Scenario: Go to Claim Names page
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Products"
    Then I should be redirected and follow
    When I follow the link containing "Claim Names"
    Then I should see the following Claim Names items
      | claim_name         |
      | Role               |
      | Market permissions |
    And I should see the following Claim Names in the sidebar
      | claim_name         |
      | Role               |
      | Market permissions |

  Scenario: Search Claim Names
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Products"
    Then I should be redirected and follow
    When I follow the link containing "Claim Names"
    Then I should see the following Claim Names items
      | claim_name         |
      | Role               |
      | Market permissions |
    And I should see the following Claim Names in the sidebar
      | claim_name         |
      | Role               |
      | Market permissions |
    When I search the following "Claim Names" item "Market permissions"
    Then I should see the exact "Apollo - Claim Names" claim names items
      | name               | is_active |
      | Market permissions | Yes       |

  Scenario: Add new Claim Name
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Products"
    Then I should be redirected and follow
    When I follow the link containing "Claim Names"
    Then I should see the following Claim Names items
      | claim_name         |
      | Role               |
      | Market permissions |
    When I add new user settings item with "friendly" "New claim"
    Then I should be redirected and follow
    Then I should see the following Claim Names items
      | claim_name         |
      | Role               |
      | Market permissions |
      | New claim          |

  Scenario: Go to Claim Values page
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Products"
    Then I should be redirected and follow
    When I follow the link containing "Role"
    Then I should see the following Claim Values items for "Role"
      | claim_values |
      | User         |
      | Superuser    |
    When I follow the link containing "Market permissions"
    Then I should see the following Claim Values items for "Market permissions"
      | claim_values |
      | USA          |
      | UAE          |
      | UK           |

  Scenario: Search Claim Values
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Products"
    Then I should be redirected and follow
    When I follow the link containing "Role"
    Then I should see the following Claim Values items for "Role"
      | claim_values |
      | User         |
      | Superuser    |
    When I follow the link containing "Market permissions"
    Then I should see the following Claim Values items for "Market permissions"
      | claim_values |
      | USA          |
      | UAE          |
      | UK           |
    When I search the following "Claim Values" item "UAE"
    Then I should see the exact "Apollo - Market permissions" claim values items
      | name | is_active |
      | UAE  | Yes       |

  Scenario: Add new Claim Value
    Given I authenticated as admin
    And the following Claims
      | resource_group | claim_name         | claim_values    | multi |
      | Apollo         | Role               | User, Superuser | No    |
      | Apollo         | Market permissions | USA, UAE, UK    | Yes   |
    When I visit admin settings page
    Then I should be redirected and follow
    When I follow the link containing "Products"
    Then I should be redirected and follow
    When I follow the link containing "Role"
    Then I should see the following Claim Values items for "Role"
      | claim_values |
      | User         |
      | Superuser    |
    When I add new user settings item with "friendly" "New role"
    Then I should be redirected and follow
    Then I should see the following Claim Values items for "Role"
      | claim_values |
      | User         |
      | Superuser    |
      | New role     |
