From 5aeaf248f1730ba1698d9e98ec43920b172b9e0c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 21 Feb 2013 13:09:47 +0200 Subject: [PATCH] Fixing rspec after upgrade to capybara pt1 --- app/views/snippets/show.html.haml | 2 +- .../features/gitlab_flavored_markdown_spec.rb | 24 +++++++---- spec/features/snippets_spec.rb | 2 +- spec/features/users_spec.rb | 19 ++++++++ spec/requests/api/users_spec.rb | 43 ++++++++----------- 5 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 spec/features/users_spec.rb diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index e6bcd88f..64b7d933 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -4,7 +4,7 @@ = @snippet.title %small= @snippet.file_name - if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user - = link_to "Edit", edit_project_snippet_path(@project, @snippet), class: "btn btn-small pull-right" + = link_to "Edit", edit_project_snippet_path(@project, @snippet), class: "btn btn-small pull-right", title: 'Edit Snippet' %br %div= render 'blob' diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb index 9a568511..769fcd68 100644 --- a/spec/features/gitlab_flavored_markdown_spec.rb +++ b/spec/features/gitlab_flavored_markdown_spec.rb @@ -169,32 +169,40 @@ describe "Gitlab Flavored Markdown" do describe "for notes" do it "should render in commits#show", js: true do visit project_commit_path(project, commit) - fill_in "note_note", with: "see ##{issue.id}" - click_button "Add Comment" + within ".new_note.js-main-target-form" do + fill_in "note_note", with: "see ##{issue.id}" + click_button "Add Comment" + end page.should have_link("##{issue.id}") end it "should render in issue#show", js: true do visit project_issue_path(project, issue) - fill_in "note_note", with: "see ##{issue.id}" - click_button "Add Comment" + within ".new_note.js-main-target-form" do + fill_in "note_note", with: "see ##{issue.id}" + click_button "Add Comment" + end page.should have_link("##{issue.id}") end it "should render in merge_request#show", js: true do visit project_merge_request_path(project, merge_request) - fill_in "note_note", with: "see ##{issue.id}" - click_button "Add Comment" + within ".new_note.js-main-target-form" do + fill_in "note_note", with: "see ##{issue.id}" + click_button "Add Comment" + end page.should have_link("##{issue.id}") end it "should render in projects#wall", js: true do visit wall_project_path(project) - fill_in "note_note", with: "see ##{issue.id}" - click_button "Add Comment" + within ".new_note.js-main-target-form" do + fill_in "note_note", with: "see ##{issue.id}" + click_button "Add Comment" + end page.should have_link("##{issue.id}") end diff --git a/spec/features/snippets_spec.rb b/spec/features/snippets_spec.rb index 770e34dc..1a0f6eae 100644 --- a/spec/features/snippets_spec.rb +++ b/spec/features/snippets_spec.rb @@ -72,7 +72,7 @@ describe "Snippets" do author: @user, project: project) visit project_snippet_path(project, @snippet) - click_link "Edit" + click_link "Edit Snippet" end it "should open edit page" do diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb new file mode 100644 index 00000000..ed9e44fb --- /dev/null +++ b/spec/features/users_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'Users' do + describe "GET /users/sign_up" do + before do + Gitlab.config.gitlab.stub(:signup_enabled).and_return(true) + end + + it "should create a new user account" do + visit new_user_registration_path + fill_in "user_name", with: "Name Surname" + fill_in "user_username", with: "Great" + fill_in "user_email", with: "name@mail.com" + fill_in "user_password", with: "password1234" + fill_in "user_password_confirmation", with: "password1234" + expect { click_button "Sign up" }.to change {User.count}.by(1) + end + end +end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 1645117e..33254eed 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -54,32 +54,27 @@ describe Gitlab::API do end describe "GET /users/sign_up" do - before do - Gitlab.config.gitlab.stub(:signup_enabled).and_return(false) - end - it "should redirect to sign in page if signup is disabled" do - get "/users/sign_up" - response.status.should == 302 - response.should redirect_to(new_user_session_path) - end - end + context 'enabled' do + before do + Gitlab.config.gitlab.stub(:signup_enabled).and_return(true) + end - describe "GET /users/sign_up" do - before do - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true) + it "should return sign up page if signup is enabled" do + get "/users/sign_up" + response.status.should == 200 + end end - it "should return sign up page if signup is enabled" do - get "/users/sign_up" - response.status.should == 200 - end - it "should create a new user account" do - visit new_user_registration_path - fill_in "user_name", with: "Name Surname" - fill_in "user_username", with: "Great" - fill_in "user_email", with: "name@mail.com" - fill_in "user_password", with: "password1234" - fill_in "user_password_confirmation", with: "password1234" - expect { click_button "Sign up" }.to change {User.count}.by(1) + + context 'disabled' do + before do + Gitlab.config.gitlab.stub(:signup_enabled).and_return(false) + end + + it "should redirect to sign in page if signup is disabled" do + get "/users/sign_up" + response.status.should == 302 + response.should redirect_to(new_user_session_path) + end end end