bcms_polling 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GPL.txt +674 -0
- data/Gemfile +4 -0
- data/README.markdown +8 -11
- data/{public/bcms/polling → app/assets}/README +0 -0
- data/app/assets/javascripts/bcms_polling.js +5 -0
- data/{public/bcms/polling → app/assets/javascripts/bcms_polling}/bcms-polling.js +0 -0
- data/app/assets/stylesheets/bcms_polling/application.css +13 -0
- data/{public/bcms/polling → app/assets/stylesheets/bcms_polling}/bcms-polling.css +0 -0
- data/app/controllers/bcms_polling/polling_controller.rb +46 -0
- data/app/controllers/bcms_polling/polls_controller.rb +2 -0
- data/app/helpers/bcms_polling/application_helper.rb +4 -0
- data/app/helpers/{cms → bcms_polling}/polls_helper.rb +1 -1
- data/app/models/bcms_polling/poll.rb +38 -0
- data/app/models/bcms_polling/poll_response.rb +9 -0
- data/app/views/{polling → bcms_polling/polling}/results.html.erb +1 -1
- data/app/views/{cms → bcms_polling}/polls/_form.html.erb +1 -2
- data/app/views/{cms → bcms_polling}/polls/render.html.erb +3 -3
- data/config/routes.rb +3 -0
- data/db/bcms_polling.seeds.rb +1 -0
- data/db/migrate/20110216195733_create_polls.rb +0 -4
- data/db/migrate/20120530182315_v110.rb +8 -0
- data/lib/bcms_polling.rb +5 -1
- data/lib/bcms_polling/engine.rb +27 -0
- data/lib/bcms_polling/route_extensions.rb +13 -0
- data/lib/bcms_polling/version.rb +3 -0
- data/lib/generators/bcms_polling/install/USAGE +3 -0
- data/lib/generators/bcms_polling/install/install_generator.rb +21 -0
- data/test/bcms_polling_test.rb +7 -0
- data/test/test_helper.rb +9 -32
- data/test/unit/models/bcms_polling/poll_response_test.rb +11 -0
- data/test/unit/models/bcms_polling/poll_test.rb +52 -0
- metadata +82 -66
- data/Rakefile +0 -42
- data/VERSION +0 -1
- data/app/controllers/cms/polls_controller.rb +0 -2
- data/app/controllers/polling_controller.rb +0 -44
- data/app/models/poll.rb +0 -37
- data/app/models/poll_response.rb +0 -4
- data/doc/README_FOR_APP +0 -2
- data/lib/bcms_polling/routes.rb +0 -12
- data/rails/init.rb +0 -5
- data/test/performance/browsing_test.rb +0 -9
- data/test/unit/models/poll_response_test.rb +0 -9
- data/test/unit/models/poll_test.rb +0 -41
metadata
CHANGED
@@ -1,107 +1,123 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_polling
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 1.0.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- BrowserMedia
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-05-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: browsercms
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.6.0
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.5.0
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.6.0
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.5.0
|
22
36
|
description: Allows for user feedback via short polling questions.
|
23
37
|
email: github@browsermedia.com
|
24
38
|
executables: []
|
25
|
-
|
26
39
|
extensions: []
|
27
|
-
|
28
|
-
extra_rdoc_files:
|
29
|
-
- LICENSE.txt
|
30
|
-
- README.markdown
|
31
|
-
files:
|
32
|
-
- COPYRIGHT.txt
|
40
|
+
extra_rdoc_files:
|
33
41
|
- LICENSE.txt
|
34
42
|
- README.markdown
|
35
|
-
|
36
|
-
-
|
37
|
-
- app/
|
38
|
-
- app/
|
39
|
-
- app/
|
40
|
-
- app/
|
41
|
-
- app/
|
42
|
-
- app/
|
43
|
-
- app/
|
44
|
-
- app/
|
43
|
+
files:
|
44
|
+
- app/assets/javascripts/bcms_polling/bcms-polling.js
|
45
|
+
- app/assets/javascripts/bcms_polling.js
|
46
|
+
- app/assets/README
|
47
|
+
- app/assets/stylesheets/bcms_polling/application.css
|
48
|
+
- app/assets/stylesheets/bcms_polling/bcms-polling.css
|
49
|
+
- app/controllers/bcms_polling/polling_controller.rb
|
50
|
+
- app/controllers/bcms_polling/polls_controller.rb
|
51
|
+
- app/helpers/bcms_polling/application_helper.rb
|
52
|
+
- app/helpers/bcms_polling/polls_helper.rb
|
53
|
+
- app/models/bcms_polling/poll.rb
|
54
|
+
- app/models/bcms_polling/poll_response.rb
|
55
|
+
- app/views/bcms_polling/polling/results.html.erb
|
56
|
+
- app/views/bcms_polling/polls/_form.html.erb
|
57
|
+
- app/views/bcms_polling/polls/render.html.erb
|
58
|
+
- config/routes.rb
|
59
|
+
- db/bcms_polling.seeds.rb
|
45
60
|
- db/migrate/20110216195733_create_polls.rb
|
46
|
-
-
|
61
|
+
- db/migrate/20120530182315_v110.rb
|
62
|
+
- lib/bcms_polling/engine.rb
|
63
|
+
- lib/bcms_polling/route_extensions.rb
|
64
|
+
- lib/bcms_polling/version.rb
|
47
65
|
- lib/bcms_polling.rb
|
48
|
-
- lib/bcms_polling/
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
66
|
+
- lib/generators/bcms_polling/install/install_generator.rb
|
67
|
+
- lib/generators/bcms_polling/install/USAGE
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.markdown
|
70
|
+
- Gemfile
|
71
|
+
- COPYRIGHT.txt
|
72
|
+
- GPL.txt
|
73
|
+
- test/bcms_polling_test.rb
|
53
74
|
- test/functional/cms/poll_responses_controller_test.rb
|
54
75
|
- test/functional/cms/polls_controller_test.rb
|
55
76
|
- test/functional/poll_responses_controller_test.rb
|
56
77
|
- test/functional/polls_controller_test.rb
|
57
|
-
- test/performance/browsing_test.rb
|
58
78
|
- test/test_helper.rb
|
59
79
|
- test/unit/helpers/poll_responses_helper_test.rb
|
60
80
|
- test/unit/helpers/polls_helper_test.rb
|
61
|
-
- test/unit/models/poll_response_test.rb
|
62
|
-
- test/unit/models/poll_test.rb
|
63
|
-
has_rdoc: true
|
81
|
+
- test/unit/models/bcms_polling/poll_response_test.rb
|
82
|
+
- test/unit/models/bcms_polling/poll_test.rb
|
64
83
|
homepage: http://browsercms.org
|
65
84
|
licenses: []
|
66
|
-
|
67
85
|
post_install_message:
|
68
86
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
87
|
+
require_paths:
|
71
88
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
90
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
segments:
|
79
96
|
- 0
|
80
|
-
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
hash: 3673451308358223518
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
99
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
segments:
|
88
105
|
- 0
|
89
|
-
|
106
|
+
hash: 3673451308358223518
|
90
107
|
requirements: []
|
91
|
-
|
92
|
-
|
93
|
-
rubygems_version: 1.3.7
|
108
|
+
rubyforge_project: bcms_polling
|
109
|
+
rubygems_version: 1.8.24
|
94
110
|
signing_key:
|
95
111
|
specification_version: 3
|
96
112
|
summary: A Polling Module for BrowserCMS
|
97
|
-
test_files:
|
113
|
+
test_files:
|
114
|
+
- test/bcms_polling_test.rb
|
98
115
|
- test/functional/cms/poll_responses_controller_test.rb
|
99
116
|
- test/functional/cms/polls_controller_test.rb
|
100
117
|
- test/functional/poll_responses_controller_test.rb
|
101
118
|
- test/functional/polls_controller_test.rb
|
102
|
-
- test/performance/browsing_test.rb
|
103
119
|
- test/test_helper.rb
|
104
120
|
- test/unit/helpers/poll_responses_helper_test.rb
|
105
121
|
- test/unit/helpers/polls_helper_test.rb
|
106
|
-
- test/unit/models/poll_response_test.rb
|
107
|
-
- test/unit/models/poll_test.rb
|
122
|
+
- test/unit/models/bcms_polling/poll_response_test.rb
|
123
|
+
- test/unit/models/bcms_polling/poll_test.rb
|
data/Rakefile
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
-
|
4
|
-
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
-
|
6
|
-
require 'rake'
|
7
|
-
require 'rake/testtask'
|
8
|
-
require 'rake/rdoctask'
|
9
|
-
|
10
|
-
require 'tasks/rails'
|
11
|
-
|
12
|
-
begin
|
13
|
-
require 'jeweler'
|
14
|
-
Jeweler::Tasks.new do |gemspec|
|
15
|
-
gemspec.name = "bcms_polling"
|
16
|
-
gemspec.rubyforge_project = "browsercms"
|
17
|
-
gemspec.summary = "A Polling Module for BrowserCMS"
|
18
|
-
gemspec.email = "github@browsermedia.com"
|
19
|
-
gemspec.homepage = "http://browsercms.org"
|
20
|
-
gemspec.description = "Allows for user feedback via short polling questions."
|
21
|
-
gemspec.authors = ["BrowserMedia"]
|
22
|
-
gemspec.files = []
|
23
|
-
gemspec.files += Dir["app/**/*"]
|
24
|
-
gemspec.files -= Dir["app/views/layouts/templates/*"]
|
25
|
-
gemspec.files -= Dir["app/controllers/application_controller.rb"]
|
26
|
-
gemspec.files -= Dir["app/helpers/application_helper.rb"]
|
27
|
-
gemspec.files += Dir["doc/**/*"]
|
28
|
-
gemspec.files += Dir["db/migrate/[0-9]*.rb"].reject {|f| f =~ /_browsercms|_load_seed/ }
|
29
|
-
gemspec.files += Dir["lib/**/*"]
|
30
|
-
gemspec.files += Dir["rails/init.rb"]
|
31
|
-
gemspec.files += Dir["public/bcms/polling/**/*"]
|
32
|
-
gemspec.files += Dir["README.markdown"]
|
33
|
-
gemspec.files += Dir["Rakefile"]
|
34
|
-
gemspec.files += Dir["LICENSE.txt"]
|
35
|
-
gemspec.files += Dir["COPYRIGHT.txt"]
|
36
|
-
gemspec.files += Dir["VERSION"]
|
37
|
-
end
|
38
|
-
rescue LoadError
|
39
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
40
|
-
end
|
41
|
-
|
42
|
-
Jeweler::GemcutterTasks.new
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.3
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# Handles the public submissions of answers to poll questions.
|
2
|
-
class PollingController < ApplicationController
|
3
|
-
include Cms::PollsHelper
|
4
|
-
include Cms::Authentication::Controller
|
5
|
-
|
6
|
-
def update
|
7
|
-
@response = PollResponse.find(params[:id])
|
8
|
-
unique_key = cookie_key(@response.poll)
|
9
|
-
|
10
|
-
if !cookies[unique_key]
|
11
|
-
@response.votes += 1
|
12
|
-
@response.save!
|
13
|
-
|
14
|
-
cookies[unique_key] = {
|
15
|
-
:value => true,
|
16
|
-
:expires => 1.year.from_now
|
17
|
-
}
|
18
|
-
logger.warn "Saving cookie called '#{unique_key}'"
|
19
|
-
else
|
20
|
-
logger.warn "User attempted to submit another answer to the same poll."
|
21
|
-
end
|
22
|
-
|
23
|
-
render :nothing => true, :status => :ok
|
24
|
-
end
|
25
|
-
|
26
|
-
def results
|
27
|
-
@poll = Poll.find(params[:id])
|
28
|
-
render :layout => false
|
29
|
-
end
|
30
|
-
|
31
|
-
def reset
|
32
|
-
@poll = Poll.find(params[:id])
|
33
|
-
|
34
|
-
cookie = cookie_key(@poll)
|
35
|
-
cookies.delete(cookie)
|
36
|
-
|
37
|
-
redirect_to "/"
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def cookie_key(poll)
|
42
|
-
cookie_for(poll)
|
43
|
-
end
|
44
|
-
end
|
data/app/models/poll.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
class Poll < ActiveRecord::Base
|
2
|
-
acts_as_content_block
|
3
|
-
|
4
|
-
has_many :responses, :class_name => "PollResponse"
|
5
|
-
accepts_nested_attributes_for :responses, :allow_destroy => true
|
6
|
-
|
7
|
-
validates_presence_of :question
|
8
|
-
|
9
|
-
def total_votes
|
10
|
-
self.responses.inject(0) { |sum, r| sum += r.votes }
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
question
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
# Overridden to make sure nested attributes (i.e. poll responses) will correctly update.
|
19
|
-
def update_attributes(attributes)
|
20
|
-
unless attributes[:responses_attributes].blank?
|
21
|
-
logger.debug "Forcing update of poll so updated answers are saved."
|
22
|
-
self.updated_at = Time.now # Force this block to update, regardless of what was submitted.
|
23
|
-
|
24
|
-
else
|
25
|
-
logger.debug "No poll attributes were submitted."
|
26
|
-
end
|
27
|
-
super(attributes)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Overridden for purely debugging purposes.
|
31
|
-
def different_from_last_draft?
|
32
|
-
result = super
|
33
|
-
logger.debug "Is this poll is different than the last draft? '#{result}'"
|
34
|
-
result
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/app/models/poll_response.rb
DELETED
data/doc/README_FOR_APP
DELETED
data/lib/bcms_polling/routes.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module Cms::Routes
|
2
|
-
def routes_for_bcms_polling
|
3
|
-
|
4
|
-
poll_results '/polls/:id/results', :controller=>"polling", :action=>'results'
|
5
|
-
poll_reset '/polls/:id/reset', :controller=>"polling", :action=>'reset'
|
6
|
-
poll_response '/poll_responses/:id', :controller=>"polling", :action=>'update'
|
7
|
-
namespace(:cms) do |cms|
|
8
|
-
cms.content_blocks :poll_responses
|
9
|
-
cms.content_blocks :polls
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
data/rails/init.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '/../../test_helper')
|
2
|
-
|
3
|
-
class PollTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test "should be able to create new block" do
|
6
|
-
assert Poll.create!(:question=>"A?")
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
test "Should have responses" do
|
11
|
-
p = Poll.create!(:question=>"What color?")
|
12
|
-
|
13
|
-
p.responses << PollResponse.create!(:answer=>"Red")
|
14
|
-
p.responses << PollResponse.create!(:answer=>"Blue")
|
15
|
-
|
16
|
-
found = Poll.find(p.id)
|
17
|
-
assert_equal 2, p.responses.size
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
test "Should have responses unpublished" do
|
22
|
-
p = Poll.create!(:question=>"What color?")
|
23
|
-
|
24
|
-
p.responses << PollResponse.create!(:answer=>"Red")
|
25
|
-
p.responses << PollResponse.create!(:answer=>"Blue")
|
26
|
-
|
27
|
-
found = Poll.find(p.id)
|
28
|
-
found = found.as_of_draft_version
|
29
|
-
assert_equal 2, p.responses.size
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
test "Binding responses as nested attributes for new object" do
|
34
|
-
poll = Poll.create!(:question=>"Are you different?")
|
35
|
-
poll.update_attributes({ :responses_attributes=>{"0"=>{"answer"=>"Answer 1"}}})
|
36
|
-
assert_equal 1, poll.responses.size
|
37
|
-
assert_equal 1, PollResponse.count
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|