Commit 665da0dc authored by Leandro Nunes's avatar Leandro Nunes

Merge branch 'fix-oauth-plugins' into 'master'

fix oauth plugins

See merge request noosfero/noosfero!1679
parents cb8faa28 54b6b2ba
...@@ -21,15 +21,12 @@ before_script: ...@@ -21,15 +21,12 @@ before_script:
- bundle exec rake db:migrate - bundle exec rake db:migrate
stages: stages:
- smoke-tests - test
- all-tests - test-plugins
- test-cucumber
- test-selenium
- code-quality - code-quality
smoke:
script: bundle exec rails ci:smoke
stage: all-tests
stage: smoke-tests
.cache: &cache .cache: &cache
cache: cache:
key: "$CI_BUILD_REF_NAME" key: "$CI_BUILD_REF_NAME"
...@@ -43,72 +40,72 @@ rspec: ...@@ -43,72 +40,72 @@ rspec:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: bundle exec rails test:specs script: bundle exec rails test:specs
stage: all-tests stage: test
api: api:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: bundle exec rails test:api script: bundle exec rails test:api
stage: all-tests stage: test
models: models:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: bundle exec rails test:models script: bundle exec rails test:models
stage: all-tests stage: test
controllers: controllers:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: bundle exec rails test:controllers script: bundle exec rails test:controllers
stage: all-tests stage: test
integration: integration:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: bundle exec rails test:integration script: bundle exec rails test:integration
stage: all-tests stage: test
cucumber-1: cucumber-1:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=1/2 bundle exec cucumber --profile default script: SLICE=1/2 bundle exec cucumber --profile default
stage: all-tests stage: test-cucumber
cucumber-2: cucumber-2:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=2/2 bundle exec cucumber --profile default script: SLICE=2/2 bundle exec cucumber --profile default
stage: all-tests stage: test-cucumber
selenium-1: selenium-1:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=1/6 bundle exec rails selenium script: SLICE=1/6 bundle exec rails selenium
stage: all-tests stage: test-selenium
selenium-2: selenium-2:
<<: *retriable <<: *retriable
script: SLICE=2/6 bundle exec rails selenium script: SLICE=2/6 bundle exec rails selenium
stage: all-tests stage: test-selenium
selenium-3: selenium-3:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=3/6 bundle exec rails selenium script: SLICE=3/6 bundle exec rails selenium
stage: all-tests stage: test-selenium
selenium-4: selenium-4:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=4/6 bundle exec rails selenium script: SLICE=4/6 bundle exec rails selenium
stage: all-tests stage: test-selenium
selenium-5: selenium-5:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=5/6 bundle exec rails selenium script: SLICE=5/6 bundle exec rails selenium
stage: all-tests stage: test-selenium
selenium-6: selenium-6:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=6/6 bundle exec rails selenium script: SLICE=6/6 bundle exec rails selenium
stage: all-tests stage: test-selenium
# NOOSFERO_BUNDLE_OPTS=install makes migrations fails # NOOSFERO_BUNDLE_OPTS=install makes migrations fails
# probably because of rubygems-integration # probably because of rubygems-integration
...@@ -116,33 +113,33 @@ plugins-1: ...@@ -116,33 +113,33 @@ plugins-1:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=1/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install script: SLICE=1/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests stage: test-plugins
plugins-2: plugins-2:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=2/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install script: SLICE=2/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests stage: test-plugins
plugins-3: plugins-3:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=3/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install script: SLICE=3/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests stage: test-plugins
plugins-4: plugins-4:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=4/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install script: SLICE=4/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests stage: test-plugins
plugins-5: plugins-5:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: SLICE=5/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install script: SLICE=5/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests stage: test-plugins
cypress: cypress:
<<: *retriable <<: *retriable
<<: *cache <<: *cache
script: bundle exec rails cypress:run script: bundle exec rails cypress:run
stage: all-tests stage: test
rubocop: rubocop:
<<: *cache <<: *cache
......
...@@ -137,7 +137,7 @@ GEM ...@@ -137,7 +137,7 @@ GEM
addressable (2.5.2) addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 4.0)
ansi (1.5.0) ansi (1.5.0)
api-pagination (4.8.1) api-pagination (4.8.2)
archive-zip (0.11.0) archive-zip (0.11.0)
io-like (~> 0.3.0) io-like (~> 0.3.0)
arel (8.0.0) arel (8.0.0)
...@@ -164,7 +164,7 @@ GEM ...@@ -164,7 +164,7 @@ GEM
chronic (0.10.2) chronic (0.10.2)
coercible (1.0.0) coercible (1.0.0)
descendants_tracker (~> 0.0.1) descendants_tracker (~> 0.0.1)
concurrent-ruby (1.0.5) concurrent-ruby (1.1.5)
connection_pool (2.2.2) connection_pool (2.2.2)
contacts (1.2.4) contacts (1.2.4)
gdata (= 1.1.1) gdata (= 1.1.1)
...@@ -211,7 +211,7 @@ GEM ...@@ -211,7 +211,7 @@ GEM
actionpack (>= 3.1.0) actionpack (>= 3.1.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
equalizer (0.0.11) equalizer (0.0.11)
erubi (1.7.1) erubi (1.8.0)
exception_notification (4.2.2) exception_notification (4.2.2)
actionmailer (>= 4.0, < 6) actionmailer (>= 4.0, < 6)
activesupport (>= 4.0, < 6) activesupport (>= 4.0, < 6)
...@@ -228,7 +228,7 @@ GEM ...@@ -228,7 +228,7 @@ GEM
gherkin (5.1.0) gherkin (5.1.0)
globalid (0.4.1) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
grape (1.1.0) grape (1.2.3)
activesupport activesupport
builder builder
mustermann-grape (~> 1.0.0) mustermann-grape (~> 1.0.0)
...@@ -238,7 +238,7 @@ GEM ...@@ -238,7 +238,7 @@ GEM
grape-entity (0.7.1) grape-entity (0.7.1)
activesupport (>= 4.0) activesupport (>= 4.0)
multi_json (>= 1.3.2) multi_json (>= 1.3.2)
grape_logging (1.8.0) grape_logging (1.8.1)
grape grape
rack rack
hkdf (0.3.0) hkdf (0.3.0)
...@@ -246,7 +246,7 @@ GEM ...@@ -246,7 +246,7 @@ GEM
http-2 (0.9.0) http-2 (0.9.0)
http-cookie (1.0.3) http-cookie (1.0.3)
domain_name (~> 0.5) domain_name (~> 0.5)
i18n (1.1.1) i18n (1.6.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
ice_nine (0.11.2) ice_nine (0.11.2)
io-like (0.3.0) io-like (0.3.0)
...@@ -271,7 +271,7 @@ GEM ...@@ -271,7 +271,7 @@ GEM
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812) mime-types-data (3.2018.0812)
mini_mime (1.0.1) mini_mime (1.0.1)
mini_portile2 (2.3.0) mini_portile2 (2.4.0)
minitest (5.11.3) minitest (5.11.3)
minitest-reporters (1.3.5) minitest-reporters (1.3.5)
ansi ansi
...@@ -291,8 +291,8 @@ GEM ...@@ -291,8 +291,8 @@ GEM
http-2 (= 0.9.0) http-2 (= 0.9.0)
netrc (0.11.0) netrc (0.11.0)
nio4r (2.3.1) nio4r (2.3.1)
nokogiri (1.8.5) nokogiri (1.10.2)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.4.0)
parallel (1.12.1) parallel (1.12.1)
parser (2.5.3.0) parser (2.5.3.0)
ast (~> 2.4.0) ast (~> 2.4.0)
...@@ -437,10 +437,10 @@ GEM ...@@ -437,10 +437,10 @@ GEM
sprockets (3.7.2) sprockets (3.7.2)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (> 1, < 3) rack (> 1, < 3)
sprockets-rails (2.3.3) sprockets-rails (3.2.1)
actionpack (>= 3.0) actionpack (>= 4.0)
activesupport (>= 3.0) activesupport (>= 4.0)
sprockets (>= 2.8, < 4.0) sprockets (>= 3.0.0)
temple (0.8.0) temple (0.8.0)
test-unit (3.2.8) test-unit (3.2.8)
power_assert power_assert
......
require_dependency 'api/helpers' require_dependency 'api/helpers'
module Api module Api
class App < Grape::API class App < Grape::API::Instance
logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log")) logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log"))
logger.formatter = GrapeLogging::Formatters::Default.new logger.formatter = GrapeLogging::Formatters::Default.new
...@@ -60,7 +60,7 @@ module Api ...@@ -60,7 +60,7 @@ module Api
@plugins.each do |klass| @plugins.each do |klass|
if klass.public_methods.include? :api_mount_points if klass.public_methods.include? :api_mount_points
klass.api_mount_points.each do |mount_class| klass.api_mount_points.each do |mount_class|
mount mount_class if mount_class && ( mount_class < Grape::API ) mount mount_class if mount_class && ( mount_class < Grape::API::Instance )
end end
end end
end end
......
...@@ -253,7 +253,8 @@ module Api ...@@ -253,7 +253,8 @@ module Api
end end
class Article < ArticleBase class Article < ArticleBase
expose :parent, :using => ArticleBase expose :parent, :using => ArticleBase, :if => lambda {|article, options| Entities.expose_optional_field?(:parent, options)}
expose :parent_id
expose :children, :using => ArticleBase do |article, options| expose :children, :using => ArticleBase do |article, options|
article.children.published.limit(V1::Articles::MAX_PER_PAGE) article.children.published.limit(V1::Articles::MAX_PER_PAGE)
end end
......
module Api module Api
module V1 module V1
class Activities < Grape::API class Activities < Grape::API::Instance
resource :profiles do resource :profiles do
......
module Api module Api
module V1 module V1
class Articles < Grape::API class Articles < Grape::API::Instance
ARTICLE_TYPES = Article.descendants.map{|a| a.to_s} ARTICLE_TYPES = Article.descendants.map{|a| a.to_s}
......
module Api module Api
module V1 module V1
class Blocks < Grape::API class Blocks < Grape::API::Instance
resource :profiles do resource :profiles do
segment '/:id' do segment '/:id' do
......
module Api module Api
module V1 module V1
class Boxes < Grape::API class Boxes < Grape::API::Instance
kinds = %w[profile community person enterprise] kinds = %w[profile community person enterprise]
kinds.each do |kind| kinds.each do |kind|
......
module Api module Api
module V1 module V1
class Categories < Grape::API class Categories < Grape::API::Instance
resource :categories do resource :categories do
......
module Api module Api
module V1 module V1
class Comments < Grape::API class Comments < Grape::API::Instance
MAX_PER_PAGE = 20 MAX_PER_PAGE = 20
......
module Api module Api
module V1 module V1
class Communities < Grape::API class Communities < Grape::API::Instance
resource :communities do resource :communities do
......
module Api module Api
module V1 module V1
class Domains < Grape::API class Domains < Grape::API::Instance
MAX_PER_PAGE = 20 MAX_PER_PAGE = 20
paginate per_page: MAX_PER_PAGE, max_per_page: MAX_PER_PAGE paginate per_page: MAX_PER_PAGE, max_per_page: MAX_PER_PAGE
......
module Api module Api
module V1 module V1
class Enterprises < Grape::API class Enterprises < Grape::API::Instance
resource :enterprises do resource :enterprises do
......
module Api module Api
module V1 module V1
class Environments < Grape::API class Environments < Grape::API::Instance
resource :environments do resource :environments do
......
module Api module Api
module V1 module V1
class People < Grape::API class People < Grape::API::Instance
MAX_PER_PAGE = 50 MAX_PER_PAGE = 50
......
module Api module Api
module V1 module V1
class Profiles < Grape::API class Profiles < Grape::API::Instance
resource :profiles do resource :profiles do
......
module Api module Api
module V1 module V1
class Roles < Grape::API class Roles < Grape::API::Instance
MAX_PER_PAGE = 50 MAX_PER_PAGE = 50
......
...@@ -2,7 +2,7 @@ require "uri" ...@@ -2,7 +2,7 @@ require "uri"
module Api module Api
module V1 module V1
class Session < Grape::API class Session < Grape::API::Instance
# Login to get token # Login to get token
# #
......
module Api module Api
module V1 module V1
class Settings < Grape::API class Settings < Grape::API::Instance
kinds = %w[profile environment] kinds = %w[profile environment]
kinds.each do |kind| kinds.each do |kind|
......
module Api module Api
module V1 module V1
class Tags < Grape::API class Tags < Grape::API::Instance
resource :articles do resource :articles do
resource ':id/tags' do resource ':id/tags' do
get do get do
......
module Api module Api
module V1 module V1
class Tasks < Grape::API class Tasks < Grape::API::Instance
before { authenticate! } before { authenticate! }
MAX_PER_PAGE = 50 MAX_PER_PAGE = 50
......
module Api module Api
module V1 module V1
class Users < Grape::API class Users < Grape::API::Instance
resource :users do resource :users do
......
...@@ -61,12 +61,19 @@ module LayoutHelper ...@@ -61,12 +61,19 @@ module LayoutHelper
unless plugins_stylesheets.empty? unless plugins_stylesheets.empty?
# FIXME: caching does not work with asset pipeline # FIXME: caching does not work with asset pipeline
#cacheid = "cache/plugins-#{Digest::MD5.hexdigest plugins_stylesheets.to_s}" #cacheid = "cache/plugins-#{Digest::MD5.hexdigest plugins_stylesheets.to_s}"
output << stylesheet_link_tag(*plugins_stylesheets) plugins_stylesheets.map do |plugin_stylesheet|
if File.exists?(File.join(Rails.root.join, 'public', plugin_stylesheet))
output << stylesheet_link_tag(plugin_stylesheet)
end
end
end end
if File.exists? global_css_at_fs if File.exists? global_css_at_fs
output << stylesheet_link_tag(global_css_pub) output << stylesheet_link_tag(global_css_pub)
end end
output << stylesheet_link_tag(theme_stylesheet_path)
if File.exists?(File.join(Rails.root.join, 'public', theme_stylesheet_path))
output << stylesheet_link_tag(theme_stylesheet_path)
end
# This output should be safe! # This output should be safe!
output.join("\n").html_safe output.join("\n").html_safe
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
%></title> %></title>
<%= stylesheet_import "slideshow" %> <%= stylesheet_import "slideshow" %>
<%= javascript_include_tag 'jquery-2.1.1.min', 'vendor/sliderjs', 'vendor/pikachoose' %> <%= javascript_include_tag 'vendor/jquery-2.1.1.min', 'vendor/sliderjs', 'vendor/pikachoose' %>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function (){ $(document).ready(function (){
$("#slideshow").PikaChoose({ $("#slideshow").PikaChoose({
......
...@@ -115,6 +115,36 @@ module Noosfero ...@@ -115,6 +115,36 @@ module Noosfero
# Version of your assets, change this if you want to expire all your assets # Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0' config.assets.version = '1.0'
initializer 'setup_asset_pipeline', :group => :all do |app|
# We don't want the default of everything that isn't js or css, because it pulls too many things in
app.config.assets.precompile.shift
# Explicitly register the extensions we are interested in compiling
app.config.assets.precompile.push(Proc.new do |path|
File.extname(path).in? [
# '.html', '.erb', '.haml', # Templates
'.png', '.gif', '.jpg', '.jpeg', # Images
'.eot', '.otf', '.svc', '.woff', '.ttf', # Fonts
]
end)
# Add extra assets
app.config.assets.precompile += Dir.glob('public/plugins/*/**/*.js').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/javascripts/*').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/javascripts/*/**/*.js').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/designs/icons/*/**/*.js').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/stylesheets/*/**/*.css').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/stylesheets/*/**/*.scss').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/stylesheets/*').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/plugins/*/*.css').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/plugins/*/**/*.css').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/plugins/*/**/*.scss').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/designs/themes/*/**/*.css').map{|path| path.gsub('public/', '')}