Commit 03f6a28ec0dab308070e83ec422f12fa289aad9f

Authored by Dmitriy Zaporozhets
1 parent 9f722427

move capybara scenarios to spec/features

spec/features/admin/admin_hooks_spec.rb 0 → 100644
@@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Admin::Hooks" do
  4 + before do
  5 + @project = create(:project)
  6 + login_as :admin
  7 +
  8 + @system_hook = create(:system_hook)
  9 +
  10 + end
  11 +
  12 + describe "GET /admin/hooks" do
  13 + it "should be ok" do
  14 + visit admin_root_path
  15 + within ".main_menu" do
  16 + click_on "Hooks"
  17 + end
  18 + current_path.should == admin_hooks_path
  19 + end
  20 +
  21 + it "should have hooks list" do
  22 + visit admin_hooks_path
  23 + page.should have_content(@system_hook.url)
  24 + end
  25 + end
  26 +
  27 + describe "New Hook" do
  28 + before do
  29 + @url = Faker::Internet.uri("http")
  30 + visit admin_hooks_path
  31 + fill_in "hook_url", with: @url
  32 + expect { click_button "Add System Hook" }.to change(SystemHook, :count).by(1)
  33 + end
  34 +
  35 + it "should open new hook popup" do
  36 + page.current_path.should == admin_hooks_path
  37 + page.should have_content(@url)
  38 + end
  39 + end
  40 +
  41 + describe "Test" do
  42 + before do
  43 + WebMock.stub_request(:post, @system_hook.url)
  44 + visit admin_hooks_path
  45 + click_link "Test Hook"
  46 + end
  47 +
  48 + it { page.current_path.should == admin_hooks_path }
  49 + end
  50 +
  51 +end
spec/features/admin/admin_projects_spec.rb 0 → 100644
@@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Admin::Projects" do
  4 + before do
  5 + @project = create(:project)
  6 + login_as :admin
  7 + end
  8 +
  9 + describe "GET /admin/projects" do
  10 + before do
  11 + visit admin_projects_path
  12 + end
  13 +
  14 + it "should be ok" do
  15 + current_path.should == admin_projects_path
  16 + end
  17 +
  18 + it "should have projects list" do
  19 + page.should have_content(@project.name)
  20 + end
  21 + end
  22 +
  23 + describe "GET /admin/projects/:id" do
  24 + before do
  25 + visit admin_projects_path
  26 + click_link "#{@project.name}"
  27 + end
  28 +
  29 + it "should have project info" do
  30 + page.should have_content(@project.path)
  31 + page.should have_content(@project.name)
  32 + end
  33 + end
  34 +
  35 + describe "GET /admin/projects/:id/edit" do
  36 + before do
  37 + visit admin_projects_path
  38 + click_link "edit_project_#{@project.id}"
  39 + end
  40 +
  41 + it "should have project edit page" do
  42 + page.should have_content("Edit project")
  43 + page.should have_button("Save Project")
  44 + end
  45 +
  46 + describe "Update project" do
  47 + before do
  48 + fill_in "project_name", with: "Big Bang"
  49 + click_button "Save Project"
  50 + @project.reload
  51 + end
  52 +
  53 + it "should show page with new data" do
  54 + page.should have_content("Big Bang")
  55 + end
  56 +
  57 + it "should change project entry" do
  58 + @project.name.should == "Big Bang"
  59 + end
  60 + end
  61 + end
  62 +
  63 + describe "Add new team member" do
  64 + before do
  65 + @new_user = create(:user)
  66 + visit admin_project_path(@project)
  67 + end
  68 +
  69 + it "should create new user" do
  70 + select @new_user.name, from: "user_ids"
  71 + expect { click_button "Add" }.to change { UsersProject.count }.by(1)
  72 + page.should have_content @new_user.name
  73 + current_path.should == admin_project_path(@project)
  74 + end
  75 + end
  76 +end
spec/features/admin/admin_users_spec.rb 0 → 100644
@@ -0,0 +1,135 @@ @@ -0,0 +1,135 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Admin::Users" do
  4 + before { login_as :admin }
  5 +
  6 + describe "GET /admin/users" do
  7 + before do
  8 + visit admin_users_path
  9 + end
  10 +
  11 + it "should be ok" do
  12 + current_path.should == admin_users_path
  13 + end
  14 +
  15 + it "should have users list" do
  16 + page.should have_content(@user.email)
  17 + page.should have_content(@user.name)
  18 + end
  19 + end
  20 +
  21 + describe "GET /admin/users/new" do
  22 + before do
  23 + @password = "123ABC"
  24 + visit new_admin_user_path
  25 + fill_in "user_name", with: "Big Bang"
  26 + fill_in "user_username", with: "bang"
  27 + fill_in "user_email", with: "bigbang@mail.com"
  28 + fill_in "user_password", with: @password
  29 + fill_in "user_password_confirmation", with: @password
  30 + end
  31 +
  32 + it "should create new user" do
  33 + expect { click_button "Save" }.to change {User.count}.by(1)
  34 + end
  35 +
  36 + it "should create user with valid data" do
  37 + click_button "Save"
  38 + user = User.last
  39 + user.name.should == "Big Bang"
  40 + user.email.should == "bigbang@mail.com"
  41 + end
  42 +
  43 + it "should call send mail" do
  44 + Notify.should_receive(:new_user_email)
  45 +
  46 + User.observers.enable :user_observer do
  47 + click_button "Save"
  48 + end
  49 + end
  50 +
  51 + it "should send valid email to user with email & password" do
  52 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
  53 + User.observers.enable :user_observer do
  54 + click_button "Save"
  55 + user = User.last
  56 + email = ActionMailer::Base.deliveries.last
  57 + email.subject.should have_content("Account was created")
  58 + email.body.should have_content(user.email)
  59 + email.body.should have_content(@password)
  60 + end
  61 + end
  62 +
  63 + it "should send valid email to user with email without password when signup is enabled" do
  64 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
  65 + User.observers.enable :user_observer do
  66 + click_button "Save"
  67 + user = User.last
  68 + email = ActionMailer::Base.deliveries.last
  69 + email.subject.should have_content("Account was created")
  70 + email.body.should have_content(user.email)
  71 + email.body.should_not have_content(@password)
  72 + end
  73 + end
  74 + end
  75 +
  76 + describe "GET /admin/users/:id" do
  77 + before do
  78 + visit admin_users_path
  79 + click_link "#{@user.name}"
  80 + end
  81 +
  82 + it "should have user info" do
  83 + page.should have_content(@user.email)
  84 + page.should have_content(@user.name)
  85 + page.should have_content(@user.projects_limit)
  86 + end
  87 + end
  88 +
  89 + describe "GET /admin/users/:id/edit" do
  90 + before do
  91 + @simple_user = create(:user)
  92 + visit admin_users_path
  93 + click_link "edit_user_#{@simple_user.id}"
  94 + end
  95 +
  96 + it "should have user edit page" do
  97 + page.should have_content("Name")
  98 + page.should have_content("Password")
  99 + end
  100 +
  101 + describe "Update user" do
  102 + before do
  103 + fill_in "user_name", with: "Big Bang"
  104 + fill_in "user_email", with: "bigbang@mail.com"
  105 + check "user_admin"
  106 + click_button "Save"
  107 + end
  108 +
  109 + it "should show page with new data" do
  110 + page.should have_content("bigbang@mail.com")
  111 + page.should have_content("Big Bang")
  112 + end
  113 +
  114 + it "should change user entry" do
  115 + @simple_user.reload
  116 + @simple_user.name.should == "Big Bang"
  117 + @simple_user.is_admin?.should be_true
  118 + end
  119 + end
  120 + end
  121 +
  122 + describe "Add new project" do
  123 + before do
  124 + @new_project = create(:project)
  125 + visit admin_user_path(@user)
  126 + end
  127 +
  128 + it "should create new user" do
  129 + select @new_project.name, from: "project_ids"
  130 + expect { click_button "Add" }.to change { UsersProject.count }.by(1)
  131 + page.should have_content @new_project.name
  132 + current_path.should == admin_user_path(@user)
  133 + end
  134 + end
  135 +end
spec/features/admin/security_spec.rb 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Admin::Projects" do
  4 + describe "GET /admin/projects" do
  5 + subject { admin_projects_path }
  6 +
  7 + it { should be_allowed_for :admin }
  8 + it { should be_denied_for :user }
  9 + it { should be_denied_for :visitor }
  10 + end
  11 +
  12 + describe "GET /admin/users" do
  13 + subject { admin_users_path }
  14 +
  15 + it { should be_allowed_for :admin }
  16 + it { should be_denied_for :user }
  17 + it { should be_denied_for :visitor }
  18 + end
  19 +
  20 + describe "GET /admin/hooks" do
  21 + subject { admin_hooks_path }
  22 +
  23 + it { should be_allowed_for :admin }
  24 + it { should be_denied_for :user }
  25 + it { should be_denied_for :visitor }
  26 + end
  27 +end
spec/features/atom/dashboard_issues_spec.rb 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Dashboard Issues Feed" do
  4 + describe "GET /issues" do
  5 + let!(:user) { create(:user) }
  6 + let!(:project1) { create(:project) }
  7 + let!(:project2) { create(:project) }
  8 + let!(:issue1) { create(:issue, author: user, assignee: user, project: project1) }
  9 + let!(:issue2) { create(:issue, author: user, assignee: user, project: project2) }
  10 +
  11 + describe "atom feed" do
  12 + it "should render atom feed via private token" do
  13 + visit issues_dashboard_path(:atom, private_token: user.private_token)
  14 +
  15 + page.response_headers['Content-Type'].should have_content("application/atom+xml")
  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)
  21 + end
  22 + end
  23 + end
  24 +end
spec/features/atom/dashboard_spec.rb 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Dashboard Feed" do
  4 + describe "GET /" do
  5 + let!(:user) { create(:user) }
  6 +
  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
  12 + end
  13 + end
  14 +end
spec/features/atom/issues_spec.rb 0 → 100644
@@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Issues Feed" do
  4 + describe "GET /issues" do
  5 + let!(:user) { create(:user) }
  6 + let!(:project) { create(:project, namespace: user.namespace) }
  7 + let!(:issue) { create(:issue, author: user, project: project) }
  8 +
  9 + before { project.team << [user, :developer] }
  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
  21 + end
  22 +
  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)
  26 +
  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
  32 + end
  33 + end
  34 +end
spec/features/gitlab_flavored_markdown_spec.rb 0 → 100644
@@ -0,0 +1,223 @@ @@ -0,0 +1,223 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Gitlab Flavored Markdown" do
  4 + let(:project) { create(:project) }
  5 + let(:issue) { create(:issue, project: project) }
  6 + let(:merge_request) { create(:merge_request, project: project) }
  7 + let(:fred) do
  8 + u = create(:user, name: "fred")
  9 + project.team << [u, :master]
  10 + u
  11 + end
  12 +
  13 + before do
  14 + # add test branch
  15 + @branch_name = "gfm-test"
  16 + r = project.repo
  17 + i = r.index
  18 + # add test file
  19 + @test_file = "gfm_test_file"
  20 + i.add(@test_file, "foo\nbar\n")
  21 + # add commit with gfm
  22 + i.commit("fix ##{issue.id}\n\nask @#{fred.username} for details", head: @branch_name)
  23 +
  24 + # add test tag
  25 + @tag_name = "gfm-test-tag"
  26 + r.git.native(:tag, {}, @tag_name, commit.id)
  27 + end
  28 +
  29 + after do
  30 + # delete test branch and tag
  31 + project.repo.git.native(:branch, {D: true}, @branch_name)
  32 + project.repo.git.native(:tag, {d: true}, @tag_name)
  33 + project.repo.gc_auto
  34 + end
  35 +
  36 + let(:commit) { project.repository.commits(@branch_name).first }
  37 +
  38 + before do
  39 + login_as :user
  40 + project.team << [@user, :developer]
  41 + end
  42 +
  43 + describe "for commits" do
  44 + it "should render title in commits#index" do
  45 + visit project_commits_path(project, @branch_name, limit: 1)
  46 +
  47 + page.should have_link("##{issue.id}")
  48 + end
  49 +
  50 + it "should render title in commits#show" do
  51 + visit project_commit_path(project, commit)
  52 +
  53 + page.should have_link("##{issue.id}")
  54 + end
  55 +
  56 + it "should render description in commits#show" do
  57 + visit project_commit_path(project, commit)
  58 +
  59 + page.should have_link("@#{fred.username}")
  60 + end
  61 +
  62 + it "should render title in refs#tree", js: true do
  63 + visit project_tree_path(project, @branch_name)
  64 +
  65 + within(".tree_commit") do
  66 + page.should have_link("##{issue.id}")
  67 + end
  68 + end
  69 +
  70 + # @wip
  71 + #it "should render title in refs#blame" do
  72 + #visit project_blame_path(project, File.join(@branch_name, @test_file))
  73 +
  74 + #within(".blame_commit") do
  75 + #page.should have_link("##{issue.id}")
  76 + #end
  77 + #end
  78 +
  79 + it "should render title in repositories#branches" do
  80 + visit branches_project_repository_path(project)
  81 +
  82 + page.should have_link("##{issue.id}")
  83 + end
  84 + end
  85 +
  86 + describe "for issues" do
  87 + before do
  88 + @other_issue = create(:issue,
  89 + author: @user,
  90 + assignee: @user,
  91 + project: project)
  92 + @issue = create(:issue,
  93 + author: @user,
  94 + assignee: @user,
  95 + project: project,
  96 + title: "fix ##{@other_issue.id}",
  97 + description: "ask @#{fred.username} for details")
  98 + end
  99 +
  100 + it "should render subject in issues#index" do
  101 + visit project_issues_path(project)
  102 +
  103 + page.should have_link("##{@other_issue.id}")
  104 + end
  105 +
  106 + it "should render subject in issues#show" do
  107 + visit project_issue_path(project, @issue)
  108 +
  109 + page.should have_link("##{@other_issue.id}")
  110 + end
  111 +
  112 + it "should render details in issues#show" do
  113 + visit project_issue_path(project, @issue)
  114 +
  115 + page.should have_link("@#{fred.username}")
  116 + end
  117 + end
  118 +
  119 +
  120 + describe "for merge requests" do
  121 + before do
  122 + @merge_request = create(:merge_request,
  123 + project: project,
  124 + title: "fix ##{issue.id}")
  125 + end
  126 +
  127 + it "should render title in merge_requests#index" do
  128 + visit project_merge_requests_path(project)
  129 +
  130 + page.should have_link("##{issue.id}")
  131 + end
  132 +
  133 + it "should render title in merge_requests#show" do
  134 + visit project_merge_request_path(project, @merge_request)
  135 +
  136 + page.should have_link("##{issue.id}")
  137 + end
  138 + end
  139 +
  140 +
  141 + describe "for milestones" do
  142 + before do
  143 + @milestone = create(:milestone,
  144 + project: project,
  145 + title: "fix ##{issue.id}",
  146 + description: "ask @#{fred.username} for details")
  147 + end
  148 +
  149 + it "should render title in milestones#index" do
  150 + visit project_milestones_path(project)
  151 +
  152 + page.should have_link("##{issue.id}")
  153 + end
  154 +
  155 + it "should render title in milestones#show" do
  156 + visit project_milestone_path(project, @milestone)
  157 +
  158 + page.should have_link("##{issue.id}")
  159 + end
  160 +
  161 + it "should render description in milestones#show" do
  162 + visit project_milestone_path(project, @milestone)
  163 +
  164 + page.should have_link("@#{fred.username}")
  165 + end
  166 + end
  167 +
  168 +
  169 + describe "for notes" do
  170 + it "should render in commits#show", js: true do
  171 + visit project_commit_path(project, commit)
  172 + fill_in "note_note", with: "see ##{issue.id}"
  173 + click_button "Add Comment"
  174 +
  175 + page.should have_link("##{issue.id}")
  176 + end
  177 +
  178 + it "should render in issue#show", js: true do
  179 + visit project_issue_path(project, issue)
  180 + fill_in "note_note", with: "see ##{issue.id}"
  181 + click_button "Add Comment"
  182 +
  183 + page.should have_link("##{issue.id}")
  184 + end
  185 +
  186 + it "should render in merge_request#show", js: true do
  187 + visit project_merge_request_path(project, merge_request)
  188 + fill_in "note_note", with: "see ##{issue.id}"
  189 + click_button "Add Comment"
  190 +
  191 + page.should have_link("##{issue.id}")
  192 + end
  193 +
  194 + it "should render in projects#wall", js: true do
  195 + visit wall_project_path(project)
  196 + fill_in "note_note", with: "see ##{issue.id}"
  197 + click_button "Add Comment"
  198 +
  199 + page.should have_link("##{issue.id}")
  200 + end
  201 + end
  202 +
  203 +
  204 + describe "for wikis" do
  205 + before do
  206 + visit project_wiki_path(project, :index)
  207 + fill_in "Title", with: "Circumvent ##{issue.id}"
  208 + fill_in "Content", with: "# Other pages\n\n* [Foo](foo)\n* [Bar](bar)\n\nAlso look at ##{issue.id} :-)"
  209 + click_on "Save"
  210 + end
  211 +
  212 + it "should NOT render title in wikis#show" do
  213 + within(".content h3") do # page title
  214 + page.should have_content("Circumvent ##{issue.id}")
  215 + page.should_not have_link("##{issue.id}")
  216 + end
  217 + end
  218 +
  219 + it "should render content in wikis#show" do
  220 + page.should have_link("##{issue.id}")
  221 + end
  222 + end
  223 +end
spec/features/issues_spec.rb 0 → 100644
@@ -0,0 +1,132 @@ @@ -0,0 +1,132 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Issues" do
  4 + let(:project) { create(:project) }
  5 +
  6 + before do
  7 + login_as :user
  8 + user2 = create(:user)
  9 +
  10 + project.team << [[@user, user2], :developer]
  11 + end
  12 +
  13 + describe "Edit issue" do
  14 + let!(:issue) do
  15 + create(:issue,
  16 + author: @user,
  17 + assignee: @user,
  18 + project: project)
  19 + end
  20 +
  21 + before do
  22 + visit project_issues_path(project)
  23 + click_link "Edit"
  24 + end
  25 +
  26 + it "should open new issue popup" do
  27 + page.should have_content("Issue ##{issue.id}")
  28 + end
  29 +
  30 + describe "fill in" do
  31 + before do
  32 + fill_in "issue_title", with: "bug 345"
  33 + fill_in "issue_description", with: "bug description"
  34 + end
  35 +
  36 + it { expect { click_button "Save changes" }.to_not change {Issue.count} }
  37 +
  38 + it "should update issue fields" do
  39 + click_button "Save changes"
  40 +
  41 + page.should have_content @user.name
  42 + page.should have_content "bug 345"
  43 + page.should have_content project.name
  44 + end
  45 + end
  46 + end
  47 +
  48 + describe "Search issue", js: true do
  49 + before do
  50 + ['foobar', 'foobar2', 'gitlab'].each do |title|
  51 + create(:issue,
  52 + author: @user,
  53 + assignee: @user,
  54 + project: project,
  55 + title: title)
  56 + end
  57 + end
  58 +
  59 + it "should be able to search on different statuses" do
  60 + issue = Issue.first # with title 'foobar'
  61 + issue.close
  62 +
  63 + visit project_issues_path(project)
  64 + click_link 'Closed'
  65 + fill_in 'issue_search', with: 'foobar'
  66 +
  67 + page.should have_content 'foobar'
  68 + page.should_not have_content 'foobar2'
  69 + page.should_not have_content 'gitlab'
  70 + end
  71 +
  72 + it "should search for term and return the correct results" do
  73 + visit project_issues_path(project)
  74 + fill_in 'issue_search', with: 'foobar'
  75 +
  76 + page.should have_content 'foobar'
  77 + page.should have_content 'foobar2'
  78 + page.should_not have_content 'gitlab'
  79 + end
  80 + end
  81 +
  82 + describe "Filter issue" do
  83 + before do
  84 + ['foobar', 'barbaz', 'gitlab'].each do |title|
  85 + create(:issue,
  86 + author: @user,
  87 + assignee: @user,
  88 + project: project,
  89 + title: title)
  90 + end
  91 +
  92 + @issue = Issue.first # with title 'foobar'
  93 + @issue.milestone = create(:milestone, project: project)
  94 + @issue.assignee = nil
  95 + @issue.save
  96 + end
  97 +
  98 + let(:issue) { @issue }
  99 +
  100 + it "should allow filtering by issues with no specified milestone" do
  101 + visit project_issues_path(project, milestone_id: '0')
  102 +
  103 + page.should_not have_content 'foobar'
  104 + page.should have_content 'barbaz'
  105 + page.should have_content 'gitlab'
  106 + end
  107 +
  108 + it "should allow filtering by a specified milestone" do
  109 + visit project_issues_path(project, milestone_id: issue.milestone.id)
  110 +
  111 + page.should have_content 'foobar'
  112 + page.should_not have_content 'barbaz'
  113 + page.should_not have_content 'gitlab'
  114 + end
  115 +
  116 + it "should allow filtering by issues with no specified assignee" do
  117 + visit project_issues_path(project, assignee_id: '0')
  118 +
  119 + page.should have_content 'foobar'
  120 + page.should_not have_content 'barbaz'
  121 + page.should_not have_content 'gitlab'
  122 + end
  123 +
  124 + it "should allow filtering by a specified assignee" do
  125 + visit project_issues_path(project, assignee_id: @user.id)
  126 +
  127 + page.should_not have_content 'foobar'
  128 + page.should have_content 'barbaz'
  129 + page.should have_content 'gitlab'
  130 + end
  131 + end
  132 +end
spec/features/notes_on_merge_requests_spec.rb 0 → 100644
@@ -0,0 +1,234 @@ @@ -0,0 +1,234 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "On a merge request", js: true do
  4 + let!(:project) { create(:project) }
  5 + let!(:merge_request) { create(:merge_request, project: project) }
  6 +
  7 + before do
  8 + login_as :user
  9 + project.team << [@user, :master]
  10 +
  11 + visit project_merge_request_path(project, merge_request)
  12 + end
  13 +
  14 + subject { page }
  15 +
  16 + describe "the note form" do
  17 + # main target form creation
  18 + it { should have_css(".js-main-target-form", visible: true, count: 1) }
  19 +
  20 + # button initalization
  21 + it { within(".js-main-target-form") { should have_button("Add Comment") } }
  22 + it { within(".js-main-target-form") { should_not have_link("Cancel") } }
  23 +
  24 + # notifiactions
  25 + it { within(".js-main-target-form") { should have_checked_field("Notify team via email") } }
  26 + it { within(".js-main-target-form") { should_not have_checked_field("Notify commit author") } }
  27 + it { within(".js-main-target-form") { should_not have_unchecked_field("Notify commit author") } }
  28 +
  29 + describe "without text" do
  30 + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
  31 + end
  32 +
  33 + describe "with text" do
  34 + before do
  35 + within(".js-main-target-form") do
  36 + fill_in "note[note]", with: "This is awesome"
  37 + end
  38 + end
  39 +
  40 + it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } }
  41 +
  42 + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } }
  43 + end
  44 +
  45 + describe "with preview" do
  46 + before do
  47 + within(".js-main-target-form") do
  48 + fill_in "note[note]", with: "This is awesome"
  49 + find(".js-note-preview-button").trigger("click")
  50 + end
  51 + end
  52 +
  53 + it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } }
  54 +
  55 + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
  56 + it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } }
  57 + end
  58 + end
  59 +
  60 + describe "when posting a note" do
  61 + before do
  62 + within(".js-main-target-form") do
  63 + fill_in "note[note]", with: "This is awsome!"
  64 + find(".js-note-preview-button").trigger("click")
  65 + click_button "Add Comment"
  66 + end
  67 + end
  68 +
  69 + # note added
  70 + it { within(".js-main-target-form") { should have_content("This is awsome!") } }
  71 +
  72 + # reset form
  73 + it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } }
  74 +
  75 + # return from preview
  76 + it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } }
  77 + it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } }
  78 +
  79 +
  80 + it "should be removable" do
  81 + find(".js-note-delete").trigger("click")
  82 +
  83 + should_not have_css(".note")
  84 + end
  85 + end
  86 +end
  87 +
  88 +
  89 +
  90 +describe "On a merge request diff", js: true, focus: true do
  91 + let!(:project) { create(:project) }
  92 + let!(:merge_request) { create(:merge_request_with_diffs, project: project) }
  93 +
  94 + before do
  95 + login_as :user
  96 + project.team << [@user, :master]
  97 +
  98 + visit diffs_project_merge_request_path(project, merge_request)
  99 +
  100 + within '.diffs-tab' do
  101 + click_link("Diff")
  102 + end
  103 + end
  104 +
  105 + subject { page }
  106 +
  107 + describe "when adding a note" do
  108 + before do
  109 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
  110 + end
  111 +
  112 + describe "the notes holder" do
  113 + it { should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") }
  114 +
  115 + it { within(".js-temp-notes-holder") { should have_css(".new_note") } }
  116 + end
  117 +
  118 + describe "the note form" do
  119 + # set up hidden fields correctly
  120 + it { within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" } }
  121 + it { within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s } }
  122 + it { within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" } }
  123 + it { within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" } }
  124 +
  125 + # buttons
  126 + it { should have_button("Add Comment") }
  127 + it { should have_css(".js-close-discussion-note-form", text: "Cancel") }
  128 +
  129 + # notification options
  130 + it { should have_checked_field("Notify team via email") }
  131 +
  132 + it "shouldn't add a second form for same row" do
  133 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
  134 +
  135 + should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder form", count: 1)
  136 + end
  137 +
  138 + it "should be removed when canceled" do
  139 + find(".js-close-discussion-note-form").trigger("click")
  140 +
  141 + should have_no_css(".js-temp-notes-holder")
  142 + end
  143 + end
  144 + end
  145 +
  146 + describe "with muliple note forms" do
  147 + before do
  148 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
  149 + find("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder .js-add-diff-note-button").trigger("click")
  150 + end
  151 +
  152 + # has two line forms
  153 + it { should have_css(".js-temp-notes-holder", count: 2) }
  154 +
  155 + describe "previewing them separately" do
  156 + before do
  157 + # add two separate texts and trigger previews on both
  158 + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") do
  159 + fill_in "note[note]", with: "One comment on line 185"
  160 + find(".js-note-preview-button").trigger("click")
  161 + end
  162 + within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do
  163 + fill_in "note[note]", with: "Another comment on line 17"
  164 + find(".js-note-preview-button").trigger("click")
  165 + end
  166 + end
  167 +
  168 + # check if previews were rendered separately
  169 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "One comment on line 185") } }
  170 + it { within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "Another comment on line 17") } }
  171 + end
  172 +
  173 + describe "posting a note" do
  174 + before do
  175 + within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do
  176 + fill_in "note[note]", with: "Another comment on line 17"
  177 + click_button("Add Comment")
  178 + end
  179 + end
  180 +
  181 + # removed form after submit
  182 + it { should have_no_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") }
  183 +
  184 + # added discussion
  185 + it { should have_content("Another comment on line 17") }
  186 + it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") }
  187 + it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder .note", count: 1) }
  188 + it { should have_link("Reply") }
  189 +
  190 + it "should remove last note of a discussion" do
  191 + within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") do
  192 + find(".js-note-delete").trigger("click")
  193 + end
  194 +
  195 + # removed whole discussion
  196 + should_not have_css(".note_holder")
  197 + should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + #342e16cbbd482ac2047dc679b2749d248cc1428f_18_18.line_holder")
  198 + end
  199 + end
  200 + end
  201 +
  202 + describe "when replying to a note" do
  203 + before do
  204 + # create first note
  205 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder .js-add-diff-note-button").trigger("click")
  206 + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .js-temp-notes-holder") do
  207 + fill_in "note[note]", with: "One comment on line 184"
  208 + click_button("Add Comment")
  209 + end
  210 + # create second note
  211 + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") do
  212 + find(".js-discussion-reply-button").trigger("click")
  213 + fill_in "note[note]", with: "An additional comment in reply"
  214 + click_button("Add Comment")
  215 + end
  216 + end
  217 +
  218 + # inserted note
  219 + it { should have_content("An additional comment in reply") }
  220 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_css(".note", count: 2) } }
  221 +
  222 + # removed form after reply
  223 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_no_css("form") } }
  224 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_link("Reply") } }
  225 + end
  226 +end
  227 +
  228 +
  229 +
  230 +describe "On merge request discussion", js: true do
  231 + describe "with merge request diff note"
  232 + describe "with commit note"
  233 + describe "with commit diff note"
  234 +end
spec/features/notes_on_wall_spec.rb 0 → 100644
@@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "On the project wall", js: true do
  4 + let!(:project) { create(:project) }
  5 + let!(:commit) { project.repository.commit("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }
  6 +
  7 + before do
  8 + login_as :user
  9 + project.team << [@user, :master]
  10 + visit wall_project_path(project)
  11 + end
  12 +
  13 + subject { page }
  14 +
  15 + describe "the note form" do
  16 + # main target form creation
  17 + it { should have_css(".js-main-target-form", visible: true, count: 1) }
  18 +
  19 + # button initalization
  20 + it { within(".js-main-target-form") { should have_button("Add Comment") } }
  21 + it { within(".js-main-target-form") { should_not have_link("Cancel") } }
  22 +
  23 + # notifiactions
  24 + it { within(".js-main-target-form") { should have_checked_field("Notify team via email") } }
  25 + it { within(".js-main-target-form") { should_not have_checked_field("Notify commit author") } }
  26 + it { within(".js-main-target-form") { should_not have_unchecked_field("Notify commit author") } }
  27 +
  28 + describe "without text" do
  29 + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
  30 + end
  31 +
  32 + describe "with text" do
  33 + before do
  34 + within(".js-main-target-form") do
  35 + fill_in "note[note]", with: "This is awesome"
  36 + end
  37 + end
  38 +
  39 + it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } }
  40 +
  41 + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } }
  42 + end
  43 +
  44 + describe "with preview" do
  45 + before do
  46 + within(".js-main-target-form") do
  47 + fill_in "note[note]", with: "This is awesome"
  48 + find(".js-note-preview-button").trigger("click")
  49 + end
  50 + end
  51 +
  52 + it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } }
  53 +
  54 + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
  55 + it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } }
  56 + end
  57 + end
  58 +
  59 + describe "when posting a note" do
  60 + before do
  61 + within(".js-main-target-form") do
  62 + fill_in "note[note]", with: "This is awsome!"
  63 + find(".js-note-preview-button").trigger("click")
  64 + click_button "Add Comment"
  65 + end
  66 + end
  67 +
  68 + # note added
  69 + it { within(".js-main-target-form") { should have_content("This is awsome!") } }
  70 +
  71 + # reset form
  72 + it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } }
  73 +
  74 + # return from preview
  75 + it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } }
  76 + it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } }
  77 +
  78 +
  79 + it "should be removable" do
  80 + find(".js-note-delete").trigger("click")
  81 +
  82 + should_not have_css(".note")
  83 + end
  84 + end
  85 +end
spec/features/profile_spec.rb 0 → 100644
@@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Profile account page" do
  4 + let(:user) { create(:user) }
  5 +
  6 + before do
  7 + login_as :user
  8 + end
  9 +
  10 + describe "when signup is enabled" do
  11 + before do
  12 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
  13 + visit account_profile_path
  14 + end
  15 + it { page.should have_content("Remove account") }
  16 +
  17 + it "should delete the account", js: true do
  18 + expect { click_link "Delete account" }.to change {User.count}.by(-1)
  19 + current_path.should == new_user_session_path
  20 + end
  21 + end
  22 +
  23 + describe "when signup is enabled and user has a project" do
  24 + before do
  25 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
  26 + @project = create(:project, namespace: @user.namespace)
  27 + @project.team << [@user, :master]
  28 + visit account_profile_path
  29 + end
  30 + it { page.should have_content("Remove account") }
  31 +
  32 + it "should not allow user to delete the account" do
  33 + expect { click_link "Delete account" }.not_to change {User.count}.by(-1)
  34 + end
  35 + end
  36 +
  37 + describe "when signup is disabled" do
  38 + before do
  39 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
  40 + visit account_profile_path
  41 + end
  42 +
  43 + it "should not have option to remove account" do
  44 + page.should_not have_content("Remove account")
  45 + current_path.should == account_profile_path
  46 + end
  47 + end
  48 +end
0 \ No newline at end of file 49 \ No newline at end of file
spec/features/projects_deploy_keys_spec.rb 0 → 100644
@@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Projects", "DeployKeys" do
  4 + let(:project) { create(:project) }
  5 +
  6 + before do
  7 + login_as :user
  8 + project.team << [@user, :master]
  9 + end
  10 +
  11 + describe "GET /keys" do
  12 + before do
  13 + @key = create(:key, project: project)
  14 + visit project_deploy_keys_path(project)
  15 + end
  16 +
  17 + subject { page }
  18 +
  19 + it { should have_content(@key.title) }
  20 +
  21 + describe "Destroy" do
  22 + before { visit project_deploy_key_path(project, @key) }
  23 +
  24 + it "should remove entry" do
  25 + expect {
  26 + click_link "Remove"
  27 + }.to change { project.deploy_keys.count }.by(-1)
  28 + end
  29 + end
  30 + end
  31 +
  32 + describe "New key" do
  33 + before do
  34 + visit project_deploy_keys_path(project)
  35 + click_link "New Deploy Key"
  36 + end
  37 +
  38 + it "should open new key popup" do
  39 + page.should have_content("New Deploy key")
  40 + end
  41 +
  42 + describe "fill in" do
  43 + before do
  44 + fill_in "key_title", with: "laptop"
  45 + fill_in "key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop"
  46 + end
  47 +
  48 + it { expect { click_button "Save" }.to change {Key.count}.by(1) }
  49 +
  50 + it "should add new key to table" do
  51 + click_button "Save"
  52 +
  53 + page.should have_content "laptop"
  54 + end
  55 + end
  56 + end
  57 +
  58 + describe "Show page" do
  59 + before do
  60 + @key = create(:key, project: project)
  61 + visit project_deploy_key_path(project, @key)
  62 + end
  63 +
  64 + it { page.should have_content @key.title }
  65 + it { page.should have_content @key.key[0..10] }
  66 + end
  67 +end
spec/features/projects_spec.rb 0 → 100644
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Projects" do
  4 + before { login_as :user }
  5 +
  6 + describe "DELETE /projects/:id" do
  7 + before do
  8 + @project = create(:project, namespace: @user.namespace)
  9 + @project.team << [@user, :master]
  10 + visit edit_project_path(@project)
  11 + end
  12 +
  13 + it "should be correct path" do
  14 + expect { click_link "Remove" }.to change {Project.count}.by(-1)
  15 + end
  16 + end
  17 +end
spec/features/search_spec.rb 0 → 100644
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Search" do
  4 + before do
  5 + login_as :user
  6 + @project = create(:project)
  7 + @project.team << [@user, :reporter]
  8 + visit search_path
  9 + fill_in "search", with: @project.name[0..3]
  10 + click_button "Search"
  11 + end
  12 +
  13 + it "should show project in search results" do
  14 + page.should have_content @project.name
  15 + end
  16 +end
  17 +
spec/features/security/profile_access_spec.rb 0 → 100644
@@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Users Security" do
  4 + describe "Project" do
  5 + before do
  6 + @u1 = create(:user)
  7 + end
  8 +
  9 + describe "GET /login" do
  10 + it { new_user_session_path.should_not be_404_for :visitor }
  11 + end
  12 +
  13 + describe "GET /keys" do
  14 + subject { keys_path }
  15 +
  16 + it { should be_allowed_for @u1 }
  17 + it { should be_allowed_for :admin }
  18 + it { should be_allowed_for :user }
  19 + it { should be_denied_for :visitor }
  20 + end
  21 +
  22 + describe "GET /profile" do
  23 + subject { profile_path }
  24 +
  25 + it { should be_allowed_for @u1 }
  26 + it { should be_allowed_for :admin }
  27 + it { should be_allowed_for :user }
  28 + it { should be_denied_for :visitor }
  29 + end
  30 +
  31 + describe "GET /profile/account" do
  32 + subject { account_profile_path }
  33 +
  34 + it { should be_allowed_for @u1 }
  35 + it { should be_allowed_for :admin }
  36 + it { should be_allowed_for :user }
  37 + it { should be_denied_for :visitor }
  38 + end
  39 +
  40 + describe "GET /profile/design" do
  41 + subject { design_profile_path }
  42 +
  43 + it { should be_allowed_for @u1 }
  44 + it { should be_allowed_for :admin }
  45 + it { should be_allowed_for :user }
  46 + it { should be_denied_for :visitor }
  47 + end
  48 + end
  49 +end
spec/features/security/project_access_spec.rb 0 → 100644
@@ -0,0 +1,243 @@ @@ -0,0 +1,243 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Application access" do
  4 + describe "GET /" do
  5 + it { root_path.should be_allowed_for :admin }
  6 + it { root_path.should be_allowed_for :user }
  7 + it { root_path.should be_denied_for :visitor }
  8 + end
  9 +
  10 + describe "GET /projects/new" do
  11 + it { new_project_path.should be_allowed_for :admin }
  12 + it { new_project_path.should be_allowed_for :user }
  13 + it { new_project_path.should be_denied_for :visitor }
  14 + end
  15 +
  16 + describe "Project" do
  17 + let(:project) { create(:project) }
  18 +
  19 + let(:master) { create(:user) }
  20 + let(:guest) { create(:user) }
  21 + let(:reporter) { create(:user) }
  22 +
  23 + before do
  24 + # full access
  25 + project.team << [master, :master]
  26 +
  27 + # readonly
  28 + project.team << [reporter, :reporter]
  29 + end
  30 +
  31 + describe "GET /project_code" do
  32 + subject { project_path(project) }
  33 +
  34 + it { should be_allowed_for master }
  35 + it { should be_allowed_for reporter }
  36 + it { should be_denied_for :admin }
  37 + it { should be_denied_for guest }
  38 + it { should be_denied_for :user }
  39 + it { should be_denied_for :visitor }
  40 + end
  41 +
  42 + describe "GET /project_code/tree/master" do
  43 + subject { project_tree_path(project, project.repository.root_ref) }
  44 +
  45 + it { should be_allowed_for master }
  46 + it { should be_allowed_for reporter }
  47 + it { should be_denied_for :admin }
  48 + it { should be_denied_for guest }
  49 + it { should be_denied_for :user }
  50 + it { should be_denied_for :visitor }
  51 + end
  52 +
  53 + describe "GET /project_code/commits/master" do
  54 + subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
  55 +
  56 + it { should be_allowed_for master }
  57 + it { should be_allowed_for reporter }
  58 + it { should be_denied_for :admin }
  59 + it { should be_denied_for guest }
  60 + it { should be_denied_for :user }
  61 + it { should be_denied_for :visitor }
  62 + end
  63 +
  64 + describe "GET /project_code/commit/:sha" do
  65 + subject { project_commit_path(project, project.repository.commit) }
  66 +
  67 + it { should be_allowed_for master }
  68 + it { should be_allowed_for reporter }
  69 + it { should be_denied_for :admin }
  70 + it { should be_denied_for guest }
  71 + it { should be_denied_for :user }
  72 + it { should be_denied_for :visitor }
  73 + end
  74 +
  75 + describe "GET /project_code/compare" do
  76 + subject { project_compare_index_path(project) }
  77 +
  78 + it { should be_allowed_for master }
  79 + it { should be_allowed_for reporter }
  80 + it { should be_denied_for :admin }
  81 + it { should be_denied_for guest }
  82 + it { should be_denied_for :user }
  83 + it { should be_denied_for :visitor }
  84 + end
  85 +
  86 + describe "GET /project_code/team" do
  87 + subject { project_team_index_path(project) }
  88 +
  89 + it { should be_allowed_for master }
  90 + it { should be_allowed_for reporter }
  91 + it { should be_denied_for :admin }
  92 + it { should be_denied_for guest }
  93 + it { should be_denied_for :user }
  94 + it { should be_denied_for :visitor }
  95 + end
  96 +
  97 + describe "GET /project_code/wall" do
  98 + subject { wall_project_path(project) }
  99 +
  100 + it { should be_allowed_for master }
  101 + it { should be_allowed_for reporter }
  102 + it { should be_denied_for :admin }
  103 + it { should be_denied_for guest }
  104 + it { should be_denied_for :user }
  105 + it { should be_denied_for :visitor }
  106 + end
  107 +
  108 + describe "GET /project_code/blob" do
  109 + before do
  110 + commit = project.repository.commit
  111 + path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name
  112 + @blob_path = project_blob_path(project, File.join(commit.id, path))
  113 + end
  114 +
  115 + it { @blob_path.should be_allowed_for master }
  116 + it { @blob_path.should be_allowed_for reporter }
  117 + it { @blob_path.should be_denied_for :admin }
  118 + it { @blob_path.should be_denied_for guest }
  119 + it { @blob_path.should be_denied_for :user }
  120 + it { @blob_path.should be_denied_for :visitor }
  121 + end
  122 +
  123 + describe "GET /project_code/edit" do
  124 + subject { edit_project_path(project) }
  125 +
  126 + it { should be_allowed_for master }
  127 + it { should be_denied_for reporter }
  128 + it { should be_denied_for :admin }
  129 + it { should be_denied_for guest }
  130 + it { should be_denied_for :user }
  131 + it { should be_denied_for :visitor }
  132 + end
  133 +
  134 + describe "GET /project_code/deploy_keys" do
  135 + subject { project_deploy_keys_path(project) }
  136 +
  137 + it { should be_allowed_for master }
  138 + it { should be_denied_for reporter }
  139 + it { should be_denied_for :admin }
  140 + it { should be_denied_for guest }
  141 + it { should be_denied_for :user }
  142 + it { should be_denied_for :visitor }
  143 + end
  144 +
  145 + describe "GET /project_code/issues" do
  146 + subject { project_issues_path(project) }
  147 +
  148 + it { should be_allowed_for master }
  149 + it { should be_allowed_for reporter }
  150 + it { should be_denied_for :admin }
  151 + it { should be_denied_for guest }
  152 + it { should be_denied_for :user }
  153 + it { should be_denied_for :visitor }
  154 + end
  155 +
  156 + describe "GET /project_code/snippets" do
  157 + subject { project_snippets_path(project) }
  158 +
  159 + it { should be_allowed_for master }
  160 + it { should be_allowed_for reporter }
  161 + it { should be_denied_for :admin }
  162 + it { should be_denied_for guest }
  163 + it { should be_denied_for :user }
  164 + it { should be_denied_for :visitor }
  165 + end
  166 +
  167 + describe "GET /project_code/merge_requests" do
  168 + subject { project_merge_requests_path(project) }
  169 +
  170 + it { should be_allowed_for master }
  171 + it { should be_allowed_for reporter }
  172 + it { should be_denied_for :admin }
  173 + it { should be_denied_for guest }
  174 + it { should be_denied_for :user }
  175 + it { should be_denied_for :visitor }
  176 + end
  177 +
  178 + describe "GET /project_code/repository" do
  179 + subject { project_repository_path(project) }
  180 +
  181 + it { should be_allowed_for master }
  182 + it { should be_allowed_for reporter }
  183 + it { should be_denied_for :admin }
  184 + it { should be_denied_for guest }
  185 + it { should be_denied_for :user }
  186 + it { should be_denied_for :visitor }
  187 + end
  188 +
  189 + describe "GET /project_code/repository/branches" do
  190 + subject { branches_project_repository_path(project) }
  191 +
  192 + before do
  193 + # Speed increase
  194 + Project.any_instance.stub(:branches).and_return([])
  195 + end
  196 +
  197 + it { should be_allowed_for master }
  198 + it { should be_allowed_for reporter }
  199 + it { should be_denied_for :admin }
  200 + it { should be_denied_for guest }
  201 + it { should be_denied_for :user }
  202 + it { should be_denied_for :visitor }
  203 + end
  204 +
  205 + describe "GET /project_code/repository/tags" do
  206 + subject { tags_project_repository_path(project) }
  207 +
  208 + before do
  209 + # Speed increase
  210 + Project.any_instance.stub(:tags).and_return([])
  211 + end
  212 +
  213 + it { should be_allowed_for master }
  214 + it { should be_allowed_for reporter }
  215 + it { should be_denied_for :admin }
  216 + it { should be_denied_for guest }
  217 + it { should be_denied_for :user }
  218 + it { should be_denied_for :visitor }
  219 + end
  220 +
  221 + describe "GET /project_code/hooks" do
  222 + subject { project_hooks_path(project) }
  223 +
  224 + it { should be_allowed_for master }
  225 + it { should be_allowed_for reporter }
  226 + it { should be_denied_for :admin }
  227 + it { should be_denied_for guest }
  228 + it { should be_denied_for :user }
  229 + it { should be_denied_for :visitor }
  230 + end
  231 +
  232 + describe "GET /project_code/files" do
  233 + subject { files_project_path(project) }
  234 +
  235 + it { should be_allowed_for master }
  236 + it { should be_allowed_for reporter }
  237 + it { should be_denied_for :admin }
  238 + it { should be_denied_for guest }
  239 + it { should be_denied_for :user }
  240 + it { should be_denied_for :visitor }
  241 + end
  242 + end
  243 +end
spec/features/snippets_spec.rb 0 → 100644
@@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Snippets" do
  4 + let(:project) { create(:project) }
  5 +
  6 + before do
  7 + login_as :user
  8 + project.team << [@user, :developer]
  9 + end
  10 +
  11 + describe "GET /snippets" do
  12 + before do
  13 + @snippet = create(:snippet,
  14 + author: @user,
  15 + project: project)
  16 +
  17 + visit project_snippets_path(project)
  18 + end
  19 +
  20 + subject { page }
  21 +
  22 + it { should have_content(@snippet.title[0..10]) }
  23 + it { should have_content(@snippet.project.name) }
  24 +
  25 + describe "Destroy" do
  26 + before do
  27 + # admin access to remove snippet
  28 + @user.users_projects.destroy_all
  29 + project.team << [@user, :master]
  30 + visit edit_project_snippet_path(project, @snippet)
  31 + end
  32 +
  33 + it "should remove entry" do
  34 + expect {
  35 + click_link "destroy_snippet_#{@snippet.id}"
  36 + }.to change { Snippet.count }.by(-1)
  37 + end
  38 + end
  39 + end
  40 +
  41 + describe "New snippet" do
  42 + before do
  43 + visit project_snippets_path(project)
  44 + click_link "New Snippet"
  45 + end
  46 +
  47 + it "should open new snippet popup" do
  48 + page.current_path.should == new_project_snippet_path(project)
  49 + end
  50 +
  51 + describe "fill in", js: true do
  52 + before do
  53 + fill_in "snippet_title", with: "login function"
  54 + fill_in "snippet_file_name", with: "test.rb"
  55 + page.execute_script("editor.insert('def login; end');")
  56 + end
  57 +
  58 + it { expect { click_button "Save" }.to change {Snippet.count}.by(1) }
  59 +
  60 + it "should add new snippet to table" do
  61 + click_button "Save"
  62 + page.current_path.should == project_snippet_path(project, Snippet.last)
  63 + page.should have_content "login function"
  64 + page.should have_content "test.rb"
  65 + end
  66 + end
  67 + end
  68 +
  69 + describe "Edit snippet" do
  70 + before do
  71 + @snippet = create(:snippet,
  72 + author: @user,
  73 + project: project)
  74 + visit project_snippet_path(project, @snippet)
  75 + click_link "Edit"
  76 + end
  77 +
  78 + it "should open edit page" do
  79 + page.current_path.should == edit_project_snippet_path(project, @snippet)
  80 + end
  81 +
  82 + describe "fill in" do
  83 + before do
  84 + fill_in "snippet_title", with: "login function"
  85 + fill_in "snippet_file_name", with: "test.rb"
  86 + end
  87 +
  88 + it { expect { click_button "Save" }.to_not change {Snippet.count} }
  89 +
  90 + it "should update snippet fields" do
  91 + click_button "Save"
  92 +
  93 + page.current_path.should == project_snippet_path(project, @snippet)
  94 + page.should have_content "login function"
  95 + page.should have_content "test.rb"
  96 + end
  97 + end
  98 + end
  99 +end
spec/requests/admin/admin_hooks_spec.rb
@@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Admin::Hooks" do  
4 - before do  
5 - @project = create(:project)  
6 - login_as :admin  
7 -  
8 - @system_hook = create(:system_hook)  
9 -  
10 - end  
11 -  
12 - describe "GET /admin/hooks" do  
13 - it "should be ok" do  
14 - visit admin_root_path  
15 - within ".main_menu" do  
16 - click_on "Hooks"  
17 - end  
18 - current_path.should == admin_hooks_path  
19 - end  
20 -  
21 - it "should have hooks list" do  
22 - visit admin_hooks_path  
23 - page.should have_content(@system_hook.url)  
24 - end  
25 - end  
26 -  
27 - describe "New Hook" do  
28 - before do  
29 - @url = Faker::Internet.uri("http")  
30 - visit admin_hooks_path  
31 - fill_in "hook_url", with: @url  
32 - expect { click_button "Add System Hook" }.to change(SystemHook, :count).by(1)  
33 - end  
34 -  
35 - it "should open new hook popup" do  
36 - page.current_path.should == admin_hooks_path  
37 - page.should have_content(@url)  
38 - end  
39 - end  
40 -  
41 - describe "Test" do  
42 - before do  
43 - WebMock.stub_request(:post, @system_hook.url)  
44 - visit admin_hooks_path  
45 - click_link "Test Hook"  
46 - end  
47 -  
48 - it { page.current_path.should == admin_hooks_path }  
49 - end  
50 -  
51 -end  
spec/requests/admin/admin_projects_spec.rb
@@ -1,76 +0,0 @@ @@ -1,76 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Admin::Projects" do  
4 - before do  
5 - @project = create(:project)  
6 - login_as :admin  
7 - end  
8 -  
9 - describe "GET /admin/projects" do  
10 - before do  
11 - visit admin_projects_path  
12 - end  
13 -  
14 - it "should be ok" do  
15 - current_path.should == admin_projects_path  
16 - end  
17 -  
18 - it "should have projects list" do  
19 - page.should have_content(@project.name)  
20 - end  
21 - end  
22 -  
23 - describe "GET /admin/projects/:id" do  
24 - before do  
25 - visit admin_projects_path  
26 - click_link "#{@project.name}"  
27 - end  
28 -  
29 - it "should have project info" do  
30 - page.should have_content(@project.path)  
31 - page.should have_content(@project.name)  
32 - end  
33 - end  
34 -  
35 - describe "GET /admin/projects/:id/edit" do  
36 - before do  
37 - visit admin_projects_path  
38 - click_link "edit_project_#{@project.id}"  
39 - end  
40 -  
41 - it "should have project edit page" do  
42 - page.should have_content("Edit project")  
43 - page.should have_button("Save Project")  
44 - end  
45 -  
46 - describe "Update project" do  
47 - before do  
48 - fill_in "project_name", with: "Big Bang"  
49 - click_button "Save Project"  
50 - @project.reload  
51 - end  
52 -  
53 - it "should show page with new data" do  
54 - page.should have_content("Big Bang")  
55 - end  
56 -  
57 - it "should change project entry" do  
58 - @project.name.should == "Big Bang"  
59 - end  
60 - end  
61 - end  
62 -  
63 - describe "Add new team member" do  
64 - before do  
65 - @new_user = create(:user)  
66 - visit admin_project_path(@project)  
67 - end  
68 -  
69 - it "should create new user" do  
70 - select @new_user.name, from: "user_ids"  
71 - expect { click_button "Add" }.to change { UsersProject.count }.by(1)  
72 - page.should have_content @new_user.name  
73 - current_path.should == admin_project_path(@project)  
74 - end  
75 - end  
76 -end  
spec/requests/admin/admin_users_spec.rb
@@ -1,135 +0,0 @@ @@ -1,135 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Admin::Users" do  
4 - before { login_as :admin }  
5 -  
6 - describe "GET /admin/users" do  
7 - before do  
8 - visit admin_users_path  
9 - end  
10 -  
11 - it "should be ok" do  
12 - current_path.should == admin_users_path  
13 - end  
14 -  
15 - it "should have users list" do  
16 - page.should have_content(@user.email)  
17 - page.should have_content(@user.name)  
18 - end  
19 - end  
20 -  
21 - describe "GET /admin/users/new" do  
22 - before do  
23 - @password = "123ABC"  
24 - visit new_admin_user_path  
25 - fill_in "user_name", with: "Big Bang"  
26 - fill_in "user_username", with: "bang"  
27 - fill_in "user_email", with: "bigbang@mail.com"  
28 - fill_in "user_password", with: @password  
29 - fill_in "user_password_confirmation", with: @password  
30 - end  
31 -  
32 - it "should create new user" do  
33 - expect { click_button "Save" }.to change {User.count}.by(1)  
34 - end  
35 -  
36 - it "should create user with valid data" do  
37 - click_button "Save"  
38 - user = User.last  
39 - user.name.should == "Big Bang"  
40 - user.email.should == "bigbang@mail.com"  
41 - end  
42 -  
43 - it "should call send mail" do  
44 - Notify.should_receive(:new_user_email)  
45 -  
46 - User.observers.enable :user_observer do  
47 - click_button "Save"  
48 - end  
49 - end  
50 -  
51 - it "should send valid email to user with email & password" do  
52 - Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)  
53 - User.observers.enable :user_observer do  
54 - click_button "Save"  
55 - user = User.last  
56 - email = ActionMailer::Base.deliveries.last  
57 - email.subject.should have_content("Account was created")  
58 - email.body.should have_content(user.email)  
59 - email.body.should have_content(@password)  
60 - end  
61 - end  
62 -  
63 - it "should send valid email to user with email without password when signup is enabled" do  
64 - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)  
65 - User.observers.enable :user_observer do  
66 - click_button "Save"  
67 - user = User.last  
68 - email = ActionMailer::Base.deliveries.last  
69 - email.subject.should have_content("Account was created")  
70 - email.body.should have_content(user.email)  
71 - email.body.should_not have_content(@password)  
72 - end  
73 - end  
74 - end  
75 -  
76 - describe "GET /admin/users/:id" do  
77 - before do  
78 - visit admin_users_path  
79 - click_link "#{@user.name}"  
80 - end  
81 -  
82 - it "should have user info" do  
83 - page.should have_content(@user.email)  
84 - page.should have_content(@user.name)  
85 - page.should have_content(@user.projects_limit)  
86 - end  
87 - end  
88 -  
89 - describe "GET /admin/users/:id/edit" do  
90 - before do  
91 - @simple_user = create(:user)  
92 - visit admin_users_path  
93 - click_link "edit_user_#{@simple_user.id}"  
94 - end  
95 -  
96 - it "should have user edit page" do  
97 - page.should have_content("Name")  
98 - page.should have_content("Password")  
99 - end  
100 -  
101 - describe "Update user" do  
102 - before do  
103 - fill_in "user_name", with: "Big Bang"  
104 - fill_in "user_email", with: "bigbang@mail.com"  
105 - check "user_admin"  
106 - click_button "Save"  
107 - end  
108 -  
109 - it "should show page with new data" do  
110 - page.should have_content("bigbang@mail.com")  
111 - page.should have_content("Big Bang")  
112 - end  
113 -  
114 - it "should change user entry" do  
115 - @simple_user.reload  
116 - @simple_user.name.should == "Big Bang"  
117 - @simple_user.is_admin?.should be_true  
118 - end  
119 - end  
120 - end  
121 -  
122 - describe "Add new project" do  
123 - before do  
124 - @new_project = create(:project)  
125 - visit admin_user_path(@user)  
126 - end  
127 -  
128 - it "should create new user" do  
129 - select @new_project.name, from: "project_ids"  
130 - expect { click_button "Add" }.to change { UsersProject.count }.by(1)  
131 - page.should have_content @new_project.name  
132 - current_path.should == admin_user_path(@user)  
133 - end  
134 - end  
135 -end  
spec/requests/admin/security_spec.rb
@@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Admin::Projects" do  
4 - describe "GET /admin/projects" do  
5 - subject { admin_projects_path }  
6 -  
7 - it { should be_allowed_for :admin }  
8 - it { should be_denied_for :user }  
9 - it { should be_denied_for :visitor }  
10 - end  
11 -  
12 - describe "GET /admin/users" do  
13 - subject { admin_users_path }  
14 -  
15 - it { should be_allowed_for :admin }  
16 - it { should be_denied_for :user }  
17 - it { should be_denied_for :visitor }  
18 - end  
19 -  
20 - describe "GET /admin/hooks" do  
21 - subject { admin_hooks_path }  
22 -  
23 - it { should be_allowed_for :admin }  
24 - it { should be_denied_for :user }  
25 - it { should be_denied_for :visitor }  
26 - end  
27 -end  
spec/requests/atom/dashboard_issues_spec.rb
@@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Dashboard Issues Feed" do  
4 - describe "GET /issues" do  
5 - let!(:user) { create(:user) }  
6 - let!(:project1) { create(:project) }  
7 - let!(:project2) { create(:project) }  
8 - let!(:issue1) { create(:issue, author: user, assignee: user, project: project1) }  
9 - let!(:issue2) { create(:issue, author: user, assignee: user, project: project2) }  
10 -  
11 - describe "atom feed" do  
12 - it "should render atom feed via private token" do  
13 - visit issues_dashboard_path(:atom, private_token: user.private_token)  
14 -  
15 - page.response_headers['Content-Type'].should have_content("application/atom+xml")  
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)  
21 - end  
22 - end  
23 - end  
24 -end  
spec/requests/atom/dashboard_spec.rb
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Dashboard Feed" do  
4 - describe "GET /" do  
5 - let!(:user) { create(:user) }  
6 -  
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  
12 - end  
13 - end  
14 -end  
spec/requests/atom/issues_spec.rb
@@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Issues Feed" do  
4 - describe "GET /issues" do  
5 - let!(:user) { create(:user) }  
6 - let!(:project) { create(:project, namespace: user.namespace) }  
7 - let!(:issue) { create(:issue, author: user, project: project) }  
8 -  
9 - before { project.team << [user, :developer] }  
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  
21 - end  
22 -  
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)  
26 -  
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  
32 - end  
33 - end  
34 -end  
spec/requests/gitlab_flavored_markdown_spec.rb
@@ -1,223 +0,0 @@ @@ -1,223 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Gitlab Flavored Markdown" do  
4 - let(:project) { create(:project) }  
5 - let(:issue) { create(:issue, project: project) }  
6 - let(:merge_request) { create(:merge_request, project: project) }  
7 - let(:fred) do  
8 - u = create(:user, name: "fred")  
9 - project.team << [u, :master]  
10 - u  
11 - end  
12 -  
13 - before do  
14 - # add test branch  
15 - @branch_name = "gfm-test"  
16 - r = project.repo  
17 - i = r.index  
18 - # add test file  
19 - @test_file = "gfm_test_file"  
20 - i.add(@test_file, "foo\nbar\n")  
21 - # add commit with gfm  
22 - i.commit("fix ##{issue.id}\n\nask @#{fred.username} for details", head: @branch_name)  
23 -  
24 - # add test tag  
25 - @tag_name = "gfm-test-tag"  
26 - r.git.native(:tag, {}, @tag_name, commit.id)  
27 - end  
28 -  
29 - after do  
30 - # delete test branch and tag  
31 - project.repo.git.native(:branch, {D: true}, @branch_name)  
32 - project.repo.git.native(:tag, {d: true}, @tag_name)  
33 - project.repo.gc_auto  
34 - end  
35 -  
36 - let(:commit) { project.repository.commits(@branch_name).first }  
37 -  
38 - before do  
39 - login_as :user  
40 - project.team << [@user, :developer]  
41 - end  
42 -  
43 - describe "for commits" do  
44 - it "should render title in commits#index" do  
45 - visit project_commits_path(project, @branch_name, limit: 1)  
46 -  
47 - page.should have_link("##{issue.id}")  
48 - end  
49 -  
50 - it "should render title in commits#show" do  
51 - visit project_commit_path(project, commit)  
52 -  
53 - page.should have_link("##{issue.id}")  
54 - end  
55 -  
56 - it "should render description in commits#show" do  
57 - visit project_commit_path(project, commit)  
58 -  
59 - page.should have_link("@#{fred.username}")  
60 - end  
61 -  
62 - it "should render title in refs#tree", js: true do  
63 - visit project_tree_path(project, @branch_name)  
64 -  
65 - within(".tree_commit") do  
66 - page.should have_link("##{issue.id}")  
67 - end  
68 - end  
69 -  
70 - # @wip  
71 - #it "should render title in refs#blame" do  
72 - #visit project_blame_path(project, File.join(@branch_name, @test_file))  
73 -  
74 - #within(".blame_commit") do  
75 - #page.should have_link("##{issue.id}")  
76 - #end  
77 - #end  
78 -  
79 - it "should render title in repositories#branches" do  
80 - visit branches_project_repository_path(project)  
81 -  
82 - page.should have_link("##{issue.id}")  
83 - end  
84 - end  
85 -  
86 - describe "for issues" do  
87 - before do  
88 - @other_issue = create(:issue,  
89 - author: @user,  
90 - assignee: @user,  
91 - project: project)  
92 - @issue = create(:issue,  
93 - author: @user,  
94 - assignee: @user,  
95 - project: project,  
96 - title: "fix ##{@other_issue.id}",  
97 - description: "ask @#{fred.username} for details")  
98 - end  
99 -  
100 - it "should render subject in issues#index" do  
101 - visit project_issues_path(project)  
102 -  
103 - page.should have_link("##{@other_issue.id}")  
104 - end  
105 -  
106 - it "should render subject in issues#show" do  
107 - visit project_issue_path(project, @issue)  
108 -  
109 - page.should have_link("##{@other_issue.id}")  
110 - end  
111 -  
112 - it "should render details in issues#show" do  
113 - visit project_issue_path(project, @issue)  
114 -  
115 - page.should have_link("@#{fred.username}")  
116 - end  
117 - end  
118 -  
119 -  
120 - describe "for merge requests" do  
121 - before do  
122 - @merge_request = create(:merge_request,  
123 - project: project,  
124 - title: "fix ##{issue.id}")  
125 - end  
126 -  
127 - it "should render title in merge_requests#index" do  
128 - visit project_merge_requests_path(project)  
129 -  
130 - page.should have_link("##{issue.id}")  
131 - end  
132 -  
133 - it "should render title in merge_requests#show" do  
134 - visit project_merge_request_path(project, @merge_request)  
135 -  
136 - page.should have_link("##{issue.id}")  
137 - end  
138 - end  
139 -  
140 -  
141 - describe "for milestones" do  
142 - before do  
143 - @milestone = create(:milestone,  
144 - project: project,  
145 - title: "fix ##{issue.id}",  
146 - description: "ask @#{fred.username} for details")  
147 - end  
148 -  
149 - it "should render title in milestones#index" do  
150 - visit project_milestones_path(project)  
151 -  
152 - page.should have_link("##{issue.id}")  
153 - end  
154 -  
155 - it "should render title in milestones#show" do  
156 - visit project_milestone_path(project, @milestone)  
157 -  
158 - page.should have_link("##{issue.id}")  
159 - end  
160 -  
161 - it "should render description in milestones#show" do  
162 - visit project_milestone_path(project, @milestone)  
163 -  
164 - page.should have_link("@#{fred.username}")  
165 - end  
166 - end  
167 -  
168 -  
169 - describe "for notes" do  
170 - it "should render in commits#show", js: true do  
171 - visit project_commit_path(project, commit)  
172 - fill_in "note_note", with: "see ##{issue.id}"  
173 - click_button "Add Comment"  
174 -  
175 - page.should have_link("##{issue.id}")  
176 - end  
177 -  
178 - it "should render in issue#show", js: true do  
179 - visit project_issue_path(project, issue)  
180 - fill_in "note_note", with: "see ##{issue.id}"  
181 - click_button "Add Comment"  
182 -  
183 - page.should have_link("##{issue.id}")  
184 - end  
185 -  
186 - it "should render in merge_request#show", js: true do  
187 - visit project_merge_request_path(project, merge_request)  
188 - fill_in "note_note", with: "see ##{issue.id}"  
189 - click_button "Add Comment"  
190 -  
191 - page.should have_link("##{issue.id}")  
192 - end  
193 -  
194 - it "should render in projects#wall", js: true do  
195 - visit wall_project_path(project)  
196 - fill_in "note_note", with: "see ##{issue.id}"  
197 - click_button "Add Comment"  
198 -  
199 - page.should have_link("##{issue.id}")  
200 - end  
201 - end  
202 -  
203 -  
204 - describe "for wikis" do  
205 - before do  
206 - visit project_wiki_path(project, :index)  
207 - fill_in "Title", with: "Circumvent ##{issue.id}"  
208 - fill_in "Content", with: "# Other pages\n\n* [Foo](foo)\n* [Bar](bar)\n\nAlso look at ##{issue.id} :-)"  
209 - click_on "Save"  
210 - end  
211 -  
212 - it "should NOT render title in wikis#show" do  
213 - within(".content h3") do # page title  
214 - page.should have_content("Circumvent ##{issue.id}")  
215 - page.should_not have_link("##{issue.id}")  
216 - end  
217 - end  
218 -  
219 - it "should render content in wikis#show" do  
220 - page.should have_link("##{issue.id}")  
221 - end  
222 - end  
223 -end  
spec/requests/issues_spec.rb
@@ -1,132 +0,0 @@ @@ -1,132 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Issues" do  
4 - let(:project) { create(:project) }  
5 -  
6 - before do  
7 - login_as :user  
8 - user2 = create(:user)  
9 -  
10 - project.team << [[@user, user2], :developer]  
11 - end  
12 -  
13 - describe "Edit issue" do  
14 - let!(:issue) do  
15 - create(:issue,  
16 - author: @user,  
17 - assignee: @user,  
18 - project: project)  
19 - end  
20 -  
21 - before do  
22 - visit project_issues_path(project)  
23 - click_link "Edit"  
24 - end  
25 -  
26 - it "should open new issue popup" do  
27 - page.should have_content("Issue ##{issue.id}")  
28 - end  
29 -  
30 - describe "fill in" do  
31 - before do  
32 - fill_in "issue_title", with: "bug 345"  
33 - fill_in "issue_description", with: "bug description"  
34 - end  
35 -  
36 - it { expect { click_button "Save changes" }.to_not change {Issue.count} }  
37 -  
38 - it "should update issue fields" do  
39 - click_button "Save changes"  
40 -  
41 - page.should have_content @user.name  
42 - page.should have_content "bug 345"  
43 - page.should have_content project.name  
44 - end  
45 - end  
46 - end  
47 -  
48 - describe "Search issue", js: true do  
49 - before do  
50 - ['foobar', 'foobar2', 'gitlab'].each do |title|  
51 - create(:issue,  
52 - author: @user,  
53 - assignee: @user,  
54 - project: project,  
55 - title: title)  
56 - end  
57 - end  
58 -  
59 - it "should be able to search on different statuses" do  
60 - issue = Issue.first # with title 'foobar'  
61 - issue.close  
62 -  
63 - visit project_issues_path(project)  
64 - click_link 'Closed'  
65 - fill_in 'issue_search', with: 'foobar'  
66 -  
67 - page.should have_content 'foobar'  
68 - page.should_not have_content 'foobar2'  
69 - page.should_not have_content 'gitlab'  
70 - end  
71 -  
72 - it "should search for term and return the correct results" do  
73 - visit project_issues_path(project)  
74 - fill_in 'issue_search', with: 'foobar'  
75 -  
76 - page.should have_content 'foobar'  
77 - page.should have_content 'foobar2'  
78 - page.should_not have_content 'gitlab'  
79 - end  
80 - end  
81 -  
82 - describe "Filter issue" do  
83 - before do  
84 - ['foobar', 'barbaz', 'gitlab'].each do |title|  
85 - create(:issue,  
86 - author: @user,  
87 - assignee: @user,  
88 - project: project,  
89 - title: title)  
90 - end  
91 -  
92 - @issue = Issue.first # with title 'foobar'  
93 - @issue.milestone = create(:milestone, project: project)  
94 - @issue.assignee = nil  
95 - @issue.save  
96 - end  
97 -  
98 - let(:issue) { @issue }  
99 -  
100 - it "should allow filtering by issues with no specified milestone" do  
101 - visit project_issues_path(project, milestone_id: '0')  
102 -  
103 - page.should_not have_content 'foobar'  
104 - page.should have_content 'barbaz'  
105 - page.should have_content 'gitlab'  
106 - end  
107 -  
108 - it "should allow filtering by a specified milestone" do  
109 - visit project_issues_path(project, milestone_id: issue.milestone.id)  
110 -  
111 - page.should have_content 'foobar'  
112 - page.should_not have_content 'barbaz'  
113 - page.should_not have_content 'gitlab'  
114 - end  
115 -  
116 - it "should allow filtering by issues with no specified assignee" do  
117 - visit project_issues_path(project, assignee_id: '0')  
118 -  
119 - page.should have_content 'foobar'  
120 - page.should_not have_content 'barbaz'  
121 - page.should_not have_content 'gitlab'  
122 - end  
123 -  
124 - it "should allow filtering by a specified assignee" do  
125 - visit project_issues_path(project, assignee_id: @user.id)  
126 -  
127 - page.should_not have_content 'foobar'  
128 - page.should have_content 'barbaz'  
129 - page.should have_content 'gitlab'  
130 - end  
131 - end  
132 -end  
spec/requests/notes_on_merge_requests_spec.rb
@@ -1,232 +0,0 @@ @@ -1,232 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "On a merge request", js: true do  
4 - let!(:project) { create(:project) }  
5 - let!(:merge_request) { create(:merge_request, project: project) }  
6 -  
7 - before do  
8 - login_as :user  
9 - project.team << [@user, :master]  
10 -  
11 - visit project_merge_request_path(project, merge_request)  
12 - end  
13 -  
14 - subject { page }  
15 -  
16 - describe "the note form" do  
17 - # main target form creation  
18 - it { should have_css(".js-main-target-form", visible: true, count: 1) }  
19 -  
20 - # button initalization  
21 - it { within(".js-main-target-form") { should have_button("Add Comment") } }  
22 - it { within(".js-main-target-form") { should_not have_link("Cancel") } }  
23 -  
24 - # notifiactions  
25 - it { within(".js-main-target-form") { should have_checked_field("Notify team via email") } }  
26 - it { within(".js-main-target-form") { should_not have_checked_field("Notify commit author") } }  
27 - it { within(".js-main-target-form") { should_not have_unchecked_field("Notify commit author") } }  
28 -  
29 - describe "without text" do  
30 - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }  
31 - end  
32 -  
33 - describe "with text" do  
34 - before do  
35 - within(".js-main-target-form") do  
36 - fill_in "note[note]", with: "This is awesome"  
37 - end  
38 - end  
39 -  
40 - it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } }  
41 -  
42 - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } }  
43 - end  
44 -  
45 - describe "with preview" do  
46 - before do  
47 - within(".js-main-target-form") do  
48 - fill_in "note[note]", with: "This is awesome"  
49 - find(".js-note-preview-button").trigger("click")  
50 - end  
51 - end  
52 -  
53 - it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } }  
54 -  
55 - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }  
56 - it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } }  
57 - end  
58 - end  
59 -  
60 - describe "when posting a note" do  
61 - before do  
62 - within(".js-main-target-form") do  
63 - fill_in "note[note]", with: "This is awsome!"  
64 - find(".js-note-preview-button").trigger("click")  
65 - click_button "Add Comment"  
66 - end  
67 - end  
68 -  
69 - # note added  
70 - it { within(".js-main-target-form") { should have_content("This is awsome!") } }  
71 -  
72 - # reset form  
73 - it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } }  
74 -  
75 - # return from preview  
76 - it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } }  
77 - it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } }  
78 -  
79 -  
80 - it "should be removable" do  
81 - find(".js-note-delete").trigger("click")  
82 -  
83 - should_not have_css(".note")  
84 - end  
85 - end  
86 -end  
87 -  
88 -  
89 -  
90 -describe "On a merge request diff", js: true, focus: true do  
91 - let!(:project) { create(:project) }  
92 - let!(:merge_request) { create(:merge_request_with_diffs, project: project) }  
93 -  
94 - before do  
95 - login_as :user  
96 - project.team << [@user, :master]  
97 -  
98 - visit diffs_project_merge_request_path(project, merge_request)  
99 -  
100 - click_link("Diff")  
101 - end  
102 -  
103 - subject { page }  
104 -  
105 - describe "when adding a note" do  
106 - before do  
107 - find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")  
108 - end  
109 -  
110 - describe "the notes holder" do  
111 - it { should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") }  
112 -  
113 - it { within(".js-temp-notes-holder") { should have_css(".new_note") } }  
114 - end  
115 -  
116 - describe "the note form" do  
117 - # set up hidden fields correctly  
118 - it { within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" } }  
119 - it { within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s } }  
120 - it { within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" } }  
121 - it { within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" } }  
122 -  
123 - # buttons  
124 - it { should have_button("Add Comment") }  
125 - it { should have_css(".js-close-discussion-note-form", text: "Cancel") }  
126 -  
127 - # notification options  
128 - it { should have_checked_field("Notify team via email") }  
129 -  
130 - it "shouldn't add a second form for same row" do  
131 - find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")  
132 -  
133 - should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder form", count: 1)  
134 - end  
135 -  
136 - it "should be removed when canceled" do  
137 - find(".js-close-discussion-note-form").trigger("click")  
138 -  
139 - should have_no_css(".js-temp-notes-holder")  
140 - end  
141 - end  
142 - end  
143 -  
144 - describe "with muliple note forms" do  
145 - before do  
146 - find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")  
147 - find("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder .js-add-diff-note-button").trigger("click")  
148 - end  
149 -  
150 - # has two line forms  
151 - it { should have_css(".js-temp-notes-holder", count: 2) }  
152 -  
153 - describe "previewing them separately" do  
154 - before do  
155 - # add two separate texts and trigger previews on both  
156 - within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") do  
157 - fill_in "note[note]", with: "One comment on line 185"  
158 - find(".js-note-preview-button").trigger("click")  
159 - end  
160 - within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do  
161 - fill_in "note[note]", with: "Another comment on line 17"  
162 - find(".js-note-preview-button").trigger("click")  
163 - end  
164 - end  
165 -  
166 - # check if previews were rendered separately  
167 - it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "One comment on line 185") } }  
168 - it { within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "Another comment on line 17") } }  
169 - end  
170 -  
171 - describe "posting a note" do  
172 - before do  
173 - within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do  
174 - fill_in "note[note]", with: "Another comment on line 17"  
175 - click_button("Add Comment")  
176 - end  
177 - end  
178 -  
179 - # removed form after submit  
180 - it { should have_no_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") }  
181 -  
182 - # added discussion  
183 - it { should have_content("Another comment on line 17") }  
184 - it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") }  
185 - it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder .note", count: 1) }  
186 - it { should have_link("Reply") }  
187 -  
188 - it "should remove last note of a discussion" do  
189 - within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") do  
190 - find(".js-note-delete").trigger("click")  
191 - end  
192 -  
193 - # removed whole discussion  
194 - should_not have_css(".note_holder")  
195 - should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + #342e16cbbd482ac2047dc679b2749d248cc1428f_18_18.line_holder")  
196 - end  
197 - end  
198 - end  
199 -  
200 - describe "when replying to a note" do  
201 - before do  
202 - # create first note  
203 - find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder .js-add-diff-note-button").trigger("click")  
204 - within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .js-temp-notes-holder") do  
205 - fill_in "note[note]", with: "One comment on line 184"  
206 - click_button("Add Comment")  
207 - end  
208 - # create second note  
209 - within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") do  
210 - find(".js-discussion-reply-button").trigger("click")  
211 - fill_in "note[note]", with: "An additional comment in reply"  
212 - click_button("Add Comment")  
213 - end  
214 - end  
215 -  
216 - # inserted note  
217 - it { should have_content("An additional comment in reply") }  
218 - it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_css(".note", count: 2) } }  
219 -  
220 - # removed form after reply  
221 - it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_no_css("form") } }  
222 - it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_link("Reply") } }  
223 - end  
224 -end  
225 -  
226 -  
227 -  
228 -describe "On merge request discussion", js: true do  
229 - describe "with merge request diff note"  
230 - describe "with commit note"  
231 - describe "with commit diff note"  
232 -end  
spec/requests/notes_on_wall_spec.rb
@@ -1,85 +0,0 @@ @@ -1,85 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "On the project wall", js: true do  
4 - let!(:project) { create(:project) }  
5 - let!(:commit) { project.repository.commit("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }  
6 -  
7 - before do  
8 - login_as :user  
9 - project.team << [@user, :master]  
10 - visit wall_project_path(project)  
11 - end  
12 -  
13 - subject { page }  
14 -  
15 - describe "the note form" do  
16 - # main target form creation  
17 - it { should have_css(".js-main-target-form", visible: true, count: 1) }  
18 -  
19 - # button initalization  
20 - it { within(".js-main-target-form") { should have_button("Add Comment") } }  
21 - it { within(".js-main-target-form") { should_not have_link("Cancel") } }  
22 -  
23 - # notifiactions  
24 - it { within(".js-main-target-form") { should have_checked_field("Notify team via email") } }  
25 - it { within(".js-main-target-form") { should_not have_checked_field("Notify commit author") } }  
26 - it { within(".js-main-target-form") { should_not have_unchecked_field("Notify commit author") } }  
27 -  
28 - describe "without text" do  
29 - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }  
30 - end  
31 -  
32 - describe "with text" do  
33 - before do  
34 - within(".js-main-target-form") do  
35 - fill_in "note[note]", with: "This is awesome"  
36 - end  
37 - end  
38 -  
39 - it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } }  
40 -  
41 - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } }  
42 - end  
43 -  
44 - describe "with preview" do  
45 - before do  
46 - within(".js-main-target-form") do  
47 - fill_in "note[note]", with: "This is awesome"  
48 - find(".js-note-preview-button").trigger("click")  
49 - end  
50 - end  
51 -  
52 - it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } }  
53 -  
54 - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }  
55 - it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } }  
56 - end  
57 - end  
58 -  
59 - describe "when posting a note" do  
60 - before do  
61 - within(".js-main-target-form") do  
62 - fill_in "note[note]", with: "This is awsome!"  
63 - find(".js-note-preview-button").trigger("click")  
64 - click_button "Add Comment"  
65 - end  
66 - end  
67 -  
68 - # note added  
69 - it { within(".js-main-target-form") { should have_content("This is awsome!") } }  
70 -  
71 - # reset form  
72 - it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } }  
73 -  
74 - # return from preview  
75 - it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } }  
76 - it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } }  
77 -  
78 -  
79 - it "should be removable" do  
80 - find(".js-note-delete").trigger("click")  
81 -  
82 - should_not have_css(".note")  
83 - end  
84 - end  
85 -end  
spec/requests/profile_spec.rb
@@ -1,48 +0,0 @@ @@ -1,48 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Profile account page" do  
4 - let(:user) { create(:user) }  
5 -  
6 - before do  
7 - login_as :user  
8 - end  
9 -  
10 - describe "when signup is enabled" do  
11 - before do  
12 - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)  
13 - visit account_profile_path  
14 - end  
15 - it { page.should have_content("Remove account") }  
16 -  
17 - it "should delete the account", js: true do  
18 - expect { click_link "Delete account" }.to change {User.count}.by(-1)  
19 - current_path.should == new_user_session_path  
20 - end  
21 - end  
22 -  
23 - describe "when signup is enabled and user has a project" do  
24 - before do  
25 - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)  
26 - @project = create(:project, namespace: @user.namespace)  
27 - @project.team << [@user, :master]  
28 - visit account_profile_path  
29 - end  
30 - it { page.should have_content("Remove account") }  
31 -  
32 - it "should not allow user to delete the account" do  
33 - expect { click_link "Delete account" }.not_to change {User.count}.by(-1)  
34 - end  
35 - end  
36 -  
37 - describe "when signup is disabled" do  
38 - before do  
39 - Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)  
40 - visit account_profile_path  
41 - end  
42 -  
43 - it "should not have option to remove account" do  
44 - page.should_not have_content("Remove account")  
45 - current_path.should == account_profile_path  
46 - end  
47 - end  
48 -end  
49 \ No newline at end of file 0 \ No newline at end of file
spec/requests/projects_deploy_keys_spec.rb
@@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Projects", "DeployKeys" do  
4 - let(:project) { create(:project) }  
5 -  
6 - before do  
7 - login_as :user  
8 - project.team << [@user, :master]  
9 - end  
10 -  
11 - describe "GET /keys" do  
12 - before do  
13 - @key = create(:key, project: project)  
14 - visit project_deploy_keys_path(project)  
15 - end  
16 -  
17 - subject { page }  
18 -  
19 - it { should have_content(@key.title) }  
20 -  
21 - describe "Destroy" do  
22 - before { visit project_deploy_key_path(project, @key) }  
23 -  
24 - it "should remove entry" do  
25 - expect {  
26 - click_link "Remove"  
27 - }.to change { project.deploy_keys.count }.by(-1)  
28 - end  
29 - end  
30 - end  
31 -  
32 - describe "New key" do  
33 - before do  
34 - visit project_deploy_keys_path(project)  
35 - click_link "New Deploy Key"  
36 - end  
37 -  
38 - it "should open new key popup" do  
39 - page.should have_content("New Deploy key")  
40 - end  
41 -  
42 - describe "fill in" do  
43 - before do  
44 - fill_in "key_title", with: "laptop"  
45 - fill_in "key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop"  
46 - end  
47 -  
48 - it { expect { click_button "Save" }.to change {Key.count}.by(1) }  
49 -  
50 - it "should add new key to table" do  
51 - click_button "Save"  
52 -  
53 - page.should have_content "laptop"  
54 - end  
55 - end  
56 - end  
57 -  
58 - describe "Show page" do  
59 - before do  
60 - @key = create(:key, project: project)  
61 - visit project_deploy_key_path(project, @key)  
62 - end  
63 -  
64 - it { page.should have_content @key.title }  
65 - it { page.should have_content @key.key[0..10] }  
66 - end  
67 -end  
spec/requests/projects_spec.rb
@@ -1,17 +0,0 @@ @@ -1,17 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Projects" do  
4 - before { login_as :user }  
5 -  
6 - describe "DELETE /projects/:id" do  
7 - before do  
8 - @project = create(:project, namespace: @user.namespace)  
9 - @project.team << [@user, :master]  
10 - visit edit_project_path(@project)  
11 - end  
12 -  
13 - it "should be correct path" do  
14 - expect { click_link "Remove" }.to change {Project.count}.by(-1)  
15 - end  
16 - end  
17 -end  
spec/requests/search_spec.rb
@@ -1,17 +0,0 @@ @@ -1,17 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Search" do  
4 - before do  
5 - login_as :user  
6 - @project = create(:project)  
7 - @project.team << [@user, :reporter]  
8 - visit search_path  
9 - fill_in "search", with: @project.name[0..3]  
10 - click_button "Search"  
11 - end  
12 -  
13 - it "should show project in search results" do  
14 - page.should have_content @project.name  
15 - end  
16 -end  
17 -  
spec/requests/security/profile_access_spec.rb
@@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Users Security" do  
4 - describe "Project" do  
5 - before do  
6 - @u1 = create(:user)  
7 - end  
8 -  
9 - describe "GET /login" do  
10 - it { new_user_session_path.should_not be_404_for :visitor }  
11 - end  
12 -  
13 - describe "GET /keys" do  
14 - subject { keys_path }  
15 -  
16 - it { should be_allowed_for @u1 }  
17 - it { should be_allowed_for :admin }  
18 - it { should be_allowed_for :user }  
19 - it { should be_denied_for :visitor }  
20 - end  
21 -  
22 - describe "GET /profile" do  
23 - subject { profile_path }  
24 -  
25 - it { should be_allowed_for @u1 }  
26 - it { should be_allowed_for :admin }  
27 - it { should be_allowed_for :user }  
28 - it { should be_denied_for :visitor }  
29 - end  
30 -  
31 - describe "GET /profile/account" do  
32 - subject { account_profile_path }  
33 -  
34 - it { should be_allowed_for @u1 }  
35 - it { should be_allowed_for :admin }  
36 - it { should be_allowed_for :user }  
37 - it { should be_denied_for :visitor }  
38 - end  
39 -  
40 - describe "GET /profile/design" do  
41 - subject { design_profile_path }  
42 -  
43 - it { should be_allowed_for @u1 }  
44 - it { should be_allowed_for :admin }  
45 - it { should be_allowed_for :user }  
46 - it { should be_denied_for :visitor }  
47 - end  
48 - end  
49 -end  
spec/requests/security/project_access_spec.rb
@@ -1,243 +0,0 @@ @@ -1,243 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Application access" do  
4 - describe "GET /" do  
5 - it { root_path.should be_allowed_for :admin }  
6 - it { root_path.should be_allowed_for :user }  
7 - it { root_path.should be_denied_for :visitor }  
8 - end  
9 -  
10 - describe "GET /projects/new" do  
11 - it { new_project_path.should be_allowed_for :admin }  
12 - it { new_project_path.should be_allowed_for :user }  
13 - it { new_project_path.should be_denied_for :visitor }  
14 - end  
15 -  
16 - describe "Project" do  
17 - let(:project) { create(:project) }  
18 -  
19 - let(:master) { create(:user) }  
20 - let(:guest) { create(:user) }  
21 - let(:reporter) { create(:user) }  
22 -  
23 - before do  
24 - # full access  
25 - project.team << [master, :master]  
26 -  
27 - # readonly  
28 - project.team << [reporter, :reporter]  
29 - end  
30 -  
31 - describe "GET /project_code" do  
32 - subject { project_path(project) }  
33 -  
34 - it { should be_allowed_for master }  
35 - it { should be_allowed_for reporter }  
36 - it { should be_denied_for :admin }  
37 - it { should be_denied_for guest }  
38 - it { should be_denied_for :user }  
39 - it { should be_denied_for :visitor }  
40 - end  
41 -  
42 - describe "GET /project_code/tree/master" do  
43 - subject { project_tree_path(project, project.repository.root_ref) }  
44 -  
45 - it { should be_allowed_for master }  
46 - it { should be_allowed_for reporter }  
47 - it { should be_denied_for :admin }  
48 - it { should be_denied_for guest }  
49 - it { should be_denied_for :user }  
50 - it { should be_denied_for :visitor }  
51 - end  
52 -  
53 - describe "GET /project_code/commits/master" do  
54 - subject { project_commits_path(project, project.repository.root_ref, limit: 1) }  
55 -  
56 - it { should be_allowed_for master }  
57 - it { should be_allowed_for reporter }  
58 - it { should be_denied_for :admin }  
59 - it { should be_denied_for guest }  
60 - it { should be_denied_for :user }  
61 - it { should be_denied_for :visitor }  
62 - end  
63 -  
64 - describe "GET /project_code/commit/:sha" do  
65 - subject { project_commit_path(project, project.repository.commit) }  
66 -  
67 - it { should be_allowed_for master }  
68 - it { should be_allowed_for reporter }  
69 - it { should be_denied_for :admin }  
70 - it { should be_denied_for guest }  
71 - it { should be_denied_for :user }  
72 - it { should be_denied_for :visitor }  
73 - end  
74 -  
75 - describe "GET /project_code/compare" do  
76 - subject { project_compare_index_path(project) }  
77 -  
78 - it { should be_allowed_for master }  
79 - it { should be_allowed_for reporter }  
80 - it { should be_denied_for :admin }  
81 - it { should be_denied_for guest }  
82 - it { should be_denied_for :user }  
83 - it { should be_denied_for :visitor }  
84 - end  
85 -  
86 - describe "GET /project_code/team" do  
87 - subject { project_team_index_path(project) }  
88 -  
89 - it { should be_allowed_for master }  
90 - it { should be_allowed_for reporter }  
91 - it { should be_denied_for :admin }  
92 - it { should be_denied_for guest }  
93 - it { should be_denied_for :user }  
94 - it { should be_denied_for :visitor }  
95 - end  
96 -  
97 - describe "GET /project_code/wall" do  
98 - subject { wall_project_path(project) }  
99 -  
100 - it { should be_allowed_for master }  
101 - it { should be_allowed_for reporter }  
102 - it { should be_denied_for :admin }  
103 - it { should be_denied_for guest }  
104 - it { should be_denied_for :user }  
105 - it { should be_denied_for :visitor }  
106 - end  
107 -  
108 - describe "GET /project_code/blob" do  
109 - before do  
110 - commit = project.repository.commit  
111 - path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name  
112 - @blob_path = project_blob_path(project, File.join(commit.id, path))  
113 - end  
114 -  
115 - it { @blob_path.should be_allowed_for master }  
116 - it { @blob_path.should be_allowed_for reporter }  
117 - it { @blob_path.should be_denied_for :admin }  
118 - it { @blob_path.should be_denied_for guest }  
119 - it { @blob_path.should be_denied_for :user }  
120 - it { @blob_path.should be_denied_for :visitor }  
121 - end  
122 -  
123 - describe "GET /project_code/edit" do  
124 - subject { edit_project_path(project) }  
125 -  
126 - it { should be_allowed_for master }  
127 - it { should be_denied_for reporter }  
128 - it { should be_denied_for :admin }  
129 - it { should be_denied_for guest }  
130 - it { should be_denied_for :user }  
131 - it { should be_denied_for :visitor }  
132 - end  
133 -  
134 - describe "GET /project_code/deploy_keys" do  
135 - subject { project_deploy_keys_path(project) }  
136 -  
137 - it { should be_allowed_for master }  
138 - it { should be_denied_for reporter }  
139 - it { should be_denied_for :admin }  
140 - it { should be_denied_for guest }  
141 - it { should be_denied_for :user }  
142 - it { should be_denied_for :visitor }  
143 - end  
144 -  
145 - describe "GET /project_code/issues" do  
146 - subject { project_issues_path(project) }  
147 -  
148 - it { should be_allowed_for master }  
149 - it { should be_allowed_for reporter }  
150 - it { should be_denied_for :admin }  
151 - it { should be_denied_for guest }  
152 - it { should be_denied_for :user }  
153 - it { should be_denied_for :visitor }  
154 - end  
155 -  
156 - describe "GET /project_code/snippets" do  
157 - subject { project_snippets_path(project) }  
158 -  
159 - it { should be_allowed_for master }  
160 - it { should be_allowed_for reporter }  
161 - it { should be_denied_for :admin }  
162 - it { should be_denied_for guest }  
163 - it { should be_denied_for :user }  
164 - it { should be_denied_for :visitor }  
165 - end  
166 -  
167 - describe "GET /project_code/merge_requests" do  
168 - subject { project_merge_requests_path(project) }  
169 -  
170 - it { should be_allowed_for master }  
171 - it { should be_allowed_for reporter }  
172 - it { should be_denied_for :admin }  
173 - it { should be_denied_for guest }  
174 - it { should be_denied_for :user }  
175 - it { should be_denied_for :visitor }  
176 - end  
177 -  
178 - describe "GET /project_code/repository" do  
179 - subject { project_repository_path(project) }  
180 -  
181 - it { should be_allowed_for master }  
182 - it { should be_allowed_for reporter }  
183 - it { should be_denied_for :admin }  
184 - it { should be_denied_for guest }  
185 - it { should be_denied_for :user }  
186 - it { should be_denied_for :visitor }  
187 - end  
188 -  
189 - describe "GET /project_code/repository/branches" do  
190 - subject { branches_project_repository_path(project) }  
191 -  
192 - before do  
193 - # Speed increase  
194 - Project.any_instance.stub(:branches).and_return([])  
195 - end  
196 -  
197 - it { should be_allowed_for master }  
198 - it { should be_allowed_for reporter }  
199 - it { should be_denied_for :admin }  
200 - it { should be_denied_for guest }  
201 - it { should be_denied_for :user }  
202 - it { should be_denied_for :visitor }  
203 - end  
204 -  
205 - describe "GET /project_code/repository/tags" do  
206 - subject { tags_project_repository_path(project) }  
207 -  
208 - before do  
209 - # Speed increase  
210 - Project.any_instance.stub(:tags).and_return([])  
211 - end  
212 -  
213 - it { should be_allowed_for master }  
214 - it { should be_allowed_for reporter }  
215 - it { should be_denied_for :admin }  
216 - it { should be_denied_for guest }  
217 - it { should be_denied_for :user }  
218 - it { should be_denied_for :visitor }  
219 - end  
220 -  
221 - describe "GET /project_code/hooks" do  
222 - subject { project_hooks_path(project) }  
223 -  
224 - it { should be_allowed_for master }  
225 - it { should be_allowed_for reporter }  
226 - it { should be_denied_for :admin }  
227 - it { should be_denied_for guest }  
228 - it { should be_denied_for :user }  
229 - it { should be_denied_for :visitor }  
230 - end  
231 -  
232 - describe "GET /project_code/files" do  
233 - subject { files_project_path(project) }  
234 -  
235 - it { should be_allowed_for master }  
236 - it { should be_allowed_for reporter }  
237 - it { should be_denied_for :admin }  
238 - it { should be_denied_for guest }  
239 - it { should be_denied_for :user }  
240 - it { should be_denied_for :visitor }  
241 - end  
242 - end  
243 -end  
spec/requests/snippets_spec.rb
@@ -1,99 +0,0 @@ @@ -1,99 +0,0 @@
1 -require 'spec_helper'  
2 -  
3 -describe "Snippets" do  
4 - let(:project) { create(:project) }  
5 -  
6 - before do  
7 - login_as :user  
8 - project.team << [@user, :developer]  
9 - end  
10 -  
11 - describe "GET /snippets" do  
12 - before do  
13 - @snippet = create(:snippet,  
14 - author: @user,  
15 - project: project)  
16 -  
17 - visit project_snippets_path(project)  
18 - end  
19 -  
20 - subject { page }  
21 -  
22 - it { should have_content(@snippet.title[0..10]) }  
23 - it { should have_content(@snippet.project.name) }  
24 -  
25 - describe "Destroy" do  
26 - before do  
27 - # admin access to remove snippet  
28 - @user.users_projects.destroy_all  
29 - project.team << [@user, :master]  
30 - visit edit_project_snippet_path(project, @snippet)  
31 - end  
32 -  
33 - it "should remove entry" do  
34 - expect {  
35 - click_link "destroy_snippet_#{@snippet.id}"  
36 - }.to change { Snippet.count }.by(-1)  
37 - end  
38 - end  
39 - end  
40 -  
41 - describe "New snippet" do  
42 - before do  
43 - visit project_snippets_path(project)  
44 - click_link "New Snippet"  
45 - end  
46 -  
47 - it "should open new snippet popup" do  
48 - page.current_path.should == new_project_snippet_path(project)  
49 - end  
50 -  
51 - describe "fill in", js: true do  
52 - before do  
53 - fill_in "snippet_title", with: "login function"  
54 - fill_in "snippet_file_name", with: "test.rb"  
55 - page.execute_script("editor.insert('def login; end');")  
56 - end  
57 -  
58 - it { expect { click_button "Save" }.to change {Snippet.count}.by(1) }  
59 -  
60 - it "should add new snippet to table" do  
61 - click_button "Save"  
62 - page.current_path.should == project_snippet_path(project, Snippet.last)  
63 - page.should have_content "login function"  
64 - page.should have_content "test.rb"  
65 - end  
66 - end  
67 - end  
68 -  
69 - describe "Edit snippet" do  
70 - before do  
71 - @snippet = create(:snippet,  
72 - author: @user,  
73 - project: project)  
74 - visit project_snippet_path(project, @snippet)  
75 - click_link "Edit"  
76 - end  
77 -  
78 - it "should open edit page" do  
79 - page.current_path.should == edit_project_snippet_path(project, @snippet)  
80 - end  
81 -  
82 - describe "fill in" do  
83 - before do  
84 - fill_in "snippet_title", with: "login function"  
85 - fill_in "snippet_file_name", with: "test.rb"  
86 - end  
87 -  
88 - it { expect { click_button "Save" }.to_not change {Snippet.count} }  
89 -  
90 - it "should update snippet fields" do  
91 - click_button "Save"  
92 -  
93 - page.current_path.should == project_snippet_path(project, @snippet)  
94 - page.should have_content "login function"  
95 - page.should have_content "test.rb"  
96 - end  
97 - end  
98 - end  
99 -end