Commit de7aba86b443e86345347d89c135f1a2233be17c
1 parent
1c125da7
Exists in
master
and in
29 other branches
small fixes on chat
* removing one level of includes in apache conf * be verbose about apache config update * chat_message should not be created without "from" or "to" * the database table indexes is "from_id / to_id" not "from / to"
Showing
7 changed files
with
14 additions
and
19 deletions
Show diff stats
app/models/chat_message.rb
db/migrate/20141014205254_create_chat_messages.rb
1 | 1 | class CreateChatMessages < ActiveRecord::Migration |
2 | 2 | def up |
3 | 3 | create_table :chat_messages do |t| |
4 | - t.references :from | |
5 | - t.references :to | |
4 | + t.references :from, :null => false | |
5 | + t.references :to, :null => false | |
6 | 6 | t.text :body |
7 | 7 | t.timestamps |
8 | 8 | end |
... | ... | @@ -12,9 +12,9 @@ class CreateChatMessages < ActiveRecord::Migration |
12 | 12 | end |
13 | 13 | |
14 | 14 | def down |
15 | - drop_table :chat_messages | |
16 | - remove_index :chat_messages, :from | |
17 | - remove_index :chat_messages, :to | |
15 | + remove_index :chat_messages, :from_id | |
16 | + remove_index :chat_messages, :to_id | |
18 | 17 | remove_index :chat_messages, :created_at |
18 | + drop_table :chat_messages | |
19 | 19 | end |
20 | 20 | end | ... | ... |
db/schema.rb
... | ... | @@ -245,8 +245,8 @@ ActiveRecord::Schema.define(:version => 20150513213939) do |
245 | 245 | end |
246 | 246 | |
247 | 247 | create_table "chat_messages", :force => true do |t| |
248 | - t.integer "from_id" | |
249 | - t.integer "to_id" | |
248 | + t.integer "from_id", :null => false | |
249 | + t.integer "to_id", :null => false | |
250 | 250 | t.text "body" |
251 | 251 | t.datetime "created_at", :null => false |
252 | 252 | t.datetime "updated_at", :null => false | ... | ... |
debian/noosfero.install
debian/update-noosfero-apache
... | ... | @@ -18,18 +18,14 @@ if test -x /usr/share/noosfero/script/apacheconf; then |
18 | 18 | fi |
19 | 19 | |
20 | 20 | apache_site='/etc/apache2/sites-available/noosfero' |
21 | - apache_site_configs='/etc/noosfero/apache.d' | |
22 | 21 | if ! test -e "$apache_site"; then |
23 | 22 | echo "Generating apache virtual host ..." |
24 | 23 | cd /usr/share/noosfero && su noosfero -c "RAILS_ENV=production ./script/apacheconf virtualhosts" > "$apache_site" |
25 | - if ! test -d "$apache_site_configs"; then | |
26 | - echo "Creating noosfero site config folder ..." | |
27 | - mkdir $apache_site_configs | |
28 | - fi | |
29 | 24 | else |
30 | 25 | pattern="Include \/etc\/noosfero\/apache\/virtualhost.conf" |
31 | - include="Include \/etc\/noosfero\/apache.d\/*" | |
26 | + include="Include \/usr\/share\/noosfero\/util\/chat\/apache\/xmpp.conf" | |
32 | 27 | if ! cat $apache_site | grep "^ *$include" > /dev/null ; then |
28 | + echo "Updating apache virtual host ..." | |
33 | 29 | sed -i "s/.*$pattern.*/ $include\n&/" $apache_site |
34 | 30 | fi |
35 | 31 | fi | ... | ... |
etc/noosfero/apache.d/noosfero-chat
test/functional/chat_controller_test.rb
... | ... | @@ -100,7 +100,7 @@ class ChatControllerTest < ActionController::TestCase |
100 | 100 | @request.stubs(:xhr?).returns(true) |
101 | 101 | |
102 | 102 | post :save_message, {:body =>'Hello!'} |
103 | - assert ActiveSupport::JSON.decode(@response.body)['status'] == 1 | |
103 | + assert_equal 3, ActiveSupport::JSON.decode(@response.body)['status'] | |
104 | 104 | end |
105 | 105 | |
106 | 106 | should 'forbid to register a message without body' do |
... | ... | @@ -108,7 +108,7 @@ class ChatControllerTest < ActionController::TestCase |
108 | 108 | @request.stubs(:xhr?).returns(true) |
109 | 109 | |
110 | 110 | post :save_message, {:to =>'mary'} |
111 | - assert ActiveSupport::JSON.decode(@response.body)['status'] == 1 | |
111 | + assert_equal 3, ActiveSupport::JSON.decode(@response.body)['status'] | |
112 | 112 | end |
113 | 113 | |
114 | 114 | should 'forbid user to register a message to a stranger' do |
... | ... | @@ -116,7 +116,7 @@ class ChatControllerTest < ActionController::TestCase |
116 | 116 | @request.stubs(:xhr?).returns(true) |
117 | 117 | |
118 | 118 | post :save_message, {:to =>'random', :body => 'Hello, stranger!'} |
119 | - assert ActiveSupport::JSON.decode(@response.body)['status'] == 2 | |
119 | + assert_equal 3, ActiveSupport::JSON.decode(@response.body)['status'] | |
120 | 120 | end |
121 | 121 | |
122 | 122 | should 'register a message to a friend' do | ... | ... |