Project

General

Profile

Defect #14817 » save_time_entries_queries_in_session.patch

Marius BĂLTEANU, 2016-12-10 23:27

View differences:

app/controllers/timelog_controller.rb
281 281
  end
282 282

  
283 283
  def retrieve_time_entry_query
284
    retrieve_query(TimeEntryQuery, false)
284
    retrieve_query(TimeEntryQuery, true)
285 285
  end
286 286
end
test/fixtures/queries.yml
1
--- 
2
queries_001: 
1
---
2
queries_001:
3 3
  id: 1
4 4
  type: IssueQuery
5 5
  project_id: 1
6 6
  visibility: 2
7 7
  name: Multiple custom fields query
8 8
  filters: |
9
    --- 
10
    cf_1: 
11
      :values: 
9
    ---
10
    cf_1:
11
      :values:
12 12
      - MySQL
13 13
      :operator: "="
14
    status_id: 
15
      :values: 
14
    status_id:
15
      :values:
16 16
      - "1"
17 17
      :operator: o
18
    cf_2: 
19
      :values: 
18
    cf_2:
19
      :values:
20 20
      - "125"
21 21
      :operator: "="
22 22

  
23 23
  user_id: 1
24
  column_names: 
25
queries_002: 
24
  column_names:
25
queries_002:
26 26
  id: 2
27 27
  type: IssueQuery
28 28
  project_id: 1
29 29
  visibility: 0
30 30
  name: Private query for cookbook
31 31
  filters: |
32
    --- 
33
    tracker_id: 
34
      :values: 
32
    ---
33
    tracker_id:
34
      :values:
35 35
      - "3"
36 36
      :operator: "="
37
    status_id: 
38
      :values: 
37
    status_id:
38
      :values:
39 39
      - "1"
40 40
      :operator: o
41 41

  
42 42
  user_id: 3
43
  column_names: 
44
queries_003: 
43
  column_names:
44
queries_003:
45 45
  id: 3
46 46
  type: IssueQuery
47
  project_id: 
47
  project_id:
48 48
  visibility: 0
49 49
  name: Private query for all projects
50 50
  filters: |
51
    --- 
52
    tracker_id: 
53
      :values: 
51
    ---
52
    tracker_id:
53
      :values:
54 54
      - "3"
55 55
      :operator: "="
56 56

  
57 57
  user_id: 3
58
  column_names: 
59
queries_004: 
58
  column_names:
59
queries_004:
60 60
  id: 4
61 61
  type: IssueQuery
62
  project_id: 
62
  project_id:
63 63
  visibility: 2
64 64
  name: Public query for all projects
65 65
  filters: |
66
    --- 
67
    tracker_id: 
68
      :values: 
66
    ---
67
    tracker_id:
68
      :values:
69 69
      - "3"
70 70
      :operator: "="
71 71

  
72 72
  user_id: 2
73
  column_names: 
74
queries_005: 
73
  column_names:
74
queries_005:
75 75
  id: 5
76 76
  type: IssueQuery
77
  project_id: 
77
  project_id:
78 78
  visibility: 2
79 79
  name: Open issues by priority and tracker
80 80
  filters: |
81
    --- 
82
    status_id: 
83
      :values: 
81
    ---
82
    status_id:
83
      :values:
84 84
      - "1"
85 85
      :operator: o
86 86

  
87 87
  user_id: 1
88
  column_names: 
88
  column_names:
89 89
  sort_criteria: |
90
    --- 
90
    ---
91 91
    - - priority
92 92
      - desc
93 93
    - - tracker
94 94
      - asc
95
queries_006: 
95
queries_006:
96 96
  id: 6
97 97
  type: IssueQuery
98
  project_id: 
98
  project_id:
99 99
  visibility: 2
100 100
  name: Open issues grouped by tracker
101 101
  filters: |
102
    --- 
103
    status_id: 
104
      :values: 
102
    ---
103
    status_id:
104
      :values:
105 105
      - "1"
106 106
      :operator: o
107 107

  
108 108
  user_id: 1
109
  column_names: 
109
  column_names:
110 110
  group_by: tracker
111 111
  sort_criteria: |
112
    --- 
112
    ---
113 113
    - - priority
114 114
      - desc
115
queries_007: 
115
queries_007:
116 116
  id: 7
117 117
  type: IssueQuery
118 118
  project_id: 2
119 119
  visibility: 2
120 120
  name: Public query for project 2
121 121
  filters: |
122
    --- 
123
    tracker_id: 
124
      :values: 
122
    ---
123
    tracker_id:
124
      :values:
125 125
      - "3"
126 126
      :operator: "="
127 127

  
128 128
  user_id: 2
129
  column_names: 
130
queries_008: 
129
  column_names:
130
queries_008:
131 131
  id: 8
132 132
  type: IssueQuery
133 133
  project_id: 2
134 134
  visibility: 0
135 135
  name: Private query for project 2
136 136
  filters: |
137
    --- 
138
    tracker_id: 
139
      :values: 
137
    ---
138
    tracker_id:
139
      :values:
140 140
      - "3"
141 141
      :operator: "="
142 142

  
143 143
  user_id: 2
144
  column_names: 
145
queries_009: 
144
  column_names:
145
queries_009:
146 146
  id: 9
147 147
  type: IssueQuery
148
  project_id: 
148
  project_id:
149 149
  visibility: 2
150 150
  name: Open issues grouped by list custom field
151 151
  filters: |
152
    --- 
153
    status_id: 
154
      :values: 
152
    ---
153
    status_id:
154
      :values:
155 155
      - "1"
156 156
      :operator: o
157 157

  
158 158
  user_id: 1
159
  column_names: 
159
  column_names:
160 160
  group_by: cf_1
161 161
  sort_criteria: |
162
    --- 
162
    ---
163 163
    - - priority
164 164
      - desc
165

  
165
queries_010:
166
  id: 10
167
  type: TimeEntryQuery
168
  project_id: 1
169
  visibility: 2
170
  name: Time entries
171
  filters: |
172
    ---
173
    hours:
174
      :values:
175
      - "5"
176
      :operator: "<="
test/functional/timelog_controller_test.rb
24 24
           :trackers, :enumerations, :issue_statuses,
25 25
           :custom_fields, :custom_values,
26 26
           :projects_trackers, :custom_fields_trackers,
27
           :custom_fields_projects
27
           :custom_fields_projects, :queries
28 28

  
29 29
  include Redmine::I18n
30 30

  
......
952 952
    assert_select '#sidebar a.selected', :text => query.name
953 953
  end
954 954

  
955
  def test_index_with_query_id_and_project_id_should_set_session_query
956
    get :index, :project_id => 1, :query_id => 10
957
    assert_response :success
958

  
959
    assert_kind_of Hash, session[:time_entry_query]
960
    assert_equal 10, session[:time_entry_query][:id]
961
    assert_equal 1, session[:time_entry_query][:project_id]
962
  end
963

  
955 964
  def test_index_atom_feed
956 965
    get :index, :params => {:project_id => 1, :format => 'atom'}
957 966
    assert_response :success
    (1-1/1)