Show More
@@ -613,6 +613,7 b' class TestAdminSettingsIssueTracker(obje' | |||
|
613 | 613 | RC_PREFIX = 'rhodecode_' |
|
614 | 614 | SHORT_PATTERN_KEY = 'issuetracker_pat_' |
|
615 | 615 | PATTERN_KEY = RC_PREFIX + SHORT_PATTERN_KEY |
|
616 | DESC_KEY = RC_PREFIX + 'issuetracker_desc_' | |
|
616 | 617 | |
|
617 | 618 | def test_issuetracker_index(self, autologin_user): |
|
618 | 619 | response = self.app.get(route_path('admin_settings_issuetracker')) |
@@ -665,30 +666,43 b' class TestAdminSettingsIssueTracker(obje' | |||
|
665 | 666 | |
|
666 | 667 | def test_edit_issuetracker_pattern( |
|
667 | 668 | self, autologin_user, backend, csrf_token, request): |
|
668 | old_pattern = 'issuetracker_pat' | |
|
669 | ||
|
670 | old_pattern = 'issuetracker_pat1' | |
|
669 | 671 | old_uid = md5(old_pattern) |
|
670 | pattern = 'issuetracker_pat_new' | |
|
671 | self.new_uid = md5(pattern) | |
|
672 | ||
|
673 | SettingsModel().create_or_update_setting( | |
|
674 | self.SHORT_PATTERN_KEY+old_uid, old_pattern, 'unicode') | |
|
675 | 672 | |
|
676 | 673 | post_url = route_path('admin_settings_issuetracker_update') |
|
677 | 674 | post_data = { |
|
678 | 'new_pattern_pattern_0': pattern, | |
|
679 |
'new_pattern_url_0': 'http |
|
|
675 | 'new_pattern_pattern_0': old_pattern, | |
|
676 | 'new_pattern_url_0': 'http://url', | |
|
680 | 677 | 'new_pattern_prefix_0': 'prefix', |
|
681 | 678 | 'new_pattern_description_0': 'description', |
|
679 | ||
|
680 | 'csrf_token': csrf_token | |
|
681 | } | |
|
682 | self.app.post(post_url, post_data, status=302) | |
|
683 | ||
|
684 | new_pattern = 'issuetracker_pat1_edited' | |
|
685 | self.new_uid = md5(new_pattern) | |
|
686 | ||
|
687 | post_url = route_path('admin_settings_issuetracker_update') | |
|
688 | post_data = { | |
|
689 | 'new_pattern_pattern_{}'.format(old_uid): new_pattern, | |
|
690 | 'new_pattern_url_{}'.format(old_uid): 'https://url_edited', | |
|
691 | 'new_pattern_prefix_{}'.format(old_uid): 'prefix_edited', | |
|
692 | 'new_pattern_description_{}'.format(old_uid): 'description_edited', | |
|
682 | 693 | 'uid': old_uid, |
|
683 | 694 | 'csrf_token': csrf_token |
|
684 | 695 | } |
|
685 | 696 | self.app.post(post_url, post_data, status=302) |
|
697 | ||
|
686 | 698 | settings = SettingsModel().get_all_settings() |
|
687 | assert settings[self.PATTERN_KEY+self.new_uid] == pattern | |
|
699 | assert settings[self.PATTERN_KEY+self.new_uid] == new_pattern | |
|
700 | assert settings[self.DESC_KEY + self.new_uid] == 'description_edited' | |
|
688 | 701 | assert self.PATTERN_KEY+old_uid not in settings |
|
689 | 702 | |
|
690 | 703 | @request.addfinalizer |
|
691 | 704 | def cleanup(): |
|
705 | IssueTrackerSettingsModel().delete_entries(old_uid) | |
|
692 | 706 | IssueTrackerSettingsModel().delete_entries(self.new_uid) |
|
693 | 707 | |
|
694 | 708 | def test_replace_issuetracker_pattern_description( |
@@ -727,16 +741,27 b' class TestAdminSettingsIssueTracker(obje' | |||
|
727 | 741 | |
|
728 | 742 | def test_delete_issuetracker_pattern( |
|
729 | 743 | self, autologin_user, backend, csrf_token, settings_util, xhr_header): |
|
730 | pattern = 'issuetracker_pat' | |
|
731 | uid = md5(pattern) | |
|
732 | settings_util.create_rhodecode_setting( | |
|
733 | self.SHORT_PATTERN_KEY+uid, pattern, 'unicode', cleanup=False) | |
|
744 | ||
|
745 | old_pattern = 'issuetracker_pat_deleted' | |
|
746 | old_uid = md5(old_pattern) | |
|
747 | ||
|
748 | post_url = route_path('admin_settings_issuetracker_update') | |
|
749 | post_data = { | |
|
750 | 'new_pattern_pattern_0': old_pattern, | |
|
751 | 'new_pattern_url_0': 'http://url', | |
|
752 | 'new_pattern_prefix_0': 'prefix', | |
|
753 | 'new_pattern_description_0': 'description', | |
|
754 | ||
|
755 | 'csrf_token': csrf_token | |
|
756 | } | |
|
757 | self.app.post(post_url, post_data, status=302) | |
|
734 | 758 | |
|
735 | 759 | post_url = route_path('admin_settings_issuetracker_delete') |
|
736 | 760 | post_data = { |
|
737 | 'uid': uid, | |
|
761 | 'uid': old_uid, | |
|
738 | 762 | 'csrf_token': csrf_token |
|
739 | 763 | } |
|
740 | 764 | self.app.post(post_url, post_data, extra_environ=xhr_header, status=200) |
|
741 | 765 | settings = SettingsModel().get_all_settings() |
|
742 |
assert |
|
|
766 | assert self.PATTERN_KEY+old_uid not in settings | |
|
767 | assert self.DESC_KEY + old_uid not in settings |
@@ -174,7 +174,7 b' class SettingsModel(BaseModel):' | |||
|
174 | 174 | self, name, val=Optional(''), type_=Optional('unicode')): |
|
175 | 175 | """ |
|
176 | 176 | Creates or updates RhodeCode setting. If updates is triggered it will |
|
177 |
only update parameters that are explicit |
|
|
177 | only update parameters that are explicitly set Optional instance will | |
|
178 | 178 | be skipped |
|
179 | 179 | |
|
180 | 180 | :param name: |
@@ -267,7 +267,7 b' class SettingsModel(BaseModel):' | |||
|
267 | 267 | statsd.timing("rhodecode_settings_timing.histogram", elapsed_time_ms, |
|
268 | 268 | use_decimals=False) |
|
269 | 269 | |
|
270 | log.debug('Fetching app settings for key: %s took: %.4fs', cache_key, compute_time) | |
|
270 | log.debug('Fetching app settings for key: %s took: %.4fs: cache: %s', cache_key, compute_time, cache) | |
|
271 | 271 | |
|
272 | 272 | return result |
|
273 | 273 |
General Comments 0
You need to be logged in to leave comments.
Login now