Commit a87c268f7d3b083534a76065040aa78744c46862
1 parent
46b9aafc
Exists in
master
and in
4 other branches
remove duplicate code from atom request specs
Showing
3 changed files
with
50 additions
and
81 deletions
Show diff stats
spec/requests/atom/dashboard_issues_spec.rb
1 | require 'spec_helper' | 1 | require 'spec_helper' |
2 | 2 | ||
3 | -describe "User Issues Dashboard" do | 3 | +describe "Dashboard Issues Feed" do |
4 | describe "GET /issues" do | 4 | describe "GET /issues" do |
5 | - before do | 5 | + let!(:user) { Factory :user } |
6 | + let!(:project1) { Factory :project } | ||
7 | + let!(:project2) { Factory :project } | ||
8 | + let!(:issue1) { Factory :issue, author: user, assignee: user, project: project1 } | ||
9 | + let!(:issue2) { Factory :issue, author: user, assignee: user, project: project2 } | ||
6 | 10 | ||
7 | - login_as :user | ||
8 | - | ||
9 | - @project1 = Factory :project | ||
10 | - | ||
11 | - @project2 = Factory :project | ||
12 | - | ||
13 | - @project1.add_access(@user, :read, :write) | ||
14 | - @project2.add_access(@user, :read, :write) | ||
15 | - | ||
16 | - @issue1 = Factory :issue, | ||
17 | - author: @user, | ||
18 | - assignee: @user, | ||
19 | - project: @project1 | ||
20 | - | ||
21 | - @issue2 = Factory :issue, | ||
22 | - author: @user, | ||
23 | - assignee: @user, | ||
24 | - project: @project2 | ||
25 | - | ||
26 | - visit dashboard_issues_path | ||
27 | - end | ||
28 | - | ||
29 | - describe "atom feed", js: false do | 11 | + describe "atom feed" do |
30 | it "should render atom feed via private token" do | 12 | it "should render atom feed via private token" do |
31 | - logout | ||
32 | - visit dashboard_issues_path(:atom, private_token: @user.private_token) | 13 | + visit dashboard_issues_path(:atom, private_token: user.private_token) |
33 | 14 | ||
34 | page.response_headers['Content-Type'].should have_content("application/atom+xml") | 15 | page.response_headers['Content-Type'].should have_content("application/atom+xml") |
35 | - page.body.should have_selector("title", text: "#{@user.name} issues") | ||
36 | - page.body.should have_selector("author email", text: @issue1.author_email) | ||
37 | - page.body.should have_selector("entry summary", text: @issue1.title) | ||
38 | - page.body.should have_selector("author email", text: @issue2.author_email) | ||
39 | - page.body.should have_selector("entry summary", text: @issue2.title) | 16 | + page.body.should have_selector("title", text: "#{user.name} issues") |
17 | + page.body.should have_selector("author email", text: issue1.author_email) | ||
18 | + page.body.should have_selector("entry summary", text: issue1.title) | ||
19 | + page.body.should have_selector("author email", text: issue2.author_email) | ||
20 | + page.body.should have_selector("entry summary", text: issue2.title) | ||
40 | end | 21 | end |
41 | end | 22 | end |
42 | end | 23 | end |
spec/requests/atom/dashboard_spec.rb
1 | require 'spec_helper' | 1 | require 'spec_helper' |
2 | 2 | ||
3 | -describe "User Dashboard" do | ||
4 | - before { login_as :user } | ||
5 | - | 3 | +describe "Dashboard Feed" do |
6 | describe "GET /" do | 4 | describe "GET /" do |
7 | - before do | ||
8 | - @project = Factory :project, owner: @user | ||
9 | - @project.add_access(@user, :read) | ||
10 | - visit dashboard_path | ||
11 | - end | 5 | + let!(:user) { Factory :user } |
12 | 6 | ||
13 | - it "should render projects atom feed via private token" do | ||
14 | - logout | ||
15 | - | ||
16 | - visit dashboard_path(:atom, private_token: @user.private_token) | ||
17 | - page.body.should have_selector("feed title") | 7 | + context "projects atom feed via private token" do |
8 | + it "should render projects atom feed" do | ||
9 | + visit dashboard_path(:atom, private_token: user.private_token) | ||
10 | + page.body.should have_selector("feed title") | ||
11 | + end | ||
18 | end | 12 | end |
19 | 13 | ||
20 | - it "should not render projects page via private token" do | ||
21 | - logout | ||
22 | - | ||
23 | - visit dashboard_path(private_token: @user.private_token) | ||
24 | - current_path.should == new_user_session_path | 14 | + context "projects page via private token" do |
15 | + it "should redirect to login page" do | ||
16 | + visit dashboard_path(private_token: user.private_token) | ||
17 | + current_path.should == new_user_session_path | ||
18 | + end | ||
25 | end | 19 | end |
26 | end | 20 | end |
27 | end | 21 | end |
spec/requests/atom/issues_spec.rb
1 | require 'spec_helper' | 1 | require 'spec_helper' |
2 | 2 | ||
3 | -describe "Issues" do | ||
4 | - let(:project) { Factory :project } | ||
5 | - | ||
6 | - before do | ||
7 | - login_as :user | ||
8 | - project.add_access(@user, :read, :write) | ||
9 | - end | ||
10 | - | 3 | +describe "Issues Feed" do |
11 | describe "GET /issues" do | 4 | describe "GET /issues" do |
12 | - before do | ||
13 | - @issue = Factory :issue, | ||
14 | - author: @user, | ||
15 | - assignee: @user, | ||
16 | - project: project | ||
17 | - | ||
18 | - visit project_issues_path(project) | ||
19 | - end | ||
20 | - | ||
21 | - it "should render atom feed" do | ||
22 | - visit project_issues_path(project, :atom) | ||
23 | - | ||
24 | - page.response_headers['Content-Type'].should have_content("application/atom+xml") | ||
25 | - page.body.should have_selector("title", text: "#{project.name} issues") | ||
26 | - page.body.should have_selector("author email", text: @issue.author_email) | ||
27 | - page.body.should have_selector("entry summary", text: @issue.title) | 5 | + let!(:user) { Factory :user } |
6 | + let!(:project) { Factory :project, owner: user } | ||
7 | + let!(:issue) { Factory :issue, author: user, project: project } | ||
8 | + | ||
9 | + before { project.add_access(user, :read, :write) } | ||
10 | + | ||
11 | + context "when authenticated" do | ||
12 | + it "should render atom feed" do | ||
13 | + login_with user | ||
14 | + visit project_issues_path(project, :atom) | ||
15 | + | ||
16 | + page.response_headers['Content-Type'].should have_content("application/atom+xml") | ||
17 | + page.body.should have_selector("title", text: "#{project.name} issues") | ||
18 | + page.body.should have_selector("author email", text: issue.author_email) | ||
19 | + page.body.should have_selector("entry summary", text: issue.title) | ||
20 | + end | ||
28 | end | 21 | end |
29 | 22 | ||
30 | - it "should render atom feed via private token" do | ||
31 | - logout | ||
32 | - visit project_issues_path(project, :atom, private_token: @user.private_token) | 23 | + context "when authenticated via private token" do |
24 | + it "should render atom feed" do | ||
25 | + visit project_issues_path(project, :atom, private_token: user.private_token) | ||
33 | 26 | ||
34 | - page.response_headers['Content-Type'].should have_content("application/atom+xml") | ||
35 | - page.body.should have_selector("title", text: "#{project.name} issues") | ||
36 | - page.body.should have_selector("author email", text: @issue.author_email) | ||
37 | - page.body.should have_selector("entry summary", text: @issue.title) | 27 | + page.response_headers['Content-Type'].should have_content("application/atom+xml") |
28 | + page.body.should have_selector("title", text: "#{project.name} issues") | ||
29 | + page.body.should have_selector("author email", text: issue.author_email) | ||
30 | + page.body.should have_selector("entry summary", text: issue.title) | ||
31 | + end | ||
38 | end | 32 | end |
39 | end | 33 | end |
40 | end | 34 | end |