answers-core 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +6 -0
- data/answers-core.gemspec +30 -0
- data/app/assets/fonts/answers/League_Gothic-webfont.eot +0 -0
- data/app/assets/fonts/answers/League_Gothic-webfont.svg +230 -0
- data/app/assets/fonts/answers/League_Gothic-webfont.ttf +0 -0
- data/app/assets/fonts/answers/League_Gothic-webfont.woff +0 -0
- data/app/assets/images/OaklandCityTree.png +0 -0
- data/app/assets/images/background_image.jpg +0 -0
- data/app/assets/images/background_pattern.png +0 -0
- data/app/assets/images/beta.png +0 -0
- data/app/assets/images/bg_transparent.png +0 -0
- data/app/assets/images/border.png +0 -0
- data/app/assets/images/brigade.png +0 -0
- data/app/assets/images/cfa.png +0 -0
- data/app/assets/images/cfa_logo.png +0 -0
- data/app/assets/images/cfa_logo_footer.png +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/forest.jpeg +0 -0
- data/app/assets/images/getting_started_btn.png +0 -0
- data/app/assets/images/govuk.png +0 -0
- data/app/assets/images/openoaklandlogo.png +0 -0
- data/app/assets/images/quick_answers_icon.png +0 -0
- data/app/assets/images/quick_answers_icon_small.png +0 -0
- data/app/assets/images/searchIcon.png +0 -0
- data/app/assets/images/wmd-buttons.png +0 -0
- data/app/assets/images/yellow_bg.png +0 -0
- data/app/assets/javascripts/answers.js +19 -0
- data/app/assets/javascripts/answers/Markdown.Extra.js +304 -0
- data/app/assets/javascripts/answers/active_admin.js +62 -0
- data/app/assets/javascripts/answers/pagedown/LICENSE.txt +32 -0
- data/app/assets/javascripts/answers/pagedown/Markdown.Converter.js +1332 -0
- data/app/assets/javascripts/answers/pagedown/Markdown.Editor.js +2212 -0
- data/app/assets/javascripts/answers/pagedown/Markdown.Sanitizer.js +108 -0
- data/app/assets/javascripts/answers/pagedown/README.txt +0 -0
- data/app/assets/javascripts/answers/pagedown/demo/browser/demo.css +120 -0
- data/app/assets/javascripts/answers/pagedown/demo/browser/demo.html +83 -0
- data/app/assets/javascripts/answers/pagedown/demo/node/demo.js +44 -0
- data/app/assets/javascripts/answers/pagedown/local/Markdown.local.fr.js +43 -0
- data/app/assets/javascripts/answers/pagedown/node-pagedown.js +2 -0
- data/app/assets/javascripts/answers/pagedown/package.json +12 -0
- data/app/assets/javascripts/answers/pagedown/resources/wmd-buttons.psd +0 -0
- data/app/assets/javascripts/answers/pagedown/wmd-buttons.png +0 -0
- data/app/assets/javascripts/answers/skip_nav.js +8 -0
- data/app/assets/stylesheets/answers/active_admin.css.scss +17 -0
- data/app/assets/stylesheets/answers/active_admin_custom.css.scss +35 -0
- data/app/assets/stylesheets/answers/formatting.css +82 -0
- data/app/assets/stylesheets/answers/mobile.css +149 -0
- data/app/assets/stylesheets/answers/tags.css.scss +3 -0
- data/app/assets/stylesheets/answers/theme.css +916 -0
- data/app/controllers/answers/answers_controller.rb +26 -0
- data/app/controllers/answers/api/v1/answers_controller.rb +38 -0
- data/app/controllers/answers/api/v1/api_controller.rb +13 -0
- data/app/controllers/answers/api/v1/questions_controller.rb +39 -0
- data/app/controllers/answers/api/v1/taggings_controller.rb +46 -0
- data/app/controllers/answers/api/v1/tags_controller.rb +38 -0
- data/app/controllers/answers/application_controller.rb +27 -0
- data/app/controllers/answers/home_controller.rb +17 -0
- data/app/controllers/answers/questions_controller.rb +33 -0
- data/app/controllers/answers/search_controller.rb +22 -0
- data/app/controllers/answers/tags_controller.rb +36 -0
- data/app/helpers/answers/tags_helper.rb +7 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/answers/ability.rb +28 -0
- data/app/models/answers/administrator.rb +5 -0
- data/app/models/answers/answer.rb +6 -0
- data/app/models/answers/api/v1/api_user.rb +5 -0
- data/app/models/answers/question.rb +31 -0
- data/app/models/answers/user.rb +30 -0
- data/app/views/answers/admin/contacts/_article.html.erb +0 -0
- data/app/views/answers/admin/dashboard/_dashboard.html.erb +5 -0
- data/app/views/answers/admin/guide_steps/_form.html.erb +17 -0
- data/app/views/answers/api/v1/answers/_answer.json.jbuilder +2 -0
- data/app/views/answers/api/v1/answers/index.json.jbuilder +1 -0
- data/app/views/answers/api/v1/answers/show.json.jbuilder +1 -0
- data/app/views/answers/api/v1/questions/_question.json.jbuilder +2 -0
- data/app/views/answers/api/v1/questions/index.json.jbuilder +1 -0
- data/app/views/answers/api/v1/questions/show.json.jbuilder +1 -0
- data/app/views/answers/api/v1/taggings/_tagging.json.jbuilder +3 -0
- data/app/views/answers/api/v1/taggings/index.json.jbuilder +1 -0
- data/app/views/answers/api/v1/taggings/show.json.jbuilder +1 -0
- data/app/views/answers/api/v1/tags/_tag.json.jbuilder +2 -0
- data/app/views/answers/api/v1/tags/index.json.jbuilder +1 -0
- data/app/views/answers/api/v1/tags/show.json.jbuilder +1 -0
- data/app/views/answers/devise/confirmations/new.html.erb +12 -0
- data/app/views/answers/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/answers/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/answers/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/answers/devise/passwords/edit.html.erb +24 -0
- data/app/views/answers/devise/passwords/new.html.erb +20 -0
- data/app/views/answers/devise/registrations/edit.html.erb +25 -0
- data/app/views/answers/devise/registrations/new.html.erb +18 -0
- data/app/views/answers/devise/sessions/new.html.erb +25 -0
- data/app/views/answers/devise/shared/_links.erb +25 -0
- data/app/views/answers/devise/unlocks/new.html.erb +12 -0
- data/app/views/answers/home/_article.html.erb +3 -0
- data/app/views/answers/home/_category.html.erb +8 -0
- data/app/views/answers/home/about.html.erb +72 -0
- data/app/views/answers/home/index.html.erb +44 -0
- data/app/views/answers/questions/index.html.erb +21 -0
- data/app/views/answers/questions/show.html.erb +31 -0
- data/app/views/answers/search/index.html.erb +32 -0
- data/app/views/answers/shared/_articles_sidebar.html.erb +22 -0
- data/app/views/answers/shared/_autocomplete.html.erb +8 -0
- data/app/views/answers/shared/_categories_sidebar.html.erb +12 -0
- data/app/views/answers/shared/_search_form.html.erb +4 -0
- data/app/views/answers/shared/admin/_administration.html.erb +38 -0
- data/app/views/answers/shared/admin/_article_actions.html.erb +86 -0
- data/app/views/answers/shared/admin/_article_content.html.erb +27 -0
- data/app/views/answers/shared/admin/_article_details.html.erb +11 -0
- data/app/views/answers/shared/admin/_article_form.html.erb +20 -0
- data/app/views/answers/shared/admin/_author_pic.html.erb +0 -0
- data/app/views/answers/tags/index.html.erb +34 -0
- data/app/views/answers/tags/show.html.erb +31 -0
- data/app/views/layouts/answers/application.html.erb +97 -0
- data/config.ru +5 -0
- data/config/initializers/active_admin.rb +245 -0
- data/config/initializers/devise.rb +228 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/locales/en.yml +129 -0
- data/config/routes.rb +22 -0
- data/config/secrets.yml +68 -0
- data/db/migrate/20140911060606_answers_up.rb +79 -0
- data/lib/answers-core.rb +1 -0
- data/lib/answers.rb +175 -0
- data/lib/answers/admin/answer.rb +29 -0
- data/lib/answers/admin/dashboard.rb +75 -0
- data/lib/answers/admin/question.rb +57 -0
- data/lib/answers/admin/tag.rb +12 -0
- data/lib/answers/admin/users.rb +65 -0
- data/lib/answers/core.rb +25 -0
- data/lib/answers/core/configuration.rb +90 -0
- data/lib/answers/core/engine.rb +116 -0
- data/lib/answers/engine.rb +62 -0
- data/lib/answers/errors.rb +13 -0
- data/lib/answers/plugin.rb +75 -0
- data/lib/answers/plugins.rb +73 -0
- data/lib/answers/version.rb +16 -0
- data/lib/api_client.rb +20 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/assets/eng_stop.csv +1 -0
- data/lib/generators/answers/clash_keywords.yml +3 -0
- data/lib/generators/answers/cms/cms_generator.rb +314 -0
- data/lib/generators/answers/cms/templates/.gitignore +91 -0
- data/lib/generators/answers/cms/templates/app/decorators/controllers/answers/.keep +0 -0
- data/lib/generators/answers/cms/templates/app/decorators/models/answers/.keep +0 -0
- data/lib/generators/answers/cms/templates/app/views/sitemap/index.xml.builder +15 -0
- data/lib/generators/answers/cms/templates/config/database.yml.mysql +20 -0
- data/lib/generators/answers/cms/templates/config/database.yml.postgresql +58 -0
- data/lib/generators/answers/cms/templates/config/database.yml.sqlite3 +18 -0
- data/lib/generators/answers/core/core_generator.rb +10 -0
- data/lib/generators/answers/core/templates/config/initializers/answers/core.rb.erb +35 -0
- data/lib/generators/answers/dummy/dummy_generator.rb +86 -0
- data/lib/generators/answers/dummy/templates/rails/Rakefile +7 -0
- data/lib/generators/answers/dummy/templates/rails/application.js +3 -0
- data/lib/generators/answers/dummy/templates/rails/application.rb.erb +12 -0
- data/lib/generators/answers/dummy/templates/rails/boot.rb.erb +6 -0
- data/lib/generators/answers/dummy/templates/rails/database.yml +34 -0
- data/lib/generators/answers/dummy/templates/rails/routes.rb +3 -0
- data/lib/generators/answers/engine/USAGE +24 -0
- data/lib/generators/answers/engine/engine_generator.rb +44 -0
- data/lib/generators/answers/engine/templates/.gitignore +2 -0
- data/lib/generators/answers/engine/templates/Gemfile +42 -0
- data/lib/generators/answers/engine/templates/Rakefile +19 -0
- data/lib/generators/answers/engine/templates/answers-extension_plural_name.gemspec +19 -0
- data/lib/generators/answers/engine/templates/app/controllers/answers/namespace/admin/plural_name_controller.rb.erb +14 -0
- data/lib/generators/answers/engine/templates/app/controllers/answers/namespace/plural_name_controller.rb.erb +34 -0
- data/lib/generators/answers/engine/templates/app/models/answers/namespace/singular_name.rb.erb +37 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/_actions.html.erb +25 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/_form.html.erb +65 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/_plural_name.html.erb +2 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/_records.html.erb +16 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/_singular_name.html.erb +33 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/_sortable_list.html.erb +5 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/edit.html.erb +1 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/index.html.erb +7 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/admin/plural_name/new.html.erb +1 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/plural_name/index.html.erb +11 -0
- data/lib/generators/answers/engine/templates/app/views/answers/namespace/plural_name/show.html.erb +39 -0
- data/lib/generators/answers/engine/templates/config/locales/cs.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/en.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/es.yml +29 -0
- data/lib/generators/answers/engine/templates/config/locales/fr.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/it.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/nb.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/nl.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/sk.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/tr.yml +28 -0
- data/lib/generators/answers/engine/templates/config/locales/zh-CN.yml +30 -0
- data/lib/generators/answers/engine/templates/config/routes.rb.erb +19 -0
- data/lib/generators/answers/engine/templates/db/migrate/1_create_namespace_plural_name.rb.erb +39 -0
- data/lib/generators/answers/engine/templates/db/seeds.rb.erb +21 -0
- data/lib/generators/answers/engine/templates/lib/answers-extension_plural_name.rb.erb +1 -0
- data/lib/generators/answers/engine/templates/lib/answers/plural_name.rb.erb +21 -0
- data/lib/generators/answers/engine/templates/lib/answers/plural_name/engine.rb.erb +23 -0
- data/lib/generators/answers/engine/templates/lib/generators/answers/extension_plural_name_generator.rb.erb +19 -0
- data/lib/generators/answers/engine/templates/lib/tasks/answers/extension_plural_name.rake +13 -0
- data/lib/generators/answers/engine/templates/readme.md +10 -0
- data/lib/generators/answers/engine/templates/script/rails +10 -0
- data/lib/generators/answers/engine/templates/spec/features/answers/namespace/admin/plural_name_spec.rb.erb +200 -0
- data/lib/generators/answers/engine/templates/spec/models/answers/namespace/singular_name_spec.rb.erb +20 -0
- data/lib/generators/answers/engine/templates/spec/spec_helper.rb +31 -0
- data/lib/generators/answers/engine/templates/spec/support/factories/answers/plural_name.rb.erb +7 -0
- data/lib/generators/answers/engine/templates/tasks/rspec.rake +6 -0
- data/lib/generators/answers/engine/templates/tasks/testing.rake +8 -0
- data/lib/generators/answers/generator.rb +292 -0
- data/lib/markdownifier.rb +11 -0
- data/log/.gitkeep +0 -0
- data/log/development.log +12870 -0
- data/log/newrelic_agent.log +1339 -0
- data/log/test.log +233181 -0
- data/public/404.html +25 -0
- data/public/422.html +25 -0
- data/public/500.html +24 -0
- data/public/favicon.ico +0 -0
- data/public/robots.txt +5 -0
- data/script/delayed_job +5 -0
- data/spec/controllers/answers_controller_spec.rb +55 -0
- data/spec/controllers/api/v1/answers_controller_spec.rb +144 -0
- data/spec/controllers/api/v1/questions_controller_spec.rb +144 -0
- data/spec/controllers/api/v1/taggings_controller_spec.rb +126 -0
- data/spec/controllers/api/v1/tags_controller_spec.rb +126 -0
- data/spec/controllers/home_controller_spec.rb +60 -0
- data/spec/controllers/questions_controller_spec.rb +55 -0
- data/spec/controllers/tags_controller_spec.rb +42 -0
- data/spec/factories/answers.rb +10 -0
- data/spec/factories/questions.rb +8 -0
- data/spec/factories/tags.rb +8 -0
- data/spec/factories/user.rb +32 -0
- data/spec/features/admin_dashboard_spec.rb +53 -0
- data/spec/features/admin_user_spec.rb +61 -0
- data/spec/features/searches_spec.rb +101 -0
- data/spec/fixtures/Article/_before_validation/sets_access_count_if_nil.yml +223 -0
- data/spec/fixtures/Article/_delete_orphaned_keywords/updating_an_article/destroys_orphaned_keywords_associated.yml +223 -0
- data/spec/fixtures/Article/_delete_orphaned_keywords/when_deleting_an_article/destroys_all_keywords_associated.yml +223 -0
- data/spec/fixtures/Article/_find_by_friendly_id/when_an_article_does_not_exist/does_not_raise_an_exception.yml +223 -0
- data/spec/fixtures/Article/_find_by_friendly_id/when_an_article_exists/returns_the_corresponding_article.yml +223 -0
- data/spec/fixtures/Article/_find_by_type/excludes_articles_not_matching_specified_type.yml +223 -0
- data/spec/fixtures/Article/_find_by_type/returns_articles_matching_type.yml +223 -0
- data/spec/fixtures/Article/_hits/before_an_article_has_been_viewed/has_zero_hits.yml +223 -0
- data/spec/fixtures/Article/_hits/returns_number_of_views/has_seven_views.yml +223 -0
- data/spec/fixtures/Article/_indexable_/returns_false_if_article_is_not_published.yml +223 -0
- data/spec/fixtures/Article/_indexable_/returns_true_if_article_is_published.yml +223 -0
- data/spec/fixtures/Article/_legacy_/returns_true_if_render_markdown_is_false.yml +223 -0
- data/spec/fixtures/Article/_qm_after_create/creates_wordcounts_for_relevant_keywords.yml +223 -0
- data/spec/fixtures/Article/_record_hit/viewing_an_article/increases_hit_by_one.yml +223 -0
- data/spec/fixtures/Article/_related/has_no_related_articles/.yml +223 -0
- data/spec/fixtures/Article/_related/has_related_articles/.yml +223 -0
- data/spec/fixtures/Article/_remove_stop_words/removes_common_english_words_from_the_string.yml +223 -0
- data/spec/fixtures/Article/_search/_search_titles/query_is_present_in_the_title/.yml +223 -0
- data/spec/fixtures/Article/_search/_search_titles/returns_an_empty_array_when_the_search_term_is_present_in_an_article_but_not_the_title.yml +223 -0
- data/spec/fixtures/Article/_search/matches_articles_in_the_database.yml +223 -0
- data/spec/fixtures/Article/_search/query_does_not_match_anything_in_the_database/returns_an_empty_array.yml +223 -0
- data/spec/fixtures/Article/_search/query_is_a_single_space/.yml +223 -0
- data/spec/fixtures/Article/_search/query_is_an_empty_string/.yml +223 -0
- data/spec/fixtures/Article/_to_s/when_an_article_has_a_category/returns_a_string_containing_title_id_and_category.yml +223 -0
- data/spec/fixtures/Article/can_be_published/an_unpublished_article/is_published.yml +223 -0
- data/spec/fixtures/Article/can_be_published/an_unpublished_article/returns_status_Published.yml +223 -0
- data/spec/fixtures/Article/has_a_friendly_url.yml +223 -0
- data/spec/fixtures/Article/is_valid_with_a_title.yml +223 -0
- data/spec/fixtures/Searches/search_results/1_result_found/.yml +22047 -0
- data/spec/fixtures/Searches/search_results/no_results_found/.yml +393 -0
- data/spec/fixtures/Searches/search_results/several_results_found/should_contain_the_title_and_preview_of_both_articles.yml +223 -0
- data/spec/fixtures/Searches/search_results/several_results_found/show_the_query.yml +277 -0
- data/spec/fixtures/articles.yml +428 -0
- data/spec/fixtures/categories.yml +17 -0
- data/spec/fixtures/contacts.yml +11 -0
- data/spec/fixtures/dragon_keyword_cassette.yml +77 -0
- data/spec/fixtures/oakland_answers.yml +2379 -0
- data/spec/helpers/tags_helper_spec.rb +15 -0
- data/spec/lib/markdownifier_spec.rb +12 -0
- data/spec/models/ability_spec.rb +36 -0
- data/spec/models/answer_spec.rb +5 -0
- data/spec/models/question_spec.rb +70 -0
- data/spec/models/user_spec.rb +55 -0
- data/spec/routing/answers_routing_spec.rb +19 -0
- data/spec/routing/questions_routing_spec.rb +19 -0
- data/spec/routing/routes_spec.rb +13 -0
- data/spec/security/brakeman_spec.rb +37 -0
- data/spec/spec_helper.rb +61 -0
- data/spec/support/login_helpers.rb +10 -0
- data/spec/support/wait_for_ajax_helper.rb +7 -0
- data/spec/support/wait_for_dom_helper.rb +12 -0
- data/spec/views/questions/index.html.erb_spec.rb +16 -0
- data/spec/views/questions/show.html.erb_spec.rb +14 -0
- data/spec/views/tags/index.html.erb_spec.rb +5 -0
- data/spec/views/tags/show.html.erb_spec.rb +5 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/bootstrap.css +3990 -0
- data/vendor/crudgen/lib/generators/crudgen/install_generator.rb +23 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +484 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Answers::Api::V1::TagsController, :type => :controller do
|
|
4
|
+
|
|
5
|
+
# This should return the minimal set of attributes required to create a valid
|
|
6
|
+
# ActsAsTaggableOn::Tag. As you add validations to ActsAsTaggableOn::Tag, be sure to
|
|
7
|
+
# adjust the attributes here as well.
|
|
8
|
+
let(:valid_attributes) {
|
|
9
|
+
skip("Add a hash of attributes valid for your model")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let(:invalid_attributes) {
|
|
13
|
+
skip("Add a hash of attributes invalid for your model")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# This should return the minimal set of values that should be in the session
|
|
17
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
18
|
+
# ActsAsTaggableOn::TagsController. Be sure to keep this updated too.
|
|
19
|
+
let(:valid_session) { {} }
|
|
20
|
+
|
|
21
|
+
describe "GET index" do
|
|
22
|
+
it "assigns all tags as @tags" do
|
|
23
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
24
|
+
get :index, {}, valid_session
|
|
25
|
+
expect(assigns(:tags)).to eq([tag])
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "GET show" do
|
|
30
|
+
it "assigns the requested tag as @tag" do
|
|
31
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
32
|
+
get :show, {:id => tag.to_param}, valid_session
|
|
33
|
+
expect(assigns(:tag)).to eq(tag)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "POST create" do
|
|
38
|
+
describe "with valid params" do
|
|
39
|
+
it "creates a new ActsAsTaggableOn::Tag" do
|
|
40
|
+
expect {
|
|
41
|
+
post :create, {:tag => valid_attributes}, valid_session
|
|
42
|
+
}.to change(ActsAsTaggableOn::Tag, :count).by(1)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "assigns a newly created tag as @tag" do
|
|
46
|
+
post :create, {:tag => valid_attributes}, valid_session
|
|
47
|
+
expect(assigns(:tag)).to be_a(ActsAsTaggableOn::Tag)
|
|
48
|
+
expect(assigns(:tag)).to be_persisted
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "redirects to the created tag" do
|
|
52
|
+
post :create, {:tag => valid_attributes}, valid_session
|
|
53
|
+
expect(response).to redirect_to(ActsAsTaggableOn::Tag.last)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "with invalid params" do
|
|
58
|
+
it "assigns a newly created but unsaved tag as @tag" do
|
|
59
|
+
post :create, {:tag => invalid_attributes}, valid_session
|
|
60
|
+
expect(assigns(:tag)).to be_a_new(ActsAsTaggableOn::Tag)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "re-renders the 'new' template" do
|
|
64
|
+
post :create, {:tag => invalid_attributes}, valid_session
|
|
65
|
+
expect(response).to render_template("new")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "PUT update" do
|
|
71
|
+
describe "with valid params" do
|
|
72
|
+
let(:new_attributes) {
|
|
73
|
+
skip("Add a hash of attributes valid for your model")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
it "updates the requested tag" do
|
|
77
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
78
|
+
put :update, {:id => tag.to_param, :tag => new_attributes}, valid_session
|
|
79
|
+
tag.reload
|
|
80
|
+
skip("Add assertions for updated state")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "assigns the requested tag as @tag" do
|
|
84
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
85
|
+
put :update, {:id => tag.to_param, :tag => valid_attributes}, valid_session
|
|
86
|
+
expect(assigns(:tag)).to eq(tag)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "redirects to the tag" do
|
|
90
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
91
|
+
put :update, {:id => tag.to_param, :tag => valid_attributes}, valid_session
|
|
92
|
+
expect(response).to redirect_to(tag)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe "with invalid params" do
|
|
97
|
+
it "assigns the tag as @tag" do
|
|
98
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
99
|
+
put :update, {:id => tag.to_param, :tag => invalid_attributes}, valid_session
|
|
100
|
+
expect(assigns(:tag)).to eq(tag)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "re-renders the 'edit' template" do
|
|
104
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
105
|
+
put :update, {:id => tag.to_param, :tag => invalid_attributes}, valid_session
|
|
106
|
+
expect(response).to render_template("edit")
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
describe "DELETE destroy" do
|
|
112
|
+
it "destroys the requested tag" do
|
|
113
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
114
|
+
expect {
|
|
115
|
+
delete :destroy, {:id => tag.to_param}, valid_session
|
|
116
|
+
}.to change(ActsAsTaggableOn::Tag, :count).by(-1)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "redirects to the tags list" do
|
|
120
|
+
tag = ActsAsTaggableOn::Tag.create! valid_attributes
|
|
121
|
+
delete :destroy, {:id => tag.to_param}, valid_session
|
|
122
|
+
expect(response).to redirect_to(tags_url)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Answers::HomeController, :type => :feature do
|
|
4
|
+
|
|
5
|
+
# This should return the minimal set of attributes required to create a valid
|
|
6
|
+
# Answer. As you add validations to Answer, be sure to
|
|
7
|
+
# adjust the attributes here as well.
|
|
8
|
+
let(:valid_attributes) {
|
|
9
|
+
skip("Add a hash of attributes valid for your model")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let(:invalid_attributes) {
|
|
13
|
+
skip("Add a hash of attributes invalid for your model")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# This should return the minimal set of values that should be in the session
|
|
17
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
18
|
+
# AnswersController. Be sure to keep this updated too.
|
|
19
|
+
let(:valid_session) { {} }
|
|
20
|
+
|
|
21
|
+
before(:each) do
|
|
22
|
+
words = %w[
|
|
23
|
+
pets cars education transportation business employment housing trash
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
tags = words.map do |word|
|
|
27
|
+
create(:tag, name: word)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
100.times do
|
|
31
|
+
q = create(:question)
|
|
32
|
+
q.tag_list = [tags.sample]
|
|
33
|
+
q.save
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "GET index" do
|
|
38
|
+
it "displays a list of top Tags" do
|
|
39
|
+
pending 'Need to update for new engine layout.'
|
|
40
|
+
|
|
41
|
+
visit "/"
|
|
42
|
+
# check for basic text
|
|
43
|
+
expect(page).to(have_content("Most Popular Tags"))
|
|
44
|
+
# check for div
|
|
45
|
+
expect(page).to(have_tag("div#tags"))
|
|
46
|
+
|
|
47
|
+
div_children = 4 # four tags listed
|
|
48
|
+
p_children = 3 # three links per tag
|
|
49
|
+
|
|
50
|
+
div_children.times do |div_child|
|
|
51
|
+
expect(page).to(have_css("#tags > div:nth-child(#{div_child+1}) > span > a"))
|
|
52
|
+
|
|
53
|
+
p_children.times do |p_child|
|
|
54
|
+
expect(page).to(have_css("#tags > div:nth-child(#{div_child+1}) > ul > p:nth-child(#{p_child+1}) > a"))
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
|
6
|
+
#
|
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
|
9
|
+
# controller code, this generated spec may or may not pass.
|
|
10
|
+
#
|
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
14
|
+
#
|
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
|
19
|
+
# that an instance is receiving a specific message.
|
|
20
|
+
|
|
21
|
+
RSpec.describe Answers::QuestionsController, :type => :controller do
|
|
22
|
+
|
|
23
|
+
# This should return the minimal set of attributes required to create a valid
|
|
24
|
+
# Question. As you add validations to Question, be sure to
|
|
25
|
+
# adjust the attributes here as well.
|
|
26
|
+
let(:valid_attributes) {
|
|
27
|
+
skip("Add a hash of attributes valid for your model")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let(:invalid_attributes) {
|
|
31
|
+
skip("Add a hash of attributes invalid for your model")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# This should return the minimal set of values that should be in the session
|
|
35
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
36
|
+
# QuestionsController. Be sure to keep this updated too.
|
|
37
|
+
let(:valid_session) { {} }
|
|
38
|
+
|
|
39
|
+
describe "GET index" do
|
|
40
|
+
it "assigns all questions as @questions" do
|
|
41
|
+
question = Answers::Question.create! valid_attributes
|
|
42
|
+
get :index, {}, valid_session
|
|
43
|
+
expect(assigns(:questions)).to eq([question])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "GET show" do
|
|
48
|
+
it "assigns the requested question as @question" do
|
|
49
|
+
question = Answers::Question.create! valid_attributes
|
|
50
|
+
get :show, {:id => question.to_param}, valid_session
|
|
51
|
+
expect(assigns(:question)).to eq(question)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Answers::TagsController, type: :feature do
|
|
4
|
+
context "When tags exist" do
|
|
5
|
+
let(:tag_name) { "Sampletag" }
|
|
6
|
+
let(:tag) { create(:tag, name: tag_name) }
|
|
7
|
+
let(:tags) do
|
|
8
|
+
[tag, create(:tag), create(:tag), create(:tag)]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
before(:each) do
|
|
12
|
+
#create(:tag, id: 1, name: tag_name)
|
|
13
|
+
9.times do
|
|
14
|
+
create(:tag)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "GET index" do
|
|
19
|
+
|
|
20
|
+
it "displays a list of links to tag pages" do
|
|
21
|
+
allow(ActsAsTaggableOn::Tag).to(receive(:all)).and_return(tags)
|
|
22
|
+
|
|
23
|
+
visit answers.tags_path
|
|
24
|
+
expect(page).to(have_content("Listing of All Tags"))
|
|
25
|
+
css = "ul#tags"
|
|
26
|
+
expect(page).to(have_css(css))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "GET show" do
|
|
32
|
+
it "returns http success" do
|
|
33
|
+
allow(ActsAsTaggableOn::Tag).to(receive(:find).with(tag.id)).and_return(tag)
|
|
34
|
+
|
|
35
|
+
visit answers.tag_path(tag)
|
|
36
|
+
expect(page).to(have_content(tag_name))
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
FactoryGirl.define do
|
|
2
|
+
factory :user, class: Answers::User do
|
|
3
|
+
sequence(:email) { |n| "person#{n}@example.com" }
|
|
4
|
+
password "Mahalo43"
|
|
5
|
+
password_confirmation "Mahalo43"
|
|
6
|
+
is_editor true
|
|
7
|
+
is_writer true
|
|
8
|
+
is_admin false
|
|
9
|
+
|
|
10
|
+
factory :admin do
|
|
11
|
+
is_admin true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
factory :editor do
|
|
15
|
+
is_editor true
|
|
16
|
+
is_writer false
|
|
17
|
+
is_admin false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
factory :writer do
|
|
21
|
+
is_writer true
|
|
22
|
+
is_editor false
|
|
23
|
+
is_admin false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
factory :user_no_abilities do
|
|
27
|
+
is_writer false
|
|
28
|
+
is_editor false
|
|
29
|
+
is_admin false
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
include LoginHelpers
|
|
3
|
+
|
|
4
|
+
describe 'Admin Dashboard', :type => :feature do
|
|
5
|
+
describe 'user views the admin dashboard page' do
|
|
6
|
+
context 'with correct login credentials' do
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@article = create(:question, text: 'example title')
|
|
10
|
+
@another_article = create(:question)
|
|
11
|
+
# login_user
|
|
12
|
+
# visit admin_dashboard_path
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'displays a list of recent articles' do
|
|
16
|
+
pending 'needs to be fixed for new engine layout'
|
|
17
|
+
|
|
18
|
+
expect(page).to have_content('Recent Articles')
|
|
19
|
+
expect(page).to have_content(@article.title)
|
|
20
|
+
expect(page).to have_content(@another_article.title)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'displays details about the first article' do
|
|
24
|
+
pending 'needs to be fixed for new engine layout'
|
|
25
|
+
|
|
26
|
+
expect(page).to have_content(@article.type)
|
|
27
|
+
expect(page).to have_content(@article.user.email)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'displays details about the second article' do
|
|
31
|
+
pending 'needs to be fixed for new engine layout'
|
|
32
|
+
|
|
33
|
+
expect(page).to have_content(@another_article.type)
|
|
34
|
+
expect(page).to have_content(@another_article.user.email)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'displays the article details page when the article title is clicked' do
|
|
38
|
+
pending 'needs to be fixed for new engine layout'
|
|
39
|
+
|
|
40
|
+
click_link @article.title
|
|
41
|
+
expect(page).to have_content(@article.preview)
|
|
42
|
+
expect(page).to have_content(@article.content)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context 'without correct login credentials' do
|
|
47
|
+
it 'redirects to the root path and provides a flash message' do
|
|
48
|
+
visit admin_dashboard_path
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
include LoginHelpers
|
|
3
|
+
|
|
4
|
+
describe 'Users', :type => :feature do
|
|
5
|
+
# before { login_user(create(:user, is_admin: true)) }
|
|
6
|
+
|
|
7
|
+
describe 'admin user views user details page' do
|
|
8
|
+
let(:user) { create(:user) }
|
|
9
|
+
before { visit admin_answers_user_path(user) }
|
|
10
|
+
|
|
11
|
+
it 'displays user details' do
|
|
12
|
+
pending 'needs to be fixed for new engine layout'
|
|
13
|
+
|
|
14
|
+
expect(page).to have_content(user.email)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'admin user creates a new user' do
|
|
20
|
+
before { visit new_admin_answers_user_path }
|
|
21
|
+
|
|
22
|
+
it 'successfully creates a user' do
|
|
23
|
+
pending 'needs to be fixed for new engine layout'
|
|
24
|
+
|
|
25
|
+
fill_in 'Email', with: 'another@example.com'
|
|
26
|
+
fill_in 'user_password', with: 'Mahalo43'
|
|
27
|
+
fill_in 'user_password_confirmation', with: 'Mahalo43'
|
|
28
|
+
check 'Writer'
|
|
29
|
+
click_button 'Create User'
|
|
30
|
+
|
|
31
|
+
expect(page).to have_content('User Details')
|
|
32
|
+
expect(page).to have_content('User was successfully created.')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe 'admin user updates an existing user' do
|
|
37
|
+
before { visit edit_admin_answers_user_path(create(:user)) }
|
|
38
|
+
|
|
39
|
+
it 'successfully updates an existing user' do
|
|
40
|
+
pending 'needs to be fixed for new engine layout'
|
|
41
|
+
|
|
42
|
+
fill_in 'Email', with: 'another@example.com'
|
|
43
|
+
click_button 'Update User'
|
|
44
|
+
|
|
45
|
+
expect(page).to have_content('User Details')
|
|
46
|
+
expect(page).to have_content('User was successfully updated')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe 'admin user deletes a user' do
|
|
51
|
+
before { visit admin_answers_user_path(create(:user)) }
|
|
52
|
+
|
|
53
|
+
it 'successfully destroys a user' do
|
|
54
|
+
pending 'needs to be fixed for new engine layout'
|
|
55
|
+
|
|
56
|
+
click_link 'Delete User'
|
|
57
|
+
|
|
58
|
+
expect(page).to have_content('User was successfully destroyed.')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|