Commit 3018162d6165536bf2f2c4a61c142f6b0e24d3a5
Exists in
web_steps_improvements
and in
9 other branches
Merge branch 'newsletter-search-all-profiles' into 'master'
newsletter: search blogs also by profile's names We already allow the admin to choose any blog in the environment to feed the newsletter, however it's only possible to search a blog by its name or community's name. With this patch the admin can search for a blog either by its name or the name of the profile the blog belongs to. See merge request !706
Showing
5 changed files
with
61 additions
and
20 deletions
Show diff stats
plugins/newsletter/controllers/newsletter_plugin_admin_controller.rb
| ... | ... | @@ -30,14 +30,14 @@ class NewsletterPluginAdminController < PluginAdminController |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | #TODO: Make this query faster |
| 33 | - def search_communities | |
| 34 | - communities = environment.communities | |
| 33 | + def search_profiles | |
| 34 | + profiles = environment.profiles | |
| 35 | 35 | blogs = Blog.joins(:profile).where(profiles: {environment_id: environment.id}) |
| 36 | 36 | |
| 37 | - found_communities = find_by_contents(:communities, environment, communities, params['q'], {:page => 1})[:results] | |
| 37 | + found_profiles = find_by_contents(:profiles, environment, profiles, params['q'], {:page => 1})[:results] | |
| 38 | 38 | found_blogs = find_by_contents(:blogs, environment, blogs, params['q'], {:page => 1})[:results] |
| 39 | 39 | |
| 40 | - results = (found_blogs + found_communities.map(&:blogs).flatten).uniq | |
| 40 | + results = (found_blogs + found_profiles.map(&:blogs).flatten).uniq | |
| 41 | 41 | render :text => results.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} }.to_json |
| 42 | 42 | end |
| 43 | 43 | ... | ... |
plugins/newsletter/features/newsletter_plugin.feature
| 1 | 1 | Feature: newsletter plugin |
| 2 | 2 | |
| 3 | 3 | Background: |
| 4 | - Given the following users | |
| 5 | - | login | name | | |
| 6 | - | joaosilva | Joao Silva | | |
| 7 | - And I am logged in as "joaosilva" | |
| 4 | + Given I am logged in as admin | |
| 8 | 5 | |
| 9 | 6 | Scenario: as admin I can configure plugin |
| 10 | - Given I am logged in as admin | |
| 11 | 7 | When I go to the environment control panel |
| 12 | 8 | And I follow "Plugins" |
| 13 | 9 | Then I should see "Configuration" linking to "/admin/plugin/newsletter" |
| 14 | 10 | |
| 15 | 11 | Scenario: in the newsletter settings I can see the field to enable/disable |
| 16 | - Given I am logged in as admin | |
| 17 | 12 | When I go to the environment control panel |
| 18 | 13 | And I follow "Plugins" |
| 19 | 14 | And I follow "Configuration" |
| 20 | 15 | Then I should see "Enable send of newsletter to members on this environment" |
| 21 | 16 | |
| 22 | 17 | Scenario: redirect to newsletter visualization after save and visualize |
| 23 | - Given I am logged in as admin | |
| 24 | - And "NewsletterPlugin" plugin is enabled | |
| 18 | + Given "NewsletterPlugin" plugin is enabled | |
| 25 | 19 | When I go to the environment control panel |
| 26 | 20 | And I follow "Plugins" |
| 27 | 21 | And I follow "Configuration" |
| ... | ... | @@ -30,11 +24,58 @@ Feature: newsletter plugin |
| 30 | 24 | And I should not see "Newsletter settings" |
| 31 | 25 | |
| 32 | 26 | Scenario: stay on newsletter settings page after save |
| 33 | - Given I am logged in as admin | |
| 34 | - And "NewsletterPlugin" plugin is enabled | |
| 27 | + Given "NewsletterPlugin" plugin is enabled | |
| 35 | 28 | When I go to the environment control panel |
| 36 | 29 | And I follow "Plugins" |
| 37 | 30 | And I follow "Configuration" |
| 38 | 31 | And I press "Save" |
| 39 | 32 | Then I should see "Newsletter settings" |
| 40 | 33 | And I should not see "If you can't view this email, click here" |
| 34 | + | |
| 35 | + @selenium | |
| 36 | + Scenario: search community and select blog for newsletter | |
| 37 | + Given the following communities | |
| 38 | + | identifier | name | | |
| 39 | + | sample-community | Sample Community | | |
| 40 | + And the following blogs | |
| 41 | + | owner | name | | |
| 42 | + | sample-community | Sample Blog | | |
| 43 | + And "NewsletterPlugin" plugin is enabled | |
| 44 | + When I go to the environment control panel | |
| 45 | + And I follow "Plugins" | |
| 46 | + And I follow "Configuration" | |
| 47 | + And I type in "Sample Community" into autocomplete list "search-profiles" and I choose "Sample Blog in Sample Community" | |
| 48 | + And I press "Save" | |
| 49 | + Then I should see "Sample Blog in Sample Community" | |
| 50 | + | |
| 51 | + @selenium | |
| 52 | + Scenario: search profile and select blog for newsletter | |
| 53 | + Given the following users | |
| 54 | + | login | name | | |
| 55 | + | joaosilva | Joao Silva | | |
| 56 | + And the following blogs | |
| 57 | + | owner | name | | |
| 58 | + | joaosilva | Joao Blog | | |
| 59 | + And "NewsletterPlugin" plugin is enabled | |
| 60 | + When I go to the environment control panel | |
| 61 | + And I follow "Plugins" | |
| 62 | + And I follow "Configuration" | |
| 63 | + And I type in "Silva" into autocomplete list "search-profiles" and I choose "Joao Blog in Joao Silva" | |
| 64 | + And I press "Save" | |
| 65 | + Then I should see "Joao Blog in Joao Silva" | |
| 66 | + | |
| 67 | + @selenium | |
| 68 | + Scenario: search blog and select it for newsletter | |
| 69 | + Given the following communities | |
| 70 | + | identifier | name | | |
| 71 | + | sample-community | Sample Community | | |
| 72 | + And the following blogs | |
| 73 | + | owner | name | | |
| 74 | + | sample-community | Sample Blog | | |
| 75 | + And "NewsletterPlugin" plugin is enabled | |
| 76 | + When I go to the environment control panel | |
| 77 | + And I follow "Plugins" | |
| 78 | + And I follow "Configuration" | |
| 79 | + And I type in "Sample Blog" into autocomplete list "search-profiles" and I choose "Sample Blog in Sample Community" | |
| 80 | + And I press "Save" | |
| 81 | + Then I should see "Sample Blog in Sample Community" | ... | ... |
plugins/newsletter/po/newsletter.pot
| ... | ... | @@ -158,7 +158,7 @@ msgid "Blogs from which news will be compiled" |
| 158 | 158 | msgstr "" |
| 159 | 159 | |
| 160 | 160 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36 |
| 161 | -msgid "Type in the communities' or blogs' names" | |
| 161 | +msgid "Type in the profiles' or blogs' names" | |
| 162 | 162 | msgstr "" |
| 163 | 163 | |
| 164 | 164 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42 | ... | ... |
plugins/newsletter/po/pt/newsletter.po
| ... | ... | @@ -164,8 +164,8 @@ msgid "Blogs from which news will be compiled" |
| 164 | 164 | msgstr "Blogs utilizados como fonte do boletim informativo" |
| 165 | 165 | |
| 166 | 166 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36 |
| 167 | -msgid "Type in the communities' or blogs' names" | |
| 168 | -msgstr "Digite nomes de comunidades ou blogs" | |
| 167 | +msgid "Type in the profiles' or blogs' names" | |
| 168 | +msgstr "Digite nomes de perfis ou blogs" | |
| 169 | 169 | |
| 170 | 170 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42 |
| 171 | 171 | msgid "Recipients" | ... | ... |
plugins/newsletter/views/newsletter_plugin_admin/index.html.erb
| ... | ... | @@ -29,11 +29,11 @@ |
| 29 | 29 | %> |
| 30 | 30 | |
| 31 | 31 | <p><%= _('Blogs from which news will be compiled') %></p> |
| 32 | - <% search_action = url_for(:action => 'search_communities') %> | |
| 32 | + <% search_action = url_for(:action => 'search_profiles') %> | |
| 33 | 33 | <% selected_blogs = @blogs.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} } %> |
| 34 | 34 | <%= token_input_field_tag( |
| 35 | - 'newsletter[blog_ids]', 'search-communities', search_action, | |
| 36 | - { hint_text: _('Type in the communities\' or blogs\' names'), | |
| 35 | + 'newsletter[blog_ids]', 'search-profiles', search_action, | |
| 36 | + { hint_text: _('Type in the profiles\' or blogs\' names'), | |
| 37 | 37 | focus: false, pre_populate: selected_blogs }) %> |
| 38 | 38 | |
| 39 | 39 | <br/> | ... | ... |