Commit 1c4523946d20537a4ee02f7ec345193fb2bb9452
1 parent
fc32f179
Exists in
stable-spb-1.5
Organization ratings: show rejected msg to admin
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com> (cherry picked from commit 0c447053371bfbc6e4e3a8fa05addc4965d53812)
Showing
3 changed files
with
42 additions
and
0 deletions
Show diff stats
plugins/organization_ratings/lib/create_organization_rating_comment.rb
@@ -14,6 +14,12 @@ class CreateOrganizationRatingComment < Task | @@ -14,6 +14,12 @@ class CreateOrganizationRatingComment < Task | ||
14 | settings_items field.to_sym | 14 | settings_items field.to_sym |
15 | end | 15 | end |
16 | 16 | ||
17 | + scope :with_rating, -> (user_rating){ | ||
18 | + CreateOrganizationRatingComment.find_each do |task| | ||
19 | + return task if(task.organization_rating_id == user_rating.id) | ||
20 | + end | ||
21 | + } | ||
22 | + | ||
17 | def perform | 23 | def perform |
18 | if (self.body && !self.body.blank?) | 24 | if (self.body && !self.body.blank?) |
19 | comment = Comment.create!(:source => self.target, :body => self.body, :author => self.requestor) | 25 | comment = Comment.create!(:source => self.target, :body => self.body, :author => self.requestor) |
plugins/organization_ratings/test/functional/organization_ratings_plugin_profile_controller_test.rb
@@ -148,6 +148,39 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas | @@ -148,6 +148,39 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas | ||
148 | 148 | ||
149 | get :new_rating, profile: @community.identifier | 149 | get :new_rating, profile: @community.identifier |
150 | assert_tag :tag => 'p', :content => /Report waiting for approval/, :attributes => {:class =>/moderation-msg/} | 150 | assert_tag :tag => 'p', :content => /Report waiting for approval/, :attributes => {:class =>/moderation-msg/} |
151 | + assert_tag :tag => 'p', :attributes => {:class =>/comment-body/} | ||
152 | + end | ||
153 | + | ||
154 | + test "display rejected comment to env admin" do | ||
155 | + post :new_rating, profile: @community.identifier, :comments => {:body => "rejected comment"}, :organization_rating_value => 3 | ||
156 | + | ||
157 | + @admin = create_admin_user(@environment) | ||
158 | + login_as @admin | ||
159 | + @controller.stubs(:current_user).returns(Profile[@admin].user) | ||
160 | + | ||
161 | + CreateOrganizationRatingComment.last.cancel | ||
162 | + | ||
163 | + get :new_rating, profile: @community.identifier | ||
164 | + assert_tag :tag => 'p', :attributes => {:class =>/comment-body/}, :content => /rejected comment/ | ||
165 | + end | ||
166 | + | ||
167 | + test "not display rejected comment to regular user" do | ||
168 | + p1 = create_user('regularUser').person | ||
169 | + @community.add_member p1 | ||
170 | + login_as(p1.identifier) | ||
171 | + @controller.stubs(:logged_in?).returns(true) | ||
172 | + @controller.stubs(:current_user).returns(p1.user) | ||
173 | + | ||
174 | + post :new_rating, profile: @community.identifier, :comments => {:body => "rejected comment"}, :organization_rating_value => 3 | ||
175 | + CreateOrganizationRatingComment.last.cancel | ||
176 | + get :new_rating, profile: @community.identifier | ||
177 | + assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} | ||
178 | + end | ||
179 | + | ||
180 | + test "not display rejected comment to community admin" do | ||
181 | + post :new_rating, profile: @community.identifier, :comments => {:body => "rejected comment"}, :organization_rating_value => 3 | ||
182 | + CreateOrganizationRatingComment.last.cancel | ||
183 | + get :new_rating, profile: @community.identifier | ||
151 | assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} | 184 | assert_no_tag :tag => 'p', :attributes => {:class =>/comment-body/} |
152 | end | 185 | end |
153 | 186 |
plugins/organization_ratings/views/shared/_user_rating_container.html.erb
@@ -29,6 +29,9 @@ | @@ -29,6 +29,9 @@ | ||
29 | <%= status_message_for(user, user_rate) %> | 29 | <%= status_message_for(user, user_rate) %> |
30 | <% if user_rate.comment.present? %> | 30 | <% if user_rate.comment.present? %> |
31 | <p class="comment-body"> <%= user_rate.comment.body %> </p> | 31 | <p class="comment-body"> <%= user_rate.comment.body %> </p> |
32 | + <% elsif user && user.is_admin? %> | ||
33 | + <% rating_task = CreateOrganizationRatingComment.with_rating(user_rate) %> | ||
34 | + <p class="comment-body"> <%= rating_task.body %> </p> | ||
32 | <% end %> | 35 | <% end %> |
33 | </div> | 36 | </div> |
34 | <%= @plugins.dispatch(:organization_ratings_plugin_container_extra_fields, user_rate).collect { |content| instance_exec(&content) }.join("") %> | 37 | <%= @plugins.dispatch(:organization_ratings_plugin_container_extra_fields, user_rate).collect { |content| instance_exec(&content) }.join("") %> |