pageflow-support 12.1.0 → 12.3.0

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
  SHA256:
3
- metadata.gz: d4e7e933531bd4c3bbf24d8a54d84339a6c2c6dd47b12bb4defb45b2c1486696
4
- data.tar.gz: 381ffa9ad933d83f9e4b6868c9ada6b9de517125916f5ee9214d1fb5e1b5069e
3
+ metadata.gz: 4249878c16a819e6b3bc72fd48b1d92cf42a377f19071ca38cda6dd45fbc2271
4
+ data.tar.gz: c1eb8dd8121511fb372bd913805da54dccbb630d0f39496e99f76c713c18cbcd
5
5
  SHA512:
6
- metadata.gz: 13330c440ec4c5890cd69148119b6b892a7b343ba491da000b0acaaf2160e540bb502201364b5f5ba7f01bd29969fa4e68b85dff6d99ea36eff4b7c005220439
7
- data.tar.gz: 9f3cc71fcf52d1b2c0502b560b6cc221e6e906af150b0ca1399368787dc80b6aec79b501fe66985773b9c3416df67942cf91f60eaa586ddc91a1a51b1cd56d27
6
+ metadata.gz: dbe883eda9941bba9013e69e6a525d2f0ea18d306d8e796f5e4ff4569349c53e3ca635573890250194a5a5397d19334c9d2dff56334109e3ceeb8e449c7f9eb6
7
+ data.tar.gz: 52b233c3dfbc4b40e9737666de4084c338d5807dd67db737312b6c872eea27d5b85f74c804afdb493d39b72bad3f6be219c37ba19387f91850e53a5a70b1aa48
@@ -0,0 +1,64 @@
1
+ module Pageflow
2
+ module Dom
3
+ module Admin
4
+ # Base class for attribute table dominos.
5
+ #
6
+ # @since edge
7
+ class AttributesTable < Domino
8
+ # Visit the admin page of the given resource and find the
9
+ # attributes table.
10
+ def self.for(resource)
11
+ visit(url(resource))
12
+ find!
13
+ end
14
+
15
+ # Find the Capybara node of the contents cell for the given
16
+ # attribute.
17
+ def contents_of_row(name)
18
+ node.find(".row-#{name} td")
19
+ end
20
+
21
+ def self.url_helpers
22
+ Rails.application.routes.url_helpers
23
+ end
24
+ private_class_method :url_helpers
25
+ end
26
+
27
+ # The attributes table on the account page.
28
+ #
29
+ # @since edge
30
+ class AccountAttributesTable < AttributesTable
31
+ selector '.attributes_table.pageflow_account'
32
+
33
+ def self.url(account)
34
+ url_helpers.admin_account_path(account)
35
+ end
36
+ private_class_method :url
37
+ end
38
+
39
+ # The attributes table on the entry page
40
+ #
41
+ # @since edge
42
+ class EntryAttributesTable < AttributesTable
43
+ selector '.attributes_table.pageflow_entry'
44
+
45
+ def self.url(entry)
46
+ url_helpers.admin_entry_path(entry)
47
+ end
48
+ private_class_method :url
49
+ end
50
+
51
+ # The theming attributes table on the account page
52
+ #
53
+ # @since edge
54
+ class ThemingAttributesTable < AttributesTable
55
+ selector '.attributes_table.pageflow_theming'
56
+
57
+ def self.url(theming)
58
+ url_helpers.admin_account_path(theming.account)
59
+ end
60
+ private_class_method :url
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,86 @@
1
+ module Pageflow
2
+ module Dom
3
+ module Admin
4
+ # Base class for admin form dominos
5
+ #
6
+ # @since edge
7
+ class EditForm < Domino
8
+ # Visit the edit page and find the form.
9
+ def self.for(resource)
10
+ visit(url(resource))
11
+ find!
12
+ end
13
+
14
+ # Test whether a field for the given attribute is present.
15
+ def has_input_for_attribute?(name)
16
+ node.has_selector?("input[name='#{field_prefix}[#{name}]']")
17
+ end
18
+
19
+ def self.url_helpers
20
+ Rails.application.routes.url_helpers
21
+ end
22
+ private_class_method :url_helpers
23
+
24
+ private
25
+
26
+ def field_prefix
27
+ raise NotImplementedError
28
+ end
29
+ end
30
+
31
+ # Edit form of entry admin.
32
+ #
33
+ # @since edge
34
+ class EntryEditForm < EditForm
35
+ selector '.edit.admin_entries'
36
+
37
+ def self.url(entry)
38
+ url_helpers.edit_admin_entry_path(entry)
39
+ end
40
+ private_class_method :url
41
+
42
+ private
43
+
44
+ def field_prefix
45
+ 'entry'
46
+ end
47
+ end
48
+
49
+ # Edit form of account admin.
50
+ #
51
+ # @since edge
52
+ class AccountEditForm < EditForm
53
+ selector '.edit.admin_accounts'
54
+
55
+ def self.url(account)
56
+ url_helpers.edit_admin_account_path(account)
57
+ end
58
+ private_class_method :url
59
+
60
+ private
61
+
62
+ def field_prefix
63
+ 'account'
64
+ end
65
+ end
66
+
67
+ # Edit form for theming in account admin.
68
+ #
69
+ # @since edge
70
+ class ThemingEditForm < EditForm
71
+ selector '.edit.admin_accounts'
72
+
73
+ def self.url(theming)
74
+ url_helpers.edit_admin_account_path(theming.account)
75
+ end
76
+ private_class_method :url
77
+
78
+ private
79
+
80
+ def field_prefix
81
+ 'account[default_theming_attributes]'
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,54 @@
1
+ module Pageflow
2
+ module Dom
3
+ module Admin
4
+ # @api private
5
+ class Page < Domino
6
+ selector 'body.active_admin'
7
+
8
+ attribute :title
9
+
10
+ def has_signed_in_user?
11
+ page.has_css?('#current_user')
12
+ end
13
+
14
+ def self.sign_out
15
+ visit '/admin/logout'
16
+ end
17
+
18
+ def self.sign_in(options)
19
+ visit '/admin/login'
20
+ SignInForm.first.submit_with(options)
21
+ end
22
+
23
+ def self.sign_in_as(role, options = {})
24
+ email = "#{role}@example.com"
25
+ password = '!Pass123'
26
+ user = FactoryGirl.create(:user, options.reverse_merge(email: email, password: password))
27
+
28
+ if role.to_sym == :admin
29
+ user.admin = true
30
+ user.save
31
+ else
32
+ FactoryGirl.create(:membership, user: user, role: role, entity: options[:on])
33
+ end
34
+
35
+ visit '/admin/login'
36
+ SignInForm.find!.submit_with(email: email, password: password)
37
+
38
+ unless page.has_content?(I18n.t('devise.sessions.signed_in'))
39
+ raise 'Expected to find sign in flash message.'
40
+ end
41
+
42
+ user
43
+ end
44
+
45
+ def self.accessible_with?(options)
46
+ sign_out
47
+ sign_in(options)
48
+
49
+ Page.first.has_signed_in_user?
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,25 @@
1
+ module Pageflow
2
+ module Dom
3
+ module Admin
4
+ # @api private
5
+ class SignInForm < Domino
6
+ selector '#login'
7
+
8
+ def submit_with(options)
9
+ within(id) do
10
+ fill_in 'user_email', with: options[:email]
11
+ fill_in 'user_password', with: options[:password]
12
+
13
+ find('[name="commit"]').click
14
+ end
15
+ end
16
+
17
+ def forgot_password_link
18
+ within(id) do
19
+ find('a')
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ require 'pageflow/dom/admin/attributes_tables'
2
+ require 'pageflow/dom/admin/edit_forms'
3
+ require 'pageflow/dom/admin/page'
4
+ require 'pageflow/dom/admin/sign_in_form'
5
+
6
+ module Pageflow
7
+ module Dom
8
+ # Dominos for admin ui elements and helper methods.
9
+ #
10
+ # @since edge
11
+ module Admin
12
+ # Sign in with the given role
13
+ #
14
+ # @param role [Symbol] Either :admin or one of the membership
15
+ # roles :publisher, :editor, :previewer or :member.
16
+ #
17
+ # @option options [Entry|Account] :on Membership entity if role
18
+ # is a membership role.
19
+ #
20
+ # @returns [User] Created user record.
21
+ #
22
+ # @example
23
+ # Pageflow::Dom::Admin.sign_in_as(:admin)
24
+ # Pageflow::Dom::Admin.sign_in_as(:editor, on: entry)
25
+ def self.sign_in_as(role, options = {})
26
+ Page.sign_in_as(role, options)
27
+ end
28
+ end
29
+ end
30
+ end
data/pageflow/dom.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'domino'
2
+
3
+ require 'pageflow/dom/admin'
4
+
5
+ # Dominos to be used by plugin tests.
6
+ module Pageflow
7
+ module Dom
8
+ end
9
+ end
data/pageflow/support.rb CHANGED
@@ -1 +1,2 @@
1
1
  require 'pageflow/dummy'
2
+ require 'pageflow/dom'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pageflow-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.1.0
4
+ version: 12.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codevise Solutions Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pageflow
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 12.1.0
19
+ version: 12.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 12.1.0
26
+ version: 12.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mysql2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -45,6 +45,12 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - pageflow/dom.rb
49
+ - pageflow/dom/admin.rb
50
+ - pageflow/dom/admin/attributes_tables.rb
51
+ - pageflow/dom/admin/edit_forms.rb
52
+ - pageflow/dom/admin/page.rb
53
+ - pageflow/dom/admin/sign_in_form.rb
48
54
  - pageflow/dummy.rb
49
55
  - pageflow/dummy/app.rb
50
56
  - pageflow/dummy/rails_template.rb
@@ -54,7 +60,7 @@ files:
54
60
  - pageflow/dummy/templates/database.yml
55
61
  - pageflow/rails_version.rb
56
62
  - pageflow/support.rb
57
- homepage: http://www.pageflow.io
63
+ homepage: https://pageflow.io
58
64
  licenses: []
59
65
  metadata: {}
60
66
  post_install_message:
@@ -73,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
79
  version: '0'
74
80
  requirements: []
75
81
  rubyforge_project:
76
- rubygems_version: 2.7.0
82
+ rubygems_version: 2.7.5
77
83
  signing_key:
78
84
  specification_version: 4
79
85
  summary: Spec support for Pageflow extensions.