BigW Consortium Gitlab

group.rb 2.86 KB
Newer Older
1 2 3
class Groups < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedPaths
4
  include Select2Helper
5 6

  Then 'I should see projects list' do
Dmitriy Zaporozhets committed
7
    current_user.authorized_projects.each do |project|
8 9 10 11 12
      page.should have_link project.name
    end
  end

  And 'I have group with projects' do
Andrey Kumanyaev committed
13
    @group   = create(:group, owner: current_user)
14
    @project = create(:project, namespace: @group)
15
    @event   = create(:closed_issue_event, project: @project)
16

17
    @project.team << [current_user, :master]
18 19 20 21 22 23
  end

  And 'I should see projects activity feed' do
    page.should have_content 'closed issue'
  end

randx committed
24 25 26 27 28 29 30 31
  Then 'I should see issues from this group assigned to me' do
    assigned_to_me(:issues).each do |issue|
      page.should have_content issue.title
    end
  end

  Then 'I should see merge requests from this group assigned to me' do
    assigned_to_me(:merge_requests).each do |issue|
Cyril committed
32
      page.should have_content issue.title[0..80]
randx committed
33 34 35
    end
  end

36 37 38 39
  Given 'I have new user "John"' do
    create(:user, name: "John")
  end

Andrey Kumanyaev committed
40
  And 'I select user "John" from list with role "Reporter"' do
41
    user = User.find_by_name("John")
Dmitriy Zaporozhets committed
42
    within ".new_users_group" do
43
      select2(user.id, from: "#user_ids", multiple: true)
Dmitriy Zaporozhets committed
44
      select "Reporter", from: "group_access"
45
    end
Dmitriy Zaporozhets committed
46
    click_button "Add users into group"
47 48 49
  end

  Then 'I should see user "John" in team list' do
Andrey Kumanyaev committed
50
    projects_with_access = find(".ui-box .well-list")
51 52 53
    projects_with_access.should have_content("John")
  end

randx committed
54 55 56 57 58 59 60 61 62
  Given 'project from group has issues assigned to me' do
    create :issue,
      project: project,
      assignee: current_user,
      author: current_user
  end

  Given 'project from group has merge requests assigned to me' do
    create :merge_request,
63 64
      source_project: project,
      target_project: project,
randx committed
65 66 67 68
      assignee: current_user,
      author: current_user
  end

69
  When 'I click new group link' do
70
    click_link "New group"
71 72 73
  end

  And 'submit form with new group info' do
Andrew8xx8 committed
74 75
    fill_in 'group_name', with: 'Samurai'
    fill_in 'group_description', with: 'Tokugawa Shogunate'
76 77 78 79 80
    click_button "Create group"
  end

  Then 'I should see newly created group' do
    page.should have_content "Samurai"
81
    page.should have_content "Tokugawa Shogunate"
82 83 84 85 86 87 88
    page.should have_content "You will only see events from projects in this group"
  end

  Then 'I should be redirected to group page' do
    current_path.should == group_path(Group.last)
  end

89
  And 'I change group name' do
90
    fill_in 'group_name', with: 'new-name'
91 92 93 94 95 96 97 98 99
    click_button "Save group"
  end

  Then 'I should see new group name' do
    within ".navbar-gitlab" do
      page.should have_content "group: new-name"
    end
  end

100 101 102 103 104
  protected

  def current_group
    @group ||= Group.first
  end
randx committed
105 106

  def project
107
    current_group.projects.first
randx committed
108 109 110 111 112
  end

  def assigned_to_me key
    project.send(key).where(assignee_id: current_user.id)
  end
113
end