diff options
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/issues/filter_by_labels_spec.rb | 51 | ||||
-rw-r--r-- | spec/features/security/project/internal_access_spec.rb | 10 | ||||
-rw-r--r-- | spec/features/security/project/private_access_spec.rb | 6 | ||||
-rw-r--r-- | spec/features/security/project/public_access_spec.rb | 12 | ||||
-rw-r--r-- | spec/features/todos/todos_spec.rb | 79 |
5 files changed, 116 insertions, 42 deletions
diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb index 7944403f874..7f654684143 100644 --- a/spec/features/issues/filter_by_labels_spec.rb +++ b/spec/features/issues/filter_by_labels_spec.rb @@ -1,26 +1,26 @@ require 'rails_helper' feature 'Issue filtering by Labels', feature: true do + include WaitForAjax + let(:project) { create(:project, :public) } let!(:user) { create(:user)} let!(:label) { create(:label, project: project) } before do - ['bug', 'feature', 'enhancement'].each do |title| - create(:label, - project: project, - title: title) - end + bug = create(:label, project: project, title: 'bug') + feature = create(:label, project: project, title: 'feature') + enhancement = create(:label, project: project, title: 'enhancement') issue1 = create(:issue, title: "Bugfix1", project: project) - issue1.labels << project.labels.find_by(title: 'bug') + issue1.labels << bug issue2 = create(:issue, title: "Bugfix2", project: project) - issue2.labels << project.labels.find_by(title: 'bug') - issue2.labels << project.labels.find_by(title: 'enhancement') + issue2.labels << bug + issue2.labels << enhancement issue3 = create(:issue, title: "Feature1", project: project) - issue3.labels << project.labels.find_by(title: 'feature') + issue3.labels << feature project.team << [user, :master] login_as(user) @@ -31,10 +31,10 @@ feature 'Issue filtering by Labels', feature: true do context 'filter by label bug', js: true do before do page.find('.js-label-select').click - sleep 0.5 + wait_for_ajax execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()") page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click - sleep 2 + wait_for_ajax end it 'should show issue "Bugfix1" and "Bugfix2" in issues list' do @@ -59,10 +59,10 @@ feature 'Issue filtering by Labels', feature: true do context 'filter by label feature', js: true do before do page.find('.js-label-select').click - sleep 0.5 + wait_for_ajax execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()") page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click - sleep 2 + wait_for_ajax end it 'should show issue "Feature1" in issues list' do @@ -87,10 +87,10 @@ feature 'Issue filtering by Labels', feature: true do context 'filter by label enhancement', js: true do before do page.find('.js-label-select').click - sleep 0.5 + wait_for_ajax execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()") page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click - sleep 2 + wait_for_ajax end it 'should show issue "Bugfix2" in issues list' do @@ -115,20 +115,16 @@ feature 'Issue filtering by Labels', feature: true do context 'filter by label enhancement or feature', js: true do before do page.find('.js-label-select').click - sleep 0.5 + wait_for_ajax execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()") execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()") page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click - sleep 2 + wait_for_ajax end - it 'should show issue "Bugfix2" or "Feature1" in issues list' do - expect(page).to have_content "Bugfix2" - expect(page).to have_content "Feature1" - end - - it 'should not show "Bugfix1" in issues list' do + it 'should not show "Bugfix1" or "Feature1" in issues list' do expect(page).not_to have_content "Bugfix1" + expect(page).not_to have_content "Feature1" end it 'should show label "enhancement" and "feature" in filtered-labels' do @@ -141,19 +137,18 @@ feature 'Issue filtering by Labels', feature: true do end end - context 'filter by label enhancement or bug in issues list', js: true do + context 'filter by label enhancement and bug in issues list', js: true do before do page.find('.js-label-select').click - sleep 0.5 + wait_for_ajax execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()") execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()") page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click - sleep 2 + wait_for_ajax end - it 'should show issue "Bugfix2" or "Bugfix1" in issues list' do + it 'should show issue "Bugfix2" in issues list' do expect(page).to have_content "Bugfix2" - expect(page).to have_content "Bugfix1" end it 'should not show "Feature1"' do diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index 79d5bf4cf06..8625ea6bc10 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -101,12 +101,12 @@ describe "Internal Project Access", feature: true do it { is_expected.to be_allowed_for :admin } it { is_expected.to be_allowed_for owner } it { is_expected.to be_allowed_for master } - it { is_expected.to be_denied_for developer } - it { is_expected.to be_denied_for reporter } - it { is_expected.to be_denied_for guest } - it { is_expected.to be_denied_for :user } - it { is_expected.to be_denied_for :external } + it { is_expected.to be_allowed_for developer } + it { is_expected.to be_allowed_for reporter } + it { is_expected.to be_allowed_for guest } + it { is_expected.to be_allowed_for :user } it { is_expected.to be_denied_for :visitor } + it { is_expected.to be_denied_for :external } end describe "GET /:project_path/blob" do diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index 0a89193eb67..544270b4037 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -101,9 +101,9 @@ describe "Private Project Access", feature: true do it { is_expected.to be_allowed_for :admin } it { is_expected.to be_allowed_for owner } it { is_expected.to be_allowed_for master } - it { is_expected.to be_denied_for developer } - it { is_expected.to be_denied_for reporter } - it { is_expected.to be_denied_for guest } + it { is_expected.to be_allowed_for developer } + it { is_expected.to be_allowed_for reporter } + it { is_expected.to be_allowed_for guest } it { is_expected.to be_denied_for :user } it { is_expected.to be_denied_for :external } it { is_expected.to be_denied_for :visitor } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 40daac89d40..4def4f99bc0 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -101,12 +101,12 @@ describe "Public Project Access", feature: true do it { is_expected.to be_allowed_for :admin } it { is_expected.to be_allowed_for owner } it { is_expected.to be_allowed_for master } - it { is_expected.to be_denied_for developer } - it { is_expected.to be_denied_for reporter } - it { is_expected.to be_denied_for guest } - it { is_expected.to be_denied_for :user } - it { is_expected.to be_denied_for :external } - it { is_expected.to be_denied_for :visitor } + it { is_expected.to be_allowed_for developer } + it { is_expected.to be_allowed_for reporter } + it { is_expected.to be_allowed_for guest } + it { is_expected.to be_allowed_for :user } + it { is_expected.to be_allowed_for :visitor } + it { is_expected.to be_allowed_for :external } end describe "GET /:project_path/builds" do diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb new file mode 100644 index 00000000000..113d4c40cfc --- /dev/null +++ b/spec/features/todos/todos_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper' + +describe 'Dashboard Todos', feature: true do + let(:user){ create(:user) } + let(:author){ create(:user) } + let(:project){ create(:project) } + let(:issue){ create(:issue) } + let(:todos_per_page){ Todo.default_per_page } + let(:todos_total){ todos_per_page + 1 } + + describe 'GET /dashboard/todos' do + context 'User does not have todos' do + before do + login_as(user) + visit dashboard_todos_path + end + it 'shows "All done" message' do + expect(page).to have_content "You're all done!" + end + end + + context 'User has a todo', js: true do + before do + create(:todo, :mentioned, user: user, project: project, target: issue, author: author) + login_as(user) + visit dashboard_todos_path + end + + it 'todo is present' do + expect(page).to have_selector('.todos-list .todo', count: 1) + end + + describe 'deleting the todo' do + before do + first('.done-todo').click + end + + it 'is removed from the list' do + expect(page).not_to have_selector('.todos-list .todo') + end + + it 'shows "All done" message' do + expect(page).to have_content("You're all done!") + end + end + end + + context 'User has multiple pages of Todos' do + let(:todo_total_pages){ (todos_total.to_f/todos_per_page).ceil } + + before do + todos_total.times do + create(:todo, :mentioned, user: user, project: project, target: issue, author: author) + end + + login_as(user) + visit dashboard_todos_path + end + + it 'is paginated' do + expect(page).to have_selector('.gl-pagination') + end + + it 'is has the right number of pages' do + expect(page).to have_selector('.gl-pagination .page', count: todo_total_pages) + end + + describe 'deleting last todo from last page', js: true do + it 'redirects to the previous page' do + page.within('.gl-pagination') do + click_link todo_total_pages.to_s + end + first('.done-todo').click + expect(page).to have_content(Todo.last.body) + end + end + end + end +end |