Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Commit

Permalink
Better spec coverage + fixes
Browse files Browse the repository at this point in the history
- Fix so specs pass.
- Add more specs now 95%+
- Fix all locales and removed duplicate sub locales (tested with
i18n_spec).
- Add Swedish locale.
- Moved generator.rb to sub "install” dir because it didn’t init.
- Fix assets paths.
- Admin pages tab moved to Configuration due to it made top menu
items collapse, new layout same style as products for consistency.
- Fixed hooks etc to correspond to Spree 2.1+ way.
  • Loading branch information
futhr committed Feb 4, 2014
1 parent 6ac885b commit 4e8562e
Show file tree
Hide file tree
Showing 56 changed files with 841 additions and 662 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ nbproject
**.gem
Gemfile.lock
spec/dummy/
.rvmrc
tmp
coverage
7 changes: 0 additions & 7 deletions CONTRIBUTORS.textile

This file was deleted.

9 changes: 9 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
guard "rspec", cmd: "bundle exec rspec" do
watch("spec/spec_helper.rb") { "spec" }
watch("config/routes.rb") { "spec/controllers" }
watch("app/controllers/application_controller.rb") { "spec/controllers" }
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
end
26 changes: 26 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2014 Peter Berkenbosch and contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Spree nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113 changes: 43 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,93 @@
# Spree Static Content

[![Build Status](https://secure.travis-ci.org/spree/spree_static_content.png?branch=master)](http://travis-ci.org/spree/spree_static_content)
[![Build Status](https://api.travis-ci.org/spree/spree_static_content.png?branch=master)](https://travis-ci.org/spree/spree_static_content)

Good, clean content management of pages for Spree. You can use this to:

- Add and manage static pages such as an 'About' page.
- Show a static page instead of existing dynamic pages such as the home page,
products pages, and taxon pages.

## HowTo

Using the 'Pages' option in the admin tab, you can add static pages to your Spree install. The page content can
be pulled directly from the database, be a separate layout file or rendered as a partial.

In the admin tab, use the 'New page' option to create a new static page.

The title, slug, body, and meta fields will replace their respective page elements on load. The title, slug and
The title, slug, body, and meta fields will replace their respective page elements on load. The title, slug and
body element are all required fields.

Body text provided without a layout / partial being specified will be loaded in the spree_application layout after
it is pulled from the database.

**Layout and Partial Rendering**

To render an entire page without the spree_application layout, specify a relative path to the layout file (eg.
spree/layouts/layout_file_name). This file will not be prefixed with an underscore as it is a layout, not a partial.
To render an entire page without the spree_application layout, specify a relative path to the layout file (eg.
`spree/layouts/layout_file_name`). This file will not be prefixed with an underscore as it is a layout, not a partial.

To render a partial, specify the path in the layout file name and check the 'Render layout as partial' option. The
path specified in the layout area will not have an underscore, but it will be required in the filename.

Also note the availability of the render_snippet helper which finds a page by its slug and renders the raw page
Also note the availability of the render_snippet helper which finds a page by its slug and renders the raw page
body anywhere in your view.

**Options**

Use the 'Show in' checkboxes to specify whether to display the page links in the header, footer or sidebar. The
Use the 'Show in' checkboxes to specify whether to display the page links in the header, footer or sidebar. The
position setting alters the order in which they appear.

Finally, toggle the visibility using the 'Visible' checkbox. If it is unchecked, the page will not be available.

## Basic Installation

**For Spree HEAD**

1. Add the following to your Gemfile

```
gem 'spree_static_content', :github => 'spree/spree_static_content'
```

2. Run `bundle install`
3. To copy and apply migrations run: `rails g spree_static_content:install`
Add to your `Gemfile`:

**For Spree 1.3.x**

1. Add the following to your Gemfile

```
gem 'spree_static_content', :github => 'spree/spree_static_content', :branch => '1-3-stable'
```ruby
gem 'spree_static_content', github: 'spree/spree_static_content', branch: 'master'
```

2. Run `bundle install`
3. To copy and apply migrations run: `rails g spree_static_content:install`
Run:

bundle install
rails g spree_static_content:install

**For Spree 1.2.x**
That's all!

1. Add the following to your Gemfile

```
gem 'spree_static_content', :github => 'spree/spree_static_content', :branch => '1-2-stable'
```
**NOTE: Check [Versionfile][1] for corresponding gem `branch` for your Spree version.**

2. Run `bundle install`
3. To copy and apply migrations run: `rails g spree_static_content:install`
## Contributing

In the spirit of [free software][2], **everyone** is encouraged to help improve this project.

**For Spree 1.1.x**

1. Add the following to your Gemfile

```
gem 'spree_static_content', :github => 'spree/spree_static_content', :branch => '1-1-stable'
```

2. Run `bundle install`
3. To copy and apply migrations run: `rails g spree_static_content:install`

**For Spree 1.0.x**

1. Add the following to your Gemfile

```
gem 'spree_static_content', :github => 'spree/spree_static_content', :branch => '1-0-stable'
```

2. Run `bundle install`
3. To copy and apply migrations run: `rails g spree_static_content:install`
Here are some ways *you* can contribute:

## Development
* by using prerelease versions
* by reporting [bugs][3]
* by suggesting new features
* by writing translations
* by writing or editing documentation
* by writing specifications
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
* by refactoring code
* by resolving [issues][3]
* by reviewing patches

1. fork the repo here: https://github.com/spree/spree_static_content
2. inside your fork run `bundle install`
3. make sure the tests can run on your system run : `bundle exec rake test_app && bundle exec rspec spec`
Starting point:

You can also run `bundle exec rake test_app` and then to run the specs run `bundle exec rake`
* Fork the repo
* Clone your repo
* Run `bundle install`
* Run `bundle exec rake test_app` to create the test application in `spec/test_app`
* Make your changes
* Ensure specs pass by running `bundle exec rspec spec`
* Submit your pull request

### Fix bugs or add functionality
Copyright (c) 2014 [Peter Berkenbosch][4] and [contributors][5], released under the [New BSD License][6]

1. create a feature branch
<pre>
git checkout -b my-feature-branch
</pre>
2. Apply your changes and add specs.
3. Push the feature branch to your fork:
<pre>
git push -u origin my-feature-branch
</pre>
4. Send a pull request from your feature branch in the forked repository on github.
[1]: https://github.com/spree/spree_static_content/blob/master/Versionfile
[2]: http://www.fsf.org/licensing/essays/free-sw.html
[3]: https://github.com/spree/spree_static_content/issues
[4]: https://github.com/peterberkenbosch
[5]: https://github.com/spree/spree_static_content/graphs/contributors
[6]: https://github.com/spree/spree_static_content/blob/master/LICENSE.md
14 changes: 2 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# encoding: utf-8
require 'bundler'
Bundler::GemHelper.install_tasks
Bundler.setup

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

require 'spree/testing_support/common_rake'

desc "Default Task"
task :default => [ :spec ]
RSpec::Core::RakeTask.new

namespace :test_app do
desc 'Rebuild test and cucumber databases'
task :rebuild_dbs do
system("cd spec/test_app && rake db:drop db:migrate RAILS_ENV=test && rake db:drop db:migrate RAILS_ENV=cucumber && rake railties:install:migrations FROM=spree_static_content db:migrate")
end
end
task :default => [:spec]

desc "Generates a dummy app for testing"
task :test_app do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//= require spree/backend
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//= require spree/frontend
Empty file.
6 changes: 0 additions & 6 deletions app/assets/stylesheets/admin/spree_static_content.css

This file was deleted.

3 changes: 3 additions & 0 deletions app/assets/stylesheets/spree/backend/spree_static_content.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
*= require spree/backend
*/
11 changes: 11 additions & 0 deletions app/assets/stylesheets/spree/frontend/spree_static_content.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
*= require spree/frontend
*/

/* Sidebar */
nav#pages .pages-root {
text-transform: uppercase;
border-bottom: 1px solid rgb(217, 217, 219);
margin-bottom: 5px;
font-size: 14px;
}
Empty file.
1 change: 0 additions & 1 deletion app/controllers/spree/static_content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ def determine_layout
def accurate_title
@page ? (@page.meta_title.present? ? @page.meta_title : @page.title) : nil
end

end
5 changes: 5 additions & 0 deletions app/overrides/add_pages_to_admin_configuration_sidebar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deface::Override.new(virtual_path: "spree/admin/shared/_configuration_menu",
name: "pages_admin_configurations_menu",
insert_bottom: "[data-hook='admin_configurations_sidebar_menu'], #admin_configurations_sidebar_menu[data-hook]",
text: "<%= configurations_sidebar_menu_item Spree.t(:pages), admin_pages_path %>",
disabled: false)
5 changes: 0 additions & 5 deletions app/overrides/static_content_admin_tab.rb

This file was deleted.

Loading

0 comments on commit 4e8562e

Please sign in to comment.