Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_interacts_with_stars_spec.rb « show « projects « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aa61b629d92c439a6c82bf26ba55ba75601fc1ba (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
36
37
38
39
40
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Projects > Show > User interacts with project stars' do
  let(:project) { create(:project, :public, :repository) }

  context 'when user is signed in', :js do
    let(:user) { create(:user) }

    before do
      sign_in(user)
      visit(project_path(project))
    end

    it 'toggles the star' do
      find('.star-btn').click

      expect(page).to have_css('.star-count', text: 1)

      find('.star-btn').click

      expect(page).to have_css('.star-count', text: 0)
    end
  end

  context 'when user is not signed in' do
    before do
      visit(project_path(project))
    end

    it 'does not allow to star a project' do
      expect(page).not_to have_content('.toggle-star')

      find('.star-btn').click

      expect(page).to have_current_path(new_user_session_path, ignore_query: true)
    end
  end
end