enju_question 0.1.1 → 0.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -3
- data/app/controllers/answers_controller.rb +13 -8
- data/app/controllers/concerns/enju_question/controller.rb +10 -0
- data/app/controllers/questions_controller.rb +12 -6
- data/app/models/concerns/enju_question/enju_item.rb +10 -0
- data/app/models/concerns/enju_question/enju_manifestation.rb +23 -0
- data/app/models/concerns/enju_question/enju_user.rb +18 -0
- data/app/policies/answer_policy.rb +43 -0
- data/app/policies/question_policy.rb +43 -0
- data/app/views/answers/index.html.erb +3 -1
- data/app/views/answers/index.rss.builder +1 -1
- data/app/views/answers/show.html.erb +1 -1
- data/app/views/questions/_index.html.erb +1 -1
- data/app/views/questions/_list.html.erb +5 -5
- data/app/views/questions/_solved_facet.html.erb +2 -2
- data/app/views/questions/show.html.erb +1 -1
- data/lib/enju_question.rb +0 -26
- data/lib/enju_question/version.rb +1 -1
- data/lib/generators/enju_question/setup/setup_generator.rb +16 -2
- data/spec/controllers/answers_controller_spec.rb +9 -6
- data/spec/controllers/questions_controller_spec.rb +3 -3
- data/spec/dummy/app/controllers/application_controller.rb +7 -3
- data/spec/dummy/app/models/user.rb +2 -3
- data/spec/dummy/config/application.rb +5 -24
- data/spec/dummy/config/environments/development.rb +22 -18
- data/spec/dummy/config/environments/production.rb +46 -34
- data/spec/dummy/config/environments/test.rb +21 -14
- data/spec/dummy/config/initializers/enju_leaf.rb +2 -0
- data/spec/support/devise.rb +2 -2
- data/spec/views/questions/index.rss.builder_spec.rb +0 -3
- metadata +64 -20
- data/app/models/enju_question/ability.rb +0 -44
- data/lib/enju_question/item.rb +0 -14
- data/lib/enju_question/manifestation.rb +0 -33
- data/lib/enju_question/user.rb +0 -25
- data/spec/dummy/config/application.yml +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8c50fbc3dbbf2769dc61f5bdf8a351f6d09c9b6
|
4
|
+
data.tar.gz: 09696786aa59405978fd1a418361c4e290708afc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 661ebfda2216670479e3d015d31380c29770498725dd35d40456770fd8057e52313de3a914206ae78abd2bf19444cee6efa37627968f70e31605e93a9d1e0938
|
7
|
+
data.tar.gz: 6f05e23fbc850c192f48a833fab195496e67e22470ad574912220351e9b93315bc5d7e78aa1379000aec0fb07da7c2a02e1bab506b065ea4e8eb875fa6eac723
|
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= EnjuQuestion
|
2
|
-
{<img src="https://travis-ci.org/next-l/enju_question.svg?branch=1.
|
3
|
-
{<img src="https://coveralls.io/repos/next-l/enju_question/badge.svg?branch=1.
|
4
|
-
{<img src="https://hakiri.io/github/next-l/enju_question/1.
|
2
|
+
{<img src="https://travis-ci.org/next-l/enju_question.svg?branch=1.2" alt="Build Status" />}[https://travis-ci.org/next-l/enju_question]
|
3
|
+
{<img src="https://coveralls.io/repos/next-l/enju_question/badge.svg?branch=1.2&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_question?branch=1.2]
|
4
|
+
{<img src="https://hakiri.io/github/next-l/enju_question/1.2.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_question/1.2]
|
5
5
|
|
6
6
|
This project rocks and uses MIT-LICENSE.
|
7
7
|
|
@@ -1,10 +1,8 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
class AnswersController < ApplicationController
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
before_filter :get_question
|
2
|
+
before_action :set_answer, only: [:show, :edit, :update, :destroy]
|
3
|
+
before_action :check_policy, only: [:index, :new, :create]
|
4
|
+
before_action :get_user, except: [:edit]
|
5
|
+
before_action :get_question
|
8
6
|
|
9
7
|
# GET /answers
|
10
8
|
# GET /answers.json
|
@@ -103,11 +101,9 @@ class AnswersController < ApplicationController
|
|
103
101
|
flash[:notice] = t('controller.successfully_created', model: t('activerecord.models.answer'))
|
104
102
|
format.html { redirect_to @answer }
|
105
103
|
format.json { render json: @answer, status: :created, location: answer_url(@answer) }
|
106
|
-
format.mobile { redirect_to question_url(@answer.question) }
|
107
104
|
else
|
108
105
|
format.html { render action: "new" }
|
109
106
|
format.json { render json: @answer.errors, status: :unprocessable_entity }
|
110
|
-
format.mobile { render action: "new" }
|
111
107
|
end
|
112
108
|
end
|
113
109
|
end
|
@@ -139,6 +135,15 @@ class AnswersController < ApplicationController
|
|
139
135
|
end
|
140
136
|
|
141
137
|
private
|
138
|
+
def set_answer
|
139
|
+
@answer = Answer.find(params[:id])
|
140
|
+
authorize @answer
|
141
|
+
end
|
142
|
+
|
143
|
+
def check_policy
|
144
|
+
authorize Answer
|
145
|
+
end
|
146
|
+
|
142
147
|
def answer_params
|
143
148
|
params.require(:answer).permit(
|
144
149
|
:question_id, :body, :item_identifier_list, :url_list
|
@@ -1,14 +1,11 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
class QuestionsController < ApplicationController
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
after_filter :solr_commit, only: [:create, :update, :destroy]
|
2
|
+
before_action :set_question, only: [:show, :edit, :update, :destroy]
|
3
|
+
before_action :check_policy, only: [:index, :new, :create]
|
4
|
+
before_action :get_user, except: [:edit]
|
7
5
|
|
8
6
|
# GET /questions
|
9
7
|
# GET /questions.json
|
10
8
|
def index
|
11
|
-
store_location
|
12
9
|
if @user and user_signed_in?
|
13
10
|
user = @user
|
14
11
|
end
|
@@ -171,6 +168,15 @@ class QuestionsController < ApplicationController
|
|
171
168
|
end
|
172
169
|
|
173
170
|
private
|
171
|
+
def set_question
|
172
|
+
@question = Question.find(params[:id])
|
173
|
+
authorize @question
|
174
|
+
end
|
175
|
+
|
176
|
+
def check_policy
|
177
|
+
authorize Question
|
178
|
+
end
|
179
|
+
|
174
180
|
def question_params
|
175
181
|
params.require(:question).permit(:body, :shared, :solved, :note)
|
176
182
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module EnjuQuestion
|
2
|
+
module EnjuManifestation
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def questions(options = {})
|
6
|
+
id = self.id
|
7
|
+
options = {page: 1, per_page: Question.default_per_page}.merge(options)
|
8
|
+
page = options[:page]
|
9
|
+
per_page = options[:per_page]
|
10
|
+
user = options[:user]
|
11
|
+
Question.search do
|
12
|
+
with(:manifestation_id).equal_to id
|
13
|
+
any_of do
|
14
|
+
unless user.try(:has_role?, 'Librarian')
|
15
|
+
with(:shared).equal_to true
|
16
|
+
# with(:username).equal_to user.try(:username)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
paginate page: page, per_page: per_page
|
20
|
+
end.results
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EnjuQuestion
|
2
|
+
module EnjuUser
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_many :questions
|
7
|
+
has_many :answers
|
8
|
+
end
|
9
|
+
|
10
|
+
def reset_answer_feed_token
|
11
|
+
self.answer_feed_token = Devise.friendly_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete_answer_feed_token
|
15
|
+
self.answer_feed_token = nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class AnswerPolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
case user.try(:role).try(:name)
|
8
|
+
when 'Administrator'
|
9
|
+
true
|
10
|
+
when 'Librarian'
|
11
|
+
true
|
12
|
+
when 'User'
|
13
|
+
if record.user == user
|
14
|
+
true
|
15
|
+
elsif record.question.shared?
|
16
|
+
true
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
else
|
21
|
+
true if record.question.shared?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def create?
|
26
|
+
user.try(:has_role?, 'User')
|
27
|
+
end
|
28
|
+
|
29
|
+
def update?
|
30
|
+
case user.try(:role).try(:name)
|
31
|
+
when 'Administrator'
|
32
|
+
true
|
33
|
+
when 'Librarian'
|
34
|
+
true
|
35
|
+
when 'User'
|
36
|
+
true if record.user == user
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy?
|
41
|
+
update?
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class QuestionPolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
case user.try(:role).try(:name)
|
8
|
+
when 'Administrator'
|
9
|
+
true
|
10
|
+
when 'Librarian'
|
11
|
+
true
|
12
|
+
when 'User'
|
13
|
+
if record.user == user
|
14
|
+
true
|
15
|
+
elsif record.shared?
|
16
|
+
true
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
else
|
21
|
+
true if record.shared?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def create?
|
26
|
+
user.try(:has_role?, 'User')
|
27
|
+
end
|
28
|
+
|
29
|
+
def update?
|
30
|
+
case user.try(:role).try(:name)
|
31
|
+
when 'Administrator'
|
32
|
+
true
|
33
|
+
when 'Librarian'
|
34
|
+
true
|
35
|
+
when 'User'
|
36
|
+
true if record.user == user
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy?
|
41
|
+
update?
|
42
|
+
end
|
43
|
+
end
|
@@ -22,8 +22,10 @@
|
|
22
22
|
<td><%= l(answer.created_at) -%></td>
|
23
23
|
<td><%= l(answer.updated_at) -%></td>
|
24
24
|
<td>
|
25
|
-
<%- if
|
25
|
+
<%- if policy(answer).update? -%>
|
26
26
|
<%= link_to t('page.edit'), edit_answer_path(answer) -%>
|
27
|
+
<%- end -%>
|
28
|
+
<%- if policy(answer).destroy? -%>
|
27
29
|
<%= link_to t('page.destroy'), answer, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
|
28
30
|
<%- end -%>
|
29
31
|
</td>
|
@@ -8,7 +8,7 @@ xml.rss('version' => "2.0",
|
|
8
8
|
xml.description "Next-L Enju, an open source integrated library system developed by Project Next-L"
|
9
9
|
xml.language @locale.to_s
|
10
10
|
xml.ttl "60"
|
11
|
-
xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.merge(format: :rss, only_path: true))}"
|
11
|
+
xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.permit.merge(format: :rss, only_path: true))}"
|
12
12
|
xml.tag! "atom:link", rel: 'alternate', href: "#{request.protocol}#{request.host_with_port}"
|
13
13
|
#xml.tag! "atom:link", rel: 'search', :type => 'application/opensearchdescription+xml', href: "http://#{request.host_with_port}/page/opensearch"
|
14
14
|
unless params[:query].blank?
|
@@ -47,7 +47,7 @@
|
|
47
47
|
|
48
48
|
<div id="submenu" class="ui-corner-all ui-widget-content">
|
49
49
|
<ul>
|
50
|
-
<%- if
|
50
|
+
<%- if policy(@answer).update? -%>
|
51
51
|
<li><%= link_to t('page.edit'), edit_answer_path(@answer) -%></li>
|
52
52
|
<%- end -%>
|
53
53
|
<li><%= link_to t('page.back'), question_answers_path(@answer.question) -%></li>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<div id="submenu" class="ui-corner-all ui-widget-content">
|
17
17
|
<%= render 'solved_facet' -%>
|
18
18
|
<ul>
|
19
|
-
<%- if
|
19
|
+
<%- if policy(Question).create? -%>
|
20
20
|
<li><%= link_to t('question.my'), user_questions_path(current_user) -%></li>
|
21
21
|
<li><%= link_to t('page.new', model: t('activerecord.models.question')), new_question_path -%></li>
|
22
22
|
<%- end -%>
|
@@ -4,17 +4,17 @@
|
|
4
4
|
<%- if params[:sort_by].blank? -%>
|
5
5
|
<strong><%= t('question.last_answered_at') -%></strong>
|
6
6
|
<%- else -%>
|
7
|
-
<%= link_to t('question.last_answered_at'), url_for(params.merge(sort_by: nil, only_path: true)) -%>
|
7
|
+
<%= link_to t('question.last_answered_at'), url_for(params.permit.merge(sort_by: nil, only_path: true)) -%>
|
8
8
|
<%- end -%>
|
9
9
|
<%- if params[:sort_by] == 'created_at' -%>
|
10
10
|
<strong><%= t('question.created_at') -%></strong>
|
11
11
|
<%- else -%>
|
12
|
-
<%= link_to t('question.created_at'), url_for(params.merge(sort_by: 'created_at', only_path: true)) -%>
|
12
|
+
<%= link_to t('question.created_at'), url_for(params.permit.merge(sort_by: 'created_at', only_path: true)) -%>
|
13
13
|
<%- end -%>
|
14
14
|
<%- if params[:sort_by] == 'answers_count' -%>
|
15
15
|
<strong><%= t('activerecord.attributes.question.answers_count') -%></strong>
|
16
16
|
<%- else -%>
|
17
|
-
<%= link_to t('activerecord.attributes.question.answers_count'), url_for(params.merge(sort_by: 'answers_count', only_path: true)) -%>
|
17
|
+
<%= link_to t('activerecord.attributes.question.answers_count'), url_for(params.permit.merge(sort_by: 'answers_count', only_path: true)) -%>
|
18
18
|
<%- end -%>
|
19
19
|
</p>
|
20
20
|
|
@@ -50,10 +50,10 @@
|
|
50
50
|
<% end %>
|
51
51
|
</td>
|
52
52
|
<td>
|
53
|
-
<%- if
|
53
|
+
<%- if policy(question).update? -%>
|
54
54
|
<%= link_to t('page.edit'), edit_question_path(question) -%>
|
55
55
|
<% end %>
|
56
|
-
<%- if
|
56
|
+
<%- if policy(question).destroy? -%>
|
57
57
|
<%= link_to t('page.destroy'), question, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
|
58
58
|
<%- end -%>
|
59
59
|
</td>
|
@@ -4,12 +4,12 @@
|
|
4
4
|
<% facet.value ? facet_solved = true : facet_solved = false %>
|
5
5
|
<li>
|
6
6
|
<%- if @solved == facet_solved -%><strong><%- end -%>
|
7
|
-
<%= link_to localized_boolean(facet.value), url_for(params.merge(page: nil, :solved => facet.value.to_s, view: nil, only_path: true)) -%>
|
7
|
+
<%= link_to localized_boolean(facet.value), url_for(params.permit.merge(page: nil, :solved => facet.value.to_s, view: nil, only_path: true)) -%>
|
8
8
|
(<%= facet.count -%>)
|
9
9
|
<%- if @solved == facet_solved -%></strong><%- end -%>
|
10
10
|
</li>
|
11
11
|
<%- end -%>
|
12
12
|
<%- if @solved -%>
|
13
|
-
<li><%= link_to t('page.remove_this_facet'), url_for(params.merge(solved: nil, page: nil, view: nil, only_path: true)) -%></li>
|
13
|
+
<li><%= link_to t('page.remove_this_facet'), url_for(params.permit.merge(solved: nil, page: nil, view: nil, only_path: true)) -%></li>
|
14
14
|
<%- end -%>
|
15
15
|
</ul>
|
@@ -53,7 +53,7 @@
|
|
53
53
|
<div id="submenu" class="ui-corner-all ui-widget-content">
|
54
54
|
<ul>
|
55
55
|
<li><%= link_to t('question.answer_question'), new_question_answer_path(@question) -%></li>
|
56
|
-
<%- if
|
56
|
+
<%- if policy(@question).update? -%>
|
57
57
|
<li><%= link_to t('page.edit'), edit_question_path(@question) -%></li>
|
58
58
|
<%- end -%>
|
59
59
|
<li><%= back_to_index(flash[:page_info]) -%></li>
|
data/lib/enju_question.rb
CHANGED
@@ -1,31 +1,5 @@
|
|
1
1
|
require "enju_question/engine"
|
2
|
-
require "enju_question/user"
|
3
|
-
require "enju_question/manifestation"
|
4
|
-
require "enju_question/item"
|
5
2
|
require "timeout"
|
6
3
|
|
7
4
|
module EnjuQuestion
|
8
|
-
def self.included(base)
|
9
|
-
base.extend(ClassMethods)
|
10
|
-
end
|
11
|
-
|
12
|
-
module ClassMethods
|
13
|
-
def enju_question
|
14
|
-
include EnjuQuestion::InstanceMethods
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module InstanceMethods
|
19
|
-
private
|
20
|
-
|
21
|
-
def get_question
|
22
|
-
@question = Question.find(params[:question_id]) if params[:question_id]
|
23
|
-
authorize! :show, @question if @question
|
24
|
-
end
|
25
|
-
end
|
26
5
|
end
|
27
|
-
|
28
|
-
ActionController::Base.send(:include, EnjuQuestion)
|
29
|
-
ActiveRecord::Base.send :include, EnjuQuestion::QuestionUser
|
30
|
-
ActiveRecord::Base.send :include, EnjuQuestion::QuestionManifestation
|
31
|
-
ActiveRecord::Base.send :include, EnjuQuestion::QuestionItem
|
@@ -3,7 +3,21 @@ class EnjuQuestion::SetupGenerator < Rails::Generators::Base
|
|
3
3
|
|
4
4
|
def setup
|
5
5
|
rake("enju_question_engine:install:migrations")
|
6
|
-
|
7
|
-
"
|
6
|
+
inject_into_class "app/models/user.rb", User do
|
7
|
+
<<"EOS"
|
8
|
+
include EnjuQuestion::EnjuUser
|
9
|
+
EOS
|
10
|
+
end
|
11
|
+
inject_into_class "app/controllers/application.rb", User do
|
12
|
+
<<"EOS"
|
13
|
+
include EnjuQuestion::Controller
|
14
|
+
EOS
|
15
|
+
end
|
16
|
+
append_to_file("config/initializers/enju_leaf.rb") do
|
17
|
+
<<"EOS"
|
18
|
+
Manifestation.include(EnjuQuestion::EnjuManifestation)
|
19
|
+
Item.include(EnjuQuestion::EnjuItem)
|
20
|
+
EOS
|
21
|
+
end
|
8
22
|
end
|
9
23
|
end
|
@@ -189,7 +189,8 @@ describe AnswersController do
|
|
189
189
|
|
190
190
|
it "assigns the requested answer as @answer" do
|
191
191
|
get :new
|
192
|
-
assigns(:answer).
|
192
|
+
assigns(:answer).should be_nil
|
193
|
+
response.should redirect_to questions_url
|
193
194
|
end
|
194
195
|
end
|
195
196
|
|
@@ -198,7 +199,8 @@ describe AnswersController do
|
|
198
199
|
|
199
200
|
it "assigns the requested answer as @answer" do
|
200
201
|
get :new
|
201
|
-
assigns(:answer).
|
202
|
+
assigns(:answer).should be_nil
|
203
|
+
response.should redirect_to questions_url
|
202
204
|
end
|
203
205
|
end
|
204
206
|
|
@@ -207,7 +209,8 @@ describe AnswersController do
|
|
207
209
|
|
208
210
|
it "should assign the requested answer as @answer" do
|
209
211
|
get :new
|
210
|
-
assigns(:answer).
|
212
|
+
assigns(:answer).should be_nil
|
213
|
+
response.should redirect_to questions_url
|
211
214
|
end
|
212
215
|
|
213
216
|
it "should get new template with question_id" do
|
@@ -220,7 +223,7 @@ describe AnswersController do
|
|
220
223
|
describe "When not logged in" do
|
221
224
|
it "should not assign the requested answer as @answer" do
|
222
225
|
get :new
|
223
|
-
assigns(:answer).
|
226
|
+
assigns(:answer).should be_nil
|
224
227
|
response.should redirect_to(new_user_session_url)
|
225
228
|
end
|
226
229
|
end
|
@@ -329,7 +332,7 @@ describe AnswersController do
|
|
329
332
|
describe "with valid params" do
|
330
333
|
it "assigns a newly created answer as @answer" do
|
331
334
|
post :create, answer: @attrs
|
332
|
-
assigns(:answer).
|
335
|
+
assigns(:answer).should be_nil
|
333
336
|
end
|
334
337
|
|
335
338
|
it "redirects to the created answer" do
|
@@ -341,7 +344,7 @@ describe AnswersController do
|
|
341
344
|
describe "with invalid params" do
|
342
345
|
it "assigns a newly created but unsaved answer as @answer" do
|
343
346
|
post :create, answer: @invalid_attrs
|
344
|
-
assigns(:answer).
|
347
|
+
assigns(:answer).should be_nil
|
345
348
|
end
|
346
349
|
|
347
350
|
it "re-renders the 'new' template" do
|
@@ -186,7 +186,7 @@ describe QuestionsController do
|
|
186
186
|
describe "When not logged in" do
|
187
187
|
it "should not assign the requested question as @question" do
|
188
188
|
get :new
|
189
|
-
assigns(:question).
|
189
|
+
assigns(:question).should be_nil
|
190
190
|
response.should redirect_to(new_user_session_url)
|
191
191
|
end
|
192
192
|
end
|
@@ -344,7 +344,7 @@ describe QuestionsController do
|
|
344
344
|
describe "with valid params" do
|
345
345
|
it "assigns a newly created question as @question" do
|
346
346
|
post :create, question: @attrs
|
347
|
-
assigns(:question).
|
347
|
+
assigns(:question).should be_nil
|
348
348
|
end
|
349
349
|
|
350
350
|
it "should be forbidden" do
|
@@ -356,7 +356,7 @@ describe QuestionsController do
|
|
356
356
|
describe "with invalid params" do
|
357
357
|
it "assigns a newly created but unsaved question as @question" do
|
358
358
|
post :create, question: @invalid_attrs
|
359
|
-
assigns(:question).
|
359
|
+
assigns(:question).should be_nil
|
360
360
|
end
|
361
361
|
|
362
362
|
it "should be forbidden" do
|
@@ -1,7 +1,11 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
2
|
protect_from_forgery
|
3
|
+
include EnjuLeaf::Controller
|
4
|
+
include EnjuBiblio::Controller
|
5
|
+
include EnjuLibrary::Controller
|
6
|
+
include EnjuQuestion::Controller
|
7
|
+
before_action :set_paper_trail_whodunnit
|
8
|
+
after_action :verify_authorized
|
3
9
|
|
4
|
-
|
5
|
-
enju_library
|
6
|
-
enju_question
|
10
|
+
include Pundit
|
7
11
|
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
class User < ActiveRecord::Base
|
3
2
|
devise :database_authenticatable, #:registerable,
|
4
3
|
:recoverable, :rememberable, :trackable, #, :validatable
|
5
4
|
:lockable, :lock_strategy => :none, :unlock_strategy => :none
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
include EnjuLeaf::EnjuUser
|
7
|
+
include EnjuQuestion::EnjuUser
|
9
8
|
end
|
@@ -2,8 +2,9 @@ require File.expand_path('../boot', __FILE__)
|
|
2
2
|
|
3
3
|
require 'rails/all'
|
4
4
|
|
5
|
-
Bundler.require
|
6
|
-
require
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require 'enju_question'
|
7
|
+
require 'enju_leaf'
|
7
8
|
|
8
9
|
module Dummy
|
9
10
|
class Application < Rails::Application
|
@@ -11,16 +12,6 @@ module Dummy
|
|
11
12
|
# Application configuration should go into files in config/initializers
|
12
13
|
# -- all .rb files in that directory are automatically loaded.
|
13
14
|
|
14
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
-
|
17
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
-
|
21
|
-
# Activate observers that should always be running.
|
22
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
-
|
24
15
|
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
16
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
17
|
# config.time_zone = 'Central Time (US & Canada)'
|
@@ -29,18 +20,8 @@ module Dummy
|
|
29
20
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
21
|
# config.i18n.default_locale = :de
|
31
22
|
|
32
|
-
#
|
33
|
-
config.
|
34
|
-
|
35
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
-
config.filter_parameters += [:password]
|
37
|
-
|
38
|
-
# Enable the asset pipeline
|
39
|
-
config.assets.enabled = true
|
40
|
-
|
41
|
-
# Version of your assets, change this if you want to expire all your assets
|
42
|
-
config.assets.version = '1.0'
|
23
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
24
|
+
config.active_record.raise_in_transactional_callbacks = true
|
43
25
|
end
|
44
26
|
end
|
45
27
|
|
46
|
-
require 'enju_leaf'
|
@@ -1,37 +1,41 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
5
5
|
# every request. This slows down response time but is perfect for development
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
#
|
10
|
-
config.
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
11
|
|
12
|
-
# Show full error reports and disable caching
|
12
|
+
# Show full error reports and disable caching.
|
13
13
|
config.consider_all_requests_local = true
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
|
-
# Don't care if the mailer can't send
|
16
|
+
# Don't care if the mailer can't send.
|
17
17
|
config.action_mailer.raise_delivery_errors = false
|
18
18
|
|
19
|
-
# Print deprecation notices to the Rails logger
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
20
|
config.active_support.deprecation = :log
|
21
21
|
|
22
|
-
#
|
23
|
-
config.
|
22
|
+
# Raise an error on page load if there are pending migrations.
|
23
|
+
config.active_record.migration_error = :page_load
|
24
24
|
|
25
|
-
#
|
26
|
-
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
27
29
|
|
28
|
-
#
|
29
|
-
#
|
30
|
-
config.
|
30
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
31
|
+
# yet still be able to expire them through the digest params.
|
32
|
+
config.assets.digest = true
|
31
33
|
|
32
|
-
#
|
33
|
-
|
34
|
+
# Adds additional error checking when serving assets at runtime.
|
35
|
+
# Checks for improperly declared sprockets dependencies.
|
36
|
+
# Raises helpful error messages.
|
37
|
+
config.assets.raise_runtime_errors = true
|
34
38
|
|
35
|
-
#
|
36
|
-
config.
|
39
|
+
# Raises error for missing translations
|
40
|
+
# config.action_view.raise_on_missing_translations = true
|
37
41
|
end
|
@@ -1,67 +1,79 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
|
-
# Code is not reloaded between requests
|
4
|
+
# Code is not reloaded between requests.
|
5
5
|
config.cache_classes = true
|
6
6
|
|
7
|
-
#
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
8
14
|
config.consider_all_requests_local = false
|
9
15
|
config.action_controller.perform_caching = true
|
10
16
|
|
11
|
-
#
|
12
|
-
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
20
|
+
# NGINX, varnish or squid.
|
21
|
+
# config.action_dispatch.rack_cache = true
|
22
|
+
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
24
|
+
# Apache or NGINX already handles this.
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
13
26
|
|
14
|
-
# Compress JavaScripts and CSS
|
15
|
-
config.assets.
|
27
|
+
# Compress JavaScripts and CSS.
|
28
|
+
config.assets.js_compressor = :uglifier
|
29
|
+
# config.assets.css_compressor = :sass
|
16
30
|
|
17
|
-
#
|
31
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
18
32
|
config.assets.compile = false
|
19
33
|
|
20
|
-
#
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
35
|
+
# yet still be able to expire them through the digest params.
|
21
36
|
config.assets.digest = true
|
22
37
|
|
23
|
-
#
|
24
|
-
# config.assets.manifest = YOUR_PATH
|
38
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
25
39
|
|
26
|
-
# Specifies the header that your server uses for sending files
|
27
|
-
# config.action_dispatch.x_sendfile_header =
|
28
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for
|
40
|
+
# Specifies the header that your server uses for sending files.
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
42
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
29
43
|
|
30
44
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
45
|
# config.force_ssl = true
|
32
46
|
|
33
|
-
#
|
34
|
-
#
|
47
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
48
|
+
# when problems arise.
|
49
|
+
config.log_level = :debug
|
35
50
|
|
36
|
-
# Prepend all log lines with the following tags
|
51
|
+
# Prepend all log lines with the following tags.
|
37
52
|
# config.log_tags = [ :subdomain, :uuid ]
|
38
53
|
|
39
|
-
# Use a different logger for distributed setups
|
54
|
+
# Use a different logger for distributed setups.
|
40
55
|
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
56
|
|
42
|
-
# Use a different cache store in production
|
57
|
+
# Use a different cache store in production.
|
43
58
|
# config.cache_store = :mem_cache_store
|
44
59
|
|
45
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
46
|
-
# config.action_controller.asset_host =
|
47
|
-
|
48
|
-
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
49
|
-
# config.assets.precompile += %w( search.js )
|
60
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
61
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
50
62
|
|
51
|
-
#
|
63
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
64
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
52
65
|
# config.action_mailer.raise_delivery_errors = false
|
53
66
|
|
54
|
-
# Enable threaded mode
|
55
|
-
# config.threadsafe!
|
56
|
-
|
57
67
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
-
# the I18n.default_locale when a translation
|
68
|
+
# the I18n.default_locale when a translation cannot be found).
|
59
69
|
config.i18n.fallbacks = true
|
60
70
|
|
61
|
-
# Send deprecation notices to registered listeners
|
71
|
+
# Send deprecation notices to registered listeners.
|
62
72
|
config.active_support.deprecation = :notify
|
63
73
|
|
64
|
-
#
|
65
|
-
|
66
|
-
|
74
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
75
|
+
config.log_formatter = ::Logger::Formatter.new
|
76
|
+
|
77
|
+
# Do not dump schema after migrations.
|
78
|
+
config.active_record.dump_schema_after_migration = false
|
67
79
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# The test environment is used exclusively to run your application's
|
5
5
|
# test suite. You never need to work with it otherwise. Remember that
|
@@ -7,31 +7,38 @@ Dummy::Application.configure do
|
|
7
7
|
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
13
14
|
|
14
|
-
#
|
15
|
-
config.
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_files = true
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
16
18
|
|
17
|
-
# Show full error reports and disable caching
|
19
|
+
# Show full error reports and disable caching.
|
18
20
|
config.consider_all_requests_local = true
|
19
21
|
config.action_controller.perform_caching = false
|
20
22
|
|
21
|
-
# Raise exceptions instead of rendering exception templates
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
22
24
|
config.action_dispatch.show_exceptions = false
|
23
25
|
|
24
|
-
# Disable request forgery protection in test environment
|
25
|
-
config.action_controller.allow_forgery_protection
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
26
28
|
|
27
29
|
# Tell Action Mailer not to deliver emails to the real world.
|
28
30
|
# The :test delivery method accumulates sent emails in the
|
29
31
|
# ActionMailer::Base.deliveries array.
|
30
32
|
config.action_mailer.delivery_method = :test
|
31
33
|
|
32
|
-
#
|
33
|
-
|
34
|
+
# Randomize the order test cases are executed.
|
35
|
+
config.active_support.test_order = :random
|
34
36
|
|
35
|
-
# Print deprecation notices to the stderr
|
37
|
+
# Print deprecation notices to the stderr.
|
36
38
|
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Raises error for missing translations
|
41
|
+
# config.action_view.raise_on_missing_translations = true
|
42
|
+
|
43
|
+
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
|
37
44
|
end
|
data/spec/support/devise.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
|
-
config.include Devise::
|
3
|
-
config.include Devise::
|
2
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
3
|
+
config.include Devise::Test::ControllerHelpers, type: :view
|
4
4
|
end
|
@@ -9,9 +9,6 @@ describe "questions/index.rss.builder" do
|
|
9
9
|
assign(:count, {query_result: Question.count})
|
10
10
|
assign(:library_group, LibraryGroup.site_config)
|
11
11
|
view.stub(:current_user).and_return(User.where(username: 'enjuadmin').first)
|
12
|
-
@ability = Object.new
|
13
|
-
@ability.extend(CanCan::Ability)
|
14
|
-
controller.stub(:current_ability) { @ability }
|
15
12
|
end
|
16
13
|
|
17
14
|
it "renders the XML template" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_question
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kosuke Tanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: mysql2
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pg
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,28 +142,70 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.1
|
145
|
+
version: 1.2.0.beta.1
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.1
|
152
|
+
version: 1.2.0.beta.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: enju_library
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.2.0.beta.1
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.2.0.beta.1
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: enju_biblio
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.2.0.beta.1
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.2.0.beta.1
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: enju_manifestation_viewer
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.2.0.beta.1
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.2.0.beta.1
|
153
195
|
- !ruby/object:Gem::Dependency
|
154
196
|
name: enju_ndl
|
155
197
|
requirement: !ruby/object:Gem::Requirement
|
156
198
|
requirements:
|
157
199
|
- - "~>"
|
158
200
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
201
|
+
version: 0.2.0.beta.1
|
160
202
|
type: :development
|
161
203
|
prerelease: false
|
162
204
|
version_requirements: !ruby/object:Gem::Requirement
|
163
205
|
requirements:
|
164
206
|
- - "~>"
|
165
207
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
208
|
+
version: 0.2.0.beta.1
|
167
209
|
- !ruby/object:Gem::Dependency
|
168
210
|
name: sunspot_solr
|
169
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,7 +277,7 @@ dependencies:
|
|
235
277
|
- !ruby/object:Gem::Version
|
236
278
|
version: '0'
|
237
279
|
- !ruby/object:Gem::Dependency
|
238
|
-
name:
|
280
|
+
name: coveralls
|
239
281
|
requirement: !ruby/object:Gem::Requirement
|
240
282
|
requirements:
|
241
283
|
- - ">="
|
@@ -259,11 +301,16 @@ files:
|
|
259
301
|
- README.rdoc
|
260
302
|
- Rakefile
|
261
303
|
- app/controllers/answers_controller.rb
|
304
|
+
- app/controllers/concerns/enju_question/controller.rb
|
262
305
|
- app/controllers/questions_controller.rb
|
263
306
|
- app/models/answer.rb
|
264
307
|
- app/models/answer_has_item.rb
|
265
|
-
- app/models/enju_question/
|
308
|
+
- app/models/concerns/enju_question/enju_item.rb
|
309
|
+
- app/models/concerns/enju_question/enju_manifestation.rb
|
310
|
+
- app/models/concerns/enju_question/enju_user.rb
|
266
311
|
- app/models/question.rb
|
312
|
+
- app/policies/answer_policy.rb
|
313
|
+
- app/policies/question_policy.rb
|
267
314
|
- app/views/answers/_form.html.erb
|
268
315
|
- app/views/answers/edit.html.erb
|
269
316
|
- app/views/answers/index.atom.builder
|
@@ -298,9 +345,6 @@ files:
|
|
298
345
|
- db/migrate/20120418124018_add_answer_feed_token_to_user.rb
|
299
346
|
- lib/enju_question.rb
|
300
347
|
- lib/enju_question/engine.rb
|
301
|
-
- lib/enju_question/item.rb
|
302
|
-
- lib/enju_question/manifestation.rb
|
303
|
-
- lib/enju_question/user.rb
|
304
348
|
- lib/enju_question/version.rb
|
305
349
|
- lib/generators/enju_question/setup/USAGE
|
306
350
|
- lib/generators/enju_question/setup/setup_generator.rb
|
@@ -323,7 +367,6 @@ files:
|
|
323
367
|
- spec/dummy/bin/setup
|
324
368
|
- spec/dummy/config.ru
|
325
369
|
- spec/dummy/config/application.rb
|
326
|
-
- spec/dummy/config/application.yml
|
327
370
|
- spec/dummy/config/boot.rb
|
328
371
|
- spec/dummy/config/database.yml
|
329
372
|
- spec/dummy/config/environment.rb
|
@@ -332,6 +375,7 @@ files:
|
|
332
375
|
- spec/dummy/config/environments/test.rb
|
333
376
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
334
377
|
- spec/dummy/config/initializers/devise.rb
|
378
|
+
- spec/dummy/config/initializers/enju_leaf.rb
|
335
379
|
- spec/dummy/config/initializers/friendly_id.rb
|
336
380
|
- spec/dummy/config/initializers/inflections.rb
|
337
381
|
- spec/dummy/config/initializers/mime_types.rb
|
@@ -511,12 +555,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
511
555
|
version: '0'
|
512
556
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
513
557
|
requirements:
|
514
|
-
- - "
|
558
|
+
- - ">"
|
515
559
|
- !ruby/object:Gem::Version
|
516
|
-
version:
|
560
|
+
version: 1.3.1
|
517
561
|
requirements: []
|
518
562
|
rubyforge_project:
|
519
|
-
rubygems_version: 2.5.
|
563
|
+
rubygems_version: 2.5.1
|
520
564
|
signing_key:
|
521
565
|
specification_version: 4
|
522
566
|
summary: enju_queestion plugin
|
@@ -537,7 +581,6 @@ test_files:
|
|
537
581
|
- spec/dummy/bin/rake
|
538
582
|
- spec/dummy/bin/setup
|
539
583
|
- spec/dummy/config/application.rb
|
540
|
-
- spec/dummy/config/application.yml
|
541
584
|
- spec/dummy/config/boot.rb
|
542
585
|
- spec/dummy/config/database.yml
|
543
586
|
- spec/dummy/config/environment.rb
|
@@ -546,6 +589,7 @@ test_files:
|
|
546
589
|
- spec/dummy/config/environments/test.rb
|
547
590
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
548
591
|
- spec/dummy/config/initializers/devise.rb
|
592
|
+
- spec/dummy/config/initializers/enju_leaf.rb
|
549
593
|
- spec/dummy/config/initializers/friendly_id.rb
|
550
594
|
- spec/dummy/config/initializers/inflections.rb
|
551
595
|
- spec/dummy/config/initializers/mime_types.rb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module EnjuQuestion
|
2
|
-
class Ability
|
3
|
-
include CanCan::Ability
|
4
|
-
|
5
|
-
def initialize(user, ip_address = nil)
|
6
|
-
case user.try(:role).try(:name)
|
7
|
-
when 'Administrator'
|
8
|
-
can :manage, Answer
|
9
|
-
can :manage, Question
|
10
|
-
when 'Librarian'
|
11
|
-
can :manage, Answer
|
12
|
-
can :manage, Question
|
13
|
-
when 'User'
|
14
|
-
can [:index, :create], Answer
|
15
|
-
can :show, Answer do |answer|
|
16
|
-
if answer.user == user
|
17
|
-
true
|
18
|
-
elsif answer.question.shared
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
can [:update, :destroy, :delete], Answer do |answer|
|
23
|
-
answer.user == user
|
24
|
-
end
|
25
|
-
can [:index, :create], Question
|
26
|
-
can [:update, :destroy, :delete], Question do |question|
|
27
|
-
question.user == user
|
28
|
-
end
|
29
|
-
can :show, Question do |question|
|
30
|
-
question.user == user or question.shared
|
31
|
-
end
|
32
|
-
else
|
33
|
-
can :index, Answer
|
34
|
-
can :show, Answer do |answer|
|
35
|
-
answer.question.shared
|
36
|
-
end
|
37
|
-
can :index, Question
|
38
|
-
can :show, Question do |question|
|
39
|
-
question.shared
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/enju_question/item.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module EnjuQuestion
|
2
|
-
module QuestionItem
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def enju_question_item_model
|
9
|
-
has_many :answer_has_items, :dependent => :destroy
|
10
|
-
has_many :answers, :through => :answer_has_items
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module EnjuQuestion
|
2
|
-
module QuestionManifestation
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def enju_question_manifestation_model
|
9
|
-
include InstanceMethods
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module InstanceMethods
|
14
|
-
def questions(options = {})
|
15
|
-
id = self.id
|
16
|
-
options = {:page => 1, :per_page => Question.default_per_page}.merge(options)
|
17
|
-
page = options[:page]
|
18
|
-
per_page = options[:per_page]
|
19
|
-
user = options[:user]
|
20
|
-
Question.search do
|
21
|
-
with(:manifestation_id).equal_to id
|
22
|
-
any_of do
|
23
|
-
unless user.try(:has_role?, 'Librarian')
|
24
|
-
with(:shared).equal_to true
|
25
|
-
# with(:username).equal_to user.try(:username)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
paginate :page => page, :per_page => per_page
|
29
|
-
end.results
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/enju_question/user.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module EnjuQuestion
|
2
|
-
module QuestionUser
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def enju_question_user_model
|
9
|
-
include InstanceMethods
|
10
|
-
has_many :questions
|
11
|
-
has_many :answers
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module InstanceMethods
|
16
|
-
def reset_answer_feed_token
|
17
|
-
self.answer_feed_token = Devise.friendly_token
|
18
|
-
end
|
19
|
-
|
20
|
-
def delete_answer_feed_token
|
21
|
-
self.answer_feed_token = nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
enju:
|
3
|
-
web_hostname: localhost
|
4
|
-
web_port_number: 3000
|
5
|
-
|
6
|
-
family_name_first: true
|
7
|
-
max_number_of_results: 500
|
8
|
-
write_search_log_to_file: true
|
9
|
-
csv_charset_conversion: true
|
10
|
-
|
11
|
-
# Choose a locale from 'ca', 'de', 'fr', 'jp', 'uk', 'us'
|
12
|
-
#AMAZON_AWS_HOSTNAME = 'ecs.amazonaws.com'
|
13
|
-
amazon:
|
14
|
-
aws_hostname: ecs.amazonaws.jp
|
15
|
-
hostname: www.amazon.co.jp
|
16
|
-
access_key: REPLACE_WITH_YOUR_AMAZON_ACCESS_KEY
|
17
|
-
secret_access_key: REPLACE_WITH_YOUR_AMAZON_SECRET_ACCESS_KEY
|
18
|
-
|
19
|
-
# :google, :amazon
|
20
|
-
book_jacket:
|
21
|
-
source: :google
|
22
|
-
unknown_resource:
|
23
|
-
|
24
|
-
# :mozshot, :simpleapi, :heartrails, :thumbalizr
|
25
|
-
screenshot:
|
26
|
-
generator: :mozshot
|
27
|
-
|
28
|
-
uploaded_file:
|
29
|
-
storage: :local
|
30
|
-
|
31
|
-
development:
|
32
|
-
<<: *defaults
|
33
|
-
|
34
|
-
test:
|
35
|
-
<<: *defaults
|
36
|
-
|
37
|
-
production:
|
38
|
-
<<: *defaults
|