group.rb 2.88 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's avatar
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
13 14
    @group   = create(:group)
    @group.add_owner(current_user)
15
    @project = create(:project, namespace: @group)
16
    @event   = create(:closed_issue_event, project: @project)
17

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

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

randx's avatar
randx committed
25 26 27 28 29 30 31 32
  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's avatar
Cyril committed
33
      page.should have_content issue.title[0..80]
randx's avatar
randx committed
34 35 36
    end
  end

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

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

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

randx's avatar
randx committed
55 56 57 58 59 60 61 62 63
  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,
64 65
      source_project: project,
      target_project: project,
randx's avatar
randx committed
66 67 68 69
      assignee: current_user,
      author: current_user
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
70
  When 'I click new group link' do
71
    click_link "New group"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
72 73 74
  end

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

  Then 'I should see newly created group' do
    page.should have_content "Samurai"
82
    page.should have_content "Tokugawa Shogunate"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
83 84 85 86 87 88 89
    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

90
  And 'I change group name' do
91
    fill_in 'group_name', with: 'new-name'
92 93 94 95 96 97 98 99 100
    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

101 102 103 104 105
  protected

  def current_group
    @group ||= Group.first
  end
randx's avatar
randx committed
106 107

  def project
108
    current_group.projects.first
randx's avatar
randx committed
109 110 111 112 113
  end

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