Commit 578cf89812fc12e99e22a3da83aaca89e7c8d430

Authored by Riyad Preukschas
1 parent a85e11fa

Fix specs

app/assets/javascripts/issues.js
... ... @@ -39,10 +39,10 @@ function backToIssues(){
39 39 }
40 40  
41 41 function initIssuesSearch() {
42   - var href = $('.issue_search').parent().attr('action');
  42 + var href = $('#issue_search_form').attr('action');
43 43 var last_terms = '';
44 44  
45   - $('.issue_search').keyup(function() {
  45 + $('#issue_search').keyup(function() {
46 46 var terms = $(this).val();
47 47 var milestone_id = $('#milestone_id').val();
48 48 var status = $('#status').val();
... ... @@ -57,10 +57,6 @@ function initIssuesSearch() {
57 57 }
58 58 }
59 59 });
60   -
61   - $('.delete-issue').live('ajax:success', function() {
62   - $(this).closest('tr').fadeOut(); updatePage();
63   - });
64 60 }
65 61  
66 62 /**
... ...
app/models/milestone.rb
... ... @@ -7,6 +7,7 @@ class Milestone < ActiveRecord::Base
7 7  
8 8 validates :title, presence: true
9 9 validates :project, presence: true
  10 + validates :closed, inclusion: { in: [true, false] }
10 11  
11 12 def self.active
12 13 where("due_date > ? OR due_date IS NULL", Date.today)
... ...
features/steps/project/project_browse_commits.rb
... ... @@ -53,8 +53,9 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
53 53 end
54 54  
55 55 Then 'I see commits stats' do
56   - page.should have_content 'Stats for master'
  56 + page.should have_content 'Stats'
57 57 page.should have_content 'Committers'
58 58 page.should have_content 'Total commits'
  59 + page.should have_content 'Authors'
59 60 end
60 61 end
... ...
spec/models/issue_spec.rb
... ... @@ -30,7 +30,6 @@ describe Issue do
30 30  
31 31 describe "Validation" do
32 32 it { should ensure_length_of(:description).is_within(0..2000) }
33   - it { should ensure_inclusion_of(:closed).in_array([true, false]) }
34 33 end
35 34  
36 35 describe 'modules' do
... ...
spec/requests/issues_spec.rb
... ... @@ -5,24 +5,27 @@ describe "Issues" do
5 5  
6 6 before do
7 7 login_as :user
8   - @user2 = create(:user)
  8 + user2 = create(:user)
9 9  
10 10 project.add_access(@user, :read, :write)
11   - project.add_access(@user2, :read, :write)
  11 + project.add_access(user2, :read, :write)
12 12 end
13 13  
14 14 describe "Edit issue", js: true do
  15 + let!(:issue) do
  16 + create(:issue,
  17 + author: @user,
  18 + assignee: @user,
  19 + project: project)
  20 + end
  21 +
15 22 before do
16   - @issue = create(:issue,
17   - author: @user,
18   - assignee: @user,
19   - project: project)
20 23 visit project_issues_path(project)
21 24 click_link "Edit"
22 25 end
23 26  
24 27 it "should open new issue popup" do
25   - page.should have_content("Issue ##{@issue.id}")
  28 + page.should have_content("Issue ##{issue.id}")
26 29 end
27 30  
28 31 describe "fill in" do
... ... @@ -46,19 +49,18 @@ describe "Issues" do
46 49 describe "Search issue", js: true do
47 50 before do
48 51 ['foobar', 'foobar2', 'gitlab'].each do |title|
49   - @issue = create(:issue,
50   - author: @user,
51   - assignee: @user,
52   - project: project,
53   - title: title)
54   - @issue.save
  52 + create(:issue,
  53 + author: @user,
  54 + assignee: @user,
  55 + project: project,
  56 + title: title)
55 57 end
56 58 end
57 59  
58 60 it "should be able to search on different statuses" do
59   - @issue = Issue.first
60   - @issue.closed = true
61   - @issue.save
  61 + issue = Issue.first # with title 'foobar'
  62 + issue.closed = true
  63 + issue.save
62 64  
63 65 visit project_issues_path(project)
64 66 click_link 'Closed'
... ... @@ -81,8 +83,9 @@ describe "Issues" do
81 83 it "should return all results if term has been cleared" do
82 84 visit project_issues_path(project)
83 85 fill_in "issue_search", with: "foobar"
84   - # Because fill_in, with: "" triggers nothing we need to trigger a keyup event
85   - page.execute_script("$('.issue_search').val('').keyup();");
  86 + # Reset the search field and trigger loading the issues
  87 + fill_in "issue_search", with: ""
  88 + page.execute_script("$('#issue_search').keyup();");
86 89  
87 90 page.should have_content 'foobar'
88 91 page.should have_content 'foobar2'
... ... @@ -93,19 +96,21 @@ describe "Issues" do
93 96 describe "Filter issue" do
94 97 before do
95 98 ['foobar', 'barbaz', 'gitlab'].each do |title|
96   - @issue = create(:issue,
97   - author: @user,
98   - assignee: @user,
99   - project: project,
100   - title: title)
  99 + create(:issue,
  100 + author: @user,
  101 + assignee: @user,
  102 + project: project,
  103 + title: title)
101 104 end
102 105  
103   - @issue = Issue.first
104   - @issue.milestone = create(:milestone, project: project)
105   - @issue.assignee = nil
106   - @issue.save
  106 + issue = Issue.first # with title 'foobar'
  107 + issue.milestone = create(:milestone, project: project)
  108 + issue.assignee = nil
  109 + issue.save
107 110 end
108 111  
  112 + let(:issue) { Issue.first }
  113 +
109 114 it "should allow filtering by issues with no specified milestone" do
110 115 visit project_issues_path(project, milestone_id: '0')
111 116  
... ... @@ -115,7 +120,7 @@ describe "Issues" do
115 120 end
116 121  
117 122 it "should allow filtering by a specified milestone" do
118   - visit project_issues_path(project, milestone_id: @issue.milestone.id)
  123 + visit project_issues_path(project, milestone_id: issue.milestone.id)
119 124  
120 125 page.should have_content 'foobar'
121 126 page.should_not have_content 'barbaz'
... ...
spec/roles/issue_commonality_spec.rb
... ... @@ -15,6 +15,7 @@ describe Issue, "IssueCommonality" do
15 15 it { should validate_presence_of(:author) }
16 16 it { should validate_presence_of(:title) }
17 17 it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) }
  18 + it { should ensure_inclusion_of(:closed).in_array([true, false]) }
18 19 end
19 20  
20 21 describe "Scope" do
... ...