entangled 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/bower.json +1 -1
- data/entangled.js +1 -1
- data/lib/entangled/version.rb +1 -1
- data/spec/dummy/app/controllers/lists_controller.rb +7 -0
- data/spec/dummy/app/models/list.rb +2 -0
- data/spec/dummy/db/migrate/20150316034305_drop_messages.rb +13 -0
- data/spec/dummy/db/schema.rb +1 -7
- data/spec/dummy/public/app/app.js +1 -9
- data/spec/dummy/public/app/entangled/entangled.js +2 -0
- data/spec/dummy/public/app/services/list.js +3 -3
- data/spec/dummy/public/index.html +0 -3
- data/spec/dummy/public/test/services/entangled_test.js +263 -0
- data/spec/models/list_spec.rb +107 -1
- metadata +6 -22
- data/spec/dummy/app/controllers/messages_controller.rb +0 -41
- data/spec/dummy/public/app/controllers/message.js +0 -15
- data/spec/dummy/public/app/controllers/messages.js +0 -23
- data/spec/dummy/public/app/services/message.js +0 -7
- data/spec/dummy/public/test/controllers/lists_test.js +0 -87
- data/spec/dummy/public/test/controllers/messages_test.js +0 -249
- data/spec/dummy/public/views/messages/index.html +0 -13
- data/spec/dummy/public/views/messages/show.html +0 -8
- data/spec/models/message_spec.rb +0 -135
- data/spec/routing/messages_routing_spec.rb +0 -53
@@ -1,13 +0,0 @@
|
|
1
|
-
<h1>Messages</h1>
|
2
|
-
|
3
|
-
<table>
|
4
|
-
<tr ng-repeat="message in messages">
|
5
|
-
<td><a ng-href="#/messages/{{ message.id }}">{{ message.body }}</a></td>
|
6
|
-
<td><button ng-click="destroy(message)">Delete</button></td>
|
7
|
-
</li>
|
8
|
-
</table>
|
9
|
-
|
10
|
-
<form ng-submit="create()">
|
11
|
-
<input type="text" ng-model="message.body">
|
12
|
-
<input type="submit">
|
13
|
-
</form>
|
data/spec/models/message_spec.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Message, type: :model do
|
4
|
-
describe 'Attributes' do
|
5
|
-
it { is_expected.to respond_to :body }
|
6
|
-
end
|
7
|
-
|
8
|
-
describe 'Database' do
|
9
|
-
it { is_expected.to have_db_column :body }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'Methods' do
|
13
|
-
describe '#collection_channel' do
|
14
|
-
let(:message) { Message.create(body: 'foo') }
|
15
|
-
|
16
|
-
it 'is the underscore, pluralized model name' do
|
17
|
-
expect(message.collection_channel).to eq '/messages'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#member_channel' do
|
22
|
-
let(:message) { Message.create(body: 'foo') }
|
23
|
-
|
24
|
-
it "is the collection channel plus the member as param" do
|
25
|
-
expect(message.member_channel).to eq "/messages/#{message.to_param}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#entangle' do
|
30
|
-
let(:stub_redis) do
|
31
|
-
mock("redis").tap do |redis|
|
32
|
-
redis.stubs(:publish)
|
33
|
-
Redis.stubs(:new).returns(redis)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'creation' do
|
38
|
-
let(:message) { Message.create(body: 'foo') }
|
39
|
-
|
40
|
-
it 'broadcasts the creation to the collection channel' do
|
41
|
-
redis = stub_redis
|
42
|
-
|
43
|
-
expect(redis).to have_received(:publish).with(
|
44
|
-
message.collection_channel, {
|
45
|
-
action: :create,
|
46
|
-
resource: message
|
47
|
-
}.to_json
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'broadcasts the creation to the member channel' do
|
52
|
-
redis = stub_redis
|
53
|
-
|
54
|
-
expect(redis).to have_received(:publish).with(
|
55
|
-
message.member_channel, {
|
56
|
-
action: :create,
|
57
|
-
resource: message
|
58
|
-
}.to_json
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'update' do
|
64
|
-
let!(:message) { Message.create(body: 'foo') }
|
65
|
-
|
66
|
-
it 'broadcasts the update to the collection channel' do
|
67
|
-
redis = stub_redis
|
68
|
-
|
69
|
-
message.update(body: 'bar')
|
70
|
-
|
71
|
-
expect(redis).to have_received(:publish).with(
|
72
|
-
message.collection_channel, {
|
73
|
-
action: :update,
|
74
|
-
resource: message
|
75
|
-
}.to_json
|
76
|
-
)
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'broadcasts the update to the member channel' do
|
80
|
-
redis = stub_redis
|
81
|
-
|
82
|
-
message.update(body: 'bar')
|
83
|
-
|
84
|
-
expect(redis).to have_received(:publish).with(
|
85
|
-
message.member_channel, {
|
86
|
-
action: :update,
|
87
|
-
resource: message
|
88
|
-
}.to_json
|
89
|
-
)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe 'destruction' do
|
94
|
-
let!(:message) { Message.create(body: 'foo') }
|
95
|
-
|
96
|
-
it 'broadcasts the destruction to the collection channel' do
|
97
|
-
redis = stub_redis
|
98
|
-
|
99
|
-
message.destroy
|
100
|
-
|
101
|
-
expect(redis).to have_received(:publish).with(
|
102
|
-
message.collection_channel, {
|
103
|
-
action: :destroy,
|
104
|
-
resource: message
|
105
|
-
}.to_json
|
106
|
-
)
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'broadcasts the destruction to the member channel' do
|
110
|
-
redis = stub_redis
|
111
|
-
|
112
|
-
message.destroy
|
113
|
-
|
114
|
-
expect(redis).to have_received(:publish).with(
|
115
|
-
message.member_channel, {
|
116
|
-
action: :destroy,
|
117
|
-
resource: message
|
118
|
-
}.to_json
|
119
|
-
)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '#as_json' do
|
125
|
-
it 'includes errors' do
|
126
|
-
message = Message.create
|
127
|
-
expect(message.as_json["errors"][:body]).to include "can't be blank"
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe 'Validations' do
|
133
|
-
it { is_expected.to validate_presence_of :body }
|
134
|
-
end
|
135
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe MessagesController, type: :routing do
|
4
|
-
describe '#index' do
|
5
|
-
it 'matches the messages_path' do
|
6
|
-
expect(messages_path).to eq '/messages'
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'routes to #index' do
|
10
|
-
expect(get: '/messages').to route_to 'messages#index'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#create' do
|
15
|
-
it 'matches the create_messages_path' do
|
16
|
-
expect(create_messages_path).to eq '/messages/create'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'routes to #create' do
|
20
|
-
expect(get: '/messages/create').to route_to 'messages#create'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#show' do
|
25
|
-
it 'matches the message_path' do
|
26
|
-
expect(message_path('1')).to eq '/messages/1'
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'routes to #show' do
|
30
|
-
expect(get: '/messages/1').to route_to 'messages#show', id: '1'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#destroy' do
|
35
|
-
it 'matches the destroy_message_path' do
|
36
|
-
expect(destroy_message_path('1')).to eq '/messages/1/destroy'
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'routes to #destroy' do
|
40
|
-
expect(get: '/messages/1/destroy').to route_to 'messages#destroy', id: '1'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#update' do
|
45
|
-
it 'matches the update_message_path' do
|
46
|
-
expect(update_message_path('1')).to eq '/messages/1/update'
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'routes to #update' do
|
50
|
-
expect(get: '/messages/1/update').to route_to 'messages#update', id: '1'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|