Feature #32302 » 0001-Option-to-filter-after-my-bookmarked-projects.patch
| app/models/query.rb | ||
|---|---|---|
| 528 | 528 | |
| 529 | 529 |
def project_values |
| 530 | 530 |
project_values = [] |
| 531 |
if User.current.logged? && User.current.memberships.any? |
|
| 532 |
project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"]
|
|
| 531 |
if User.current.logged? |
|
| 532 |
project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"] if User.current.memberships.any?
|
|
| 533 |
project_values << ["<< #{l(:label_my_bookmarks).downcase} >>", "bookmarks"] if User.current.bookmarked_project_ids.any?
|
|
| 533 | 534 |
end |
| 534 | 535 |
project_values += all_projects_values |
| 535 | 536 |
project_values |
| ... | ... | |
| 915 | 916 |
if v.delete('mine')
|
| 916 | 917 |
v += User.current.memberships.map(&:project_id).map(&:to_s) |
| 917 | 918 |
end |
| 919 |
if v.delete('bookmarks')
|
|
| 920 |
v += User.current.bookmarked_project_ids |
|
| 921 |
end |
|
| 918 | 922 |
end |
| 919 | 923 | |
| 920 | 924 |
if field =~ /^cf_(\d+)\.cf_(\d+)$/ |
| app/models/user.rb | ||
|---|---|---|
| 840 | 840 |
end |
| 841 | 841 |
end |
| 842 | 842 | |
| 843 |
def bookmarked_project_ids |
|
| 844 |
project_ids = [] |
|
| 845 |
bookmarked_project_ids = self.pref[:bookmarked_project_ids] |
|
| 846 |
project_ids = bookmarked_project_ids.split(',') unless bookmarked_project_ids.nil?
|
|
| 847 |
project_ids.map(&:to_i) |
|
| 848 |
end |
|
| 849 | ||
| 843 | 850 |
protected |
| 844 | 851 | |
| 845 | 852 |
def validate_password_length |
| config/locales/en.yml | ||
|---|---|---|
| 1076 | 1076 |
label_display_type: Display results as |
| 1077 | 1077 |
label_display_type_list: List |
| 1078 | 1078 |
label_display_type_board: Board |
| 1079 |
label_my_bookmarks: My bookmarks |
|
| 1079 | 1080 | |
| 1080 | 1081 |
button_login: Login |
| 1081 | 1082 |
button_submit: Submit |
| test/fixtures/user_preferences.yml | ||
|---|---|---|
| 1 |
---
|
|
| 2 |
user_preferences_001:
|
|
| 1 |
--- |
|
| 2 |
user_preferences_001: |
|
| 3 | 3 |
others: | |
| 4 |
---
|
|
| 4 |
--- |
|
| 5 | 5 |
:no_self_notified: false |
| 6 |
:my_page_layout:
|
|
| 7 |
left:
|
|
| 6 |
:my_page_layout: |
|
| 7 |
left: |
|
| 8 | 8 |
- latestnews |
| 9 | 9 |
- documents |
| 10 |
right:
|
|
| 10 |
right: |
|
| 11 | 11 |
- issuesassignedtome |
| 12 |
top:
|
|
| 12 |
top: |
|
| 13 | 13 |
- calendar |
| 14 |
:bookmarked_project_ids: "1,5" |
|
| 14 | 15 | |
| 15 | 16 |
id: 1 |
| 16 | 17 |
user_id: 1 |
| 17 | 18 |
hide_mail: true |
| 18 |
user_preferences_002:
|
|
| 19 |
user_preferences_002: |
|
| 19 | 20 |
others: | |
| 20 |
---
|
|
| 21 |
--- |
|
| 21 | 22 |
:no_self_notified: false |
| 22 |
|
|
| 23 | ||
| 23 | 24 |
id: 2 |
| 24 | 25 |
user_id: 2 |
| 25 | 26 |
hide_mail: true |
| 26 |
user_preferences_003:
|
|
| 27 |
user_preferences_003: |
|
| 27 | 28 |
others: | |
| 28 |
---
|
|
| 29 |
--- |
|
| 29 | 30 |
:no_self_notified: false |
| 30 |
:my_page_layout:
|
|
| 31 |
left:
|
|
| 31 |
:my_page_layout: |
|
| 32 |
left: |
|
| 32 | 33 |
- latestnews |
| 33 | 34 |
- documents |
| 34 |
right:
|
|
| 35 |
right: |
|
| 35 | 36 |
- issuesassignedtome |
| 36 |
top:
|
|
| 37 |
top: |
|
| 37 | 38 |
- calendar |
| 38 |
|
|
| 39 | ||
| 39 | 40 |
id: 3 |
| 40 | 41 |
user_id: 3 |
| 41 | 42 |
hide_mail: false |
| test/unit/query_test.rb | ||
|---|---|---|
| 922 | 922 |
assert_nil result.detect {|issue| !User.current.member_of?(issue.project)}
|
| 923 | 923 |
end |
| 924 | 924 | |
| 925 |
def test_filter_my_bookmarks |
|
| 926 |
User.current = User.find(1) |
|
| 927 |
query = ProjectQuery.new(:name => '_') |
|
| 928 |
filter = query.available_filters['id'] |
|
| 929 |
assert_not_nil filter |
|
| 930 |
assert_include 'bookmarks', filter[:values].map{|v| v[1]}
|
|
| 931 | ||
| 932 |
query.filters = { 'id' => {:operator => '=', :values => ['bookmarks']}}
|
|
| 933 |
result = query.results_scope |
|
| 934 | ||
| 935 |
assert_equal [1,5], result.map(&:id).sort |
|
| 936 |
end |
|
| 937 | ||
| 938 |
def test_filter_my_bookmarks_for_user_without_bookmarked_projects |
|
| 939 |
User.current = User.find(2) |
|
| 940 |
query = ProjectQuery.new(:name => '_') |
|
| 941 |
filter = query.available_filters['id'] |
|
| 942 | ||
| 943 |
assert_not_include 'bookmarks', filter[:values].map{|v| v[1]}
|
|
| 944 |
end |
|
| 945 | ||
| 925 | 946 |
def test_filter_watched_issues |
| 926 | 947 |
User.current = User.find(1) |
| 927 | 948 |
query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})
|
| test/unit/user_test.rb | ||
|---|---|---|
| 1280 | 1280 |
assert_equal user, User.try_to_login(user.login, "unsalted") |
| 1281 | 1281 |
end |
| 1282 | 1282 | |
| 1283 |
def test_bookmarked_project_ids |
|
| 1284 |
# User with bookmarked projects |
|
| 1285 |
assert_equal [1, 5], User.find(1).bookmarked_project_ids |
|
| 1286 |
# User without bookmarked projects |
|
| 1287 |
assert_equal [], User.find(2).bookmarked_project_ids |
|
| 1288 |
end |
|
| 1289 | ||
| 1283 | 1290 |
if Object.const_defined?(:OpenID) |
| 1284 | 1291 |
def test_setting_identity_url |
| 1285 | 1292 |
normalized_open_id_url = 'http://example.com/' |
- « Previous
- 1
- 2
- 3
- Next »