[openstreetmap/openstreetmap-website] Diary entry comment subscriptions (#1309)

Tom Hughes notifications at github.com
Tue Oct 11 20:39:10 UTC 2016


tomhughes requested changes on this pull request.

This is pretty close to being ready to merge I think - just a few minor things to look at first.

> @@ -21,6 +21,11 @@
     <%= richtext_area :diary_comment, :body, :cols => 80, :rows => 15 %>
     <%= submit_tag t('diary_entry.view.save_button') %>
   <% end %>
+  <% if @user and @entry.subscribers and @entry.subscribers.exists?(@user.id) %>

There isn't really any need to check `@entry.subscribers` here as it will always be non-nil as it is an association so will be an association proxy object.

> @@ -0,0 +1,11 @@
+class AddJoinTableBetweenUsersAndDiaryEntries < ActiveRecord::Migration
+  def change
+    create_table :diary_entry_subscriptions, :id => false do |t|
+      t.column :user_id, :bigint, :null => false
+      t.column :diary_entry_id, :bigint, :null => false
+    end
+
+    add_index :diary_entry_subscriptions, [:user_id, :diary_entry_id], :unique => true, :name => "index_diary_subscriptions_on_user_id_and_diary_entry_id"

Can we make this `add_primary_key` please and drop the unique and name options. Also we should add the foreign keys - I think this is right:

```
add_foreign_key :diary_entry_subscriptions, :diary_entries, :name => "diary_entry_subscriptions_diary_entry_id_fkey"
add_foreign_key :diary_entry_subscriptions, :users, :name => "diary_entry_subscriptions_user_id_fkey"
```

> @@ -641,6 +662,64 @@ def test_comments
     assert_response :not_found
   end
 
+  def test_subscribe_success
+    diary_entry = create(:diary_entry, :user_id => users(:normal_user).id)
+
+    assert_difference "diary_entry.subscribers.count", 1 do
+      post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => users(:public_user).id }
+    end
+    assert_response :redirect
+  end
+
+  def test_subscribe_fail
+    diary_entry = create(:diary_entry, :user_id => users(:normal_user).id)
+
+    # not signed in
+    assert_no_difference "diary_entry.subscribers.count", 1 do

I don't think `assert_no_difference` takes a second argument does it?

> @@ -1118,8 +1118,8 @@ en:
       paragraph_1_html: |
         OpenStreetMap has few formal rules but we expect all participants to collaborate
         with, and communicate with, the community. If you are considering
-        any activities other than editing by hand, please read and follow the guidelines on 
-        <a href='http://wiki.openstreetmap.org/wiki/Import/Guidelines'>Imports</a> and 
+        any activities other than editing by hand, please read and follow the guidelines on

Can we drop these trailing whitespace changes please...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/1309#pullrequestreview-3756978
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20161011/bbf37b52/attachment.html>


More information about the rails-dev mailing list