summaryrefslogtreecommitdiff
path: root/spec/features/projects/activity/user_sees_private_activity_spec.rb
blob: 61ec2ce9d29dc6e0f0639fcca146f2894ab647c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'spec_helper'

describe 'Project > Activity > User sees private activity', :js do
  let(:project) { create(:project, :public) }
  let(:author) { create(:user) }
  let(:user) { create(:user) }
  let(:issue) { create(:issue, :confidential, project: project, author: author) }
  let(:message) { "#{author.name} #{author.to_reference} opened issue #{issue.to_reference}" }

  before do
    project.add_developer(author)

    create(:event, :created, project: project, target: issue, author: author)
  end

  it 'shows the activity to a logged-in user with permissions' do
    sign_in(author)
    visit activity_project_path(project)

    expect(page).to have_content(message)
  end

  it 'hides the activity from a logged-in user without permissions' do
    sign_in(user)
    visit activity_project_path(project)

    expect(page).not_to have_content(message)
  end

  it 'hides the activity from an anonymous user' do
    visit activity_project_path(project)

    expect(page).not_to have_content(message)
  end
end