mighty_grid 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f2ecaf85f78ae13f5243d1a94d4bfd92c7c3b64
4
- data.tar.gz: c28ac23cd0ac630310e35d8781ca3e35d653dde2
3
+ metadata.gz: 6b767e8e8c424d0fd0b2aa47ef21df2228781185
4
+ data.tar.gz: 6d6db95c86982b32d8bb99b3f75a6e6dbacada99
5
5
  SHA512:
6
- metadata.gz: 53b34a9474a8a848a07970ba31888b17974460c5192f3163a0ff5dcc7d4d937c9ab004fa8688e004176e0745afb984e54041692ae68f67f6afc8a90e09d7653d
7
- data.tar.gz: 70c3fd56f39318ab809a727a04fc1e8ec1a1938d6851fffce0587c9989a17536484d714ac0e2336bf2982ec50bf15848482c3d0eaf44d0783c5aa5ad6516295c
6
+ metadata.gz: d95807732eb29bdcd4f6261e0ee5d0e0d52490f548455464f62806846267913a1faf70866fa668d2ad2afbaa0178576d06c6f453d9c98f0e062caf229b915408
7
+ data.tar.gz: 9ee5f55ba15eabbde84ef511a5f170d31f50d0af2a8f73c8ab6639f9a57a2b6cfcd5e1eabebaf08238f102f43c719284a86e5693f59f3771e51af01e6a572083
data/.travis.yml CHANGED
@@ -4,7 +4,7 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.1
6
6
 
7
- script: bundle exec rake spec
7
+ script: bundle exec rake spec cucumber
8
8
 
9
9
  before_script:
10
10
  - cp spec/fake_app/config/database.yml.example spec/fake_app/config/database.yml
data/Gemfile CHANGED
@@ -7,6 +7,8 @@ group :test do
7
7
  gem "generator_spec"
8
8
  gem 'capybara'
9
9
  gem 'database_cleaner'
10
+ gem 'cucumber-rails'
11
+ gem 'spreewald'
10
12
 
11
13
  gem 'coveralls', require: false
12
14
  gem "codeclimate-test-reporter", require: nil
data/Rakefile CHANGED
@@ -1,28 +1,16 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'appraisal'
3
3
  require 'rspec/core/rake_task'
4
+ require 'cucumber/rake/task'
4
5
 
5
- RSpec::Core::RakeTask.new(:spec) do |spec|
6
- spec.pattern = FileList['spec/**/*_spec.rb']
6
+ if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
7
+ task :default => :appraisal
7
8
  end
8
9
 
9
- desc 'Default: run unit tests.'
10
- task :default => "spec:all"
10
+ desc 'Test the paperclip plugin.'
11
+ RSpec::Core::RakeTask.new(:spec)
11
12
 
12
- namespace :spec do
13
- %w(rails_32 rails_40 rails_41).each do |gemfile|
14
- desc "Run tests against #{gemfile}"
15
- task gemfile do
16
- sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
17
- sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t spec"
18
- end
19
- end
20
-
21
- desc "Run all tests"
22
- task :all do
23
- %w(rails_32 rails_40 rails_41).each do |gemfile|
24
- sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
25
- sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec"
26
- end
27
- end
28
- end
13
+ desc 'Run integration test'
14
+ Cucumber::Rake::Task.new do |t|
15
+ t.cucumber_opts = %w{--format progress}
16
+ end
@@ -0,0 +1,42 @@
1
+ Feature: Filtering
2
+
3
+ Background:
4
+ Given I generate 100 users
5
+
6
+ Scenario: Filtering by text_field
7
+ Given I am on the list of users page
8
+ When I fill in "Name" with "user001"
9
+ And I press "Apply changes"
10
+ Then I should see "user001"
11
+ And the "Name" field should contain "user001"
12
+ And I should see "1 of 1"
13
+
14
+ Scenario: Filtering by select
15
+ Given I am on the list of users page
16
+ When I select "Admin" from "Role"
17
+ And I press "Apply changes"
18
+ Then I should see "admin001"
19
+ And "Admin" should be selected for "Role"
20
+ And I should see "1 of 1"
21
+
22
+ Scenario: Filtering by checkox
23
+ Given I am on the list of users page
24
+ When I check "Banned"
25
+ And I press "Apply changes"
26
+ Then the "Banned" checkbox should be checked
27
+ And I should see "user101"
28
+ And I should see "1 of 1"
29
+
30
+ # Scenario: Reset filter
31
+ # Given I am on the list of users page
32
+ # When I fill in "Name" with "user001"
33
+ # And I select "Admin" from "Role"
34
+ # And I check "Banned"
35
+ # And I press "Apply changes"
36
+ # Then the "Name" field should contain "user001"
37
+ # And "Admin" should be selected for "Role"
38
+ # And the "Banned" checkbox should be checked
39
+ # When I press "Reset changes"
40
+ # Then the "Name" field should contain ""
41
+ # And nothing should be selected for "Role"
42
+ # And the "Banned" checkbox should not be checked
@@ -0,0 +1,5 @@
1
+ Given /^I generate (\d+) users$/ do |n|
2
+ 1.upto(n.to_i) {|i| User.create! :name => "user#{'%03d' % i}" }
3
+ User.create! :name => "admin#{'%03d' % 1}", role: :admin
4
+ User.create! :name => "user#{'%03d' % (n.to_i + 1)}", is_banned: true
5
+ end
@@ -0,0 +1,12 @@
1
+ begin
2
+ require 'database_cleaner'
3
+ require 'database_cleaner/cucumber'
4
+
5
+ DatabaseCleaner.strategy = :truncation
6
+ rescue NameError
7
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
8
+ end
9
+
10
+ # Around do |scenario, block|
11
+ # DatabaseCleaner.cleaning(&block)
12
+ # end
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'rails'
3
+ require 'rails/generators'
4
+ rescue LoadError
5
+ end
6
+
7
+ require 'capybara/cucumber'
8
+ require 'bundler/setup'
9
+ Bundler.require
10
+
11
+ if defined? Rails
12
+ require_relative '../../spec/fake_app/rails_app'
13
+ end
14
+
15
+ require 'spreewald/web_steps'
16
+ require 'spreewald/table_steps'
17
+ require 'spreewald/development_steps'
@@ -0,0 +1,27 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.feature
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /^the list of users\s?page$/
12
+ '/users'
13
+
14
+ else
15
+ begin
16
+ page_name =~ /^the (.*) page$/
17
+ path_components = $1.split(/\s+/)
18
+ self.send(path_components.push('path').join('_').to_sym)
19
+ rescue NoMethodError, ArgumentError
20
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
21
+ "Now, go and add a mapping in #{__FILE__}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ World(NavigationHelpers)
@@ -10,6 +10,8 @@ group :test do
10
10
  gem "generator_spec"
11
11
  gem "capybara"
12
12
  gem "database_cleaner"
13
+ gem "cucumber-rails"
14
+ gem "spreewald"
13
15
  gem "coveralls", :require => false
14
16
  gem "codeclimate-test-reporter", :require => nil
15
17
  gem "pg", :require => false
@@ -10,6 +10,8 @@ group :test do
10
10
  gem "generator_spec"
11
11
  gem "capybara"
12
12
  gem "database_cleaner"
13
+ gem "cucumber-rails"
14
+ gem "spreewald"
13
15
  gem "coveralls", :require => false
14
16
  gem "codeclimate-test-reporter", :require => nil
15
17
  gem "pg", :require => false
@@ -10,6 +10,8 @@ group :test do
10
10
  gem "generator_spec"
11
11
  gem "capybara"
12
12
  gem "database_cleaner"
13
+ gem "cucumber-rails"
14
+ gem "spreewald"
13
15
  gem "coveralls", :require => false
14
16
  gem "codeclimate-test-reporter", :require => nil
15
17
  gem "pg", :require => false
@@ -41,22 +41,29 @@ module MightyGrid
41
41
  joins(@options[:joins])
42
42
  end
43
43
 
44
+ # Apply filters
44
45
  def apply_filters
45
46
  filter_params.each do |filter_name, filter_value|
46
47
  next if filter_value.blank? || !klass.column_names.include?(filter_name)
47
48
  field_type = klass.columns_hash[filter_name].type
48
- if @filters.has_key?(filter_name.to_sym) && Array === @filters[filter_name.to_sym] || field_type == :boolean
49
+
50
+ if @filters.has_key?(filter_name.to_sym) && @filters[filter_name.to_sym].is_a?(Array)
49
51
  @relation = @relation.where(filter_name => filter_value)
52
+ elsif field_type == :boolean
53
+ value = ['true', '1', 't'].include?(filter_value) ? true : false
54
+ @relation = @relation.where(filter_name => value)
50
55
  elsif [:string, :text].include?(field_type)
51
56
  @relation = @relation.where("#{klass.table_name}.#{filter_name} #{like_operator} ?", "%#{filter_value}%")
52
57
  end
53
58
  end
54
59
  end
55
60
 
61
+ # Get controller parameters
56
62
  def params
57
63
  @controller.params
58
64
  end
59
65
 
66
+ # Load grid parameters
60
67
  def load_grid_params
61
68
  @mg_params = {}
62
69
  @mg_params.merge!(@options)
@@ -65,29 +72,36 @@ module MightyGrid
65
72
  end
66
73
  end
67
74
 
75
+ # Get current grid parameter by name
68
76
  def get_current_grid_param(name)
69
77
  current_grid_params.has_key?(name) ? current_grid_params[name] : nil
70
78
  end
71
79
 
80
+ # Get filter parameters
72
81
  def filter_params
73
82
  get_current_grid_param(filter_param_name) || {}
74
83
  end
75
84
 
85
+ # Get filter parameter name
76
86
  def filter_param_name; 'f' end
77
87
 
88
+ # Get filter name by field
78
89
  def get_filter_name(filter_name)
79
90
  "#{name}[#{filter_param_name}][#{filter_name}]"
80
91
  end
81
92
 
93
+ # Get current grid parameters
82
94
  def current_grid_params
83
95
  params[name] || {}
84
96
  end
85
97
 
98
+ # Get order parameters
86
99
  def order_params(attribute)
87
100
  direction = attribute.to_s == @mg_params[:order] ? another_order_direction : 'asc'
88
101
  {@name => {order: attribute, order_direction: direction}}
89
102
  end
90
103
 
104
+ # Get current order direction
91
105
  def current_order_direction
92
106
  direction = nil
93
107
  if current_grid_params.has_key?('order_direction') && ['asc', 'desc'].include?(current_grid_params['order_direction'].downcase)
@@ -96,10 +110,12 @@ module MightyGrid
96
110
  direction
97
111
  end
98
112
 
113
+ # Get another order direction
99
114
  def another_order_direction
100
115
  (current_grid_params.has_key?('order_direction')) ? (['asc', 'desc'] - [current_grid_params['order_direction'].to_s]).first : MightyGrid.config.order_direction
101
116
  end
102
117
 
118
+ # Get <tt>like</tt> or <tt>ilike</tt> operator depending on the database adapter
103
119
  def like_operator
104
120
  if ActiveRecord::ConnectionAdapters.const_defined?(:PostgreSQLAdapter) && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
105
121
  'ILIKE'
@@ -8,7 +8,16 @@ module MightyGrid
8
8
 
9
9
  def label(name, content_or_options = nil, options = nil, &block)
10
10
  filter_name = @grid.get_filter_name(name).parameterize('_')
11
- label_tag(filter_name, content_or_options, options, &block)
11
+
12
+ if content_or_options.is_a?(Hash)
13
+ options = content_or_options
14
+ else
15
+ name ||= content_or_options
16
+ end
17
+
18
+ name = @grid.klass.human_attribute_name(name)
19
+
20
+ label_tag(filter_name, name, options, &block)
12
21
  end
13
22
 
14
23
  def text_field(name, options={})
@@ -16,7 +25,6 @@ module MightyGrid
16
25
  end
17
26
 
18
27
  def select(name, option_tags=nil, options={})
19
-
20
28
  @grid.filters[name] = option_tags
21
29
  selected = nil
22
30
  selected = options.delete(:selected) if options.has_key?(:selected)
@@ -1,3 +1,3 @@
1
1
  module MightyGrid
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -1,24 +1,25 @@
1
1
  # MODELS
2
- class Product < ActiveRecord::Base
2
+ class User < ActiveRecord::Base
3
3
  belongs_to :company
4
4
  end
5
5
 
6
6
  class Company < ActiveRecord::Base
7
- has_many :products
7
+ has_many :users
8
8
  end
9
9
 
10
10
  # MIGRATIONS
11
11
  class CreateAllTables < ActiveRecord::Migration
12
12
  def self.up
13
- create_table(:products) { |t| t.string :name; t.text :description; t.integer :company_id }
14
- create_table(:companies) { |t| t.string :name; t.text :description }
13
+ create_table(:users) { |t| t.string :name; t.string :role; t.integer :company_id; t.boolean :is_banned, default: false, null: false }
14
+ create_table(:companies) { |t| t.string :name; }
15
15
  end
16
16
 
17
17
  def self.down
18
- drop_table :products
18
+ drop_table :users
19
19
  drop_table :companies
20
20
  end
21
21
  end
22
22
 
23
+ CreateAllTables.down if User.table_exists? || Company.table_exists?
23
24
  ActiveRecord::Migration.verbose = false
24
25
  CreateAllTables.up
@@ -3,7 +3,7 @@ require 'action_view/railtie'
3
3
 
4
4
  require 'capybara/rspec'
5
5
 
6
- require 'fake_app/models/config'
6
+ require_relative 'models/config'
7
7
 
8
8
  app = Class.new(Rails::Application)
9
9
  app.config.secret_token = '7295e7f2718c940f459e5062f575cd92'
@@ -18,17 +18,17 @@ app.initialize!
18
18
 
19
19
  # ROUTES
20
20
  app.routes.draw do
21
- resources :products
21
+ resources :users
22
22
  end
23
23
 
24
24
  # MODELS
25
- require 'fake_app/models/active_record'
25
+ require_relative 'models/active_record'
26
26
 
27
27
  # CONTROLLERS
28
28
  class ApplicationController < ActionController::Base; end
29
- class ProductsController < ApplicationController
29
+ class UsersController < ApplicationController
30
30
  def index
31
- @products_grid = init_grid(Product)
31
+ @users_grid = init_grid(User)
32
32
  render 'spec/fake_app/views/index', layout: false
33
33
  end
34
34
  end
@@ -1,8 +1,20 @@
1
- <%= mighty_filter_for @products_grid do |filter| %>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <%= mighty_filter_for @users_grid do |filter| %>
6
+ <%= filter.label :name %>
2
7
  <%= filter.text_field :name %>
8
+ <%= filter.label :role %>
9
+ <%= filter.select :role, [:user, :publisher, :moderator, :admin].map{|r| [r.capitalize, r]}, prompt: 'Select role' %>
10
+ <label><%= filter.check_box :is_banned, 't' %> Banned</label>
3
11
  <%= filter.submit %>
12
+ <%= filter.reset %>
4
13
  <% end %>
5
14
 
6
- <%= grid @products_grid do |g| %>
7
- <% g.column :name %>
8
- <% end %>
15
+ <%= grid @users_grid do |g| %>
16
+ <% g.column :name %>
17
+ <% g.column :role %>
18
+ <% end %>
19
+ </body>
20
+ </html>
@@ -10,14 +10,14 @@ describe MightyGrid::Base do
10
10
 
11
11
  describe '#new' do
12
12
  context 'by default' do
13
- subject { MightyGrid::Base.new(Product, @controller) }
13
+ subject { MightyGrid::Base.new(User, @controller) }
14
14
  its(:params) { should == {} }
15
15
  its(:options) { should == @default_options }
16
16
  its(:mg_params) { should == @default_options }
17
17
  its(:filters) { should == {} }
18
18
  its(:name) { should == 'grid' }
19
- its(:relation) { should == Product }
20
- its(:klass) { should == Product }
19
+ its(:relation) { should == User }
20
+ its(:klass) { should == User }
21
21
  its(:current_grid_params) { should == {} }
22
22
  its(:current_order_direction) { should == nil }
23
23
  its(:another_order_direction) { should == 'asc' }
@@ -28,26 +28,26 @@ describe MightyGrid::Base do
28
28
  end
29
29
 
30
30
  context 'with custom' do
31
- subject { MightyGrid::Base.new(Product, @controller, page: 2, per_page: 10, name: 'grid1') }
31
+ subject { MightyGrid::Base.new(User, @controller, page: 2, per_page: 10, name: 'grid1') }
32
32
  its(:options) { should == @default_options.merge(page: 2, per_page: 10, name: 'grid1') }
33
33
  end
34
34
 
35
35
  context 'with custom' do
36
36
  before(:all){ @controller.params = {'grid' => {page: 5, per_page: 30, name: 'grid2'}} }
37
- subject { MightyGrid::Base.new(Product, @controller) }
37
+ subject { MightyGrid::Base.new(User, @controller) }
38
38
  its(:params) { should == @controller.params }
39
39
  its(:mg_params) { should == @default_options.merge(page: 5, per_page: 30, name: 'grid2') }
40
40
  after(:all){ @controller.params = {} }
41
41
  end
42
42
 
43
43
  context 'with bad options' do
44
- it { expect{MightyGrid::Base.new(Product, @controller, bad_option: 123)}.to raise_error(ArgumentError) }
44
+ it { expect{MightyGrid::Base.new(User, @controller, bad_option: 123)}.to raise_error(ArgumentError) }
45
45
  end
46
46
  end
47
47
 
48
48
  describe '#get_current_grid_param' do
49
49
  before(:all){ @controller.params = {'grid'=>{per_page: 30}} }
50
- subject { MightyGrid::Base.new(Product, @controller).get_current_grid_param(:per_page) }
50
+ subject { MightyGrid::Base.new(User, @controller).get_current_grid_param(:per_page) }
51
51
  it { should == 30 }
52
52
  after(:all){ @controller.params = {} }
53
53
  end
@@ -55,21 +55,21 @@ describe MightyGrid::Base do
55
55
  describe '#current_order_direction' do
56
56
  context 'with ASC controller param' do
57
57
  before(:all){ @controller.params = {'grid'=>{'order_direction' => 'asc'}} }
58
- subject { MightyGrid::Base.new(Product, @controller) }
58
+ subject { MightyGrid::Base.new(User, @controller) }
59
59
  its(:current_order_direction) { should == 'asc' }
60
60
  after(:all){ @controller.params = {} }
61
61
  end
62
62
 
63
63
  context 'with DESC controller param' do
64
64
  before(:all){ @controller.params = {'grid'=>{'order_direction' => 'desc'}} }
65
- subject { MightyGrid::Base.new(Product, @controller) }
65
+ subject { MightyGrid::Base.new(User, @controller) }
66
66
  its(:current_order_direction) { should == 'desc' }
67
67
  after(:all){ @controller.params = {} }
68
68
  end
69
69
 
70
70
  context 'with BAD controller param' do
71
71
  before(:all){ @controller.params = {'grid'=>{'order_direction' => 'bad'}} }
72
- subject { MightyGrid::Base.new(Product, @controller) }
72
+ subject { MightyGrid::Base.new(User, @controller) }
73
73
  its(:current_order_direction) { should == nil }
74
74
  after(:all){ @controller.params = {} }
75
75
  end
@@ -78,21 +78,21 @@ describe MightyGrid::Base do
78
78
  describe '#another_order_direction' do
79
79
  context 'with ASC controller param' do
80
80
  before(:all){ @controller.params = {'grid'=>{'order_direction' => 'asc'}} }
81
- subject { MightyGrid::Base.new(Product, @controller) }
81
+ subject { MightyGrid::Base.new(User, @controller) }
82
82
  its(:another_order_direction) { should == 'desc' }
83
83
  after(:all){ @controller.params = {} }
84
84
  end
85
85
 
86
86
  context 'with DESC controller param' do
87
87
  before(:all){ @controller.params = {'grid'=>{'order_direction' => 'desc'}} }
88
- subject { MightyGrid::Base.new(Product, @controller) }
88
+ subject { MightyGrid::Base.new(User, @controller) }
89
89
  its(:another_order_direction) { should == 'asc' }
90
90
  after(:all){ @controller.params = {} }
91
91
  end
92
92
 
93
93
  context 'with BAD controller param' do
94
94
  before(:all){ @controller.params = {'grid'=>{'order_direction' => 'bad'}} }
95
- subject { MightyGrid::Base.new(Product, @controller) }
95
+ subject { MightyGrid::Base.new(User, @controller) }
96
96
  its(:another_order_direction) { should == 'asc' }
97
97
  after(:all){ @controller.params = {} }
98
98
  end
@@ -100,7 +100,7 @@ describe MightyGrid::Base do
100
100
 
101
101
  describe '#order_params' do
102
102
  before(:all){ @controller.params = {'grid'=>{'order' => 'name', 'order_direction' => 'asc'}} }
103
- subject { MightyGrid::Base.new(Product, @controller) }
103
+ subject { MightyGrid::Base.new(User, @controller) }
104
104
  context 'with current order attribute' do
105
105
  it { subject.order_params(:name).should == {'grid'=>{order: :name, order_direction: 'desc'}} }
106
106
  end
@@ -111,7 +111,7 @@ describe MightyGrid::Base do
111
111
  end
112
112
 
113
113
  describe '#like_operator' do
114
- subject { MightyGrid::Base.new(Product, @controller) }
114
+ subject { MightyGrid::Base.new(User, @controller) }
115
115
  context "when DB is #{ENV['DB']}" do
116
116
  case ENV['DB']
117
117
  when 'postgresql'
@@ -52,19 +52,19 @@ describe MightyGrid::Column do
52
52
  end
53
53
 
54
54
  describe '.render' do
55
- let(:product){ Product.create(name: 'product name') }
55
+ let(:user){ User.create(name: 'user name') }
56
56
 
57
57
  describe 'with attribute' do
58
58
  subject(:column){ MightyGrid::Column.new(:name) }
59
59
  it 'should return attribute value' do
60
- column.render(product).should == product[:name]
60
+ column.render(user).should == user[:name]
61
61
  end
62
62
  end
63
63
 
64
64
  describe 'with block' do
65
- subject(:column){ MightyGrid::Column.new { "#{product.name} 1" } }
65
+ subject(:column){ MightyGrid::Column.new { "#{user.name} 1" } }
66
66
  it 'should return attribute value' do
67
- column.render(product).should == "#{product[:name]} 1"
67
+ column.render(user).should == "#{user[:name]} 1"
68
68
  end
69
69
  end
70
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mighty_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jurrick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-24 00:00:00.000000000 Z
11
+ date: 2014-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,11 @@ files:
103
103
  - app/views/kaminari/mighty_grid/_paginator.html.erb
104
104
  - app/views/kaminari/mighty_grid/_prev_page.html.erb
105
105
  - config/locales/en.yml
106
+ - features/filtering.feature
107
+ - features/step_definitions/steps.rb
108
+ - features/support/database_cleaner.rb
109
+ - features/support/env.rb
110
+ - features/support/paths.rb
106
111
  - gemfiles/rails_32.gemfile
107
112
  - gemfiles/rails_40.gemfile
108
113
  - gemfiles/rails_41.gemfile
@@ -131,7 +136,6 @@ files:
131
136
  - spec/lib/base_spec.rb
132
137
  - spec/lib/column_spec.rb
133
138
  - spec/lib/generators/install_generator_spec.rb
134
- - spec/requests/products_spec.rb
135
139
  - spec/spec_helper.rb
136
140
  - spec/support/capybara.rb
137
141
  - spec/support/database_cleaner.rb
@@ -162,6 +166,11 @@ signing_key:
162
166
  specification_version: 4
163
167
  summary: Flexible grid for Rails
164
168
  test_files:
169
+ - features/filtering.feature
170
+ - features/step_definitions/steps.rb
171
+ - features/support/database_cleaner.rb
172
+ - features/support/env.rb
173
+ - features/support/paths.rb
165
174
  - spec/config_spec.rb
166
175
  - spec/fake_app/config/database.yml.example
167
176
  - spec/fake_app/models/active_record.rb
@@ -171,7 +180,6 @@ test_files:
171
180
  - spec/lib/base_spec.rb
172
181
  - spec/lib/column_spec.rb
173
182
  - spec/lib/generators/install_generator_spec.rb
174
- - spec/requests/products_spec.rb
175
183
  - spec/spec_helper.rb
176
184
  - spec/support/capybara.rb
177
185
  - spec/support/database_cleaner.rb
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature 'Product' do
4
- background { 1.upto(100) {|i| Product.create! :name => "product#{'%03d' % i}" } }
5
-
6
- subject { page }
7
-
8
- describe 'Index Page' do
9
- before { visit '/products' }
10
-
11
- it { should have_selector 'form.mighty-grid-filter' }
12
- it { should have_selector 'table.mighty-grid' }
13
- it { should have_selector 'ul.pagination' }
14
- end
15
-
16
- scenario 'filtering by fields' do
17
- visit '/products'
18
-
19
- product_name = Product.first.name
20
-
21
- within '.mighty-grid-filter' do
22
- fill_in "grid_f_name", :with => product_name
23
- end
24
-
25
- click_button "Apply changes"
26
-
27
- expect(page).to have_content product_name
28
- expect(page).to have_content '1 of 1'
29
- end
30
-
31
- end